From owner-svn-src-stable@FreeBSD.ORG Fri Apr 24 02:12:26 2015 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AE66F958; Fri, 24 Apr 2015 02:12:26 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9AE5C1173; Fri, 24 Apr 2015 02:12:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3O2CQnU051986; Fri, 24 Apr 2015 02:12:26 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3O2CQpb051985; Fri, 24 Apr 2015 02:12:26 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201504240212.t3O2CQpb051985@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Fri, 24 Apr 2015 02:12:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r281911 - stable/10/sys/netinet6 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Apr 2015 02:12:26 -0000 Author: ae Date: Fri Apr 24 02:12:25 2015 New Revision: 281911 URL: https://svnweb.freebsd.org/changeset/base/281911 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/10/sys/netinet6/in6_mcast.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet6/in6_mcast.c ============================================================================== --- stable/10/sys/netinet6/in6_mcast.c Thu Apr 23 22:39:32 2015 (r281910) +++ stable/10/sys/netinet6/in6_mcast.c Fri Apr 24 02:12:25 2015 (r281911) @@ -2350,11 +2350,15 @@ in6p_set_multicast_if(struct inpcb *inp, return (error); if (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);