Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jan 2017 05:10:49 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r311475 - head/sys/net
Message-ID:  <201701060510.v065AnNE086346@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Fri Jan  6 05:10:49 2017
New Revision: 311475
URL: https://svnweb.freebsd.org/changeset/base/311475

Log:
  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.
  
  Reviewed by:	jhb, karels, gnn
  MFC after:	3 week
  Sponsored by:	Microsoft
  Differential Revision:	https://reviews.freebsd.org/D8905

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Fri Jan  6 04:38:38 2017	(r311474)
+++ head/sys/net/if.c	Fri Jan  6 05:10:49 2017	(r311475)
@@ -2300,7 +2300,7 @@ static int
 ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
 {
 	struct ifreq *ifr;
-	int error = 0;
+	int error = 0, do_ifup = 0;
 	int new_flags, temp_flags;
 	size_t namelen, onamelen;
 	size_t descrlen;
@@ -2427,7 +2427,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
 			if_down(ifp);
 		} else if (new_flags & IFF_UP &&
 		    (ifp->if_flags & IFF_UP) == 0) {
-			if_up(ifp);
+			do_ifup = 1;
 		}
 		/* See if permanently promiscuous mode bit is about to flip */
 		if ((ifp->if_flags ^ new_flags) & IFF_PPROMISC) {
@@ -2446,6 +2446,8 @@ ifhwioctl(u_long cmd, struct ifnet *ifp,
 		if (ifp->if_ioctl) {
 			(void) (*ifp->if_ioctl)(ifp, cmd, data);
 		}
+		if (do_ifup)
+			if_up(ifp);
 		getmicrotime(&ifp->if_lastchange);
 		break;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701060510.v065AnNE086346>