From patchwork Mon Oct 9 10:06:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413322 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA8861798B for ; Mon, 9 Oct 2023 10:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="i4X5UckG" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2077.outbound.protection.outlook.com [40.107.220.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B00CB10A; Mon, 9 Oct 2023 03:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T37hcsWW/PzXvn+GtK0ESJzy4u0jmIrQs5B3yaLHWUVrttr16sigFPBG7qBlmbaB2pv0Ygy4XH6lcwlIfQj7fonRGibxbxkkdOcajDbvkFo441yPWOIGaqMc9azi3GqTTagW9/nwSNh1BiWevs2iKxtDZT58ltt2mgXkgEsWRyUDfX2BnNCTGZ7HpZsIUkVgrqx3rp5qK0h56HXuihkJKaL6L0eYMweh3EcLSrjOFVYd8lMbmkEZ35AG6rb1Cop0zxkwOvgNmNKSR/O73Udt2JqaoYyg+DZjMfky5EteQ9AW0kEu94J2hW+hYmH2gjywTm4FBY3z4kMHAvWVo0h16w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5rtfrZsIGrxrPNKj1deBXKst1E6NF8TioHabpf5xoyM=; b=MnCE85QDleKbjLv+cZHFUpSsq5tVOrwq1526qlxbhNAcBRqbHmXFl/dIF+/3bvv8o4gKubncA1qZ86+8Tbq/K+ObAHbcd6dwBF8IURtQuMZVq7o59RcMRXSe9gMCjQQtQ0P8sbKudqpV/+c2vtR1Pr4pBg7B30M4LMRd3a6V4NU714Z30RVJlQpF+4+lSAeN0bOEzt1mX3PcKJsxopVviWOYqTDkhAb7fS3upkz2DivPtXX3kWUUTPgML6zB1FzKwrbDeNjwLr8himOs1E7Jgo2SU4Ir1GUQRAe3vNp17SGaFXml43Wxrwzxu+mBfJ9LLm0cvTglTBhYQ2oraGc8vQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5rtfrZsIGrxrPNKj1deBXKst1E6NF8TioHabpf5xoyM=; b=i4X5UckGC4YQVoCeBoApEXxli5XLgjlXfirrN+TmPkxE0Nf34pIYrPHHNZ6K9WzgAsGPshL1KpShG5k8h2P7LXP5/9h/ESHpVUM0uoW6OU+kR7+A38Hdec0vD5j4Yy4j4BwKM/gDyTn3X3gzwDqsmAiYSjtGNV49sNlqONQaEETL0daQjnMZediUBeWdWU3t9VogFGjV+Qqioy46if9klrzP4UkZwHbUUEI9x48ZWnwSaHS9+ZylmkmiY8qowSDOQNaP6AOVI1mNqA2F4ABZtnO3WF9RhSIDKADqKFJuClLY94j6h6sbb2LAVGQGUtFPnBiPnWg86WovksOeiAZTlQ== Received: from DS7PR06CA0011.namprd06.prod.outlook.com (2603:10b6:8:2a::6) by DM6PR12MB4156.namprd12.prod.outlook.com (2603:10b6:5:218::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Mon, 9 Oct 2023 10:07:05 +0000 Received: from DS2PEPF0000343B.namprd02.prod.outlook.com (2603:10b6:8:2a:cafe::6c) by DS7PR06CA0011.outlook.office365.com (2603:10b6:8:2a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36 via Frontend Transport; Mon, 9 Oct 2023 10:07:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS2PEPF0000343B.mail.protection.outlook.com (10.167.18.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:05 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:06:54 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:06:51 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" Subject: [PATCH net-next 01/11] net: Handle bulk delete policy in bridge driver Date: Mon, 9 Oct 2023 13:06:08 +0300 Message-ID: <20231009100618.2911374-2-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343B:EE_|DM6PR12MB4156:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c406c69-611e-40b5-8b3c-08dbc8af7db1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kUG1747g34tc4VlyJKsh4+cthpwfZmIomvu9nu0WCgG4csh+BWXK8T89eH/bhq7qDijra80bs1ajrLGv4r/JksREKjWAlg2g9jYX/4NfuLwrvKpilvYTFMRbgCv1tZcPRaDBdp9bGrmzbEI1Evgra2/6o5FKJpO2PN8og5ssTUsGKWQKFR4lT4rGOcSsW8T/9LdA4cPkLiPWALEUFbinVLg8ApRCRaciY96uDt5fDPSXpQl/XznvLWobjzHlGcFjjEfMKZatHKjY1rPYtbgGws2z+k3su8VDHMi3lNucvcFVYHdSc/eG5QJY/iVkmVIGiGhOlkBCo5dADAy00WTxr2B3SV+CjxZV7Suf8MMBtAsoYHWE2UfbXsUnQ2hHrQEXixdP9WgU8THtFORMxLcwqCprUjU+7y9L3T4mezTXyHiWDB9Vlx7g0ndKcmFiZmjRQC3hjD6R/6QQw2cn/urv2cWNlxJtgOsPypmwdSfNhmnebDgElC53LWwGAOxEK+LGwYMupYt7ZijwZjkS3fZphuiP52AmbSyqaTbJNNL4UWaDhRRCaNEpHK9pOx6R3A80w7a3lud4Ehu5W9lP5RIqfc2bmhmfut3zFo6WL/Z5hYe7iGT3qxwiDtpYBLN1EH8GqAOl8ynpOg7iih69trh1itvW+by/g/KplUQlaetkbkzTKg4/5uxt2aLa0/aiQ85h3mytQz25SLSwHey8YQtoyj6muBzGarJIDHwksiWlyV+LYFV2sfczFwvuhKh9Ajvm X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(396003)(39860400002)(376002)(346002)(136003)(230922051799003)(64100799003)(451199024)(186009)(1800799009)(82310400011)(36840700001)(46966006)(40470700004)(7636003)(356005)(86362001)(36756003)(40480700001)(2906002)(478600001)(82740400003)(4326008)(5660300002)(8936002)(8676002)(6666004)(41300700001)(83380400001)(2616005)(336012)(1076003)(107886003)(40460700003)(426003)(36860700001)(6916009)(70586007)(70206006)(316002)(54906003)(26005)(47076005)(16526019);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:05.5270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c406c69-611e-40b5-8b3c-08dbc8af7db1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4156 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The merge commit 92716869375b ("Merge branch 'br-flush-filtering'") added support for FDB flushing in bridge driver. The following patches will extend VXLAN driver to support FDB flushing as well. The netlink message for bulk delete is shared between the drivers. With the existing implementation, there is no way to prevent user from flushing with attributes that are not supported per driver. For example, when VNI will be added, user will not get an error for flush FDB entries in bridge with VNI, although this attribute is not relevant for bridge. As preparation for support of FDB flush in VXLAN driver, move the policy to be handled in bridge driver, later a new policy for VXLAN will be added in VXLAN driver. Do not pass 'vid' as part of ndo_fdb_del_bulk(), as this field is relevant only for bridge. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel --- include/linux/netdevice.h | 8 ++------ net/bridge/br_fdb.c | 29 ++++++++++++++++++++++++----- net/bridge/br_private.h | 3 +-- net/core/rtnetlink.c | 27 ++++++++++----------------- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index e070a4540fba..17b3c0e86bb4 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1290,9 +1290,7 @@ struct netdev_net_notifier { * struct net_device *dev, * const unsigned char *addr, u16 vid) * Deletes the FDB entry from dev coresponding to addr. - * int (*ndo_fdb_del_bulk)(struct ndmsg *ndm, struct nlattr *tb[], - * struct net_device *dev, - * u16 vid, + * int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh, struct net_device *dev, * struct netlink_ext_ack *extack); * int (*ndo_fdb_dump)(struct sk_buff *skb, struct netlink_callback *cb, * struct net_device *dev, struct net_device *filter_dev, @@ -1567,10 +1565,8 @@ struct net_device_ops { struct net_device *dev, const unsigned char *addr, u16 vid, struct netlink_ext_ack *extack); - int (*ndo_fdb_del_bulk)(struct ndmsg *ndm, - struct nlattr *tb[], + int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh, struct net_device *dev, - u16 vid, struct netlink_ext_ack *extack); int (*ndo_fdb_dump)(struct sk_buff *skb, struct netlink_callback *cb, diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index e69a872bfc1d..a98ad763b368 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -661,14 +661,30 @@ static int __fdb_flush_validate_ifindex(const struct net_bridge *br, return 0; } -int br_fdb_delete_bulk(struct ndmsg *ndm, struct nlattr *tb[], - struct net_device *dev, u16 vid, +static const struct nla_policy br_fdb_del_bulk_policy[NDA_MAX + 1] = { + [NDA_VLAN] = NLA_POLICY_RANGE(NLA_U16, 1, VLAN_N_VID - 2), + [NDA_IFINDEX] = NLA_POLICY_MIN(NLA_S32, 1), + [NDA_NDM_STATE_MASK] = { .type = NLA_U16 }, + [NDA_NDM_FLAGS_MASK] = { .type = NLA_U8 }, +}; + +int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, struct netlink_ext_ack *extack) { - u8 ndm_flags = ndm->ndm_flags & ~FDB_FLUSH_IGNORED_NDM_FLAGS; - struct net_bridge_fdb_flush_desc desc = { .vlan_id = vid }; + struct net_bridge_fdb_flush_desc desc = {}; + struct ndmsg *ndm = nlmsg_data(nlh); struct net_bridge_port *p = NULL; + struct nlattr *tb[NDA_MAX + 1]; struct net_bridge *br; + u8 ndm_flags; + int err; + + ndm_flags = ndm->ndm_flags & ~FDB_FLUSH_IGNORED_NDM_FLAGS; + + err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, + br_fdb_del_bulk_policy, extack); + if (err) + return err; if (netif_is_bridge_master(dev)) { br = netdev_priv(dev); @@ -681,6 +697,9 @@ int br_fdb_delete_bulk(struct ndmsg *ndm, struct nlattr *tb[], br = p->br; } + if (tb[NDA_VLAN]) + desc.vlan_id = nla_get_u16(tb[NDA_VLAN]); + if (ndm_flags & ~FDB_FLUSH_ALLOWED_NDM_FLAGS) { NL_SET_ERR_MSG(extack, "Unsupported fdb flush ndm flag bits set"); return -EINVAL; @@ -703,7 +722,7 @@ int br_fdb_delete_bulk(struct ndmsg *ndm, struct nlattr *tb[], desc.flags_mask |= __ndm_flags_to_fdb_flags(ndm_flags_mask); } if (tb[NDA_IFINDEX]) { - int err, ifidx = nla_get_s32(tb[NDA_IFINDEX]); + int ifidx = nla_get_s32(tb[NDA_IFINDEX]); err = __fdb_flush_validate_ifindex(br, ifidx, extack); if (err) diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index a1f4acfa6994..cbbe35278459 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -847,8 +847,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source, int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, struct netlink_ext_ack *extack); -int br_fdb_delete_bulk(struct ndmsg *ndm, struct nlattr *tb[], - struct net_device *dev, u16 vid, +int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, struct netlink_ext_ack *extack); int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, u16 nlh_flags, diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 7452a6d190c5..eef7f7788996 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -4367,13 +4367,6 @@ int ndo_dflt_fdb_del(struct ndmsg *ndm, } EXPORT_SYMBOL(ndo_dflt_fdb_del); -static const struct nla_policy fdb_del_bulk_policy[NDA_MAX + 1] = { - [NDA_VLAN] = { .type = NLA_U16 }, - [NDA_IFINDEX] = NLA_POLICY_MIN(NLA_S32, 1), - [NDA_NDM_STATE_MASK] = { .type = NLA_U16 }, - [NDA_NDM_FLAGS_MASK] = { .type = NLA_U8 }, -}; - static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, struct netlink_ext_ack *extack) { @@ -4394,8 +4387,10 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, err = nlmsg_parse_deprecated(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, extack); } else { - err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, - fdb_del_bulk_policy, extack); + /* For bulk delete, the drivers will parse the message with + * policy. + */ + err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, extack); } if (err < 0) return err; @@ -4418,6 +4413,10 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, return -EINVAL; } addr = nla_data(tb[NDA_LLADDR]); + + err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack); + if (err) + return err; } if (dev->type != ARPHRD_ETHER) { @@ -4425,10 +4424,6 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, return -EINVAL; } - err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack); - if (err) - return err; - err = -EOPNOTSUPP; /* Support fdb on master device the net/bridge default case */ @@ -4442,8 +4437,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid, extack); } else { if (ops->ndo_fdb_del_bulk) - err = ops->ndo_fdb_del_bulk(ndm, tb, dev, vid, - extack); + err = ops->ndo_fdb_del_bulk(nlh, dev, extack); } if (err) @@ -4464,8 +4458,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, /* in case err was cleared by NTF_MASTER call */ err = -EOPNOTSUPP; if (ops->ndo_fdb_del_bulk) - err = ops->ndo_fdb_del_bulk(ndm, tb, dev, vid, - extack); + err = ops->ndo_fdb_del_bulk(nlh, dev, extack); } if (!err) { From patchwork Mon Oct 9 10:06:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413321 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7855517989 for ; Mon, 9 Oct 2023 10:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="gCjyhapy" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F40109; Mon, 9 Oct 2023 03:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nEllMDNGAF8ssNtKfbUZdbZMGt34h8xCB19ly//rfJmPyZxRgwnUdWD256YfN0bx7yw8ApfxQvAJn7pZ7FWFZrKkTwtrfhJgoM4mWp/YGchLeQYTuSnLTUlBXXBH54D/VUoe39b/fk3rgy0b6oiFzowFIAhIZdix4s941whBHZ845UbZrRMZnYdoDMWvI5aCgGr0D5w0JAtQQ3c8TSnZMgKg0FayfApYJFwXKxpzs50OsnN1FrOEMX9Jj7Ga3yIEvSEy65e9bcvOjcXksWgQhHev3K3zharhdCIu74kPM2O9qtbjEfXHniwQ3be2VoLefZzI48TZf0gjat/HtTI9Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ath0yXoGX+w26Wh+M+ziarUJMEcVX0Kme1m4YZaKbFc=; b=acEHQGaKC9IJOTgVnHFBKxusPqveTrwmG2UEh0T35uzP5IUgrH/F0GJhbIoNViSodv5tU1T1XWXZ1BEG804roUvGPfHvf/Est6Xv14Yo0PTUQmyzP+Mvd3xqqaRXg4GmgydvD1za02bZtcDbkMzfr4bUQSX+fUxvT+xJMzrOXvXwf8Vbuin2050Vgcy4kce8Z6EEgU3zIG4rDl0m05/xx2vRwo1i2auXbo4eR6ejQZ5QI7nQA9ed+mstS46qhYIaH7STcCtZnvD2barcCAu6H/9+l4XIXZJlB2qgwZfBbmPSq39wCcAQLdfuiSvkNXJh9ogqA8yFGbup55EKWqsZqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ath0yXoGX+w26Wh+M+ziarUJMEcVX0Kme1m4YZaKbFc=; b=gCjyhapyDjpT0yQPWISKKc+wlKbi/a4B9bY8kIGN9R2gTL1Db+7wGEJhHh4SO1xSU7qJybZ0dLrIr5YqVA89FiOZ4+p0UUwgfrj9W5zwDkqZQttHfmFCh/n2ttC2+XNHWtqt3HeBp1KAaByB5FJrKrAuzPwUPVj0fZW+r4OL8MjJ/Idz8BkNH6jIinsDBxS//qZYNDVJe8vnv5cDMNvgYM88E69f7kJilYvJh/U2ATmFoIGfXyuAZZ21Cdo7ZIst7i5SSrMLEf76FwkeoetrW50+weYygoMRirikx4XI9CzLSezT2fLFkzZFAoyJRFon4VKknPmkOqvOPNeiA+UUSg== Received: from DM6PR07CA0109.namprd07.prod.outlook.com (2603:10b6:5:330::17) by SN7PR12MB6690.namprd12.prod.outlook.com (2603:10b6:806:272::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31; Mon, 9 Oct 2023 10:07:07 +0000 Received: from DS2PEPF0000343F.namprd02.prod.outlook.com (2603:10b6:5:330:cafe::23) by DM6PR07CA0109.outlook.office365.com (2603:10b6:5:330::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37 via Frontend Transport; Mon, 9 Oct 2023 10:07:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS2PEPF0000343F.mail.protection.outlook.com (10.167.18.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:06:58 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:06:54 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" , Petr Machata Subject: [PATCH net-next 02/11] vxlan: vxlan_core: Make vxlan_flush() more generic for future use Date: Mon, 9 Oct 2023 13:06:09 +0300 Message-ID: <20231009100618.2911374-3-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343F:EE_|SN7PR12MB6690:EE_ X-MS-Office365-Filtering-Correlation-Id: 35b6ce3b-f2f2-45cb-d127-08dbc8af7edf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GyFUeD4jDjyqbFEqEhImjmcUDc9KQSjPs+KIZrMdIeU67sPs+RfHoeEk3FXg0qxoPjHHdGtkixnZ8pbxzWDIYoyutsmtn4lzdHrvmt5NvNIwwuH+lqyg/RI6PBoS02mTIJYhtyU6g6lhHHFaHHQf8qFrhYO5trueZe8mXORMXzzuUJTRNh3wmgnNRrUwyqnWW5FFZ3w/s9tTvyIphlHfqXJnOgydfuNNWQ8ms9Di2k71iKh63U9MtWP3dki7B4OagmaAtvvGcCZZy1uK5eieItaLruvQmY90iGN7Qw3OlMtjSuw20RZjHhAeZR8Sr5jvROtSvTCP3OdnHfGFX3XBLGLaDZkeF+7XcRUlkodeDP/BMOCTv+quRXuth0ve3k0F/Qeo6pOwpXIgpB6a0H1/ofsJPsUaNGidKVMxXvTrv11KLrQvk1PXSilNsf25Mie06ygNXXlhcsO4HmgdHluPOc2PPZLitY1sO3duaeLPGmlqxUr5RNRRE5TMqQkAYWlJIOK6KMb41I53zM496rmxvqNJ8Y01Dyf0NFY4RGb3touMqfHsn4WQFvHz54HtYJUuJ3ydwiQQ4zkIKTz+gcRcWcSS3IBaH11F2q/kyBd3I30YCEKu3r1cyFhtNjUktMf1iGDgKvPJFc2yMHRb3slnvbRfJPL9lNelVt9hg35fAZP03co9I3CJWMKvDVEtERejevthltClMUV7GLvPfx6KuS93Uh4F3htTlIyX3Qbn+EtccOr8Vbv8UQoN99Onk3XA1/7aiKXKoeugVqf4TtejXw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(1800799009)(82310400011)(186009)(64100799003)(451199024)(40470700004)(36840700001)(46966006)(40460700003)(40480700001)(26005)(1076003)(7636003)(2616005)(107886003)(16526019)(336012)(8936002)(54906003)(70206006)(426003)(356005)(316002)(70586007)(6916009)(478600001)(41300700001)(4326008)(6666004)(8676002)(36860700001)(83380400001)(47076005)(82740400003)(36756003)(86362001)(2906002)(5660300002)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:07.5080 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35b6ce3b-f2f2-45cb-d127-08dbc8af7edf X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6690 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The function vxlan_flush() gets a boolean called 'do_all' and in case that it is false, it does not flush entries with state 'NUD_PERMANENT' or 'NUD_NOARP'. The following patches will add support for FDB flush with parameters from user space. Make the function more generic, so it can be used later. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 5b5597073b00..1c58fddb7df4 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3022,8 +3022,23 @@ static int vxlan_open(struct net_device *dev) return ret; } +struct vxlan_fdb_flush_desc { + unsigned long state; + unsigned long state_mask; +}; + +static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, + const struct vxlan_fdb_flush_desc *desc) +{ + if (desc->state_mask && (f->state & desc->state_mask) != desc->state) + return false; + + return true; +} + /* Purge the forwarding table */ -static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all) +static void vxlan_flush(struct vxlan_dev *vxlan, + const struct vxlan_fdb_flush_desc *desc) { unsigned int h; @@ -3034,8 +3049,10 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all) hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) { struct vxlan_fdb *f = container_of(p, struct vxlan_fdb, hlist); - if (!do_all && (f->state & (NUD_PERMANENT | NUD_NOARP))) + + if (!vxlan_fdb_flush_matches(f, desc)) continue; + /* the all_zeros_mac entry is deleted at vxlan_uninit */ if (is_zero_ether_addr(f->eth_addr) && f->vni == vxlan->cfg.vni) @@ -3050,12 +3067,16 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all) static int vxlan_stop(struct net_device *dev) { struct vxlan_dev *vxlan = netdev_priv(dev); + struct vxlan_fdb_flush_desc desc = { + .state = 0, + .state_mask = NUD_PERMANENT | NUD_NOARP, + }; vxlan_multicast_leave(vxlan); del_timer_sync(&vxlan->age_timer); - vxlan_flush(vxlan, false); + vxlan_flush(vxlan, &desc); vxlan_sock_release(vxlan); return 0; @@ -4294,8 +4315,9 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], static void vxlan_dellink(struct net_device *dev, struct list_head *head) { struct vxlan_dev *vxlan = netdev_priv(dev); + struct vxlan_fdb_flush_desc desc = {}; - vxlan_flush(vxlan, true); + vxlan_flush(vxlan, &desc); list_del(&vxlan->next); unregister_netdevice_queue(dev, head); From patchwork Mon Oct 9 10:06:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413323 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB83818035 for ; Mon, 9 Oct 2023 10:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="NXTap1T1" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5469BA; Mon, 9 Oct 2023 03:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SzH38LDrk6lqGUU2woefVnOqNyu52En96zIGU8O8hf4xnLfikvQIW6kde7pgpIrPxstyetAe4Svx2Q+8NXUw4KQMAcKPyD7/MwVIqLRJTLJmYqFON2ftIJr/eqCBjOKrlwpFV2HE4tEYSh/k8B4XTxZzEVg7rQN+eCsxvXOT4y6rEqHkIwI3bYhgZItV0r06SYnii0MiamFPhhMkOcikU6gOgbq1K6LJ/jpQ84EXyu8HSE1kDzlqgqWG70CLQeNuTlMxAkZnqJfUA/JR+Xrtjwzhh+B8xB1aGP0jcgfWgDS15Nw3zINqN4oyhlYUziIPIqxFtzL6fAlMnroFRTrd1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fFy74T5CAUfq3WEbbbWoXFN/ggpbuL7yyPD344US7mY=; b=b2UewQvNJkIZbf2HuFzsm05GIaKh1QQNvARY2puhzJ2zcM1sXdDxgTUWBY38hDJMnjDxE1Ke1K0ONnz/5oIUIQgTSKMOK0khMtesO4L5i43hgsA4b0qJXDJIYbqZ1e6SUfKK8Zx0ioIZrS7voZF3Vzk+Nzs+Q6V7zLgoiBBZ1i9i/BpptxyRHcL5EkHqU/nFBn17lGzlqMogode6/wA9zgCW/oN+selWL3wr9LdpwTKfn4HJOEIcd2Q1DUXY60EkHVMY5MHm4HIayBXEYLQiXlNaowfvI8cPMnDnJlLz/lN2OGzYXu8Al7Hh8nzkhLWImuGjnF/4snfI4JasZFYOBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fFy74T5CAUfq3WEbbbWoXFN/ggpbuL7yyPD344US7mY=; b=NXTap1T1L7CxVwKxnYm8FCvrW1WHdCVH1AlfsgKtq6JybJH+3FSWYMhNuAElMgBwRM1AihvlnQW+sRcJ+S7CC9U6ZqBOZhw0+B0yinItuqnoUgY3d5RTUEXKFzPVoWbIzqhWxoZ0L1mUIfsOZCOP3hyWzQBHMdiLdoPI/JqPwuQk3xn3MC+K9RV9DsJRuV+mwBKz9gPgLLyWqCMWOszcn9Aq0rpyYYbGRgCHbNu3BXAQpEeUWncKGSA00eKwhgm2pFPe4WWD9aTTf7HGNkvel0ptL96bMMDAw8CgELzm/JkVh3yhXHRHGbWD6oAJiwz/H1oYhntS+RFi4HBLcxEeYQ== Received: from CH2PR05CA0048.namprd05.prod.outlook.com (2603:10b6:610:38::25) by BY5PR12MB4196.namprd12.prod.outlook.com (2603:10b6:a03:205::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Mon, 9 Oct 2023 10:07:14 +0000 Received: from MWH0EPF000989E8.namprd02.prod.outlook.com (2603:10b6:610:38:cafe::8d) by CH2PR05CA0048.outlook.office365.com (2603:10b6:610:38::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.21 via Frontend Transport; Mon, 9 Oct 2023 10:07:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000989E8.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Mon, 9 Oct 2023 10:07:13 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:02 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:06:58 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" , Petr Machata Subject: [PATCH net-next 03/11] vxlan: vxlan_core: Do not skip default entry in vxlan_flush() by default Date: Mon, 9 Oct 2023 13:06:10 +0300 Message-ID: <20231009100618.2911374-4-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E8:EE_|BY5PR12MB4196:EE_ X-MS-Office365-Filtering-Correlation-Id: e6cac68c-bdca-4618-d24b-08dbc8af8286 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SI78xWJ1t4EW3Mkn7cuV1xzP82ubZHWzIq653nhFD3YnjG4o1slgB2rXKohb2tGV1z5pGjLCkBZRJhb568ZaAfm0bbEwvsyptA63Fua4J60266q9RmPKEX6q48Mz3MqANAEuy5P0eNluHHXU4yDECtSWC8AHslRswAKhZIS9cOYLP5FZUGTvYp9q0hqdhgQu+shuUXkVvtRsPfk+M0wjRu8r8IXoegtaWSsYEa42ucDtTzFJLQ4ewjrV+NVxKRkwwq/+vT+4wEQ+K+BVZ8MHH8W30SOG3g+m846L+ntIM6lrlwh1N0il/Qd8OSLsATngrsWxPoTPnVYMIp5xuNL9+x2yKToWUWzMkG1lGRhAsIuGh7UyiDZzkQJ0svJpn2PCet2kiSaVcCXxF+7PEoJ5TJRdHBxbmIHozpRvwOozxglDB45VrMFCcwZTWsxKfXzTd63f0ozNnkIXu+cddcnFvvcfXNMrJYrHTeKFCUTwytxHorQ6Ptuy9SbAx+nNa/YVU5+pW3agza4PayDaMxhgTFbqWEz44NIb22h9nbar0HQZL41Zsw3oXTOduK/IGC+G9RbL/lG/42I+yXTUK9slBsCwU3/wFWc76xuLib8Y3Eo630VC/aJaUr4U6KWEGkYKvwEkmxh9dBkMoBxeS1D0TByaolq/U6UjimRiZZFIpPXx+BCDxIU/0hmJOpAlDhZ+xIFtQ5IceLmR+cIFUIdlHA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(396003)(136003)(376002)(39860400002)(230922051799003)(82310400011)(451199024)(64100799003)(186009)(1800799009)(36840700001)(46966006)(1076003)(2616005)(426003)(16526019)(336012)(26005)(478600001)(36860700001)(47076005)(6666004)(107886003)(83380400001)(8676002)(2906002)(8936002)(4326008)(54906003)(70206006)(70586007)(5660300002)(41300700001)(316002)(6916009)(7636003)(356005)(36756003)(40480700001)(82740400003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:13.6825 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6cac68c-bdca-4618-d24b-08dbc8af8286 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4196 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Currently, the function vxlan_flush() does not flush the default FDB entry (an entry with all_zeros_mac and default VNI), as it is deleted at vxlan_uninit(). When this function will be used for flushing FDB entries from user space, it will have to flush also the default entry in case that other parameters match (e.g., VNI, flags). Extend 'struct vxlan_fdb_flush_desc' to include an indication whether the default entry should be flushed or not. The default value (false) indicates to flush it, adjust all the existing callers to set '.ignore_default_entry' to true, so the current behavior will not be changed. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 1c58fddb7df4..958960fdc011 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3023,16 +3023,27 @@ static int vxlan_open(struct net_device *dev) } struct vxlan_fdb_flush_desc { + bool ignore_default_entry; unsigned long state; unsigned long state_mask; }; +static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f, + const struct vxlan_dev *vxlan) +{ + return is_zero_ether_addr(f->eth_addr) && f->vni == vxlan->cfg.vni; +} + static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, + const struct vxlan_dev *vxlan, const struct vxlan_fdb_flush_desc *desc) { if (desc->state_mask && (f->state & desc->state_mask) != desc->state) return false; + if (desc->ignore_default_entry && vxlan_fdb_is_default_entry(f, vxlan)) + return false; + return true; } @@ -3050,13 +3061,9 @@ static void vxlan_flush(struct vxlan_dev *vxlan, struct vxlan_fdb *f = container_of(p, struct vxlan_fdb, hlist); - if (!vxlan_fdb_flush_matches(f, desc)) + if (!vxlan_fdb_flush_matches(f, vxlan, desc)) continue; - /* the all_zeros_mac entry is deleted at vxlan_uninit */ - if (is_zero_ether_addr(f->eth_addr) && - f->vni == vxlan->cfg.vni) - continue; vxlan_fdb_destroy(vxlan, f, true, true); } spin_unlock_bh(&vxlan->hash_lock[h]); @@ -3068,6 +3075,8 @@ static int vxlan_stop(struct net_device *dev) { struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_fdb_flush_desc desc = { + /* Default entry is deleted at vxlan_uninit. */ + .ignore_default_entry = true, .state = 0, .state_mask = NUD_PERMANENT | NUD_NOARP, }; @@ -4315,7 +4324,10 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], static void vxlan_dellink(struct net_device *dev, struct list_head *head) { struct vxlan_dev *vxlan = netdev_priv(dev); - struct vxlan_fdb_flush_desc desc = {}; + struct vxlan_fdb_flush_desc desc = { + /* Default entry is deleted at vxlan_uninit. */ + .ignore_default_entry = true, + }; vxlan_flush(vxlan, &desc); From patchwork Mon Oct 9 10:06:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413324 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20D0A17989 for ; Mon, 9 Oct 2023 10:07:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="sBZgEZ0c" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2088.outbound.protection.outlook.com [40.107.94.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D28A3A3; Mon, 9 Oct 2023 03:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZAbxBD47Y2u2GW7lpVt5fsm0OlXt4JaU/aGF37GpDp8Fd62/IJqkRhCoXcj8p8jhkg3pPNkqoM1d31z+F/D4cxGQTMZu4wpeYMcm9LmOGakTWd/wgnt/HtgnJn95ePqU0VikIBu93tO8ysGyP6DvLgt+C4KM097LBixGXNdcuo9MAXZMkVfMF+7h9kCz9ZiNSesrZYUCc4NuF4TiCfWzm7yK8uaQxd2MEl4u3LUhEW7Q14lhI0zBlDkVnUPI9XNDer6rKGptMIUU/KV7eTG5KGwhlUHFZsgPZStuhLwmxwJHEvyQBVKc+wlYkYzsOlGSDS21piDuvhbuCfFCsWmzNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6W/GVUeEAPw+17+kc4Dg0u8hpieRTRnlYPZ0koB/I0I=; b=D60ZBi8oqMSC/chYeT8mdXMUPmx0keq3ESKNg5Xadczoo0bg8gB+o/0kLcMsQ3oLAzOyiN37ookNxEx2s6Z7GljO1/alxHcI4Bh3EbE665ESi/qxZ01VIDabfnLC/z1s/eVL4JkxxsoHkDxPoBkcR3r3zZCJ6S3zet5QLHt+KzbmELwBCK9F4Lsi3Gr9VcY7we9SWNyYgc1M4KWwegg0i9uriqnlJXFldElfSwZ4iouZyEWvdFaCN5byIQjKvfxCeyw3DoiLK3KHNn84D5tgCWEQmpd63cVVI4LXtOacpCZi0fCZnyAZInuAS+oB6PrJNH10947qg1XNhFIgt2jaig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6W/GVUeEAPw+17+kc4Dg0u8hpieRTRnlYPZ0koB/I0I=; b=sBZgEZ0cOCh1BQF+xHR/vDIWPnzDJHalYkc1RjiYK6+fcOp0MB1G9dXRRX60jNuRqdOvZXqdtRYxxXcUEK5nf6vHIkWXSyu2i6HCC+Gf6gQjcNq+3Y1jyWPqgfHiFrpWvAV1UXARxJz4n1GaaBrzAC14K8ZCaFM97I0Iczb3jcA7Mg767lCzW6/Fc2Ai20UrLgZjhC+YJwEzIYE4USdvdi1YvuFwhggzWP1Fl62ww/Xr2xP8fXoWGBwiwZ5s1mYF1eUHMeDnZpsfVC1zGxlgYYHds6rOHCMxX4AjoIO0IrZlr3BbxiE1CT8E+zU7OYwghMpGfzzXGiGYxRexBo7bSg== Received: from MWH0EPF00056D06.namprd21.prod.outlook.com (2603:10b6:30f:fff2:0:1:0:10) by SJ2PR12MB7865.namprd12.prod.outlook.com (2603:10b6:a03:4cc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.43; Mon, 9 Oct 2023 10:07:16 +0000 Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2a01:111:f403:f805::) by MWH0EPF00056D06.outlook.office365.com (2603:1036:d20::b) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.4 via Frontend Transport; Mon, 9 Oct 2023 10:07:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:16 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:06 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:02 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" , Petr Machata Subject: [PATCH net-next 04/11] vxlan: vxlan_core: Add support for FDB flush Date: Mon, 9 Oct 2023 13:06:11 +0300 Message-ID: <20231009100618.2911374-5-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|SJ2PR12MB7865:EE_ X-MS-Office365-Filtering-Correlation-Id: 75266287-bff4-4dbd-a5cc-08dbc8af8430 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GcVEKzGk4VjLpArpu9IcAOZWjz4dX+Sl6wQOkqdPYru6ClFdSPr1JfgQWnZAgjpx+HyDr8kG41T4hTLR+cQw4EmM2C8tb1K00usMMXqQhsz8jobYGewwMVB3KYy6SUEg83vdsxn+gEiMy+lj4F3JEtgQUxKMEsDsMGNeWanUAgi7L0Pyloz3irgSVTUIZHkONOnuHh7gt4vZ63fhsRc+0/nXHeWpNpfBwnmKY5n4kMxTKG7d/XoI5QBGYgZc93El8fbeeqTMFQ98ho4jaDt0dVZBHbuei/DG3klCrIbGvdmZwTLJl3tLnQO0+S0uE1Haf9+9ikDbx6Y8JEWmmxms7VW3GBd+zB3IxiClOcr+tFEGsB5ziraYkR+nSqnyV5wAJvHV4AEHVok2ZqVg3hZiTjDMi01S7UiLWdCQ0MhYOzsCC9NxLvKkf0obYuETbQ2n4iOjA2u8OguJ9LBXHVjVxJAJimNDegJZ07jognwYB6CfhQRSLysS/whoN7crVik2uly9QBRQBY0jt3pcNofTjNaOra1ODho+75ghWnkZz7hCK+vUKEkapyLJKGTFnOSGM5fGH5gaQV3L0COwdGytthkfOVaWQ4JL8eY2sv81sy4DOvvF5xIZLre9flYIoohyzDx2atggw58qsFFaB5PpubGCEylqI3wxY8CXHS5uDujOfhyoli+ekSmsQBqRNzcG7LXLCxMz73bIC7qUZJvON/GrxejBHLj8NPiRJoHsZxs= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(346002)(136003)(39860400002)(396003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(82310400011)(40470700004)(36840700001)(46966006)(6666004)(1076003)(107886003)(40460700003)(36756003)(86362001)(40480700001)(356005)(7636003)(36860700001)(82740400003)(26005)(2906002)(16526019)(47076005)(426003)(336012)(66574015)(83380400001)(2616005)(478600001)(8676002)(4326008)(41300700001)(70586007)(6916009)(8936002)(316002)(70206006)(5660300002)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:16.4732 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75266287-bff4-4dbd-a5cc-08dbc8af8430 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7865 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The merge commit 92716869375b ("Merge branch 'br-flush-filtering'") added support for FDB flushing in bridge driver only, the VXLAN driver does not support such flushing. Extend VXLAN driver to support FDB flushing. In this commit, add support for flushing with state and flags, which are the fields that supported in the bridge driver. Note that bridge driver supports 'NTF_USE' flag, but there is no point to support this flag for flushing as it is ignored when flags are stored. 'NTF_STICKY' is not relevant for VXLAN driver. 'NTF_ROUTER' is not supported in bridge driver for flush as it is not relevant for bridge, add it for VXLAN. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 958960fdc011..0aeb973e3da7 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3026,6 +3026,8 @@ struct vxlan_fdb_flush_desc { bool ignore_default_entry; unsigned long state; unsigned long state_mask; + unsigned long flags; + unsigned long flags_mask; }; static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f, @@ -3041,6 +3043,9 @@ static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, if (desc->state_mask && (f->state & desc->state_mask) != desc->state) return false; + if (desc->flags_mask && (f->flags & desc->flags_mask) != desc->flags) + return false; + if (desc->ignore_default_entry && vxlan_fdb_is_default_entry(f, vxlan)) return false; @@ -3070,6 +3075,56 @@ static void vxlan_flush(struct vxlan_dev *vxlan, } } +static const struct nla_policy vxlan_del_bulk_policy[NDA_MAX + 1] = { + [NDA_NDM_STATE_MASK] = { .type = NLA_U16 }, + [NDA_NDM_FLAGS_MASK] = { .type = NLA_U8 }, +}; + +#define VXLAN_FDB_FLUSH_IGNORED_NDM_FLAGS (NTF_MASTER | NTF_SELF) +#define VXLAN_FDB_FLUSH_ALLOWED_NDM_STATES (NUD_PERMANENT | NUD_NOARP) +#define VXLAN_FDB_FLUSH_ALLOWED_NDM_FLAGS (NTF_EXT_LEARNED | NTF_OFFLOADED | \ + NTF_ROUTER) + +static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, + struct netlink_ext_ack *extack) +{ + struct vxlan_dev *vxlan = netdev_priv(dev); + struct vxlan_fdb_flush_desc desc = {}; + struct ndmsg *ndm = nlmsg_data(nlh); + struct nlattr *tb[NDA_MAX + 1]; + u8 ndm_flags; + int err; + + ndm_flags = ndm->ndm_flags & ~VXLAN_FDB_FLUSH_IGNORED_NDM_FLAGS; + + err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, vxlan_del_bulk_policy, + extack); + if (err) + return err; + + if (ndm_flags & ~VXLAN_FDB_FLUSH_ALLOWED_NDM_FLAGS) { + NL_SET_ERR_MSG(extack, "Unsupported fdb flush ndm flag bits set"); + return -EINVAL; + } + if (ndm->ndm_state & ~VXLAN_FDB_FLUSH_ALLOWED_NDM_STATES) { + NL_SET_ERR_MSG(extack, "Unsupported fdb flush ndm state bits set"); + return -EINVAL; + } + + desc.state = ndm->ndm_state; + desc.flags = ndm_flags; + + if (tb[NDA_NDM_STATE_MASK]) + desc.state_mask = nla_get_u16(tb[NDA_NDM_STATE_MASK]); + + if (tb[NDA_NDM_FLAGS_MASK]) + desc.flags_mask = nla_get_u8(tb[NDA_NDM_FLAGS_MASK]); + + vxlan_flush(vxlan, &desc); + + return 0; +} + /* Cleanup timer and forwarding table on shutdown */ static int vxlan_stop(struct net_device *dev) { @@ -3172,6 +3227,7 @@ static const struct net_device_ops vxlan_netdev_ether_ops = { .ndo_set_mac_address = eth_mac_addr, .ndo_fdb_add = vxlan_fdb_add, .ndo_fdb_del = vxlan_fdb_delete, + .ndo_fdb_del_bulk = vxlan_fdb_delete_bulk, .ndo_fdb_dump = vxlan_fdb_dump, .ndo_fdb_get = vxlan_fdb_get, .ndo_mdb_add = vxlan_mdb_add, From patchwork Mon Oct 9 10:06:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413326 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E30021171B for ; Mon, 9 Oct 2023 10:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="rqQ537MT" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2053.outbound.protection.outlook.com [40.107.243.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52CF5CF; Mon, 9 Oct 2023 03:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mkXS6jkYGiMHxgtY4dpmbY9caToPesRpVHorUaH/S0t9b1zPLtj/3LkwZdET1qd1T3CRdMpiQMgSb+H4udzcKgy8Xe+v9L2/TQ/sJI475jxS3Qewy0D8rvWgDrIHL85db+0brGjzQzacU137W+zz1+ah37erBTqp5B0+LfnWzVlc/RFs53zR4vnTVr5n+6co24mUfJ1I5ad/mx1cRAXFdcSjkmQzN3jYEKmM834SWSJDiiDpLJVoP+fO0WBuMNMVckXUBiQn/lCCgqKIM8jNVsZaT5tPIoryXlxJ1bCG+aV3UCWD1LGvhWP9nUPlg1e9QpriBFiN6aqPf3F/xDwuCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Pt/wU6WZ7GRXHaUbxO4XGUjytCIUM1CTzE/+Q9sHSjs=; b=gMaFKdg3pA76oySDD19sn/fIoLHsKABz8NOgB0yWkD7g/X0mlWcROT/Lm6+xdhY6qRCee+rolYt1oeubF5dErIouDQnG0avhfcOBw2YKvGBnmWpT0cru9OEU3SN6sRSt1S2zNZ58I4k/iSc+vk32WYkr/TWdWi73BrJqk9FFQucOQ9qTiwGKQbOIFwxExR1+k+Cy1p1Rvh4yRdkCJm4pERm8aHoDAZceTorFWlW382MFmPytn3xENlH+4wZsbX/V2Jkti2lbdcGbMjcT+OmWvTLO6d+mDI2qSVvOyH8Oc/ng1g6+Q0TueGB/9zX79EaKardsWGo19FMvc7xyS7DR9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pt/wU6WZ7GRXHaUbxO4XGUjytCIUM1CTzE/+Q9sHSjs=; b=rqQ537MTTePZo23+PRGN1cX/bhrswaiLYMG8gJXEZx8MyUZdVVqMYRS7YcH0nPApvh9wFrYYShiQfy1g24LrhXcFfi6+v+mQNzumFwDOJ0+lon/SX/+m6bT98xTmnwyMa/hg2QIdzpZpGIToFx5U41yi3NQR483gwmtDWkWaEKjX0F7UVnFppCIITWOXjS16gsmSeqmkUaYAofGhx0SIhOoR+FxgJDrSDNplsNjCUTWo6ksEVuD/CZHdCmv2hvPGD4W3fK/bqHwCEWvsgXtg+cRVHXLO3WtN6CjBB966ixpRdTkTXf2GNDgLHXX0+ok+CXR/7lJzIvtGmFcDNO2Hhw== Received: from MWH0EPF00056D13.namprd21.prod.outlook.com (2603:10b6:30f:fff2:0:1:0:16) by PH7PR12MB7258.namprd12.prod.outlook.com (2603:10b6:510:206::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Mon, 9 Oct 2023 10:07:21 +0000 Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2a01:111:f403:f805::) by MWH0EPF00056D13.outlook.office365.com (2603:1036:d20::b) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:21 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:10 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:06 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" , Petr Machata Subject: [PATCH net-next 05/11] vxlan: vxlan_core: Support FDB flushing by source VNI Date: Mon, 9 Oct 2023 13:06:12 +0300 Message-ID: <20231009100618.2911374-6-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|PH7PR12MB7258:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c39c77f-0f3f-4ac3-f7f5-08dbc8af874c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: chqF84LtRMbHLNhnXlPCxERigf8pkNiHAoGYyYIUh1GXQ9HmoKgWZK9Wtp1yU41diLvmAWVJQlheWlyrYFCCYz/rUoPa1J540UPa4TosarP9Gsem/jyl/Zf/Enmo+ng9lr1oKDwtFZdL3rHvOrO6+1RmEenIgnSymeLyMC8qLpycJ7+SSqXyHnh+mTwTP1KYMzyCLWQAg8B28H6YfN6ye7Z4fgVLBZ/zh/DM1pMqmk5AGfyWkbipB503oM8P8YDuIosajpnUgiI0OPIwr1k7l5IDHh2UcxchviC9kK2EOZG5n3ete0gQ7bp1LuJe32QnlwBM22WBFpxEZy3nLPQfEKHXk4rjP3JMKtDUt7OLTbwpePbXYYZAWnOFuk4++GdAQq2BS6j2rCFweKslAgwX0wbghd6JX+xm+yI/ct42z4mpl5NwIBgF3XHK91A7iGqCHnYPlYLw8KAzo4j7MnoS+UhtW2y3smc5tVcB67nJCOPUKLA0VVt5sYeyIdJmgjkfQod/MkIk3E1f//HSCLx1fHqN5UECiq/gcVzOAIkSyXlUSdjpa9ySOgdAVqKizmhLSDyWDCDdwi1tfIPnFj6SLwCrUReH4qnGxvBzo7lOGHxSIvZg/+BPzea2vOgUTeXP+Oqr2quiEWJALIrAmiWTNC+HSWyEilz3gKbx3Yh1NdqXP7gQt/qDgosE7A5rewRZDrueLJ5UzJ6m0ga2cFH82J4/I98IkL/vUuFEcCJpCdw= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(396003)(346002)(39860400002)(376002)(230922051799003)(451199024)(64100799003)(82310400011)(186009)(1800799009)(46966006)(40470700004)(36840700001)(40480700001)(40460700003)(83380400001)(1076003)(107886003)(2616005)(336012)(426003)(16526019)(26005)(47076005)(36860700001)(316002)(54906003)(70206006)(70586007)(6916009)(8936002)(8676002)(4326008)(5660300002)(41300700001)(6666004)(2906002)(82740400003)(478600001)(36756003)(356005)(7636003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:21.6763 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c39c77f-0f3f-4ac3-f7f5-08dbc8af874c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7258 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support for flush VXLAN FDB entries by source VNI. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 0aeb973e3da7..8214db56989d 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3028,6 +3028,7 @@ struct vxlan_fdb_flush_desc { unsigned long state_mask; unsigned long flags; unsigned long flags_mask; + __be32 src_vni; }; static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f, @@ -3049,6 +3050,9 @@ static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, if (desc->ignore_default_entry && vxlan_fdb_is_default_entry(f, vxlan)) return false; + if (desc->src_vni && f->vni != desc->src_vni) + return false; + return true; } @@ -3076,6 +3080,7 @@ static void vxlan_flush(struct vxlan_dev *vxlan, } static const struct nla_policy vxlan_del_bulk_policy[NDA_MAX + 1] = { + [NDA_SRC_VNI] = { .type = NLA_U32 }, [NDA_NDM_STATE_MASK] = { .type = NLA_U16 }, [NDA_NDM_FLAGS_MASK] = { .type = NLA_U8 }, }; @@ -3120,6 +3125,9 @@ static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, if (tb[NDA_NDM_FLAGS_MASK]) desc.flags_mask = nla_get_u8(tb[NDA_NDM_FLAGS_MASK]); + if (tb[NDA_SRC_VNI]) + desc.src_vni = cpu_to_be32(nla_get_u32(tb[NDA_SRC_VNI])); + vxlan_flush(vxlan, &desc); return 0; From patchwork Mon Oct 9 10:06:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413325 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0776B1803D for ; Mon, 9 Oct 2023 10:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="kCvro4ak" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2071.outbound.protection.outlook.com [40.107.220.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 223C5AB; Mon, 9 Oct 2023 03:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GduwwFw7KPBIkq+jQ7Kc3VfaZLfHoqD5H75q5GCP0doyYWtWkpCxv6Ck/bwta0qOLB/d6sPlDGMZ47/XCuYspTULWlp3hOdPzu7DNqhjMz4mi0ZIAzshpCFim1eUd+EYkUpuc0CjSVg04FdSSOJrCvierTB08imy9lfK+SslhgzYzmOkn3a+wmIdfjhiO2LQoWjNvT6y5QA37mCp+BD/8H+AG5dgjcBBh3FHrCQB22YBe8xkLg0k9wlWkrq+L+6wM0NCS/xsB0gqhi00aYzWTf44zqAm1dSZhzp5BRsqBubooGnVcwnpxngbfyOZrmZicqdJSxqHuNhBPftCkmccog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4HiHzqApvoOf/BYHCJv0CGWSnumfWBB0kh8K60Vg7Ng=; b=HQn6NfibJg5T3/BMOymMQAzzhQ1IjKRcD1rkhV97JDgXkYh69ftFWQRZMNOQvY73hzaZXxB6SK91fSQQNt5LTIxIaaQ56YavvrY49nomP52bTkF6V9O4Zloy5viM80wlz9MgcIRzuE71MXUuB0fThfe6beiHFdNX5bCk0rZqoV7+IChMQG+Qb2fapjbEw4SHdYtUNIVMrCqmM9HFdAPye3LHioJKRT2l2RjwTn3xYtjY5dnmUV0HS8iG9WN/BVgrinSf5fAXQZx3XuH6czcoaqxHWO7W4qvtLEYHbMv4fVbZCoiPjnh9LwtjLR2UpTU2KR6gGKOvctk0fPUMvM+Ilw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4HiHzqApvoOf/BYHCJv0CGWSnumfWBB0kh8K60Vg7Ng=; b=kCvro4akQgE9IeYQ0x4TnGb0A6EYxZe8ZdFUQdEonNwZt+uEmsF3AX0xodySd02IVyGWvSvp7vu9D/sDxs3auWG59JdsAFgOzl07RSOS+JgI8smVj8rZsY+iUcMBFA+Caf3ZPXVVq/cCPXlvWSy9cLzn4i6Ae+uRyd9hKTWCSIw4I7vH4eYOmu95jpwJLW27ry0dRTn+N6Bobq3ttSopIH+76mBgj89oj2lv1Pm+FpCQBMEg8Eb1dhrcyrZ6ghAIlDbPh32N9kj3gQKcHtB5Atpb/XsxNle41fxrDU+m3RGzsHZHeOTN2IeSGopf9fUeKusJz1MkJMxOtNv2dOxYYA== Received: from SJ0PR05CA0209.namprd05.prod.outlook.com (2603:10b6:a03:330::34) by CY5PR12MB6033.namprd12.prod.outlook.com (2603:10b6:930:2f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Mon, 9 Oct 2023 10:07:25 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:a03:330:cafe::79) by SJ0PR05CA0209.outlook.office365.com (2603:10b6:a03:330::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.21 via Frontend Transport; Mon, 9 Oct 2023 10:07:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:24 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:14 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:10 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" , Petr Machata Subject: [PATCH net-next 06/11] vxlan: vxlan_core: Support FDB flushing by nexthop ID Date: Mon, 9 Oct 2023 13:06:13 +0300 Message-ID: <20231009100618.2911374-7-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EC:EE_|CY5PR12MB6033:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f305463-e31f-43b0-8c27-08dbc8af8933 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UI2Q92MgMiW0jZvOHzRXsfVBoHUlCj5zzEayLliTw0vdcHxyGyZ8EtGQOjW9/++n+QR5AzxtvjvVpO+eLLsJfvRIJVWdaLrWWCiwKugUML2ydAPJVqkVpfIBRw8a+SSZ2tQ2KhKXSnMVxq8oyKb1/v+GOfMlQBngD2r+2oeGE+l3h7x4Ymt56lnvVMMJ5hWGMu1rw9RJas0a4h4tN62DO2yQWbM9AKPr1yKCZAq1BDqjs73U07kpy4si5b944uzfZd9mklq4N1mSUGLOUHIWj3ZvNfov0abdu/bMB7+mHGHwf38YS2iMg0HZpK1E7qr2PxmDFSFYRYmA4rqjLUiWQ+xaqFUzB97l0T57B7+rwpDs6BCX+4J8Mw+6ypAGVWzOC+V/WZtTYSjyYqnOvYPuEQhX0DqMjD/G9xFglOyxZZ5zNoRpo+YKBSTedORu4V/axuo6RYLE2OJoL8HNeYPMHWMnDIVFqaTbAPOQroDhEYreX3pyCid+zBEr4u4wsFjoHpO/tKTePuJDrdl7TDL5O7h2/iih81GDqJeCdHrgi/r3YuJJ15QZyaZCYUp/Wa2UZXoz8TygLQDvNT73IRG7G3ieXi1P5ifMyYcovTMuaQCSP9sWhyNN2vxayyhnilQFgIeheAHwMQgVNwygwuxYjSb9zZqis5FlB+z0KKw0gCOeKZb7KARm44aehCmd76PXgUWO5d39exnu/1/LTyDxK1OHHEA2BfYK9KvMk4Qnbs4= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(376002)(136003)(396003)(39860400002)(230922051799003)(64100799003)(186009)(82310400011)(451199024)(1800799009)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(83380400001)(107886003)(1076003)(2616005)(336012)(426003)(26005)(16526019)(47076005)(36860700001)(54906003)(70206006)(70586007)(316002)(6916009)(8936002)(8676002)(4326008)(41300700001)(5660300002)(2906002)(478600001)(82740400003)(36756003)(356005)(7636003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:24.8808 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f305463-e31f-43b0-8c27-08dbc8af8933 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6033 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support for flush VXLAN FDB entries by nexthop ID. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 8214db56989d..ec7147409d99 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3029,6 +3029,7 @@ struct vxlan_fdb_flush_desc { unsigned long flags; unsigned long flags_mask; __be32 src_vni; + u32 nhid; }; static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f, @@ -3037,6 +3038,13 @@ static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f, return is_zero_ether_addr(f->eth_addr) && f->vni == vxlan->cfg.vni; } +static bool vxlan_fdb_nhid_matches(const struct vxlan_fdb *f, u32 nhid) +{ + struct nexthop *nh = rtnl_dereference(f->nh); + + return nh && nh->id == nhid; +} + static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, const struct vxlan_dev *vxlan, const struct vxlan_fdb_flush_desc *desc) @@ -3053,6 +3061,9 @@ static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, if (desc->src_vni && f->vni != desc->src_vni) return false; + if (desc->nhid && !vxlan_fdb_nhid_matches(f, desc->nhid)) + return false; + return true; } @@ -3081,6 +3092,7 @@ static void vxlan_flush(struct vxlan_dev *vxlan, static const struct nla_policy vxlan_del_bulk_policy[NDA_MAX + 1] = { [NDA_SRC_VNI] = { .type = NLA_U32 }, + [NDA_NH_ID] = { .type = NLA_U32 }, [NDA_NDM_STATE_MASK] = { .type = NLA_U16 }, [NDA_NDM_FLAGS_MASK] = { .type = NLA_U8 }, }; @@ -3128,6 +3140,9 @@ static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, if (tb[NDA_SRC_VNI]) desc.src_vni = cpu_to_be32(nla_get_u32(tb[NDA_SRC_VNI])); + if (tb[NDA_NH_ID]) + desc.nhid = nla_get_u32(tb[NDA_NH_ID]); + vxlan_flush(vxlan, &desc); return 0; From patchwork Mon Oct 9 10:06:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413327 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEEFD18041 for ; Mon, 9 Oct 2023 10:07:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="P8FAiu7I" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062.outbound.protection.outlook.com [40.107.244.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49433EB; Mon, 9 Oct 2023 03:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eYJesJM08jQJoWYUhmCbX8zBV28epawNn7nA0pSwmWpRvgQLmM6LeiYwIVzz5qMaVyR3Q4USD2rKQhGolpcRIi+092cdvYLdz65q09WRGVm5URFz18Wxo8l3L56OOf88nN+JzxF7+H6aqQtF8GsUZD6Rs8519q30dg11JUFXbaVoh/H9pyqlq4agb0q9cr+WWB8ZXo4W8kj7n2RXMyYhhxkXJu/mWta0S92u5pANMKvINjusCmtWcwu/qbBbDOVlQV0vx4StBo+DNfturosTPS+Uhbqm+pZHKFFKawbhjZMtaANA0AwRTiEyB2US20i9sTMZARlsYUfcXoFB8o5ETQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gRcHIngCdxLXbNg1mM1AOfmR9WB5qyAajfBSpzdhuVg=; b=SeGImQQIBBsWYoELZ4UYfjoM0rXegyfwsMx5FO91fElLMk8gNBVp/KVc8BmLW+KqWspKhHsaq0o91s9Sz3Y+l82L7FS9dRRN19U2cKgfusS6v8lTRiKfEM7sXKCSVXH9piP3eolo6igr+IrjJBQV6CiKfW/EOZ4Cteyy6w2vBTamtoLk8nlKgkG1m76q9mBIJt1dQPTgdaQSrtJAfYBaWq85apj9sVWGkciso5Mci0qpLlg9KJUFLUB/ZM4R0mLKB7WU6zcpGQzD1AIy98k+xRbb8CFtHzFTNWQ2YNaBpARLWlvjkycJ/QKpxfknCM8PqpSnWUimCJ3L5kPByqwidw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gRcHIngCdxLXbNg1mM1AOfmR9WB5qyAajfBSpzdhuVg=; b=P8FAiu7IiBbfZQIlS7+1Obw30MsxKjvEGSOdpL4uhrn6mvk6k0d9+lM+EYo/TMVZiY/Yg7hM2YuYyVraHP8CMvfZw1dIMQcrGduz2hCJwok5m6PqwEPTF+i7gdUnYLXj0Dj25DAr5Nvv54IAFzjIbNKS053Hmd5CMxQbSmlJBPwYOC8bDVx4T7vqzMgMsF3O/DuKxXbTTO8XoBoPYCc0dWsbnaGFPxmm/cFt4ApWUNo/Rmarqcmx/cJf3O24/ZBbypKvB2FKXACEHYnoG2kVVooD6xKj1ej3OyX+d+IteTAFT04lZG6Z17vQZrv9kbuAe6If9Th+I9oTHJfefbHLeA== Received: from DM6PR07CA0065.namprd07.prod.outlook.com (2603:10b6:5:74::42) by DM6PR12MB4864.namprd12.prod.outlook.com (2603:10b6:5:209::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Mon, 9 Oct 2023 10:07:30 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:5:74:cafe::84) by DM6PR07CA0065.outlook.office365.com (2603:10b6:5:74::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36 via Frontend Transport; Mon, 9 Oct 2023 10:07:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:29 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:18 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:14 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" , Petr Machata Subject: [PATCH net-next 07/11] vxlan: vxlan_core: Support FDB flushing by destination VNI Date: Mon, 9 Oct 2023 13:06:14 +0300 Message-ID: <20231009100618.2911374-8-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003439:EE_|DM6PR12MB4864:EE_ X-MS-Office365-Filtering-Correlation-Id: 45210a96-a89f-4427-a399-08dbc8af8c3d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SnTpVsWe4txWCKYH/78XY9KJPUmo1Xgh9QoJ/dTnAaeEAA7k8U73hV5SsMkJDuwDKe8CPND+PqaT1jcZfI6+cpmg/NqS/Ztsa2nNt2Bm/hTfGwAZsAgBZIfudOG7DPtv88GupwCntUu7BgOJPCIdzEP9CVCjrC7FjgiCOdQnGDAdFi9FTMg7KtmnCl3zOFhGTU7vH5hpD320lHMG0RaW+bH90GkPSH1pxRg9KChyXpqN+oroJKP3olW1bv9ijVjLQ14yr+M6vajUqRly5ItrA2EUn7WhUhVTe0V+wXTGo0J5zE+OdAZFJoruRYzwnMnEqU3AQyQQGydqjapvPQFHZLlnwfcNyijpwVp7rz4dH9AsyvWBTCXtgp6+GSckEZ2HNrdNoib/yyJ6EmUmW8wsso55PLk54iugwI+4ftFL91++sDSxXyResdwcd4iK2VlHyL78LJywn/HH05yB7G86lELu/QCkjTJPBX/Bf081aYjcxFMMFJgckJz8f2RY9I+O6HpYRNm/FnjQta0iZE2bvwidqb91CIrargPchBg1B9Mpapyep8NxR1VPi/fYu4MfhmSbAai5Y3Jhpwhzmgz7xo3qk5hF75hz7XgsWWQlLwo/hI7Gz7VIZBKXQ6OC1Lz2StdMpd2CvP7IT+on/WVGTiTgah0JqEibjdy0Cigqs7SvM9blTOckz97Zkjqywahtnt6rFv14r6F956t5K/eadQrvRCdgMCieuvwhWRE5Q5woNNsamDYcScjt/HRJZ/qZUZ50JJT4nHMrPn9mq9DgyA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(39860400002)(346002)(396003)(376002)(230922051799003)(186009)(451199024)(64100799003)(1800799009)(82310400011)(36840700001)(40470700004)(46966006)(2616005)(1076003)(426003)(26005)(336012)(16526019)(40460700003)(36756003)(82740400003)(86362001)(40480700001)(7636003)(356005)(107886003)(83380400001)(8676002)(8936002)(4326008)(2906002)(478600001)(47076005)(36860700001)(41300700001)(6916009)(316002)(5660300002)(54906003)(70586007)(70206006)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:29.9332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45210a96-a89f-4427-a399-08dbc8af8c3d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4864 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support for flush VXLAN FDB entries by destination VNI. FDB entry is stored as {MAC, SRC_VNI} + remote. The destination VNI is an attribute of the remote. For multicast entries, the VXLAN driver stores a linked list of remotes for a given key. In user space, each remote is represented as a separate entry, so when flush is sent with filter of 'destination VNI', flush only the match remotes. In case that there are no additional remotes, destroy the entry. For example, the following are stored as one entry with several remotes: $ bridge fdb show dev vx10 00:00:00:00:00:00 dst 192.1.1.1 vni 3000 self permanent 00:00:00:00:00:00 dst 192.1.1.1 vni 4000 self permanent 00:00:00:00:00:00 dst 192.1.1.1 vni 2000 self permanent 00:00:00:00:00:00 dst 192.1.1.2 vni 2000 self permanent When user flush by VNI x, only the relevant remotes will be flushed: $ bridge fdb flush dev vx10 vni 2000 $ bridge fdb show dev vx10 00:00:00:00:00:00 dst 192.1.1.1 vni 3000 self permanent 00:00:00:00:00:00 dst 192.1.1.1 vni 4000 self permanent Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index ec7147409d99..f16328a0f9fe 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3030,6 +3030,7 @@ struct vxlan_fdb_flush_desc { unsigned long flags_mask; __be32 src_vni; u32 nhid; + __be32 vni; }; static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f, @@ -3067,10 +3068,46 @@ static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, return true; } +static bool +vxlan_fdb_flush_should_match_remotes(const struct vxlan_fdb_flush_desc *desc) +{ + return !!desc->vni; +} + +static bool +vxlan_fdb_flush_remote_matches(const struct vxlan_fdb_flush_desc *desc, + const struct vxlan_rdst *rd) +{ + if (desc->vni && rd->remote_vni != desc->vni) + return false; + + return true; +} + +static void +vxlan_fdb_flush_match_remotes(struct vxlan_fdb *f, struct vxlan_dev *vxlan, + const struct vxlan_fdb_flush_desc *desc, + bool *p_destroy_fdb) +{ + bool remotes_flushed = false; + struct vxlan_rdst *rd, *tmp; + + list_for_each_entry_safe(rd, tmp, &f->remotes, list) { + if (!vxlan_fdb_flush_remote_matches(desc, rd)) + continue; + + vxlan_fdb_dst_destroy(vxlan, f, rd, true); + remotes_flushed = true; + } + + *p_destroy_fdb = remotes_flushed && list_empty(&f->remotes); +} + /* Purge the forwarding table */ static void vxlan_flush(struct vxlan_dev *vxlan, const struct vxlan_fdb_flush_desc *desc) { + bool match_remotes = vxlan_fdb_flush_should_match_remotes(desc); unsigned int h; for (h = 0; h < FDB_HASH_SIZE; ++h) { @@ -3084,6 +3121,16 @@ static void vxlan_flush(struct vxlan_dev *vxlan, if (!vxlan_fdb_flush_matches(f, vxlan, desc)) continue; + if (match_remotes) { + bool destroy_fdb = false; + + vxlan_fdb_flush_match_remotes(f, vxlan, desc, + &destroy_fdb); + + if (!destroy_fdb) + continue; + } + vxlan_fdb_destroy(vxlan, f, true, true); } spin_unlock_bh(&vxlan->hash_lock[h]); @@ -3093,6 +3140,7 @@ static void vxlan_flush(struct vxlan_dev *vxlan, static const struct nla_policy vxlan_del_bulk_policy[NDA_MAX + 1] = { [NDA_SRC_VNI] = { .type = NLA_U32 }, [NDA_NH_ID] = { .type = NLA_U32 }, + [NDA_VNI] = { .type = NLA_U32 }, [NDA_NDM_STATE_MASK] = { .type = NLA_U16 }, [NDA_NDM_FLAGS_MASK] = { .type = NLA_U8 }, }; @@ -3143,6 +3191,9 @@ static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, if (tb[NDA_NH_ID]) desc.nhid = nla_get_u32(tb[NDA_NH_ID]); + if (tb[NDA_VNI]) + desc.vni = cpu_to_be32(nla_get_u32(tb[NDA_VNI])); + vxlan_flush(vxlan, &desc); return 0; From patchwork Mon Oct 9 10:06:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413328 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3221179B2 for ; Mon, 9 Oct 2023 10:07:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="ZJU4MWNN" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2068.outbound.protection.outlook.com [40.107.93.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DFACF7; Mon, 9 Oct 2023 03:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GEnbPqte+V3D8pNyTT1Uxqelg/0XhTLXuaoo9ivPfpUUyTWmY5AZydQR9zHCW+cyri7xfF9y7rW/YgNSyx1MfLaoo9xGiXWKruqR6XiGqd7Y78XmYMzYLB9LtHsKNgfIh83f+dDYxOKN0alHkqNOBez354gR7d781XwlST0XeIAJ0hCPHL/UzeQuId6ajGzBD4zGFdCwU00mwskudEkVL8b/2hDiKvUB2TmEIprXxqmhtXjwRH1ii82Yg5RMqlR7ClyEKQNexRFg9ZZHs5rr4FBz08ZOhslYMF+UxnC6gXu/N+CFQq4Ug9Jx76ekdJauerFioVOhWI87YdGXk40lkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/diKAQ1CB+LJzeMAPD78XPOMuWnMXWCE6TPBTz9uW/Y=; b=lVEdgrYn7BURF86ZuVVfiEvAIXj+t6MHwEwBMvso9OphMpcseuIOfftwCzEp16V4JgtooJ6Tfo2v2sNqm//BAhb7XNcjblJM89laFRvH/ypb4TS1diOCiBfJ8Cv7G5M0f7qlj1oW3xjR+J0jX8SBVFdRxG/d72gH3PNQGDaAyUD6AX5APZ0PpLPt/jsq8Tw4U/v2Cw1X2JudW5nQgmH28lIMmc74iy2XV8B+PDCsYFxkd0ePKVKZNewkteE+BClKELvBo3YaeglgoQEONGMciaUuvQpTKj7Iq2tm/2k93DzRZKc3pZu7hE3T+f8IoaROu4fhP3yVDX8eH43Z4s1vGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/diKAQ1CB+LJzeMAPD78XPOMuWnMXWCE6TPBTz9uW/Y=; b=ZJU4MWNNMNWmugktdkxe2s68RVTJ3ihVMegJ+wYQAOKNhMKOASqok6ZnDWXGa98y8uTb9BmUpirwIhbz3Ygnu9yrCk2X1KxKRxRdbH9HqfIxgRB0cyRVMRJyQG1OC5kvJ5UIiaLv1iWVgRsMCM00FCaa+VYaCWxLDLyXlnFF85o1YEyZFDGjxNRdYpiLtUH6mA7p7XPbze6gRakolW9FAXCo8DRHHzyJfGZ8PhipdUC+21vOtfBPjlvuENuaIkhhZSlCCWT5MKOg+L/Vl0wL+PEgmczcEo0jbZ5jqj1KkTL6yfO+1xOiqRtIQmfdHkzgQrligwiValhWJBnilNQi5A== Received: from MW3PR05CA0028.namprd05.prod.outlook.com (2603:10b6:303:2b::33) by MN0PR12MB6224.namprd12.prod.outlook.com (2603:10b6:208:3c0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Mon, 9 Oct 2023 10:07:35 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:2b:cafe::89) by MW3PR05CA0028.outlook.office365.com (2603:10b6:303:2b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.21 via Frontend Transport; Mon, 9 Oct 2023 10:07:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Mon, 9 Oct 2023 10:07:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:22 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:18 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" Subject: [PATCH net-next 08/11] vxlan: vxlan_core: Support FDB flushing by destination port Date: Mon, 9 Oct 2023 13:06:15 +0300 Message-ID: <20231009100618.2911374-9-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|MN0PR12MB6224:EE_ X-MS-Office365-Filtering-Correlation-Id: 96f00d90-aa87-4318-b9c7-08dbc8af8f50 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E4Y9uZuMKDPU46RRUqpJ48IeRoHW9NqdpP2uQobRyIa5hwG2d4puphJWQstADi/eHWegqaHRHtfzucpr3hE4Ed9oGdF1K+8Vp29HNoNqxAnpDKq6rYBtXMNsYlx1T2AetQLEbeGsBSDym40wN+cc2eX2/WnGacrnPkFPqr6+56AHEc2JVMaPmRU9zWpMTqhIvalGF1LPGERVFjOtuLxIAok93FnQmPcfs1SLC3SaKPLJQfH+JUYztxmHCXsyrC7JCz3WrYnPM/iCcgSF+jeIsaMV1QWGhu6dyJPbXl2n94MvTKgkhMQXr5BDqWvY7cLkcEPYPXBDrRfwblvlTyE3y1VadOAKRUA4bYoD1oKTHOv8JpKG6pb+m03/faYT8FNhs/wulFgtwJqoKTKRFXBJ8hm2CoPe1ZEF+kUrYVDB5oWysyrug1iN635I+aAH0Sr2JnkWI1pqCj41UQQm4SQ5ii5q/BLBKQqk2BeT+L2DxgJazOuvhHNlOPT8s4MvaU3sW9q+h5tV5uPhRhCMWKvIVT/VYlTuvBpI3KvIqPTGUWG8Va8gct0TiPnur85DhIHEUqwtA6Dv/nXTMT5EV68auPxXzq8pw/Xv02OmoT8OoIzNESo2ZYl9o8MkWLTUycyi7jR8PpXkwbGlhdl2i1X13aodxvRiBrvUAZDt9P63PUFcXCoKu3+6llKSvW0TaiNqF1Ae28haJ3GAG0RkPiF4f0uj5E8ZMF+JBQL6YQxT+2W4+Ajsqr/lAI1VhdBr8WBppbQ2uX7y8t1W8gmUXLBWuA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(136003)(396003)(39860400002)(376002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(82310400011)(36840700001)(40470700004)(46966006)(7636003)(356005)(86362001)(36756003)(40480700001)(82740400003)(2906002)(478600001)(41300700001)(8936002)(5660300002)(4326008)(8676002)(6666004)(83380400001)(426003)(336012)(2616005)(1076003)(107886003)(40460700003)(36860700001)(70586007)(70206006)(54906003)(6916009)(316002)(26005)(47076005)(16526019)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:35.1383 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96f00d90-aa87-4318-b9c7-08dbc8af8f50 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6224 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support for flush VXLAN FDB entries by destination port. FDB entry is stored as {MAC, SRC_VNI} + remote. The destination port is an attribute of the remote. For multicast entries, the VXLAN driver stores a linked list of remotes for a given key. In user space, each remote is represented as a separate entry, so when flush is sent with filter of 'destination port', flush only the match remotes. In case that there are no additional remotes, destroy the entry. For example, the following are stored as one entry with several remotes: $ bridge fdb show dev vx10 00:00:00:00:00:00 dst 192.1.1.1 port 1111 vni 2000 self permanent 00:00:00:00:00:00 dst 192.1.1.1 port 1111 vni 3000 self permanent 00:00:00:00:00:00 dst 192.1.1.1 port 2222 vni 2000 self permanent 00:00:00:00:00:00 dst 192.1.1.1 vni 3000 self permanent When user flush by port x, only the relevant remotes will be flushed: $ bridge fdb flush dev vx10 port 1111 $ bridge fdb show dev vx10 00:00:00:00:00:00 dst 192.1.1.1 port 2222 vni 2000 self permanent 00:00:00:00:00:00 dst 192.1.1.1 vni 3000 self permanent Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index f16328a0f9fe..1d6efca4ec4a 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3031,6 +3031,7 @@ struct vxlan_fdb_flush_desc { __be32 src_vni; u32 nhid; __be32 vni; + __be16 port; }; static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f, @@ -3071,7 +3072,7 @@ static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, static bool vxlan_fdb_flush_should_match_remotes(const struct vxlan_fdb_flush_desc *desc) { - return !!desc->vni; + return desc->vni || desc->port; } static bool @@ -3081,6 +3082,9 @@ vxlan_fdb_flush_remote_matches(const struct vxlan_fdb_flush_desc *desc, if (desc->vni && rd->remote_vni != desc->vni) return false; + if (desc->port && rd->remote_port != desc->port) + return false; + return true; } @@ -3141,6 +3145,7 @@ static const struct nla_policy vxlan_del_bulk_policy[NDA_MAX + 1] = { [NDA_SRC_VNI] = { .type = NLA_U32 }, [NDA_NH_ID] = { .type = NLA_U32 }, [NDA_VNI] = { .type = NLA_U32 }, + [NDA_PORT] = { .type = NLA_U16 }, [NDA_NDM_STATE_MASK] = { .type = NLA_U16 }, [NDA_NDM_FLAGS_MASK] = { .type = NLA_U8 }, }; @@ -3194,6 +3199,9 @@ static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, if (tb[NDA_VNI]) desc.vni = cpu_to_be32(nla_get_u32(tb[NDA_VNI])); + if (tb[NDA_PORT]) + desc.port = nla_get_be16(tb[NDA_PORT]); + vxlan_flush(vxlan, &desc); return 0; From patchwork Mon Oct 9 10:06:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413329 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 405701773C for ; Mon, 9 Oct 2023 10:07:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="UAWV55vz" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76A7C9F; Mon, 9 Oct 2023 03:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AG56LkU55dWdeQ90XFSvUMp5ES83NdB2Nj3GiJ51L4X0PBdu2J8rOX/L3FUk2Coux9r7AhxvNA8kilwImL7puuDpWesGOq0bkLIZbU2Q0UrPCtK6OBV1rRld69dw0a/ALo2EkyE5UBhLNOh8cBwZ/dAmHUSzf5iehckzxcGLxs0I86eTBjDvpr+tdWD4YomyXbfaent3Krsdiz9qb+rB00aXM3KcQbavh+Y0VPoiIGPW89zuRZm+5PfEobK0iDNx7ASE3hMexc+Via0HLYMqVbwIMWc4Mgzb5KfqzMl2d/NA3wq6zaGv7KtlgBbJVck7DmzWOxBn2Q30F2ZAwHkeig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vts9POVX0ewQ3xqs/c2ntRY8jSorF1LamTxeTz8FSz0=; b=LD33wgAqC9sDiySyB49tbB9bIHCnECQDnS577W8jS7Vz717PjLsEco8wUnNgnmFm58WGzyWK3eDWGPm1OCYDm1+yOuAB/t4nywHQVuoOLbw8iQ9POlAXgOjFpMEaQtbAVunQ8SxdWUsM6kCLRPQ1SsnrMG9CmxNufa5jAFHFgoDBpHJ02atMoz0bnio8LQrq82OqaAWIDKbZjXml765hckPuvaBUtcoDFjiqxl2GkYlfAAM/IvAXbELQgV1QnXv1l2VfcW9UAmk9w3ueVkzSCDPnI+c9Zy7cTA8n0bvEE8sQAaoaBL61lZm/k98nEKCMe7HNJlKGTh0K2kCj7C89Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vts9POVX0ewQ3xqs/c2ntRY8jSorF1LamTxeTz8FSz0=; b=UAWV55vzzF9eGJq4q28E0ZJxmWPW+lbjMC+ln+FXVM0oNzVZ+kY2OIzKummySw/gjtonFaftoMIVJLpB9lcgYQVj8mtv3j24fHb6wFepy7aeh1wRwJZ/Vu6O97rjZxV6afCZ4W2UxjZVQQWRkbLtSSopAMZM9zKvsDUbHPy23KQ0iHtdMVeXTtLM0tzuUCb1SlxBnaE3rtVUbx5Lc9/weyrTKy79D9k7k09HgbFpTzD6XDTK0pa7slqJVDQxfCGSqY5XYxPxMfd5rI+sYzUnP5mIfAU3+VtNlBR7yeIxSysRbMam7lAaKLbcEPAdWcmwKoPOa/+NhE77aMALCeg8zQ== Received: from DM6PR07CA0063.namprd07.prod.outlook.com (2603:10b6:5:74::40) by DM4PR12MB7624.namprd12.prod.outlook.com (2603:10b6:8:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Mon, 9 Oct 2023 10:07:37 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:5:74:cafe::3a) by DM6PR07CA0063.outlook.office365.com (2603:10b6:5:74::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38 via Frontend Transport; Mon, 9 Oct 2023 10:07:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:26 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:22 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" Subject: [PATCH net-next 09/11] vxlan: vxlan_core: Support FDB flushing by destination IP Date: Mon, 9 Oct 2023 13:06:16 +0300 Message-ID: <20231009100618.2911374-10-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003439:EE_|DM4PR12MB7624:EE_ X-MS-Office365-Filtering-Correlation-Id: c6ed520c-95d2-446d-938a-08dbc8af90bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UrnSsOGOPoq14c7ANi/KquWNQdQAvyMMxa6I38QAQijoHFrgBzVUIF8wsylXvG/rqYNGE84srm557G9Utolg9b0djVni/zVvWPBmLE6PNVV+8HTGkpBmtx2n3wPkVPc2wMA/OXoOVXC8DZWadN/qJadHYwXferPUoSp8G/swpQ2VdKijZC93qkv2zpplx2LnM8cwOcFCAkV3hq8GzkOEmDsSftJtEtp7Fgyr0fG9v7klF3KAfI0+S4G9XZWqLQrlQBQasHf2Wl839VnqK93UsZHIYcCRIm34hdIL1gy9Y4BJsaW+YcA7TDvGdWV6Fk/Av1NQqT9XljoVVthAmb/NfRijs/FgNT7wyBj9u3VjuZXwt47YWBkbU5egHjYri/tsKdrl/BlGnjyVNtNnirE5LfXY6IBhRc8aAIk6/wFXmFZuYLj00jG7xXg28A2RLeh89ODz3K0Mdb5Zk5qur5Uei5WFbBr21oEmLqTGe5epcvAhXUdwq+W7CNm50dIq//MiZJJrWnCdkvt7uk3sgOMtHG5hh/ddBA/W5VpIPGu2thGzW44zE65jbIiCVQk++Wk98xUz5o9QjGsyeKPnVbQsIqiiWhD70pAqWw4Nxudr6ps6hnyN85VWRyxiIdPyE7JyLDJEUdSGoBDgOHgdT9ft94AfSdmZ8x8himcOW75cZAwMx32l7S20Ktkrsb1OC0jnEDxVuRIW4/CVGrn7K5+tBcRzTiDGgBuJWvKlcrqOix0= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(39860400002)(376002)(396003)(346002)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(82310400011)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(83380400001)(1076003)(107886003)(2616005)(336012)(426003)(26005)(16526019)(47076005)(316002)(36860700001)(54906003)(70206006)(70586007)(6916009)(8936002)(8676002)(4326008)(5660300002)(41300700001)(6666004)(2906002)(82740400003)(478600001)(36756003)(356005)(7636003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:37.4957 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6ed520c-95d2-446d-938a-08dbc8af90bf X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7624 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support for flush VXLAN FDB entries by destination IP. FDB entry is stored as {MAC, SRC_VNI} + remote. The destination IP is an attribute of the remote. For multicast entries, the VXLAN driver stores a linked list of remotes for a given key. In user space, each remote is represented as a separate entry, so when flush is sent with filter of 'destination IP', flush only the match remotes. In case that there are no additional remotes, destroy the entry. For example, the following are stored as one entry with several remotes: $ bridge fdb show dev vx10 00:00:00:00:00:00 dst 192.1.1.3 self permanent 00:00:00:00:00:00 dst 192.1.1.1 self permanent 00:00:00:00:00:00 dst 192.1.1.2 self permanent 00:00:00:00:00:00 dst 192.1.1.1 vni 1000 self permanent When user flush by destination IP x, only the relevant remotes will be flushed: $ bridge fdb flush dev vx10 dst 192.1.1.1 $ bridge fdb show dev vx10 00:00:00:00:00:00 dst 192.1.1.3 self permanent 00:00:00:00:00:00 dst 192.1.1.2 self permanent Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel --- drivers/net/vxlan/vxlan_core.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 1d6efca4ec4a..ece377b1b6bd 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3032,6 +3032,7 @@ struct vxlan_fdb_flush_desc { u32 nhid; __be32 vni; __be16 port; + union vxlan_addr dst_ip; }; static bool vxlan_fdb_is_default_entry(const struct vxlan_fdb *f, @@ -3072,7 +3073,7 @@ static bool vxlan_fdb_flush_matches(const struct vxlan_fdb *f, static bool vxlan_fdb_flush_should_match_remotes(const struct vxlan_fdb_flush_desc *desc) { - return desc->vni || desc->port; + return desc->vni || desc->port || desc->dst_ip.sa.sa_family; } static bool @@ -3085,6 +3086,10 @@ vxlan_fdb_flush_remote_matches(const struct vxlan_fdb_flush_desc *desc, if (desc->port && rd->remote_port != desc->port) return false; + if (desc->dst_ip.sa.sa_family && + !vxlan_addr_equal(&rd->remote_ip, &desc->dst_ip)) + return false; + return true; } @@ -3146,6 +3151,8 @@ static const struct nla_policy vxlan_del_bulk_policy[NDA_MAX + 1] = { [NDA_NH_ID] = { .type = NLA_U32 }, [NDA_VNI] = { .type = NLA_U32 }, [NDA_PORT] = { .type = NLA_U16 }, + [NDA_DST] = NLA_POLICY_RANGE(NLA_BINARY, sizeof(struct in_addr), + sizeof(struct in6_addr)), [NDA_NDM_STATE_MASK] = { .type = NLA_U16 }, [NDA_NDM_FLAGS_MASK] = { .type = NLA_U8 }, }; @@ -3202,6 +3209,18 @@ static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, if (tb[NDA_PORT]) desc.port = nla_get_be16(tb[NDA_PORT]); + if (tb[NDA_DST]) { + union vxlan_addr ip; + + err = vxlan_nla_get_addr(&ip, tb[NDA_DST]); + if (err) { + NL_SET_ERR_MSG_ATTR(extack, tb[NDA_DST], + "Unsupported address family"); + return err; + } + desc.dst_ip = ip; + } + vxlan_flush(vxlan, &desc); return 0; From patchwork Mon Oct 9 10:06:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413331 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16F9618035 for ; Mon, 9 Oct 2023 10:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="CEiUBeq+" Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2085.outbound.protection.outlook.com [40.107.96.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 597D89C; Mon, 9 Oct 2023 03:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZFaxjpYAR1Dpq3q06mhlTY9UxYryQEeCY6puBDlNpLGwIisx+YwvxtCzcOTzJUi3A1z+T/1XCPuZjF0uKZSqxg4DIWn/0a/8cXRdu8bmmyq2imdvRVV++x+hM+LKEyLAjWKtwf4h1VR2nnTntnl/kiCXf94s2J+KVIpbo82oKxVIzWBYMcfDLGkujan35DpK1R/hhhf1AIE6bcVsUf6whyjVgoP6Q3TlTaehdMnw2thgiaQ9yKg8Dv2QNKs7J56VlKn/qF6Rr/cKGpSz4pVe4KoYp96xqWBJ5H16xb1K7PIfMeXMBWvaogE20GqTu2rGVNaMrl+WumYlbs/1hBY0GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NSxA7B+eOenRQaj+zdsxv53r0JigXq/AChjmQjLfw34=; b=R0fOePLs9yeauMbuHuZelU8X0SkQpq6bpeAQNlNiyaanBlD6k9p49r5dH/fcjLZjOk1oS75ovRPgcBCys8C9XONx+98ucaNkwI9pEGuQYKxWBhRZ5GSUigPamXGa4cmApnbd2gkT7ltoBNcNgiTzE1hfYxe2D+Ur6LEIwHTkzlvedub2PnU7UkJbEX5z2K2hL9MA0C8jnwdk3gJXtZuhBoAdo5Rr6ogYcNupJ6Rw+Evp0Mf5EVGShDK0/WkqVcVe6yEz5hptjcZs38mprEvz8ymIKlrUAAmsKLLqcvKpTr+DYHC1Qo1DT1/1unFp9JZcFxA1EjLQ5EcpXOZhLE6SLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NSxA7B+eOenRQaj+zdsxv53r0JigXq/AChjmQjLfw34=; b=CEiUBeq+lmmSuJ2h+wfIDYnXy5mRDcY1lW/u2KD2YJ/6olLPFYeLr1x7TTEVpUTQWpJqDljNjyT3d+n2wnv/qZXbb01x0cEofkin79unAiQUGJDQVHgCFQ7fwQxCQPgD+G1aIUrLVCtpCr9tuIkN52pI3NjaLIAtuHB3SN/AKLLUpbGSBty2XMnloCmMznVzmzvlx/ZLP+8P7JhI5lCW3BnTIthvMXucyMpYRJ1eN9ZqAJgn4wCrgZbSLLkvn4W9wE+XRvpMgdyltvYwvvx7nFYJT1jmN5Z40oQJgAl0+fqmUKQtWt5afLYJnjxIfNY1bC46CMEAJ1RPco7Imu+EGQ== Received: from MW3PR05CA0011.namprd05.prod.outlook.com (2603:10b6:303:2b::16) by SJ2PR12MB9211.namprd12.prod.outlook.com (2603:10b6:a03:55e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Mon, 9 Oct 2023 10:07:41 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:2b:cafe::f2) by MW3PR05CA0011.outlook.office365.com (2603:10b6:303:2b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.20 via Frontend Transport; Mon, 9 Oct 2023 10:07:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.22 via Frontend Transport; Mon, 9 Oct 2023 10:07:41 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:30 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:26 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" Subject: [PATCH net-next 10/11] selftests: Add test cases for FDB flush with VXLAN device Date: Mon, 9 Oct 2023 13:06:17 +0300 Message-ID: <20231009100618.2911374-11-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E9:EE_|SJ2PR12MB9211:EE_ X-MS-Office365-Filtering-Correlation-Id: c5efc549-c335-4f02-b67c-08dbc8af92f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eCDuUw44E+urw2XSCF4aPHo4K7r4slmkC63uQQ53+f/faEVcwiFsHK+m7mm4uxfBDNA8MkwaMlFHOtJdPBXqAdRsuj71XC9mdKkg3AGbdRDgdDVtwJkJ8XWNpxepMQOnMYV4uZPe0WpkGLV3tdIHkzBobdvKD7rhzgiEB+qSYYicvz/IBe11NKK6me75d0g7Fz4kqXQZMvMFxVEyharXE/yDIwv/Exxpiem7L+mpRt3PcSe60zHcSyuiAwnFwggzCj40kEhcIcGqgVt8KwJhU7uSP21fMCO0EkzYYZ1uQNDIdCWsQpdC2Wafd1nfxq54/KvFAOUCJabv2xxth0zEIvtKHJ96sSVlt0R+AZNclIIsxf/E3ds66oPctQTugMJi5Jizp66ysABT61GfGocRWPHrZ2bCgLd1JbWw8XapjRzBiIarmmG9IWyNDm4cXargb2fgdX0kgNWsK6LO54btnDhOf/JGqBXg8vWDYoPAD65gWX8zx3dJ5Sv1bg3mq2HbpUNtBUv5D2hJFuOAErQkgVdwr41GdJ1HRsu5KMSObGxriDfdkXc4fsI5EoLRoHouRD3UmyCPcicGSzZL2kn1XraGMBsb6P6Zp3Z/te/k/lK94Ek2vZnKNLQEbkqXVgV2HQVaiKTf3VUKA0EdkSjc+MeqpgJ0nmbkIGoxBjD0Un3pLGso1XjZOnRG6J7lRsMdUqJXjN06aYWR1soUjkvmz4ApnVqXW6H0Zpiz7eeN0BoPHQdullB/BbB1v/x/yLHm X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(82310400011)(36840700001)(46966006)(40470700004)(1076003)(2616005)(426003)(26005)(336012)(16526019)(40460700003)(36756003)(40480700001)(82740400003)(86362001)(356005)(7636003)(83380400001)(107886003)(30864003)(4326008)(2906002)(478600001)(6666004)(8676002)(47076005)(36860700001)(66574015)(8936002)(41300700001)(6916009)(316002)(5660300002)(70206006)(54906003)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:41.2634 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5efc549-c335-4f02-b67c-08dbc8af92f9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9211 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Test all the supported arguments for FDB flush. The test checks configuration, not traffic. Note that the flag 'offloaded' is not checked as it is not relevant when there is no hardware. Signed-off-by: Amit Cohen --- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/fdb_flush.sh | 716 +++++++++++++++++++++++ 2 files changed, 717 insertions(+) create mode 100755 tools/testing/selftests/net/fdb_flush.sh diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 8b017070960d..61939a695f95 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -89,6 +89,7 @@ TEST_PROGS += test_vxlan_mdb.sh TEST_PROGS += test_bridge_neigh_suppress.sh TEST_PROGS += test_vxlan_nolocalbypass.sh TEST_PROGS += test_bridge_backup_port.sh +TEST_PROGS += fdb_flush.sh TEST_FILES := settings diff --git a/tools/testing/selftests/net/fdb_flush.sh b/tools/testing/selftests/net/fdb_flush.sh new file mode 100755 index 000000000000..3050b031f46d --- /dev/null +++ b/tools/testing/selftests/net/fdb_flush.sh @@ -0,0 +1,716 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# This test is for checking functionality of flushing FDB entries. +# Check that flush works as expected with all the supported arguments and verify +# some combinations of arguments. + +FLUSH_BY_STATE_TESTS=" + vxlan_test_flush_by_permanent + vxlan_test_flush_by_nopermanent + vxlan_test_flush_by_static + vxlan_test_flush_by_nostatic + vxlan_test_flush_by_dynamic + vxlan_test_flush_by_nodynamic +" + +FLUSH_BY_FLAG_TESTS=" + vxlan_test_flush_by_extern_learn + vxlan_test_flush_by_noextern_learn + vxlan_test_flush_by_router + vxlan_test_flush_by_norouter +" + +TESTS=" + vxlan_test_flush_by_dev + vxlan_test_flush_by_vni + vxlan_test_flush_by_src_vni + vxlan_test_flush_by_port + vxlan_test_flush_by_dst_ip + vxlan_test_flush_by_nhid + $FLUSH_BY_STATE_TESTS + $FLUSH_BY_FLAG_TESTS + vxlan_test_flush_by_several_args + vxlan_test_flush_by_remote_attributes +" + +: ${VERBOSE:=0} +: ${PAUSE_ON_FAIL:=no} +: ${PAUSE:=no} +: ${VXPORT:=4789} + +run_cmd() +{ + local cmd="$1" + local out + local rc + local stderr="2>/dev/null" + + if [ "$VERBOSE" = "1" ]; then + printf "COMMAND: $cmd\n" + stderr= + fi + + out=$(eval $cmd $stderr) + rc=$? + if [ "$VERBOSE" = "1" -a -n "$out" ]; then + echo " $out" + fi + + return $rc +} + +log_test() +{ + local rc=$1 + local expected=$2 + local msg="$3" + local nsuccess + local nfail + local ret + + if [ ${rc} -eq ${expected} ]; then + printf "TEST: %-60s [ OK ]\n" "${msg}" + nsuccess=$((nsuccess+1)) + else + ret=1 + nfail=$((nfail+1)) + printf "TEST: %-60s [FAIL]\n" "${msg}" + if [ "$VERBOSE" = "1" ]; then + echo " rc=$rc, expected $expected" + fi + + if [ "${PAUSE_ON_FAIL}" = "yes" ]; then + echo + echo "hit enter to continue, 'q' to quit" + read a + [ "$a" = "q" ] && exit 1 + fi + fi + + if [ "${PAUSE}" = "yes" ]; then + echo + echo "hit enter to continue, 'q' to quit" + read a + [ "$a" = "q" ] && exit 1 + fi + + [ "$VERBOSE" = "1" ] && echo +} + +MAC_POOL_1=" + de:ad:be:ef:13:10 + de:ad:be:ef:13:11 + de:ad:be:ef:13:12 + de:ad:be:ef:13:13 + de:ad:be:ef:13:14 +" +mac_pool_1_len=$(echo "$MAC_POOL_1" | grep -c .) + +MAC_POOL_2=" + ca:fe:be:ef:13:10 + ca:fe:be:ef:13:11 + ca:fe:be:ef:13:12 + ca:fe:be:ef:13:13 + ca:fe:be:ef:13:14 +" +mac_pool_2_len=$(echo "$MAC_POOL_2" | grep -c .) + +fdb_add_mac_pool_1() +{ + local dev=$1; shift + local args="$@" + + for mac in $MAC_POOL_1 + do + $BRIDGE fdb add $mac dev $dev $args + done +} + +fdb_add_mac_pool_2() +{ + local dev=$1; shift + local args="$@" + + for mac in $MAC_POOL_2 + do + $BRIDGE fdb add $mac dev $dev $args + done +} + +fdb_check_n_entries_by_dev_filter() +{ + local dev=$1; shift + local exp_entries=$1; shift + local filter="$@" + + local entries=$($BRIDGE fdb show dev $dev | grep "$filter" | wc -l) + + [[ $entries -eq $exp_entries ]] + rc=$? + + log_test $rc 0 "$dev: Expected $exp_entries FDB entries, got $entries" + return $rc +} + +vxlan_test_flush_by_dev() +{ + local vni=3000 + local dst_ip=192.0.2.1 + + fdb_add_mac_pool_1 vx10 vni $vni dst $dst_ip + fdb_add_mac_pool_2 vx20 vni $vni dst $dst_ip + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len + fdb_check_n_entries_by_dev_filter vx20 $mac_pool_2_len + + run_cmd "$BRIDGE fdb flush dev vx10" + log_test $? 0 "Flush FDB by dev vx10" + + fdb_check_n_entries_by_dev_filter vx10 0 + log_test $? 0 "Flush FDB by dev vx10 - test vx10 entries" + + fdb_check_n_entries_by_dev_filter vx20 $mac_pool_2_len + log_test $? 0 "Flush FDB by dev vx10 - test vx20 entries" +} + +vxlan_test_flush_by_vni() +{ + local vni_1=3000 + local vni_2=4000 + local dst_ip=192.0.2.1 + + fdb_add_mac_pool_1 vx10 vni $vni_1 dst $dst_ip + fdb_add_mac_pool_2 vx10 vni $vni_2 dst $dst_ip + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len vni $vni_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len vni $vni_2 + + run_cmd "$BRIDGE fdb flush dev vx10 vni $vni_2" + log_test $? 0 "Flush FDB by dev vx10 and vni $vni_2" + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len vni $vni_1 + log_test $? 0 "Test entries with vni $vni_1" + + fdb_check_n_entries_by_dev_filter vx10 0 vni $vni_2 + log_test $? 0 "Test entries with vni $vni_2" +} + +vxlan_test_flush_by_src_vni() +{ + # Set some entries with {vni=x,src_vni=y} and some with the opposite - + # {vni=y,src_vni=x}, to verify that when we flush by src_vni=x, entries + # with vni=x are not flused. + local vni_1=3000 + local vni_2=4000 + local src_vni_1=4000 + local src_vni_2=3000 + local dst_ip=192.0.2.1 + + # Reconfigure vx10 with 'external' to get 'src_vni' details in + # 'bridge fdb' output + $IP link del dev vx10 + $IP link add name vx10 type vxlan dstport "$VXPORT" external + + fdb_add_mac_pool_1 vx10 vni $vni_1 src_vni $src_vni_1 dst $dst_ip + fdb_add_mac_pool_2 vx10 vni $vni_2 src_vni $src_vni_2 dst $dst_ip + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len \ + src_vni $src_vni_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len \ + src_vni $src_vni_2 + + run_cmd "$BRIDGE fdb flush dev vx10 src_vni $src_vni_2" + log_test $? 0 "Flush FDB by dev vx10 and src_vni $src_vni_2" + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len \ + src_vni $src_vni_1 + log_test $? 0 "Test entries with src_vni $src_vni_1" + + fdb_check_n_entries_by_dev_filter vx10 0 src_vni $src_vni_2 + log_test $? 0 "Test entries with src_vni $src_vni_2" +} + +vxlan_test_flush_by_port() +{ + local port_1=1234 + local port_2=4321 + local dst_ip=192.0.2.1 + + fdb_add_mac_pool_1 vx10 port $port_1 dst $dst_ip + fdb_add_mac_pool_2 vx10 port $port_2 dst $dst_ip + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len port $port_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len port $port_2 + + run_cmd "$BRIDGE fdb flush dev vx10 port $port_2" + log_test $? 0 "Flush FDB by dev vx10 and port $port_2" + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len port $port_1 + log_test $? 0 "Test entries with port $port_1" + + fdb_check_n_entries_by_dev_filter vx10 0 port $port_2 + log_test $? 0 "Test entries with port $port_2" +} + +vxlan_test_flush_by_dst_ip() +{ + local dst_ip_1=192.0.2.1 + local dst_ip_2=192.0.2.2 + + fdb_add_mac_pool_1 vx10 dst $dst_ip_1 + fdb_add_mac_pool_2 vx10 dst $dst_ip_2 + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len dst $dst_ip_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len dst $dst_ip_2 + + run_cmd "$BRIDGE fdb flush dev vx10 dst $dst_ip_2" + log_test $? 0 "Flush FDB by dev vx10 and dst $dst_ip_2" + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len dst $dst_ip_1 + log_test $? 0 "Test entries with dst $dst_ip_1" + + fdb_check_n_entries_by_dev_filter vx10 0 dst $dst_ip_2 + log_test $? 0 "Test entries with dst $dst_ip_2" +} + +nexthops_add() +{ + local nhid_1=$1; shift + local nhid_2=$1; shift + + $IP nexthop add id 10 via 192.0.2.1 fdb + $IP nexthop add id $nhid_1 group 10 fdb + + $IP nexthop add id 20 via 192.0.2.2 fdb + $IP nexthop add id $nhid_2 group 20 fdb +} + +vxlan_test_flush_by_nhid() +{ + local nhid_1=100 + local nhid_2=200 + + nexthops_add $nhid_1 $nhid_2 + + fdb_add_mac_pool_1 vx10 nhid $nhid_1 + fdb_add_mac_pool_2 vx10 nhid $nhid_2 + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len nhid $nhid_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len nhid $nhid_2 + + run_cmd "$BRIDGE fdb flush dev vx10 nhid $nhid_2" + log_test $? 0 "Flush FDB by dev vx10 and nhid $nhid_2" + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len nhid $nhid_1 + log_test $? 0 "Test entries with nhid $nhid_1" + + fdb_check_n_entries_by_dev_filter vx10 0 nhid $nhid_2 + log_test $? 0 "Test entries with nhid $nhid_2" + + # Flush also entries with $nhid_1, and then verify that flushing by + # 'nhid' does not return an error when there are no entries with + # nexthops. + run_cmd "$BRIDGE fdb flush dev vx10 nhid $nhid_1" + log_test $? 0 "Flush FDB by dev vx10 and nhid $nhid_1" + + fdb_check_n_entries_by_dev_filter vx10 0 nhid + log_test $? 0 "Test entries with 'nhid' keyword" + + run_cmd "$BRIDGE fdb flush dev vx10 nhid $nhid_1" + log_test $? 0 "Flush FDB by nhid when there are no entries with nexthop" +} + +vxlan_test_flush_by_state() +{ + local flush_by_state=$1; shift + local state_1=$1; shift + local exp_state_1=$1; shift + local state_2=$1; shift + local exp_state_2=$1; shift + + local dst_ip_1=192.0.2.1 + local dst_ip_2=192.0.2.2 + + fdb_add_mac_pool_1 vx10 dst $dst_ip_1 $state_1 + fdb_add_mac_pool_2 vx10 dst $dst_ip_2 $state_2 + + # Check the entries by dst_ip as not all states appear in 'bridge fdb' + # output. + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len dst $dst_ip_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len dst $dst_ip_2 + + run_cmd "$BRIDGE fdb flush dev vx10 $flush_by_state" + log_test $? 0 "Flush FDB by dev vx10 and state $flush_by_state" + + fdb_check_n_entries_by_dev_filter vx10 $exp_state_1 dst $dst_ip_1 + log_test $? 0 "Test entries with state $state_1" + + fdb_check_n_entries_by_dev_filter vx10 $exp_state_2 dst $dst_ip_2 + log_test $? 0 "Test entries with state $state_2" +} + +vxlan_test_flush_by_permanent() +{ + # Entries that are added without state get 'permanent' state by + # default, add some entries with flag 'extern_learn' instead of state, + # so they will be added with 'permanent' and should be flushed also. + local flush_by_state="permanent" + local state_1="permanent" + local exp_state_1=0 + local state_2="extern_learn" + local exp_state_2=0 + + vxlan_test_flush_by_state $flush_by_state $state_1 $exp_state_1 \ + $state_2 $exp_state_2 +} + +vxlan_test_flush_by_nopermanent() +{ + local flush_by_state="nopermanent" + local state_1="permanent" + local exp_state_1=$mac_pool_1_len + local state_2="static" + local exp_state_2=0 + + vxlan_test_flush_by_state $flush_by_state $state_1 $exp_state_1 \ + $state_2 $exp_state_2 +} + +vxlan_test_flush_by_static() +{ + local flush_by_state="static" + local state_1="static" + local exp_state_1=0 + local state_2="dynamic" + local exp_state_2=$mac_pool_2_len + + vxlan_test_flush_by_state $flush_by_state $state_1 $exp_state_1 \ + $state_2 $exp_state_2 +} + +vxlan_test_flush_by_nostatic() +{ + local flush_by_state="nostatic" + local state_1="permanent" + local exp_state_1=$mac_pool_1_len + local state_2="dynamic" + local exp_state_2=0 + + vxlan_test_flush_by_state $flush_by_state $state_1 $exp_state_1 \ + $state_2 $exp_state_2 +} + +vxlan_test_flush_by_dynamic() +{ + local flush_by_state="dynamic" + local state_1="dynamic" + local exp_state_1=0 + local state_2="static" + local exp_state_2=$mac_pool_2_len + + vxlan_test_flush_by_state $flush_by_state $state_1 $exp_state_1 \ + $state_2 $exp_state_2 +} + +vxlan_test_flush_by_nodynamic() +{ + local flush_by_state="nodynamic" + local state_1="permanent" + local exp_state_1=0 + local state_2="dynamic" + local exp_state_2=$mac_pool_2_len + + vxlan_test_flush_by_state $flush_by_state $state_1 $exp_state_1 \ + $state_2 $exp_state_2 +} + +vxlan_test_flush_by_flag() +{ + local flush_by_flag=$1; shift + local flag_1=$1; shift + local exp_flag_1=$1; shift + local flag_2=$1; shift + local exp_flag_2=$1; shift + + local dst_ip_1=192.0.2.1 + local dst_ip_2=192.0.2.2 + + fdb_add_mac_pool_1 vx10 dst $dst_ip_1 $flag_1 + fdb_add_mac_pool_2 vx10 dst $dst_ip_2 $flag_2 + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len $flag_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len $flag_2 + + run_cmd "$BRIDGE fdb flush dev vx10 $flush_by_flag" + log_test $? 0 "Flush FDB by dev vx10 and flag $flush_by_flag" + + fdb_check_n_entries_by_dev_filter vx10 $exp_flag_1 dst $dst_ip_1 + log_test $? 0 "Test entries with flag $flag_1" + + fdb_check_n_entries_by_dev_filter vx10 $exp_flag_2 dst $dst_ip_2 + log_test $? 0 "Test entries with flag $flag_2" +} + +vxlan_test_flush_by_extern_learn() +{ + local flush_by_flag="extern_learn" + local flag_1="extern_learn" + local exp_flag_1=0 + local flag_2="router" + local exp_flag_2=$mac_pool_2_len + + vxlan_test_flush_by_flag $flush_by_flag $flag_1 $exp_flag_1 \ + $flag_2 $exp_flag_2 +} + +vxlan_test_flush_by_noextern_learn() +{ + local flush_by_flag="noextern_learn" + local flag_1="extern_learn" + local exp_flag_1=$mac_pool_1_len + local flag_2="router" + local exp_flag_2=0 + + vxlan_test_flush_by_flag $flush_by_flag $flag_1 $exp_flag_1 \ + $flag_2 $exp_flag_2 +} + +vxlan_test_flush_by_router() +{ + local flush_by_flag="router" + local flag_1="router" + local exp_flag_1=0 + local flag_2="extern_learn" + local exp_flag_2=$mac_pool_2_len + + vxlan_test_flush_by_flag $flush_by_flag $flag_1 $exp_flag_1 \ + $flag_2 $exp_flag_2 +} + +vxlan_test_flush_by_norouter() +{ + + local flush_by_flag="norouter" + local flag_1="router" + local exp_flag_1=$mac_pool_1_len + local flag_2="extern_learn" + local exp_flag_2=0 + + vxlan_test_flush_by_flag $flush_by_flag $flag_1 $exp_flag_1 \ + $flag_2 $exp_flag_2 +} + +vxlan_test_flush_by_several_args() +{ + local dst_ip_1=192.0.2.1 + local dst_ip_2=192.0.2.2 + local state_1=permanent + local state_2=static + local vni=3000 + local port=1234 + local nhid=100 + local flag=router + local flush_args + + ################### Flush by 2 args - nhid and flag #################### + $IP nexthop add id 10 via 192.0.2.1 fdb + $IP nexthop add id $nhid group 10 fdb + + fdb_add_mac_pool_1 vx10 nhid $nhid $flag $state_1 + fdb_add_mac_pool_2 vx10 nhid $nhid $flag $state_2 + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len $state_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len $state_2 + + run_cmd "$BRIDGE fdb flush dev vx10 nhid $nhid $flag" + log_test $? 0 "Flush FDB by dev vx10 nhid $nhid $flag" + + # All entries should be flushed as 'state' is not an argument for flush + # filtering. + fdb_check_n_entries_by_dev_filter vx10 0 $state_1 + log_test $? 0 "Test entries with state $state_1" + + fdb_check_n_entries_by_dev_filter vx10 0 $state_2 + log_test $? 0 "Test entries with state $state_2" + + ################ Flush by 3 args - VNI, port and dst_ip ################ + fdb_add_mac_pool_1 vx10 vni $vni port $port dst $dst_ip_1 + fdb_add_mac_pool_2 vx10 vni $vni port $port dst $dst_ip_2 + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len dst $dst_ip_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len dst $dst_ip_2 + + flush_args="vni $vni port $port dst $dst_ip_2" + run_cmd "$BRIDGE fdb flush dev vx10 $flush_args" + log_test $? 0 "Flush FDB by dev vx10 $flush_args" + + # Only entries with $dst_ip_2 should be flushed, even the rest arguments + # match the filter, the flush should be AND of all the arguments. + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len dst $dst_ip_1 + log_test $? 0 "Test entries with dst $dst_ip_1" + + fdb_check_n_entries_by_dev_filter vx10 0 dst $dst_ip_2 + log_test $? 0 "Test entries with dst $dst_ip_2" +} + +multicast_fdb_entries_add() +{ + mac=00:00:00:00:00:00 + vnis=(2000 3000) + + for vni in "${vnis[@]}"; do + $BRIDGE fdb append $mac dev vx10 dst 192.0.2.1 vni $vni \ + src_vni 5000 + $BRIDGE fdb append $mac dev vx10 dst 192.0.2.1 vni $vni \ + port 1111 + $BRIDGE fdb append $mac dev vx10 dst 192.0.2.2 vni $vni \ + port 2222 + done +} + +vxlan_test_flush_by_remote_attributes() +{ + local flush_args + + # Reconfigure vx10 with 'external' to get 'src_vni' details in + # 'bridge fdb' output + $IP link del dev vx10 + $IP link add name vx10 type vxlan dstport "$VXPORT" external + + # For multicat FDB entries, the VXLAN driver stores a linked list of + # remotes for a given key. Verify that only the expected remotes are + # flushed. + multicast_fdb_entries_add + + ## Flush by 3 remote's attributes - destination IP, port and VNI ## + flush_args="dst 192.0.2.1 port 1111 vni 2000" + fdb_check_n_entries_by_dev_filter vx10 1 $flush_args + + t0_n_entries=$($BRIDGE fdb show dev vx10 | wc -l) + run_cmd "$BRIDGE fdb flush dev vx10 $flush_args" + log_test $? 0 "Flush FDB by dev vx10 $flush_args" + + fdb_check_n_entries_by_dev_filter vx10 0 $flush_args + + exp_n_entries=$((t0_n_entries - 1)) + t1_n_entries=$($BRIDGE fdb show dev vx10 | wc -l) + [[ $t1_n_entries -eq $exp_n_entries ]] + log_test $? 0 "Check how many entries were flushed" + + ## Flush by 2 remote's attributes - destination IP and port ## + flush_args="dst 192.0.2.2 port 2222" + + fdb_check_n_entries_by_dev_filter vx10 2 $flush_args + + t0_n_entries=$($BRIDGE fdb show dev vx10 | wc -l) + run_cmd "$BRIDGE fdb flush dev vx10 $flush_args" + log_test $? 0 "Flush FDB by dev vx10 $flush_args" + + fdb_check_n_entries_by_dev_filter vx10 0 $flush_args + + exp_n_entries=$((t0_n_entries - 2)) + t1_n_entries=$($BRIDGE fdb show dev vx10 | wc -l) + [[ $t1_n_entries -eq $exp_n_entries ]] + log_test $? 0 "Check how many entries were flushed" + + ## Flush by source VNI, which is not remote's attribute and VNI ## + flush_args="vni 3000 src_vni 5000" + + fdb_check_n_entries_by_dev_filter vx10 1 $flush_args + + t0_n_entries=$($BRIDGE fdb show dev vx10 | wc -l) + run_cmd "$BRIDGE fdb flush dev vx10 $flush_args" + log_test $? 0 "Flush FDB by dev vx10 $flush_args" + + fdb_check_n_entries_by_dev_filter vx10 0 $flush_args + + exp_n_entries=$((t0_n_entries -1)) + t1_n_entries=$($BRIDGE fdb show dev vx10 | wc -l) + [[ $t1_n_entries -eq $exp_n_entries ]] + log_test $? 0 "Check how many entries were flushed" + + # Flush by 1 remote's attribute - destination IP ## + flush_args="dst 192.0.2.1" + + fdb_check_n_entries_by_dev_filter vx10 2 $flush_args + + t0_n_entries=$($BRIDGE fdb show dev vx10 | wc -l) + run_cmd "$BRIDGE fdb flush dev vx10 $flush_args" + log_test $? 0 "Flush FDB by dev vx10 $flush_args" + + fdb_check_n_entries_by_dev_filter vx10 0 $flush_args + + exp_n_entries=$((t0_n_entries -2)) + t1_n_entries=$($BRIDGE fdb show dev vx10 | wc -l) + [[ $t1_n_entries -eq $exp_n_entries ]] + log_test $? 0 "Check how many entries were flushed" +} + +setup() +{ + IP="ip -netns ns1" + BRIDGE="bridge -netns ns1" + + ip netns add ns1 + + $IP link add name vx10 type vxlan id 1000 dstport "$VXPORT" + $IP link add name vx20 type vxlan id 2000 dstport "$VXPORT" +} + +cleanup() +{ + $IP link del dev vx20 + $IP link del dev vx10 + + ip netns del ns1 +} + +################################################################################ +# main + +while getopts :t:pPhvw: o +do + case $o in + t) TESTS=$OPTARG;; + p) PAUSE_ON_FAIL=yes;; + P) PAUSE=yes;; + v) VERBOSE=$(($VERBOSE + 1));; + w) PING_TIMEOUT=$OPTARG;; + h) usage; exit 0;; + *) usage; exit 1;; + esac +done + +# make sure we don't pause twice +[ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no + +if [ "$(id -u)" -ne 0 ];then + echo "SKIP: Need root privileges" + exit $ksft_skip; +fi + +if [ ! -x "$(command -v ip)" ]; then + echo "SKIP: Could not run test without ip tool" + exit $ksft_skip +fi + +# Check a flag that is added to flush command as part of VXLAN flush support +bridge fdb help 2>&1 | grep -q "\[no\]router" +if [ $? -ne 0 ]; then + echo "SKIP: iproute2 too old, missing flush command for VXLAN" + exit $ksft_skip +fi + +ip link add dev vx10 type vxlan id 1000 2> /dev/null +out=$(bridge fdb flush dev vx10 2>&1 | grep -q "Operation not supported") +if [ $? -eq 0 ]; then + echo "SKIP: kernel lacks vxlan flush support" + exit $ksft_skip +fi +ip link del dev vx10 + +for t in $TESTS +do + setup; $t; cleanup; +done From patchwork Mon Oct 9 10:06:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 13413330 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB9661798B for ; Mon, 9 Oct 2023 10:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Ig/2VZ+H" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2057.outbound.protection.outlook.com [40.107.223.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AFBDCF; Mon, 9 Oct 2023 03:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=avwYS3FyKG4AqxEEgDGckuCEfdhApXKLvOzaQJX4ZBYvw928r+GCxJJ0PTahpvHUZqXesyYSnEkH73MGpoj4NLDAtRCkgCaay3vnBuMPGvPkV86NwUqrdQwpJRIugojpokB4qGgWPbu2BooLdMAt+JsKFOmpsgcdbPyq0vNWbd1psy+3hf+QkJMuaTR0IO47YXllHpgYnYicQXAgbyxuZ00yAXya632QjRQeQ6mN/Q2PSR3RlUxxgwiIBFiMTax5UrrFmXCZgA4Pz1SBFLI2btZVuzWGlDkBH1kXA8BKUqLDI+0cC2baQ7JuYwrvKH1NUNPn72nyBG3sMf5A3mj7Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kPQrcvAu8rLpQapwQqxzBzEo7hcE9ye2l3LUdfKldvk=; b=iAgNDTIIeGZce8pYppOLFq3/5sDfCgHHsO/EV0tZR1kmQT4vvD8nd35MirC6k41gmIvmaI8adPzKyrp5ItFwjefppiamtA5s+iCkY7MAI4cm+Y2mIp5bld7zATtRl7FodTxisci4I/2apON2gURhC7FD22L96SdxAEjV8YWxu5Qb9uDG4ejRJ0pDirWT7P1dBeF5P0flAtZWYrrmnqNWePF3lmYIL3ydvr+gzfvh7ntR406F88BGZPSgeV6Lw4/fBCA6pr3Uq+FjZTQ3hjHIL57mebAIXRPc7VN25a1dZGgQXise/1ZN9MJjsEApG4YWrB9BtDFXywx6rivWfCOPug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kPQrcvAu8rLpQapwQqxzBzEo7hcE9ye2l3LUdfKldvk=; b=Ig/2VZ+H0DcAJ8g+IOo60uoTh2ObP/1IQWRrmTcait5QEGl0CzeGgEVJifezrp1jOXl5lw25iSQ2cclZkSllb7I5p3CXM8FGgEJAMeXtEANH9bSPHQpPdphiJ/JwUG61tBmFK6iW/yC0DFvy/qGA1aCoS68cjjkWmG2hZJ8/g2r94Wt4ma7+aB1CtIlHjE5auCvlNYoS5AG0ydfMuf/AQRuxE7ZCW+mUAOE+/wFteCKsJ6og9mSyBmmqu1h0LRU9tI+qa9Ur4H1IqIh3EGXnGGtPDAXFWiqq+Heh6f50LM6/svBUwGcW9LumjuNvgmAAL3hRmRWQySC97hDGTwCoBw== Received: from MWH0EPF00056D04.namprd21.prod.outlook.com (2603:10b6:30f:fff2:0:1:0:c) by PH8PR12MB6962.namprd12.prod.outlook.com (2603:10b6:510:1bd::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.41; Mon, 9 Oct 2023 10:07:43 +0000 Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2a01:111:f403:f805::) by MWH0EPF00056D04.outlook.office365.com (2603:1036:d20::b) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.12 via Frontend Transport; Mon, 9 Oct 2023 10:07:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Mon, 9 Oct 2023 10:07:43 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:33 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 9 Oct 2023 03:07:30 -0700 From: Amit Cohen To: CC: , , , , , , , , , , , "Amit Cohen" Subject: [PATCH net-next 11/11] selftests: fdb_flush: Add test cases for FDB flush with bridge device Date: Mon, 9 Oct 2023 13:06:18 +0300 Message-ID: <20231009100618.2911374-12-amcohen@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231009100618.2911374-1-amcohen@nvidia.com> References: <20231009100618.2911374-1-amcohen@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|PH8PR12MB6962:EE_ X-MS-Office365-Filtering-Correlation-Id: b8f3c1ed-635b-4f68-c4b8-08dbc8af9443 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ksfUozeWvD+nBnZUe10Fxjy10Z7l+or9g8NBEAFdQBxiwd9v0tSmPROm9wywy7xdonkdTsxcssH/Td3pxSorNu+YNPlSWJldxmLnhGu868AnMqaAGfxKt+Kmy5nPEX1ND73N+7uzcT94l0Nxd6zNC8M50+2LpdllG5kH6Em+oPvWmwsTzUzYfzDhIH84S3mkWO6G+wTD17ZTkfFezt/izNRZhcSwFBoJi8C8InHgSIo7o7o+aiGwa1pvgx5Vl2TGWyCuD+MLOBsggCJbE1LS6CnaljwCw0raP9D8ac/yj4I5y/Wf3AmaPEY3CQUiOfm6C73lwJhJDKHPcuDqNNpn9CDqHtr5y8c9S/34CXygjbedWVfAHeO+sp7U58jg8i5gzVZWX9MVzKQ2YNEdgg98IoGPNa8rLuJEdj+EsAt7W8dj4XZlVWMkzT6okJyYj/hY9Fuu0pYgzWLiOjppzp9mUM0cwG3lMjQiM9U7FdnF70ypFjdi/vdxyCJy1obAOP+7KTY2g0NleQv53Vp6tj3+bL4mQVnrxzy66YuinMwi1qAfHAFNUPVNsUt5cHRH7RcwJqqghZyCJUM2GAhQ2GPzlJ3FpiVaZk4DalpfkxzsVFpJkSf5D0kB8Uo6/HnRJsdLJtTd+ixPkXSY7Nhp0MzbLu/lq3kO7HBhGKy5AwgPzbffdOINXaKxZdOqrFL4tg4rDYfZsnKrjMWstBuGpRreso14KOsxgE4Nj9SXSaFaJf8= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(396003)(376002)(136003)(39860400002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(82310400011)(40470700004)(46966006)(36840700001)(7636003)(356005)(86362001)(36756003)(40480700001)(2906002)(82740400003)(478600001)(41300700001)(8936002)(5660300002)(4326008)(8676002)(6666004)(1076003)(83380400001)(426003)(336012)(2616005)(107886003)(40460700003)(316002)(36860700001)(70586007)(70206006)(54906003)(6916009)(26005)(47076005)(16526019);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2023 10:07:43.4420 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8f3c1ed-635b-4f68-c4b8-08dbc8af9443 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6962 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Extend the test to check flushing with bridge device, test flush by device and by VID. Add test case for flushing with "self" and "master" and attributes that are supported only in one driver, this is unrecommended configuration, check it to verify that user gets an error. Signed-off-by: Amit Cohen --- tools/testing/selftests/net/fdb_flush.sh | 96 ++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/tools/testing/selftests/net/fdb_flush.sh b/tools/testing/selftests/net/fdb_flush.sh index 3050b031f46d..90e7a29e0476 100755 --- a/tools/testing/selftests/net/fdb_flush.sh +++ b/tools/testing/selftests/net/fdb_flush.sh @@ -32,6 +32,9 @@ TESTS=" $FLUSH_BY_FLAG_TESTS vxlan_test_flush_by_several_args vxlan_test_flush_by_remote_attributes + bridge_test_flush_by_dev + bridge_test_flush_by_vlan + bridge_vxlan_test_flush " : ${VERBOSE:=0} @@ -647,6 +650,93 @@ vxlan_test_flush_by_remote_attributes() log_test $? 0 "Check how many entries were flushed" } +bridge_test_flush_by_dev() +{ + local dst_ip=192.0.2.1 + local br0_n_ent_t0=$($BRIDGE fdb show dev br0 | wc -l) + local br1_n_ent_t0=$($BRIDGE fdb show dev br1 | wc -l) + + fdb_add_mac_pool_1 br0 dst $dst_ip + fdb_add_mac_pool_2 br1 dst $dst_ip + + # Each 'fdb add' command adds one extra entry in the bridge with the + # default vlan. + local exp_br0_n_ent=$(($br0_n_ent_t0 + 2 * $mac_pool_1_len)) + local exp_br1_n_ent=$(($br1_n_ent_t0 + 2 * $mac_pool_2_len)) + + fdb_check_n_entries_by_dev_filter br0 $exp_br0_n_ent + fdb_check_n_entries_by_dev_filter br1 $exp_br1_n_ent + + run_cmd "$BRIDGE fdb flush dev br0" + log_test $? 0 "Flush FDB by dev br0" + + # The default entry should not be flushed + fdb_check_n_entries_by_dev_filter br0 1 + log_test $? 0 "Flush FDB by dev br0 - test br0 entries" + + fdb_check_n_entries_by_dev_filter br1 $exp_br1_n_ent + log_test $? 0 "Flush FDB by dev br0 - test br1 entries" +} + +bridge_test_flush_by_vlan() +{ + local vlan_1=10 + local vlan_2=20 + local vlan_1_ent_t0 + local vlan_2_ent_t0 + + $BRIDGE vlan add vid $vlan_1 dev br0 self + $BRIDGE vlan add vid $vlan_2 dev br0 self + + vlan_1_ent_t0=$($BRIDGE fdb show dev br0 | grep "vlan $vlan_1" | wc -l) + vlan_2_ent_t0=$($BRIDGE fdb show dev br0 | grep "vlan $vlan_2" | wc -l) + + fdb_add_mac_pool_1 br0 vlan $vlan_1 + fdb_add_mac_pool_2 br0 vlan $vlan_2 + + local exp_vlan_1_ent=$(($vlan_1_ent_t0 + $mac_pool_1_len)) + local exp_vlan_2_ent=$(($vlan_2_ent_t0 + $mac_pool_2_len)) + + fdb_check_n_entries_by_dev_filter br0 $exp_vlan_1_ent vlan $vlan_1 + fdb_check_n_entries_by_dev_filter br0 $exp_vlan_2_ent vlan $vlan_2 + + run_cmd "$BRIDGE fdb flush dev br0 vlan $vlan_1" + log_test $? 0 "Flush FDB by dev br0 and vlan $vlan_1" + + fdb_check_n_entries_by_dev_filter br0 0 vlan $vlan_1 + log_test $? 0 "Test entries with vlan $vlan_1" + + fdb_check_n_entries_by_dev_filter br0 $exp_vlan_2_ent vlan $vlan_2 + log_test $? 0 "Test entries with vlan $vlan_2" +} + +bridge_vxlan_test_flush() +{ + local vlan_1=10 + local dst_ip=192.0.2.1 + + $IP link set dev vx10 master br0 + $BRIDGE vlan add vid $vlan_1 dev br0 self + $BRIDGE vlan add vid $vlan_1 dev vx10 + + fdb_add_mac_pool_1 vx10 vni 3000 dst $dst_ip self master + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len vlan $vlan_1 + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len vni 3000 + + # Such command should fail in VXLAN driver as vlan is not supported, + # but the command should flush the entries in the bridge + run_cmd "$BRIDGE fdb flush dev vx10 vlan $vlan_1 master self" + log_test $? 255 \ + "Flush FDB by dev vx10, vlan $vlan_1, master and self" + + fdb_check_n_entries_by_dev_filter vx10 0 vlan $vlan_1 + log_test $? 0 "Test entries with vlan $vlan_1" + + fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len dst $dst_ip + log_test $? 0 "Test entries with dst $dst_ip" +} + setup() { IP="ip -netns ns1" @@ -656,10 +746,16 @@ setup() $IP link add name vx10 type vxlan id 1000 dstport "$VXPORT" $IP link add name vx20 type vxlan id 2000 dstport "$VXPORT" + + $IP link add br0 type bridge vlan_filtering 1 + $IP link add br1 type bridge vlan_filtering 1 } cleanup() { + $IP link del dev br1 + $IP link del dev br0 + $IP link del dev vx20 $IP link del dev vx10