From owner-svn-src-head@freebsd.org Wed Nov 25 20:58:02 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0593947427F; Wed, 25 Nov 2020 20:58:02 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ChCs56MPcz4T8n; Wed, 25 Nov 2020 20:58:01 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CD4D2178BB; Wed, 25 Nov 2020 20:58:01 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0APKw1DK043268; Wed, 25 Nov 2020 20:58:01 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0APKw1FL043266; Wed, 25 Nov 2020 20:58:01 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202011252058.0APKw1FL043266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Wed, 25 Nov 2020 20:58:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368031 - in head: libexec/rc sys/netinet6 X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: in head: libexec/rc sys/netinet6 X-SVN-Commit-Revision: 368031 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2020 20:58:02 -0000 Author: bz Date: Wed Nov 25 20:58:01 2020 New Revision: 368031 URL: https://svnweb.freebsd.org/changeset/base/368031 Log: IPv6: set ifdisabled in the kernel rather than in rc Enable ND6_IFF_IFDISABLED when the interface is created in the kernel before return to user space. This avoids a race when an interface is create by a program which also calls ifconfig IF inet6 -ifdisabled and races with the devd -> /etc/pccard_ether -> .. netif start IF -> ifdisabled calls (the devd/rc framework disabling IPv6 again after the program had enabled it already). In case the global net.inet6.ip6.accept_rtadv was turned on, we also default to enabling IPv6 on the interfaces, rather than disabling them. PR: 248172 Reported by: Gert Doering (gert greenie.muc.de) Reviewed by: glebius (, phk) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27324 Modified: head/libexec/rc/network.subr head/sys/netinet6/nd6.c Modified: head/libexec/rc/network.subr ============================================================================== --- head/libexec/rc/network.subr Wed Nov 25 20:05:05 2020 (r368030) +++ head/libexec/rc/network.subr Wed Nov 25 20:58:01 2020 (r368031) @@ -134,8 +134,6 @@ ifconfig_up() if ! noafif $1 && afexists inet6; then if checkyesno ipv6_activate_all_interfaces; then _ipv6_opts="-ifdisabled" - elif [ "$1" != "lo0" ]; then - _ipv6_opts="ifdisabled" fi # backward compatibility: $ipv6_enable Modified: head/sys/netinet6/nd6.c ============================================================================== --- head/sys/netinet6/nd6.c Wed Nov 25 20:05:05 2020 (r368030) +++ head/sys/netinet6/nd6.c Wed Nov 25 20:58:01 2020 (r368031) @@ -273,6 +273,10 @@ nd6_ifattach(struct ifnet *ifp) nd->flags = ND6_IFF_PERFORMNUD; + /* Set IPv6 disabled on all interfaces but loopback by default. */ + if ((ifp->if_flags & IFF_LOOPBACK) == 0) + nd->flags |= ND6_IFF_IFDISABLED; + /* A loopback interface always has ND6_IFF_AUTO_LINKLOCAL. * XXXHRS: Clear ND6_IFF_AUTO_LINKLOCAL on an IFT_BRIDGE interface by * default regardless of the V_ip6_auto_linklocal configuration to @@ -290,8 +294,11 @@ nd6_ifattach(struct ifnet *ifp) */ if (V_ip6_accept_rtadv && !(ifp->if_flags & IFF_LOOPBACK) && - (ifp->if_type != IFT_BRIDGE)) + (ifp->if_type != IFT_BRIDGE)) { nd->flags |= ND6_IFF_ACCEPT_RTADV; + /* If we globally accept rtadv, assume IPv6 on. */ + nd->flags &= ~ND6_IFF_IFDISABLED; + } if (V_ip6_no_radr && !(ifp->if_flags & IFF_LOOPBACK)) nd->flags |= ND6_IFF_NO_RADR;