From nobody Sun Aug 10 15:37:18 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 4c0MMf685Lz649tP; Sun, 10 Aug 2025 15:37:18 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c0MMf2pfhz3f60; Sun, 10 Aug 2025 15:37:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754840238; 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=9N2EPjMSvIAY8OnFnUh9mfJd+LDFqSRsuVDvDc2LOrY=; b=pAilyRgHydc9cw8pxB6ABv1MD1hKmQgITlHxA0ESHJV0H9xBLOhJvCwkh907t2iPWJz6tc rzlZx3oU0HeKmlxYvirN9SNqmOKCrLOOVLN/nWeiZqhqosRtqWzofpFpuRkZ6mZZVmTKNc JE94Fvzq2VJqmNHNA9nlymDqSTJmYM+KBMEZNvpfxLpCEhLmQGbqHWtiKhrOYOQizf+E9S xtx5YFVawDBekQLXr0UNYT+utsBAg6hztga+TzzLilHdKmY969seUavdA7QpZ49nuiD6pu agZsgmbU8koCPJvcOozCM4IP3T8oarxIoicHcyuefKQC/sDlWNkT48O6TQw3UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754840238; 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=9N2EPjMSvIAY8OnFnUh9mfJd+LDFqSRsuVDvDc2LOrY=; b=VJ1jND8zjE0G9XfPqL75NMae7d3L0qAECki9Varkq2hNMrgIvZvvPdh0jaAuLqhkuArRUP KZYudTwrzWVxbpJssl8OCx4+jz3DeCOkhiCi/Gp8QNyBUjvw1tn3YwJiEdgJN5jfteR4yJ 65UHtgRnviVpL1UNcBrG2IqKUUg3Bs2Q2ektoaM90BZV3cfg49piP0CJXYHNTZ2n4npzFH xeHXp66pF4Ds4SOhxG2LaMb/ckzSSlAzSL+zSd6lMorSeo8ZMUiSrcosVWd+AGDoT8lVoc be4Gj4VHdmppB42aoD3pwp6Z6NivMDjU4pVEoQ7AhaNennHNWRkGajyTwP0HoQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1754840238; a=rsa-sha256; cv=none; b=MeBKf3D7o3sDdEbYG+Xnk3hAfvbZ/M5mUgfNriyzhPPAa8cfazrqukiQzOMQ3rCLnG9NZL Xpstz8JTPO5JjLI3vcSDn+vDphK+qwNi+mPsq1Lg+1EOmulacsLMMkc+guLPYA/h8Ormsh 9lWKJUnm4k6NQRatOTZXhomHjzI5gyTwDDX14ghVsNyInLrOMKgZA+k83T5RyoACgk7YgX nKCzFqoqr2oeOMvLlmFxjf7gnwAOXu9aXBhx4MdWhMWutOvbY7xFxCgaKujig/2Mp043Ih PsMP6tLr5krGGjAii8+M4lO2V6dIkwxArZxKQ9c4P9JzkkhgZ5JrlYE3tMgtHQ== 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 4c0MMf2JKPz1B2d; Sun, 10 Aug 2025 15:37:18 +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 57AFbIqb067251; Sun, 10 Aug 2025 15:37:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57AFbIfU067248; Sun, 10 Aug 2025 15:37:18 GMT (envelope-from git) Date: Sun, 10 Aug 2025 15:37:18 GMT Message-Id: <202508101537.57AFbIfU067248@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: 43ac5806a5a3 - main - bridge: Divorce ifuntagged from vlanfilter 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: 43ac5806a5a3150f561e14a11866dd56cf1b4d42 Auto-Submitted: auto-generated The branch main has been updated by ivy: URL: https://cgit.FreeBSD.org/src/commit/?id=43ac5806a5a3150f561e14a11866dd56cf1b4d42 commit 43ac5806a5a3150f561e14a11866dd56cf1b4d42 Author: Lexi Winter AuthorDate: 2025-08-10 15:11:32 +0000 Commit: Lexi Winter CommitDate: 2025-08-10 15:36:40 +0000 bridge: Divorce ifuntagged from vlanfilter The ifuntagged option was added as part of the VLAN filtering feature, but it's useful on its own to be able to place interface traffic in a VLAN without having to configure every interface for VLAN filtering. Always do the pvid processing in bridge even if IFBRF_VLANFILTER isn't enabled, and don't prohibit configuring it. Add a test for the specific case of setting untagged without vlanfilter. This has no effect on bridges which don't have at least one interface configured with ifuntagged. Differential Revision: https://reviews.freebsd.org/D51760 --- sys/net/if_bridge.c | 28 ++++++++++++--------- tests/sys/net/if_bridge_test.sh | 54 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 14 deletions(-) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 1e444be93e9f..66555fd1feb5 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1500,8 +1500,7 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) bif->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER; bif->bif_savedcaps = ifs->if_capenable; bif->bif_vlanproto = ETHERTYPE_VLAN; - if (sc->sc_flags & IFBRF_VLANFILTER) - bif->bif_pvid = sc->sc_defpvid; + bif->bif_pvid = sc->sc_defpvid; if (sc->sc_flags & IFBRF_DEFQINQ) bif->bif_flags |= IFBIF_QINQ; @@ -1970,9 +1969,6 @@ bridge_ioctl_sifpvid(struct bridge_softc *sc, void *arg) struct ifbreq *req = arg; struct bridge_iflist *bif; - if ((sc->sc_flags & IFBRF_VLANFILTER) == 0) - return (EXTERROR(EINVAL, "VLAN filtering not enabled")); - bif = bridge_lookup_member(sc, req->ifbr_ifsname); if (bif == NULL) return (EXTERROR(ENOENT, "Interface is not a bridge member")); @@ -2410,12 +2406,10 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m, mflags = m->m_flags; /* - * If VLAN filtering is enabled, and the native VLAN ID of the - * outgoing interface matches the VLAN ID of the frame, remove - * the VLAN header. + * If the native VLAN ID of the outgoing interface matches the + * VLAN ID of the frame, remove the VLAN tag. */ - if ((sc->sc_flags & IFBRF_VLANFILTER) && - bif->bif_pvid != DOT1Q_VID_NULL && + if (bif->bif_pvid != DOT1Q_VID_NULL && VLANTAGOF(m) == bif->bif_pvid) { m->m_flags &= ~M_VLANTAG; m->m_pkthdr.ether_vtag = 0; @@ -3296,9 +3290,19 @@ bridge_vfilter_in(const struct bridge_iflist *sbif, struct mbuf *m) if (vlan > DOT1Q_VID_MAX) return (false); - /* If VLAN filtering isn't enabled, pass everything. */ - if ((sbif->bif_sc->sc_flags & IFBRF_VLANFILTER) == 0) + /* + * If VLAN filtering isn't enabled, pass everything, but add a tag + * if the port has a pvid configured. + */ + if ((sbif->bif_sc->sc_flags & IFBRF_VLANFILTER) == 0) { + if (vlan == DOT1Q_VID_NULL && + sbif->bif_pvid != DOT1Q_VID_NULL) { + m->m_pkthdr.ether_vtag = sbif->bif_pvid; + m->m_flags |= M_VLANTAG; + } + return (true); + } /* If Q-in-Q is disabled, check for stacked tags. */ if ((sbif->bif_flags & IFBIF_QINQ) == 0) { diff --git a/tests/sys/net/if_bridge_test.sh b/tests/sys/net/if_bridge_test.sh index 906f586d2483..0c19903714b1 100755 --- a/tests/sys/net/if_bridge_test.sh +++ b/tests/sys/net/if_bridge_test.sh @@ -899,7 +899,7 @@ member_ifaddrs_vlan_cleanup() atf_test_case "vlan_pvid" "cleanup" vlan_pvid_head() { - atf_set descr 'bridge with two ports with pvid set' + atf_set descr 'bridge with two ports with pvid and vlanfilter set' atf_set require.user root } @@ -1327,6 +1327,56 @@ bridge_svi_in_bridge_cleanup() vnet_cleanup } +atf_test_case "vlan_untagged" "cleanup" +vlan_untagged_head() +{ + atf_set descr 'bridge with two ports with untagged set' + atf_set require.user root +} + +vlan_untagged_body() +{ + vnet_init + vnet_init_bridge + + epone=$(vnet_mkepair) + eptwo=$(vnet_mkepair) + + vnet_mkjail one ${epone}b + vnet_mkjail two ${eptwo}b + + jexec one ifconfig ${epone}b 192.0.2.1/24 up + jexec two ifconfig ${eptwo}b 192.0.2.2/24 up + + bridge=$(vnet_mkbridge) + + ifconfig ${bridge} up + ifconfig ${epone}a up + ifconfig ${eptwo}a up + ifconfig ${bridge} addm ${epone}a untagged 20 + ifconfig ${bridge} addm ${eptwo}a untagged 30 + + # With two ports on different VLANs, traffic should not be passed. + atf_check -s exit:2 -o ignore jexec one ping -c 3 -t 1 192.0.2.2 + atf_check -s exit:2 -o ignore jexec two ping -c 3 -t 1 192.0.2.1 + + # Move the second port to VLAN 20; now traffic should be passed. + atf_check -s exit:0 ifconfig ${bridge} ifuntagged ${eptwo}a 20 + atf_check -s exit:0 -o ignore jexec one ping -c 3 -t 1 192.0.2.2 + atf_check -s exit:0 -o ignore jexec two ping -c 3 -t 1 192.0.2.1 + + # Remove the first's port untagged config, now traffic should + # not pass again. + atf_check -s exit:0 ifconfig ${bridge} -ifuntagged ${epone}a + atf_check -s exit:2 -o ignore jexec one ping -c 3 -t 1 192.0.2.2 + atf_check -s exit:2 -o ignore jexec two ping -c 3 -t 1 192.0.2.1 +} + +vlan_untagged_cleanup() +{ + vnet_cleanup +} + atf_test_case "vlan_defuntagged" "cleanup" vlan_defuntagged_head() { @@ -1340,7 +1390,6 @@ vlan_defuntagged_body() vnet_init_bridge bridge=$(vnet_mkbridge) - atf_check -s exit:0 ifconfig ${bridge} vlanfilter # Invalid VLAN IDs atf_check -s exit:1 -ematch:"invalid vlan id: 0" \ @@ -1407,6 +1456,7 @@ atf_init_test_cases() atf_add_test_case "vlan_ifconfig_iftagged" atf_add_test_case "vlan_svi" atf_add_test_case "vlan_qinq" + atf_add_test_case "vlan_untagged" atf_add_test_case "vlan_defuntagged" atf_add_test_case "bridge_svi_in_bridge" }