From e612af50c415c38440054d04bc317f5b02220ce0 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Fri, 6 Jan 2017 15:59:25 +0800 Subject: [PATCH] if: Defer the if_up until the ifnet.if_ioctl is called. This ensures the interface is initialized by the interface driver before it can be used by the rest of the system. Obtained-from: FreeBSD --- sys/net/if.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 802ec400f8..555115aa70 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1777,7 +1777,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct ucred *cred) struct ifnet *ifp; struct ifreq *ifr; struct ifstat *ifs; - int error; + int error, do_ifup = 0; short oif_flags; int new_flags; size_t namelen, onamelen; @@ -1881,7 +1881,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct ucred *cred) if_down(ifp); } else if (new_flags & IFF_UP && (ifp->if_flags & IFF_UP) == 0) { - if_up(ifp); + do_ifup = 1; } #ifdef IFPOLL_ENABLE @@ -1906,6 +1906,8 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct ucred *cred) ifp->if_ioctl(ifp, cmd, data, cred); ifnet_deserialize_all(ifp); } + if (do_ifup) + if_up(ifp); getmicrotime(&ifp->if_lastchange); break; -- 2.11.4.GIT