! ! Virtualize L2 tables (arp, nd6). ! ! Reviewed by: ! Index: sys/net/if_llatbl.c =================================================================== --- sys/net/if_llatbl.c (revision 196889) +++ sys/net/if_llatbl.c (working copy) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,8 @@ MALLOC_DEFINE(M_LLTABLE, "lltable", "link level address tables"); -static SLIST_HEAD(, lltable) lltables = SLIST_HEAD_INITIALIZER(lltables); +static VNET_DEFINE(SLIST_HEAD(, lltable), lltables); +#define V_lltables VNET(lltables) extern void arprequest(struct ifnet *, struct in_addr *, struct in_addr *, u_char *); @@ -75,7 +77,7 @@ int error = 0; LLTABLE_RLOCK(); - SLIST_FOREACH(llt, &lltables, llt_link) { + SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af == af) { error = llt->llt_dump(llt, wr); if (error != 0) @@ -157,7 +159,7 @@ KASSERT(llt != NULL, ("%s: llt is NULL", __func__)); LLTABLE_WLOCK(); - SLIST_REMOVE(&lltables, llt, lltable, llt_link); + SLIST_REMOVE(&V_lltables, llt, lltable, llt_link); LLTABLE_WUNLOCK(); for (i=0; i < LLTBL_HASHTBL_SIZE; i++) { @@ -179,8 +181,9 @@ struct llentry *lle; register int i; + CURVNET_SET_QUIET(TD_TO_VNET(curthread)); LLTABLE_RLOCK(); - SLIST_FOREACH(llt, &lltables, llt_link) { + SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af != af) continue; @@ -194,6 +197,7 @@ } } LLTABLE_RUNLOCK(); + CURVNET_RESTORE(); } void @@ -201,14 +205,16 @@ { struct lltable *llt; + CURVNET_SET_QUIET(TD_TO_VNET(curthread)); LLTABLE_RLOCK(); - SLIST_FOREACH(llt, &lltables, llt_link) { + SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af != af) continue; llt->llt_prefix_free(llt, prefix, mask); } LLTABLE_RUNLOCK(); + CURVNET_RESTORE(); } @@ -232,7 +238,7 @@ LIST_INIT(&llt->lle_head[i]); LLTABLE_WLOCK(); - SLIST_INSERT_HEAD(&lltables, llt, llt_link); + SLIST_INSERT_HEAD(&V_lltables, llt, llt_link); LLTABLE_WUNLOCK(); return (llt); @@ -302,7 +308,7 @@ /* XXX linked list may be too expensive */ LLTABLE_RLOCK(); - SLIST_FOREACH(llt, &lltables, llt_link) { + SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af == dst->sa_family && llt->llt_ifp == ifp) break; @@ -367,3 +373,14 @@ return (error); } + +static void +vnet_lltable_init(const void *unused __unused) +{ + + /* Manually do what SLIST_HEAD_INITIALIZER would do. */ + V_lltables.slh_first = NULL; +} + +VNET_SYSINIT(vnet_lltable_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_lltable_init, + NULL);