diff options
author | bms <bms@FreeBSD.org> | 2007-03-27 16:11:28 +0000 |
---|---|---|
committer | bms <bms@FreeBSD.org> | 2007-03-27 16:11:28 +0000 |
commit | 441b1fffcf1f60b98ed1a108c3b48647ffc35d6f (patch) | |
tree | 0c6e5b6e3d60d1ee93994ea858c1ce89495cf428 /sys/net | |
parent | a8be3c5db775d7348bb09c2d0618af6352050826 (diff) | |
download | FreeBSD-src-441b1fffcf1f60b98ed1a108c3b48647ffc35d6f.zip FreeBSD-src-441b1fffcf1f60b98ed1a108c3b48647ffc35d6f.tar.gz |
Fix a case where hardware removal of an interface caused an attempt to
announce an ll_ifma which has gone away. Add a KASSERT to catch regressions.
Bug found by: Tom Uffner
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 16 | ||||
-rw-r--r-- | sys/net/rtsock.c | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 7e4df75..33adc50 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2512,21 +2512,27 @@ if_delmulti_locked(struct ifnet *ifp, struct ifmultiaddr *ifma, int detaching) /* * If the ifnet is detaching, null out references to ifnet, * so that upper protocol layers will notice, and not attempt - * to obtain locks for an ifnet which no longer exists. - * It is OK to call rt_newmaddrmsg() with a NULL ifp. + * to obtain locks for an ifnet which no longer exists. The + * routing socket announcement must happen before the ifnet + * instance is detached from the system. */ if (detaching) { #ifdef DIAGNOSTIC printf("%s: detaching ifnet instance %p\n", __func__, ifp); #endif - ifma->ifma_ifp = NULL; + /* + * ifp may already be nulled out if we are being reentered + * to delete the ll_ifma. + */ + if (ifp != NULL) { + rt_newmaddrmsg(RTM_DELMADDR, ifma); + ifma->ifma_ifp = NULL; + } } if (--ifma->ifma_refcount > 0) return 0; - rt_newmaddrmsg(RTM_DELMADDR, ifma); - /* * If this ifma is a network-layer ifma, a link-layer ifma may * have been associated with it. Release it first if so. diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 16b94ad..8394786 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -964,6 +964,8 @@ rt_newmaddrmsg(int cmd, struct ifmultiaddr *ifma) if (m == NULL) return; ifmam = mtod(m, struct ifma_msghdr *); + KASSERT(ifp != NULL, ("%s: link-layer multicast address w/o ifp\n", + __func__)); ifmam->ifmam_index = ifp->if_index; ifmam->ifmam_addrs = info.rti_addrs; rt_dispatch(m, ifma->ifma_addr); |