From nobody Fri May 23 20:03:32 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4b3x1J2YVlz5wFbj; Fri, 23 May 2025 20:03:32 +0000 (UTC) (envelope-from git@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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4b3x1J20mNz3LDj; Fri, 23 May 2025 20:03:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748030612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ogF1/uNumgOgDPpKSmjF52jSx/C7maFKY7C5AZirUyw=; b=eLY/uSj8DjkfR2JxPa8GakpHYGDTn0bdymWJuDAS0nRemz2JeLb9WnfAOQBa3XW+i/BNud L4RZiZMajs8vv0ujCiGRCHEv9NllzFVPDV598VxcFb2LphUm08MYfCBi1oJH0o+UzOU+de 0w4kTRM9sCghDTsFxQczBuij2vKjnWgaLElm3lwpiUs0UmwfZRRw6PE67TaxufRI5PsOVf 6/UDV1CS1LHtAPMQa93DObYt2Cb0exSN0Ci7ungt6WEdZikCxHEV19bylQoLtnkrrqn9VP 1jYpKxEWh+XcdDQB5IdeJtFTYJXLvfgneqRM7CJXoywGS+/nGdhGt2V6veZ/nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748030612; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ogF1/uNumgOgDPpKSmjF52jSx/C7maFKY7C5AZirUyw=; b=DsvQGw+cjHOv3awVwMNaOtb0OIBSsWLWKTZQtC7N2Ohj6YUECa/ko0zgGJ3e2Gw5kkljtG eKiOgjnrR/C/bkoSEdoTCLRZYidCI4wkfhXP6OpT/g361AZvBJgG+UFrRXEBDjBfUU1+kO +21M85VlS6HgJiJxSYct7KNMjLk91e3Gp1Io50aqY7nL0sDdcP34e7OWdPMBmCYjvTG2yu XqEA8TSX9+mEfzbq0CTALSCetz8PWr9QZlB9IG5SU2BsPMDUXvYrn1FszCS1FV9eKA+vso JS4813073CyXYTOExK8odCEluX8vTRQ06UF4Rtt7KFrNsFZRNBI52EEY1e31kA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1748030612; a=rsa-sha256; cv=none; b=ldzYk2W5V8GqGIH11QP7zd/1qqijqwDRzue55iXvJXUFbkW9PthHmC4+UFIHOW0qvCeVVx MJWBSjK6cS60i0IYKZkLsYw0oBv1LnsdgJl9roZM0DMnTzIT/GVgV3+wmiYiffqKDBmYDy bg7LZbUtrKd8Pkc51px2zK+YesOoe5Nv0GQaynvelFntaOxSjc/lM3fHvp3q9T2rFEfGgK f6C/WxSiXSC6Y1156LOMXpp8C/rTwnPtfScgjzU91vHq+CcE2KUitzpSdSNqIRssze0A2L NLyNoWaILdfqmazzVa/gVltrBhfgbqrxDEI1AT2euUIApMkVpnx3WsRcUbidFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4b3x1J1Yrxz1Jrt; Fri, 23 May 2025 20:03:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 54NK3WuQ031519; Fri, 23 May 2025 20:03:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54NK3WUN031516; Fri, 23 May 2025 20:03:32 GMT (envelope-from git) Date: Fri, 23 May 2025 20:03:32 GMT Message-Id: <202505232003.54NK3WUN031516@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Lexi Winter Subject: git: da2dbdc297c9 - main - bridge: check allow_llz_overlap before member_ifaddrs List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ivy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da2dbdc297c948d5923812e3d3b777b790d3bf43 Auto-Submitted: auto-generated The branch main has been updated by ivy: URL: https://cgit.FreeBSD.org/src/commit/?id=da2dbdc297c948d5923812e3d3b777b790d3bf43 commit da2dbdc297c948d5923812e3d3b777b790d3bf43 Author: Lexi Winter AuthorDate: 2025-05-23 18:08:14 +0000 Commit: Lexi Winter CommitDate: 2025-05-23 18:08:14 +0000 bridge: check allow_llz_overlap before member_ifaddrs When adding a new interface to a bridge and allow_llz_overlap=0, which is the default value, if_bridge checks if the interface has IPv6 link local addresses assigned, and if it does, it calls in6_ifdetach() to remove all IPv6 addresses from the interface. This means it was possible to do this: % ifconfig bridge1 create inet6 -ifdisabled auto_linklocal up % ifconfig epair20 create inet6 -ifdisabled auto_linklocal up % ifconfig bridge1 addm epair20a ... with the result that the link-local address on epair20a would be removed, then the interface would be added to the bridge. If member_ifaddrs=0, which is also the default value, this no longer works: % ifconfig bridge1 addm epair20a ifconfig: BRDGADD epair20a: Invalid argument This is because the member_ifaddrs check runs before allow_llz_overlap does its thing, and returns EINVAL since the new interface has IP addresses on it. To restore the previous behaviour, reverse the order of these two checks, so the IPv6 addresses are removed before we check whether the interface has IPv6 addresses. MFC after: 1 week Reviewed by: kevans, kp Approved by: kevans (mentor) Differential Revision: https://reviews.freebsd.org/D50477 --- sys/net/if_bridge.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 475977adf68a..9338d28437d0 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1329,25 +1329,6 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) return (EINVAL); } - /* - * If member_ifaddrs is disabled, do not allow an interface with - * assigned IP addresses to be added to a bridge. - */ - if (!V_member_ifaddrs) { - struct ifaddr *ifa; - - CK_STAILQ_FOREACH(ifa, &ifs->if_addrhead, ifa_link) { -#ifdef INET - if (ifa->ifa_addr->sa_family == AF_INET) - return (EINVAL); -#endif -#ifdef INET6 - if (ifa->ifa_addr->sa_family == AF_INET6) - return (EINVAL); -#endif - } - } - #ifdef INET6 /* * Two valid inet6 addresses with link-local scope must not be @@ -1386,6 +1367,26 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) } } #endif + + /* + * If member_ifaddrs is disabled, do not allow an interface with + * assigned IP addresses to be added to a bridge. + */ + if (!V_member_ifaddrs) { + struct ifaddr *ifa; + + CK_STAILQ_FOREACH(ifa, &ifs->if_addrhead, ifa_link) { +#ifdef INET + if (ifa->ifa_addr->sa_family == AF_INET) + return (EINVAL); +#endif +#ifdef INET6 + if (ifa->ifa_addr->sa_family == AF_INET6) + return (EINVAL); +#endif + } + } + /* Allow the first Ethernet member to define the MTU */ if (CK_LIST_EMPTY(&sc->sc_iflist)) sc->sc_ifp->if_mtu = ifs->if_mtu;