diff options
author | zec <zec@FreeBSD.org> | 2008-10-02 15:37:58 +0000 |
---|---|---|
committer | zec <zec@FreeBSD.org> | 2008-10-02 15:37:58 +0000 |
commit | 8797d4caecd5881e312923ee1d07be3de68755dc (patch) | |
tree | 53fef93d1ff076abec439159e0a765427992dee1 /sys/net/if_ef.c | |
parent | e682bfadb0a191a81290af2b846d8610ef3aff5c (diff) | |
download | FreeBSD-src-8797d4caecd5881e312923ee1d07be3de68755dc.zip FreeBSD-src-8797d4caecd5881e312923ee1d07be3de68755dc.tar.gz |
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
Diffstat (limited to 'sys/net/if_ef.c')
-rw-r--r-- | sys/net/if_ef.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c index c60e615..59d4556 100644 --- a/sys/net/if_ef.c +++ b/sys/net/if_ef.c @@ -484,43 +484,51 @@ ef_clone(struct ef_link *efl, int ft) static int ef_load(void) { + VNET_ITERATOR_DECL(vnet_iter); struct ifnet *ifp; struct efnet *efp; struct ef_link *efl = NULL, *efl_temp; int error = 0, d; - IFNET_RLOCK(); - TAILQ_FOREACH(ifp, &V_ifnet, if_link) { - if (ifp->if_type != IFT_ETHER) continue; - EFDEBUG("Found interface %s\n", ifp->if_xname); - efl = (struct ef_link*)malloc(sizeof(struct ef_link), - M_IFADDR, M_WAITOK | M_ZERO); - if (efl == NULL) { - error = ENOMEM; - break; - } + VNET_LIST_RLOCK(); + VNET_FOREACH(vnet_iter) { + CURVNET_SET(vnet_iter); + INIT_VNET_NET(vnet_iter); + IFNET_RLOCK(); + TAILQ_FOREACH(ifp, &V_ifnet, if_link) { + if (ifp->if_type != IFT_ETHER) continue; + EFDEBUG("Found interface %s\n", ifp->if_xname); + efl = (struct ef_link*)malloc(sizeof(struct ef_link), + M_IFADDR, M_WAITOK | M_ZERO); + if (efl == NULL) { + error = ENOMEM; + break; + } - efl->el_ifp = ifp; + efl->el_ifp = ifp; #ifdef ETHER_II - error = ef_clone(efl, ETHER_FT_EII); - if (error) break; + error = ef_clone(efl, ETHER_FT_EII); + if (error) break; #endif #ifdef ETHER_8023 - error = ef_clone(efl, ETHER_FT_8023); - if (error) break; + error = ef_clone(efl, ETHER_FT_8023); + if (error) break; #endif #ifdef ETHER_8022 - error = ef_clone(efl, ETHER_FT_8022); - if (error) break; + error = ef_clone(efl, ETHER_FT_8022); + if (error) break; #endif #ifdef ETHER_SNAP - error = ef_clone(efl, ETHER_FT_SNAP); - if (error) break; + error = ef_clone(efl, ETHER_FT_SNAP); + if (error) break; #endif - efcount++; - SLIST_INSERT_HEAD(&efdev, efl, el_next); + efcount++; + SLIST_INSERT_HEAD(&efdev, efl, el_next); + } + IFNET_RUNLOCK(); + CURVNET_RESTORE(); } - IFNET_RUNLOCK(); + VNET_LIST_RUNLOCK(); if (error) { if (efl) SLIST_INSERT_HEAD(&efdev, efl, el_next); |