From owner-svn-src-user@FreeBSD.ORG Wed Oct 16 13:07:06 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 90C80CF3; Wed, 16 Oct 2013 13:07:06 +0000 (UTC) (envelope-from ae@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7ED3B2C05; Wed, 16 Oct 2013 13:07:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9GD76R3022730; Wed, 16 Oct 2013 13:07:06 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9GD76Zs022729; Wed, 16 Oct 2013 13:07:06 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201310161307.r9GD76Zs022729@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 16 Oct 2013 13:07:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r256625 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Oct 2013 13:07:06 -0000 Author: ae Date: Wed Oct 16 13:07:06 2013 New Revision: 256625 URL: http://svnweb.freebsd.org/changeset/base/256625 Log: Add additional error codes for IPV6_PKTINFO socket option handling corresponding to RFC3542: * Return ENETDOWN when interface specified by ipi6_ifindex is not enabled for IPv6 use. * Return EADDRNOTAVAIL when ipi6_ifindex specifies an interface but the address ipi6_addr is not available for use on that interface. * Return EINVAL when ipi6_addr is multicast address. Modified: user/ae/inet6/sys/netinet6/ip6_output.c Modified: user/ae/inet6/sys/netinet6/ip6_output.c ============================================================================== --- user/ae/inet6/sys/netinet6/ip6_output.c Wed Oct 16 12:18:44 2013 (r256624) +++ user/ae/inet6/sys/netinet6/ip6_output.c Wed Oct 16 13:07:06 2013 (r256625) @@ -2693,7 +2693,8 @@ ip6_setpktopt(int optname, u_char *buf, sticky && !IN6_IS_ADDR_UNSPECIFIED(&pktinfo->ipi6_addr)) { return (EINVAL); } - + if (IN6_IS_ADDR_MULTICAST(&pktinfo->ipi6_addr)) + return (EINVAL); /* validate the interface index if specified. */ if (pktinfo->ipi6_ifindex > V_if_index || pktinfo->ipi6_ifindex < 0) { @@ -2704,7 +2705,19 @@ ip6_setpktopt(int optname, u_char *buf, if (ifp == NULL) return (ENXIO); } - + if (ifp != NULL && ( + ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)) + return (ENETDOWN); + + if (ifp != NULL && + !IN6_IS_ADDR_UNSPECIFIED(&pktinfo->ipi6_addr)) { + struct in6_ifaddr *ia; + + ia = in6ifa_ifpwithaddr(ifp, &pktinfo->ipi6_addr); + if (ia == NULL) + return (EADDRNOTAVAIL); + ifa_free(&ia->ia_ifa); + } /* * We store the address anyway, and let in6_selectsrc() * validate the specified address. This is because ipi6_addr