Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Apr 2015 02:43:03 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r281914 - stable/9/sys/netinet6
Message-ID:  <201504240243.t3O2h3BY067077@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Fri Apr 24 02:43:02 2015
New Revision: 281914
URL: https://svnweb.freebsd.org/changeset/base/281914

Log:
  MFC r281380:
    Fix the IPV6_MULTICAST_IF sockopt handling. RFC 3493 says when the
    interface index is specified as zero, the system should select the
    interface to use for outgoing multicast packets. Even the comment
    for the in6p_set_multicast_if() function says about index of zero.
    But in fact for zero index the function just returns EADDRNOTAVAIL.
  
    I.e. if you first set some interface and then will try reset it
    with zero ifindex, you will get EADDRNOTAVAIL.
  
    Reset im6o_multicast_ifp to NULL when interface index specified as
    zero. Also return EINVAL in case when ifnet_byindex() returns NULL.
    This will be the same behaviour as when ifindex is bigger than
    V_if_index. And return EADDRNOTAVAIL only when interface is not
    multicast capable.

Modified:
  stable/9/sys/netinet6/in6_mcast.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet6/in6_mcast.c
==============================================================================
--- stable/9/sys/netinet6/in6_mcast.c	Fri Apr 24 02:15:14 2015	(r281913)
+++ stable/9/sys/netinet6/in6_mcast.c	Fri Apr 24 02:43:02 2015	(r281914)
@@ -2353,11 +2353,15 @@ in6p_set_multicast_if(struct inpcb *inp,
 		return (error);
 	if (ifindex < 0 || V_if_index < ifindex)
 		return (EINVAL);
-
-	ifp = ifnet_byindex(ifindex);
-	if (ifp == NULL || (ifp->if_flags & IFF_MULTICAST) == 0)
-		return (EADDRNOTAVAIL);
-
+	if (ifindex == 0)
+		ifp = NULL;
+	else {
+		ifp = ifnet_byindex(ifindex);
+		if (ifp == NULL)
+			return (EINVAL);
+		if ((ifp->if_flags & IFF_MULTICAST) == 0)
+			return (EADDRNOTAVAIL);
+	}
 	imo = in6p_findmoptions(inp);
 	imo->im6o_multicast_ifp = ifp;
 	INP_WUNLOCK(inp);



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