Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Jul 2009 17:38:18 +0000 (UTC)
From:      Bruce M Simpson <bms@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r195755 - head/sys/netinet6
Message-ID:  <200907181738.n6IHcIrs007528@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bms
Date: Sat Jul 18 17:38:18 2009
New Revision: 195755
URL: http://svn.freebsd.org/changeset/base/195755

Log:
  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)

Modified:
  head/sys/netinet6/in6_mcast.c

Modified: head/sys/netinet6/in6_mcast.c
==============================================================================
--- head/sys/netinet6/in6_mcast.c	Sat Jul 18 16:33:27 2009	(r195754)
+++ head/sys/netinet6/in6_mcast.c	Sat Jul 18 17:38:18 2009	(r195755)
@@ -2160,14 +2160,24 @@ in6p_leave_group(struct inpcb *inp, stru
 		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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907181738.n6IHcIrs007528>