diff options
author | bms <bms@FreeBSD.org> | 2009-07-18 17:38:18 +0000 |
---|---|---|
committer | bms <bms@FreeBSD.org> | 2009-07-18 17:38:18 +0000 |
commit | 630d769cdb32ec5f2d2fd6e11a19a5328c322a45 (patch) | |
tree | 069fac91e669ff94c10c5c3d59c50f40d65fc813 /sys/netinet6 | |
parent | 9c900caff1113cf062e846e6c2138af9d2cea87d (diff) | |
download | FreeBSD-src-630d769cdb32ec5f2d2fd6e11a19a5328c322a45.zip FreeBSD-src-630d769cdb32ec5f2d2fd6e11a19a5328c322a45.tar.gz |
Fix a problem, whereby misbehaving IPv6 applications, which don't include
a valid zone ID or interface identifier in a v6 multicast leave, would
trigger a fairly paranoid KASSERT().
Observed with Boost++ regression tests on ref8.freebsd.org.
Approved by: re (kib)
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/in6_mcast.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index f7607de..67686a4 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -2160,14 +2160,24 @@ in6p_leave_group(struct inpcb *inp, struct sockopt *sopt) if (error) return (EADDRNOTAVAIL); /* + * Some badly behaved applications don't pass an ifindex + * or a scope ID, which is an API violation. In this case, + * perform a lookup as per a v6 join. + * * XXX For now, stomp on zone ID for the corner case. * This is not the 'KAME way', but we need to see the ifp * directly until such time as this implementation is * refactored, assuming the scope IDs are the way to go. */ ifindex = ntohs(gsa->sin6.sin6_addr.s6_addr16[1]); - KASSERT(ifindex != 0, ("%s: bad zone ID", __func__)); - ifp = ifnet_byindex(ifindex); + if (ifindex == 0) { + CTR2(KTR_MLD, "%s: warning: no ifindex, looking up " + "ifp for group %s.", __func__, + ip6_sprintf(ip6tbuf, &gsa->sin6.sin6_addr)); + ifp = in6p_lookup_mcast_ifp(inp, &gsa->sin6); + } else { + ifp = ifnet_byindex(ifindex); + } if (ifp == NULL) return (EADDRNOTAVAIL); } |