patch-2.4.27 linux-2.4.27/net/ipv4/devinet.c

Next file: linux-2.4.27/net/ipv4/igmp.c
Previous file: linux-2.4.27/net/ipv4/af_inet.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.26/net/ipv4/devinet.c linux-2.4.27/net/ipv4/devinet.c
@@ -662,7 +662,23 @@
 			if (ifa->ifa_mask != sin->sin_addr.s_addr) {
 				inet_del_ifa(in_dev, ifap, 0);
 				ifa->ifa_mask = sin->sin_addr.s_addr;
-				ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask);
+				ifa->ifa_prefixlen =
+					inet_mask_len(ifa->ifa_mask);
+
+				/* See if current broadcast address matches
+				 * with current netmask, then recalculate
+				 * the broadcast address. Otherwise it's a
+				 * funny address, so don't touch it since
+				 * the user seems to know what (s)he's doing...
+				 */
+				if ((dev->flags & IFF_BROADCAST) &&
+				    (ifa->ifa_prefixlen < 31) &&
+				    (ifa->ifa_broadcast ==
+				     (ifa->ifa_local|~ifa->ifa_mask))) {
+					ifa->ifa_broadcast =
+						(ifa->ifa_local |
+						 ~sin->sin_addr.s_addr);
+				}
 				inet_insert_ifa(ifa);
 			}
 			break;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)