PERFORCE change 144543 for review

Julian Elischer julian at FreeBSD.org
Thu Jul 3 09:32:14 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=144543

Change 144543 by julian at julian_trafmon1 on 2008/07/03 09:31:58

	ifnet_byindex and friends need INIT_VNET_NET()

Affected files ...

.. //depot/projects/vimage/src/sys/net/if.c#30 edit

Differences ...

==== //depot/projects/vimage/src/sys/net/if.c#30 (text+ko) ====

@@ -151,12 +151,12 @@
 
 static int	if_indexlim;
 static struct	knlist ifklist;
-#endif /* !VIMAGE */
 
 /*
  * Table of ifnet/cdev by index.  Locked with ifnet_lock.
  */
 static struct ifindex_entry *ifindex_table = NULL;
+#endif /* !VIMAGE */
 
 static void	filt_netdetach(struct knote *kn);
 static int	filt_netdev(struct knote *kn, long hint);
@@ -190,10 +190,11 @@
 struct ifnet *
 ifnet_byindex(u_short idx)
 {
+	INIT_VNET_NET(curvnet);
 	struct ifnet *ifp;
 
 	IFNET_RLOCK();
-	ifp = ifindex_table[idx].ife_ifnet;
+	ifp = V_ifindex_table[idx].ife_ifnet;
 	IFNET_RUNLOCK();
 	return (ifp);
 }
@@ -202,9 +203,10 @@
 ifnet_setbyindex(u_short idx, struct ifnet *ifp)
 {
 
+	INIT_VNET_NET(curvnet);
 	IFNET_WLOCK_ASSERT();
 
-	ifindex_table[idx].ife_ifnet = ifp;
+	V_ifindex_table[idx].ife_ifnet = ifp;
 }
 
 struct ifaddr *
@@ -221,10 +223,11 @@
 struct cdev *
 ifdev_byindex(u_short idx)
 {
+	INIT_VNET_NET(curvnet);
 	struct cdev *cdev;
 
 	IFNET_RLOCK();
-	cdev = ifindex_table[idx].ife_dev;
+	cdev = V_ifindex_table[idx].ife_dev;
 	IFNET_RUNLOCK();
 	return (cdev);
 }
@@ -233,8 +236,9 @@
 ifdev_setbyindex(u_short idx, struct cdev *cdev)
 {
 
+	INIT_VNET_NET(curvnet);
 	IFNET_WLOCK();
-	ifindex_table[idx].ife_dev = cdev;
+	V_ifindex_table[idx].ife_dev = cdev;
 	IFNET_WUNLOCK();
 }
 
@@ -268,7 +272,6 @@
 static int
 netioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
 {
-	INIT_VNET_NET(curvnet);
 	struct ifnet *ifp;
 	int error, idx;
 
@@ -379,15 +382,8 @@
 	vnet_net_iattach(NULL);
 #endif
 	IFNET_LOCK_INIT();
-#ifdef VIMAGE
-	if (IS_DEFAULT_VNET(curvnet)) {
-	INIT_VNET_NET(curvnet);
-#endif
 	ifdev_setbyindex(0, make_dev(&net_cdevsw, 0, UID_ROOT, GID_WHEEL,
 	    0600, "network"));
-#ifdef VIMAGE
-	}
-#endif
 	if_clone_init();
 }
 


More information about the p4-projects mailing list