Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp890147pxp; Wed, 16 Mar 2022 20:19:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCufsUmQiV5/8IDQ3wEPJ/NaXKb3WIIsgOsPlkERn4ZA1EyfXwfi95Rw25tHx4KUJWX8Bo X-Received: by 2002:aa7:8215:0:b0:4f7:125a:c88c with SMTP id k21-20020aa78215000000b004f7125ac88cmr2986119pfi.70.1647487174574; Wed, 16 Mar 2022 20:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647487174; cv=none; d=google.com; s=arc-20160816; b=tT7bNWSFkwRS8Kl9CwAa7vMb2VzSnNDXEXuuAr8ENwkvL3nMLeUEENKXg5jcrh6JSM CiEpE8q1msiaZBncy7dFv/V0sxuCBrnPvkddkU9LEHg2wysyAAN0UlQ3VzOIxeVFBe0Q LcZJN/Veb4TMTZxqfsNMAHVKgh3UADkJHlm6fVdxWDfHPQamO8imbiyX0DmQOQ/ufmRZ /AcAhYGFoLUMUVrZ1UbP6gfy6+tN7xkGmTFzddKNE1oKYfwI7olBRB0diHW3ced/TnlF YFCKiPsMjo/uvCpCg5ee7JiTY9m5Ap6iOJNhP39qaGE04TDFjKu5f+PKgODfligmDBd1 Qo7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=0D/qDmhXs9KTVIVEd7/N1WYmWdmHzo+e42flk/d3j6Y=; b=SI9K8IRXQ8JFJWx8PfdUTHwuXbPYprPWHBMV/vPmA2RkXfRie6KObvZNOHm5P8/AmK kVwAA44U74v0+Vx+pZRipFJV04jqZNerrNbO4OWaMzwaBIf6p41250wos8H9T2ZC3P4j MwPUIkUjNYpR7kBjF/hitkqWnf8v1+TMIYCzRMttwmSTkutoZSaUC+vhNjFal1kZtKXW BAcIkzNwRjLkD9Z5wrNLtdoKFV6ZIchbLrqS5b0NT9pdyx/ASOJ9ZtLNjAXzPf4wKarn M/z8DsG0c8QL1O7g4zbbFcGvGmKC7+C9reAz+H/N3naE48TcLoGToDJsj3iKXO+P0Vgc O25Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VjfewExN; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n7-20020a1709026a8700b0014f85c15c61si3155191plk.479.2022.03.16.20.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:19:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VjfewExN; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 164F62251C; Wed, 16 Mar 2022 20:19:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346194AbiCOIuO (ORCPT + 99 others); Tue, 15 Mar 2022 04:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbiCOIuM (ORCPT ); Tue, 15 Mar 2022 04:50:12 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE704C795; Tue, 15 Mar 2022 01:48:57 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id l20so31645781lfg.12; Tue, 15 Mar 2022 01:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=0D/qDmhXs9KTVIVEd7/N1WYmWdmHzo+e42flk/d3j6Y=; b=VjfewExNWrMUAD3TXnOWZyUf0JFHb5alzMKxnqU3tQLJt0c46OROW/LnmxgTYkzBdH +2b3oAbbqnoHer/WwvLrzP7zhZPq75b8qYAw/4UsS6pFY7cmWYhcP0LQGgwQ8y8fnIXe uWc/TMxGjqQijqhBpyZojRwzyr60GYtqcX1mLCwdHV6GhpTF0rvwNHvoQLOvnCaBfkaF Iey5jaKWubfhtalV4lnAkvqv6teQuurDZ/l5hYY4xgTVqEc0+2ViUZBvEPdwrUTF/j2m s+GHQwSylHF/szw7gqtgQV6CEZA3mLuz6IIJC9DFkKpcXvm0wGF0fN3RCuZp3Mqppf6h OyKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=0D/qDmhXs9KTVIVEd7/N1WYmWdmHzo+e42flk/d3j6Y=; b=rj1H0F0obMIaQeFH+MWwB6b+X6GyMdzWMGjorU2ZFsn/g/DYo5wJKQdJ60f7cmjzxB Y0WzXk24A53Tk4MBt/DHdkGA2oyYqAD/kwFewJdA4WTZALpkzk5rHG2U+AmdhKitxqR3 mKVMSQ6z4tsFgdJPZb+wv+4sDE8eSr3OnjgyVBOS2HNf1ldYtctJx6i1R0x382qRDoRE faZb4QgSVRPQbx8Cni57Cd07K4U5plpbB2Zb/MDOkCBcHJBlNJgLaXGvFQQDCIq8FyWm FmnGgvDk3wWLBQsIqqmofz+2sR5xwgizhJyf0lLgBxZf8exZ7D3rnG6h2IbA0MQn6qZH kJnQ== X-Gm-Message-State: AOAM530L+ebTiXrBKGHa2jrEDSz2fPBDymmyCSYNKJ2KWc78f/vnUlP0 D9ykTaky0GVG1AntGK5FVSk= X-Received: by 2002:ac2:410d:0:b0:443:7f40:47a8 with SMTP id b13-20020ac2410d000000b004437f4047a8mr15421619lfi.228.1647334135928; Tue, 15 Mar 2022 01:48:55 -0700 (PDT) Received: from wse-c0127 ([208.127.141.29]) by smtp.gmail.com with ESMTPSA id i29-20020a0565123e1d00b004485c87722csm3198004lfv.171.2022.03.15.01.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 01:48:55 -0700 (PDT) From: Hans Schultz X-Google-Original-From: Hans Schultz To: Ido Schimmel , Hans Schultz Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Nikolay Aleksandrov , Daniel Borkmann , Ido Schimmel , linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org Subject: Re: [PATCH net-next 1/3] net: bridge: add fdb flag to extent locked port feature In-Reply-To: References: <20220310142320.611738-1-schultz.hans+netdev@gmail.com> <20220310142320.611738-2-schultz.hans+netdev@gmail.com> Date: Tue, 15 Mar 2022 09:48:52 +0100 Message-ID: <86h77zha8b.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On m=C3=A5n, mar 14, 2022 at 17:30, Ido Schimmel wrote: > On Thu, Mar 10, 2022 at 03:23:18PM +0100, Hans Schultz wrote: >> Add an intermediate state for clients behind a locked port to allow for >> possible opening of the port for said clients. This feature corresponds >> to the Mac-Auth and MAC Authentication Bypass (MAB) named features. The >> latter defined by Cisco. >>=20 >> Signed-off-by: Hans Schultz >> --- >> include/uapi/linux/neighbour.h | 1 + >> net/bridge/br_fdb.c | 6 ++++++ >> net/bridge/br_input.c | 11 ++++++++++- >> net/bridge/br_private.h | 3 ++- >> 4 files changed, 19 insertions(+), 2 deletions(-) >>=20 >> diff --git a/include/uapi/linux/neighbour.h b/include/uapi/linux/neighbo= ur.h >> index db05fb55055e..83115a592d58 100644 >> --- a/include/uapi/linux/neighbour.h >> +++ b/include/uapi/linux/neighbour.h >> @@ -208,6 +208,7 @@ enum { >> NFEA_UNSPEC, >> NFEA_ACTIVITY_NOTIFY, >> NFEA_DONT_REFRESH, >> + NFEA_LOCKED, >> __NFEA_MAX >> }; >> #define NFEA_MAX (__NFEA_MAX - 1) >> diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c >> index 6ccda68bd473..396dcf3084cf 100644 >> --- a/net/bridge/br_fdb.c >> +++ b/net/bridge/br_fdb.c >> @@ -105,6 +105,7 @@ static int fdb_fill_info(struct sk_buff *skb, const = struct net_bridge *br, >> struct nda_cacheinfo ci; >> struct nlmsghdr *nlh; >> struct ndmsg *ndm; >> + u8 ext_flags =3D 0; >>=20=20 >> nlh =3D nlmsg_put(skb, portid, seq, type, sizeof(*ndm), flags); >> if (nlh =3D=3D NULL) >> @@ -125,11 +126,16 @@ static int fdb_fill_info(struct sk_buff *skb, cons= t struct net_bridge *br, >> ndm->ndm_flags |=3D NTF_EXT_LEARNED; >> if (test_bit(BR_FDB_STICKY, &fdb->flags)) >> ndm->ndm_flags |=3D NTF_STICKY; >> + if (test_bit(BR_FDB_ENTRY_LOCKED, &fdb->flags)) >> + ext_flags |=3D 1 << NFEA_LOCKED; >>=20=20 >> if (nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->key.addr)) >> goto nla_put_failure; >> if (nla_put_u32(skb, NDA_MASTER, br->dev->ifindex)) >> goto nla_put_failure; >> + if (nla_put_u8(skb, NDA_FDB_EXT_ATTRS, ext_flags)) >> + goto nla_put_failure; >> + >> ci.ndm_used =3D jiffies_to_clock_t(now - fdb->used); >> ci.ndm_confirmed =3D 0; >> ci.ndm_updated =3D jiffies_to_clock_t(now - fdb->updated); >> diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c >> index e0c13fcc50ed..897908484b18 100644 >> --- a/net/bridge/br_input.c >> +++ b/net/bridge/br_input.c >> @@ -75,6 +75,7 @@ int br_handle_frame_finish(struct net *net, struct soc= k *sk, struct sk_buff *skb >> struct net_bridge_mcast *brmctx; >> struct net_bridge_vlan *vlan; >> struct net_bridge *br; >> + unsigned long flags =3D 0; >> u16 vid =3D 0; >> u8 state; >>=20=20 >> @@ -94,8 +95,16 @@ int br_handle_frame_finish(struct net *net, struct so= ck *sk, struct sk_buff *skb >> br_fdb_find_rcu(br, eth_hdr(skb)->h_source, vid); >>=20=20 >> if (!fdb_src || READ_ONCE(fdb_src->dst) !=3D p || >> - test_bit(BR_FDB_LOCAL, &fdb_src->flags)) >> + test_bit(BR_FDB_LOCAL, &fdb_src->flags)) { >> + if (!fdb_src) { >> + set_bit(BR_FDB_ENTRY_LOCKED, &flags); > > This flag is read-only for user space, right? That is, the kernel needs > to reject it during netlink policy validation. > Yes, the flag is only readable from user space, unless there is a wish to change that. >> + br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, flags); >> + } >> goto drop; >> + } else { > > IIUC, we get here in case there is a non-local FDB entry with the SA > that points to our port. Can you write it as: > Yes, looks like that's more optimal. :) > if (!fdb_src || READ_ONCE(fdb_src->dst) !=3D p || > test_bit(BR_FDB_LOCAL, &fdb_src->flags) || > test_bit(BR_FDB_ENTRY_LOCKED, &fdb_src->flags)) { > if (!fdb_src) { > ... > } > goto drop; > } > >> + if (test_bit(BR_FDB_ENTRY_LOCKED, &fdb_src->flags)) >> + goto drop; >> + } >> } >>=20=20 >> nbp_switchdev_frame_mark(p, skb); >> diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h >> index 48bc61ebc211..f5a0b68c4857 100644 >> --- a/net/bridge/br_private.h >> +++ b/net/bridge/br_private.h >> @@ -248,7 +248,8 @@ enum { >> BR_FDB_ADDED_BY_EXT_LEARN, >> BR_FDB_OFFLOADED, >> BR_FDB_NOTIFY, >> - BR_FDB_NOTIFY_INACTIVE >> + BR_FDB_NOTIFY_INACTIVE, >> + BR_FDB_ENTRY_LOCKED, >> }; >>=20=20 >> struct net_bridge_fdb_key { >> --=20 >> 2.30.2 >>=20