From nobody Fri Aug 7 01:47:42 2026 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 4hGRqS3MZkz6nf6W for ; Fri, 07 Aug 2026 01:47:48 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hGRqS0VNBz3nKB for ; Fri, 07 Aug 2026 01:47:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786067268; 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=QEL/x8BVkJZ7huocF+Sh+lkmxJy7JEFxQ6iLvlNHZVY=; b=cdPl2WbO1pfy1u80V/mHM5NmE6BPfT1vT+d9sn4+9x7gRTSR2lcxighSpHkTTu0Icd6Zfd 6IOOQKExjmmDhAKbCM4LVsJGiakNUOtXVcd4hA8P6fR7Y6S1DGzV7lnB4irCyH1hlz8nEe doM9mT9F3jW6pVS6zexP/iqQfoFi7VrKkvFRcFw52YwJdyzjXn4FjdT+aEEEAVVvSn1Z1+ 7jBn3PgkeqcwmsKnc0XLR7T2iPIeczaverDGtBqf0NvdCbeyv0d5RzQaKw+KyULr8vbN99 kGumyou21tbfU4MGHLqQVuU8LmIyEMXQeFT0tQ0f018NnVXr8/pP5o+NYysxvg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786067268; a=rsa-sha256; cv=none; b=wfrt5df9qqszfcL165OLTzyxZtRlwz8ni+Hh6eqToXPPHCripcbO2xOfLIQhD2hG9nIZvb eXTqbCEQFJFMrTNHDBFQpr8bnxkRgYMj8va6vMvT3xXynDQtqJktZWs3xW1CUI22mT9Udl 4c7XIrn6hZjMofyDFqU/WMvghcVtH7qBsEg7ceAD2xvHsRM0MbG/90bt5pmUm4OZpx2Zuj xLAvYEo6srxWqMD+fmrRriu4otG27lEWMYpKuCZpYr/YmEo+8VjsGviwTnv55OG+gonxYx EFIoklROEi13XBIbWVc3mbsT3fpTa8FLBYAi90HrBGY4mEMDHsTsXgt5iarlww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786067268; 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=QEL/x8BVkJZ7huocF+Sh+lkmxJy7JEFxQ6iLvlNHZVY=; b=gqiRcNhr6fVg6C98oJoCdvycCtZatmiC29MzINRNu+iLdnvUWb4HBQNNXYpX2Fk0u/KDql B3ICZznYYsClnUZw3GYttnum+CoXGozDus5Hp5sbDjSqFUG/WsirhI0JaZauaziN2PzvBs 3sXqaUqgYl2sfOTwZZn74Wx+/rtyo267Lpj41All/BawX4TAe5TCJp9frgMOM8+u6WMi/L oHfJU84JBHqbIC6e0YXwih5LSgP/bxWpsq56Tx88k0vuDdepbVCdnHe4nLKht1qJVj1P0r 6ttS2CoLsghLaPLJunPpF0BfVDoQQBSZDwpz3Uca+WCHrS+fzG6ys8GESuIJrA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hGRqR6dSNzmX1 for ; Fri, 07 Aug 2026 01:47:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3bb9b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 07 Aug 2026 01:47:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 7d3d6309398e - main - ixgbe: enforce configured VF anti-spoofing 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7d3d6309398ebeb4d60e35535160c722cd25f9bb Auto-Submitted: auto-generated Date: Fri, 07 Aug 2026 01:47:42 +0000 Message-Id: <6a75393e.3bb9b.78974731@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=7d3d6309398ebeb4d60e35535160c722cd25f9bb commit 7d3d6309398ebeb4d60e35535160c722cd25f9bb Author: Kevin Bowling AuthorDate: 2026-07-31 12:34:36 +0000 Commit: Kevin Bowling CommitDate: 2026-08-07 01:35:21 +0000 ixgbe: enforce configured VF anti-spoofing The SR-IOV schema advertises MAC anti-spoofing and enables it by default, but the VF configuration was never consumed and the hardware policy remained disabled. Record the configured policy and apply MAC and VLAN anti-spoofing throughout VF initialization and reset. On X550-family devices, also protect the LLDP and flow-control Ethertypes and enable per-VF spoof-event accounting. Remove the driver-owned state during SR-IOV teardown. Adapt the anti-spoof configuration lifecycle used by igb(4) in a2ed165f0049 to the ixgbe hardware controls. MFC after: 1 week Relnotes: yes --- sys/dev/ixgbe/if_sriov.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ sys/dev/ixgbe/ixgbe_sriov.h | 1 + 2 files changed, 51 insertions(+) diff --git a/sys/dev/ixgbe/if_sriov.c b/sys/dev/ixgbe/if_sriov.c index dd67680d9c7d..963f4392b2fd 100644 --- a/sys/dev/ixgbe/if_sriov.c +++ b/sys/dev/ixgbe/if_sriov.c @@ -124,6 +124,40 @@ ixgbe_process_vf_ack(struct ixgbe_softc *sc, struct ixgbe_vf *vf) ixgbe_send_vf_failure(sc, vf, 0); } +static void +ixgbe_vf_set_anti_spoof(struct ixgbe_softc *sc, struct ixgbe_vf *vf) +{ + struct ixgbe_hw *hw; + uint32_t reg; + bool enable; + + hw = &sc->hw; + enable = (vf->flags & IXGBE_VF_ANTI_SPOOF) != 0; + if (hw->mac.ops.set_mac_anti_spoofing != NULL) + hw->mac.ops.set_mac_anti_spoofing(hw, enable, vf->pool); + if (hw->mac.ops.set_vlan_anti_spoofing != NULL) + hw->mac.ops.set_vlan_anti_spoofing(hw, enable, vf->pool); + if (hw->mac.ops.set_ethertype_anti_spoofing != NULL) { + if (enable) { + IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_LLDP), + IXGBE_ETQF_FILTER_EN | IXGBE_ETQF_TX_ANTISPOOF | + ETHERTYPE_LLDP); + IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FC), + IXGBE_ETQF_FILTER_EN | IXGBE_ETQF_TX_ANTISPOOF | + ETHERTYPE_FLOWCONTROL); + } + hw->mac.ops.set_ethertype_anti_spoofing(hw, enable, + vf->pool); + } + + reg = IXGBE_READ_REG(hw, IXGBE_VMECM(IXGBE_VF_INDEX(vf->pool))); + if (enable) + reg |= IXGBE_VF_BIT(vf->pool); + else + reg &= ~IXGBE_VF_BIT(vf->pool); + IXGBE_WRITE_REG(hw, IXGBE_VMECM(IXGBE_VF_INDEX(vf->pool)), reg); +} + static inline boolean_t ixgbe_vf_mac_changed(struct ixgbe_vf *vf, const uint8_t *mac) { @@ -314,6 +348,7 @@ ixgbe_process_vf_reset(struct ixgbe_softc *sc, struct ixgbe_vf *vf) ixgbe_iov_rebuild_mta(sc); ixgbe_clear_rar(&sc->hw, vf->rar_index); + ixgbe_vf_set_anti_spoof(sc, vf); ixgbe_toggle_txdctl(&sc->hw, vf->pool); vf->api_ver = IXGBE_API_VER_UNKNOWN; @@ -741,6 +776,7 @@ ixgbe_if_iov_uninit(if_ctx_t ctx) struct ixgbe_hw *hw; struct ixgbe_softc *sc; uint32_t pf_reg, vf_reg; + int i; sc = iflib_get_softc(ctx); hw = &sc->hw; @@ -757,6 +793,17 @@ ixgbe_if_iov_uninit(if_ctx_t ctx) IXGBE_WRITE_REG(hw, IXGBE_VFRE(vf_reg), 0); IXGBE_WRITE_REG(hw, IXGBE_VFTE(vf_reg), 0); + for (i = 0; i < sc->num_vfs; i++) { + if (!(sc->vfs[i].flags & IXGBE_VF_ACTIVE)) + continue; + sc->vfs[i].flags &= ~IXGBE_VF_ANTI_SPOOF; + ixgbe_vf_set_anti_spoof(sc, &sc->vfs[i]); + } + if (hw->mac.ops.set_ethertype_anti_spoofing != NULL) { + IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_LLDP), 0); + IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FC), 0); + } + IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, 0); sc->num_vfs = 0; @@ -790,6 +837,7 @@ ixgbe_init_vf(struct ixgbe_softc *sc, struct ixgbe_vf *vf) ixgbe_set_rar(&sc->hw, vf->rar_index, vf->ether_addr, vf->pool, true); } + ixgbe_vf_set_anti_spoof(sc, vf); ixgbe_vf_enable_transmit(sc, vf); ixgbe_vf_enable_receive(sc, vf); @@ -890,6 +938,8 @@ ixgbe_if_iov_vf_add(if_ctx_t ctx, u16 vfnum, const nvlist_t *config) vf->default_vlan = 0; vf->maximum_frame_size = ETHER_MAX_LEN; ixgbe_update_max_frame(sc, vf->maximum_frame_size); + if (nvlist_get_bool(config, "mac-anti-spoof")) + vf->flags |= IXGBE_VF_ANTI_SPOOF; if (nvlist_exists_binary(config, "mac-addr")) { mac = nvlist_get_binary(config, "mac-addr", NULL); diff --git a/sys/dev/ixgbe/ixgbe_sriov.h b/sys/dev/ixgbe/ixgbe_sriov.h index c3a988bda886..bae3f25f7d71 100644 --- a/sys/dev/ixgbe/ixgbe_sriov.h +++ b/sys/dev/ixgbe/ixgbe_sriov.h @@ -47,6 +47,7 @@ #define IXGBE_VF_CAP_MAC (1 << 1) /* VF is permitted to change MAC. */ #define IXGBE_VF_CAP_VLAN (1 << 2) /* VF is permitted to join vlans. */ #define IXGBE_VF_ACTIVE (1 << 3) /* VF is active. */ +#define IXGBE_VF_ANTI_SPOOF (1 << 4) /* Enforce source identity. */ #define IXGBE_VF_INDEX(vmdq) ((vmdq) / 32) #define IXGBE_VF_BIT(vmdq) (1 << ((vmdq) % 32))