On Thu, Apr 17, 2008 at 06:35:23PM -0700, vijay singh wrote: > Hi all. How do we avoid a race in populating the ifindex_table? Id > this is a TODO, as it seems from the code below, would it be > acceptable if I wrote a patch and reused the ifnet_lock [IFNET_WLOCK, > IFNET_WUNLOCK]?
Locking if_index management with ifnet_lock should be ok. Ideally we should probably be using ALLOC_UNR(9) to manage if_indexes instead of this rather expensive loop. Be aware, that if_index generation is least of the issues in this area. The if_grow() call is much riskier since it changes the value of the global ifnet pointer which I'm not sure we can afford to lock. It would be worth experimenting with rmlocks to see what the impact if of locking would be. I'm serious tempted to kill if_grow in favor of some sort of if_index_max tunable. -- Brooks > if_alloc(u_char type) > { > struct ifnet *ifp; > > ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO); > > /* > * Try to find an empty slot below if_index. If we fail, take > * the next slot. > * > * XXX: should be locked! > */ > for (ifp->if_index = 1; ifp->if_index <= if_index; ifp->if_index++) { > if (ifnet_byindex(ifp->if_index) == NULL) > break; > } > > > > > > > ____________________________________________________________________________________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "[EMAIL PROTECTED]" >
pgpFMqrQ4kVXa.pgp
Description: PGP signature