diff options
author | jhb <jhb@FreeBSD.org> | 2005-08-04 14:39:47 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2005-08-04 14:39:47 +0000 |
commit | a1fc2e1330c98642f81c5438892f71b8f66c025a (patch) | |
tree | 71ef1ebc952f213f0c117aac919cd50cd767bab4 /sys/net/if.c | |
parent | 6c7fa493b728b4d3db64578dbd078e5fde197fb3 (diff) | |
download | FreeBSD-src-a1fc2e1330c98642f81c5438892f71b8f66c025a.zip FreeBSD-src-a1fc2e1330c98642f81c5438892f71b8f66c025a.tar.gz |
Initialize the if_addr mutex in if_alloc() rather than waiting until
if_attach(). This allows ethernet drivers to use it in their routines
to program their MAC filters before ether_ifattach() is called (de(4) is
one such driver). Also, the if_addr mutex is destroyed in if_free()
rather than if_detach(), so there was another potential bug in that a
driver that failed during attach and called if_free() without having
called ether_ifattach() would have tried to destroy an uninitialized mutex.
Reported by: Holm Tiffe holm at freibergnet dot de
Discussed with: rwatson
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 391fe9c..b57c698 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -408,6 +408,7 @@ if_alloc(u_char type) return (NULL); } } + IF_ADDR_LOCK_INIT(ifp); return (ifp); } @@ -462,7 +463,6 @@ if_attach(struct ifnet *ifp) TASK_INIT(&ifp->if_starttask, 0, if_start_deferred, ifp); TASK_INIT(&ifp->if_linktask, 0, do_link_state_change, ifp); IF_AFDATA_LOCK_INIT(ifp); - IF_ADDR_LOCK_INIT(ifp); ifp->if_afdata_initialized = 0; IFNET_WLOCK(); TAILQ_INSERT_TAIL(&ifnet, ifp, if_link); |