]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
When we started calling if_findindex() from if_alloc() with an empty
authorBrooks Davis <brooks@FreeBSD.org>
Thu, 18 Aug 2005 18:36:40 +0000 (18:36 +0000)
committerBrooks Davis <brooks@FreeBSD.org>
Thu, 18 Aug 2005 18:36:40 +0000 (18:36 +0000)
commitdc7c539e331e32c6e4a0d12b6bdc3618a2c11825
tree1b8b29c487f1c8e64d171da15a1369e285f1d35f
parentdcb4a693367c538f0a449dbf217c0dbf1ebcca2d
When we started calling if_findindex() from if_alloc() with an empty
struct ifnet most of if_findindex() become a complex no-op.  Remove it
and replace it with a corrected version of the four line for loop it
devolved to plus some error handling.  This should probably be replaced
with subr_unit at some point.

Switch from checking ifaddr_byindex to ifnet_byindex when looking for
empty indexes.  Since we're doing this from if_alloc/if_free, we can
only be sure that ifnet_byindex will be correct.  This fixes panics when
loading the ef(4) module.  The panics were caused by the fact that
if_alloc was called four time before if_attach was called and thus
ifaddr_byindex was not set and the same unit was allocated again.  This
in turn caused the first if_attach to fail because the ifp was not the
one in ifnet_byindex(ifp->if_index).

Reported by: "Wojciech A. Koszek" <dunstan at freebsd dot czest dot pl>
PR: kern/84987
MFC After: 1 day
sys/net/if.c