[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b0544c31-cf64-41c7-8118-a8b504a982d1@blackwall.org>
Date: Sat, 31 Aug 2024 11:31:50 +0300
From: Nikolay Aleksandrov <razor@...ckwall.org>
To: Jonas Gorski <jonas.gorski@...dn.de>, Roopa Prabhu <roopa@...dia.com>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Petr Machata <petrm@...lanox.com>, Ido Schimmel <idosch@...lanox.com>
Cc: bridge@...ts.linux.dev, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net] net: bridge: allow users setting EXT_LEARN for user
FDB entries
On 30/08/2024 17:53, Jonas Gorski wrote:
> When userspace wants to take over a fdb entry by setting it as
> EXTERN_LEARNED, we set both flags BR_FDB_ADDED_BY_EXT_LEARN and
> BR_FDB_ADDED_BY_USER in br_fdb_external_learn_add().
>
> If the bridge updates the entry later because its port changed, we clear
> the BR_FDB_ADDED_BY_EXT_LEARN flag, but leave the BR_FDB_ADDED_BY_USER
> flag set.
>
> If userspace then wants to take over the entry again,
> br_fdb_external_learn_add() sees that BR_FDB_ADDED_BY_USER and skips
> setting the BR_FDB_ADDED_BY_EXT_LEARN flags, thus silently ignores the
> update:
>
> if (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) {
> /* Refresh entry */
> fdb->used = jiffies;
> } else if (!test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags)) {
> /* Take over SW learned entry */
> set_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags);
> modified = true;
> }
>
> Fix this by relaxing the condition for setting BR_FDB_ADDED_BY_EXT_LEARN
> by also allowing it if swdev_notify is true, which it will only be for
> user initiated updates.
>
> Fixes: 710ae7287737 ("net: bridge: Mark FDB entries that were added by user as such")
> Signed-off-by: Jonas Gorski <jonas.gorski@...dn.de>
> ---
> net/bridge/br_fdb.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
> index c77591e63841..c5d9ae13a6fb 100644
> --- a/net/bridge/br_fdb.c
> +++ b/net/bridge/br_fdb.c
> @@ -1472,7 +1472,8 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
> if (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) {
> /* Refresh entry */
> fdb->used = jiffies;
> - } else if (!test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags)) {
> + } else if (swdev_notify ||
> + !test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags)) {
> /* Take over SW learned entry */
> set_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags);
> modified = true;
This literally means if added_by_user || !added_by_user, so you can probably
rewrite that whole block to be more straight-forward with test_and_set_bit -
if it was already set then refresh, if it wasn't modified = true
Powered by blists - more mailing lists