Date: Mon, 26 Dec 2016 03:28:46 +0000 From: "sepherosa_gmail.com (Sepherosa Ziehau)" <phabric-noreply@FreeBSD.org> To: freebsd-net@freebsd.org Subject: [Differential] D8904: inet: Fix routing issue by calling if_up() Message-ID: <differential-rev-PHID-DREV-ep6hmkx4cno4dfdlhp4a-req@FreeBSD.org>
index | next in thread | raw e-mail
[-- Attachment #1 --]
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
[-- Attachment #2 --]
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:
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?differential-rev-PHID-DREV-ep6hmkx4cno4dfdlhp4a-req>
