Date: Wed, 10 Sep 2008 07:50:19 GMT From: Julian Elischer <julian@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 149518 for review Message-ID: <200809100750.m8A7oJYU053853@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=149518 Change 149518 by julian@julian_trafmon1 on 2008/09/10 07:49:56 Show how to iterate through vnets Affected files ... .. //depot/projects/vimage/porting_to_vimage.txt#8 edit Differences ... ==== //depot/projects/vimage/porting_to_vimage.txt#8 (text+ko) ==== @@ -338,6 +338,35 @@ [...] } +/* + * A function which on entry has no idea of which vnet it is on + * and needs to look at them all for some reason. + * NOTE! if this code is running in a thread that + * does nothing else, or otherwise doesn't care about which + * vnet it is on then the steps that save and restore the previous vnet + * need not be done. (Marked with /* XXX */) + */ +void +foo_tick(void) +{ + VNET_ITERATOR_DECL(vnet_iter); + [...] + + [...] + VNET_LIST_REF(); + VNET_FOREACH(vnet_iter) { + CURVNET_SET(vnet_iter); + INIT_VNET_NET(vnet_iter); + [...] + do work, + including calling code that assumes we have curvnet set. + [...] + CURVNET_RESTORE(); /* XXX */ + } + VNET_LIST_UNREF(); + [...] +} + #if (defined(VIMAGE) || defined(FUTURE)) static int vnet_foo_iattach(const void *unused) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809100750.m8A7oJYU053853>