[Differential] D8904: inet: Fix routing issue by calling if_up()
sepherosa_gmail.com (Sepherosa Ziehau)
phabric-noreply at FreeBSD.org
Mon Dec 26 03:28:47 UTC 2016
sepherosa_gmail.com created this revision.
sepherosa_gmail.com added reviewers: delphij, royger, decui_microsoft.com, honzhan_microsoft.com, howard0su_gmail.com, adrian, bz, gnn, hiren, glebius, rwatson, karels.
sepherosa_gmail.com added a subscriber: freebsd-net-list.
REVISION SUMMARY
This is mainly intended to fix the following case at least:
ifconfig iface0 192.168.5.1
ifconfig iface0 down
ifconfig iface0 alias 192.168.6.1
Before this commit, the related part of the routing table is:
192.168.5.1 link#3 UHS lo0
192.168.6.0/24 link#3 U hn1
192.168.6.1 link#3 UHS lo0
The 192.168.5.0/24 can't be reached.
After this fix, the related part of the routing table is:
192.168.5.0/24 link#3 U hn1
192.168.5.1 link#3 UHS lo0
192.168.6.0/24 link#3 U hn1
192.168.6.1 link#3 UHS lo0
Everything works as expected.
REVISION DETAIL
https://reviews.freebsd.org/D8904
AFFECTED FILES
sys/netinet/in.c
CHANGE DETAILS
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -228,7 +228,7 @@
struct sockaddr_in *addr = (struct sockaddr_in *)&ifr->ifr_addr;
struct ifaddr *ifa;
struct in_ifaddr *ia;
- int error;
+ int error, was_up = 0;
if (ifp == NULL)
return (EADDRNOTAVAIL);
@@ -250,9 +250,13 @@
return (error);
case OSIOCAIFADDR: /* 9.x compat */
case SIOCAIFADDR:
+ if (ifp->if_flags & IFF_UP)
+ was_up = 1;
sx_xlock(&in_control_sx);
error = in_aifaddr_ioctl(cmd, data, ifp, td);
sx_xunlock(&in_control_sx);
+ if (!was_up && (ifp->if_flags & IFF_UP))
+ if_up(ifp);
return (error);
case SIOCSIFADDR:
case SIOCSIFBRDADDR:
EMAIL PREFERENCES
https://reviews.freebsd.org/settings/panel/emailpreferences/
To: sepherosa_gmail.com, delphij, royger, decui_microsoft.com, honzhan_microsoft.com, howard0su_gmail.com, adrian, bz, gnn, hiren, glebius, rwatson, karels
Cc: freebsd-net-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8904.23257.patch
Type: text/x-patch
Size: 691 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-net/attachments/20161226/c8b8b49a/attachment.bin>
More information about the freebsd-net
mailing list