From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795963505; b=fUFB8nIGO2cYaTet4pXI9YEyLRfzMVjKt4AW34n9DeLv1SbI5uqpeDLIfZ9X3M5LkGSr AQN7VB8o0N5+Hu3Qid2WiVMw++AVnhoqziMKxdKoJYaqF6H177OFm7PviRmTdNjxzScBE 2VV47YXbHYmGHSMNBrSjm6yFEM9pL3NCKhsm7hRVeNa9So2BoAWjcVVhBhXSnXevzk+38 AP8sA7EEUkyhpX43a6tFpfxauhDSzh7rMvPWdBrlfFLwzb1h49/R3qJQEHnkV1VRRORsY xkhT+DXjrfNUL2RIgIeM1uAziy9xaXdVbIqp8e5gcSvW+J1BlibskaQEFdxrEGn6u/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795963505; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=rVFfKGuj9PLClh9oBeB129nNMQfRVWM4uZzfr7Zlp6U=; b=JsK4rcxWxsH9gP0cECkcVxgmLJ71fRzuwZ/Y1LvbNv+kLh9MNC+hD+ycqklzUPfPSc31 bA6d7ST//u4E1HlAmb7Z17I+W+U5Wy0kTRwNyXs0OWC6phQ2kW6sbYbtO7IsXOVYDZbR6 GxAUlYItbFfiPi9256WE/T4P0+o+yVmnBAK6Ok+GYHb94Ja0b4EeVLoHQaWamWK39NQY0 rnBOaCsv3oK1tQZyx71FGttQgoYM7NrpI6v/EQuh0rwa8KeJJIsvtAQGIH9N3nusp9q23 eHM+urw8pvBQ3dgfFmcbOKdR/thIjHZ+9yCt9tnPN/TkA4rQT1SuU+csEWjRNnVB04g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SPPLatPF; arc=none smtp.remote-ip=209.85.219.71 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51D87606A339 for ; Sun, 29 Nov 2026 14:45:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 51D87606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SPPLatPF Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-91b937ecbb4so153034646d6.2 for ; Sun, 29 Nov 2026 06:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795963504; x=1796568304; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rVFfKGuj9PLClh9oBeB129nNMQfRVWM4uZzfr7Zlp6U=; b=SPPLatPFKp15y5hlVrrbEK1dHFQpwjS0E+F8f5qoUgKBMOQauJVW0kHn9UBSaZjzX4 LYEyhtJGtmaOX1Sj86aQPxc20Owho/rcvMfws/Py1127t2lydFj3pUBQd+r4rqJPiMex 2AFTw5PPHx2Z0FRMLIvEoEUx/NOYsx1tWJliRc3tu4lbQhKTJporEwkv76wkbWARS6df bok0W1t5kcl/AVMQrKCZaV08CRBJOBc8c+A4KL8K+GJ0vpjs8qaKS8obIhRP7lPbZ/vk OX0+WXKl8Q9Qu58rHEIdEWiahRZlw9Nptc3ewMg951x6IwkcZLcwLnPHLk534KxX8wu6 Ptnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795963504; x=1796568304; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rVFfKGuj9PLClh9oBeB129nNMQfRVWM4uZzfr7Zlp6U=; b=ZmKz5qVXNoIGrzlO5namyuNVRov4dxD/1mP0vsh7XfWxRGPt5N3GSSmziXWYqVP4nF UzT8zwwV1d5epA97RFYux6bKhwzYGMKfh2fxYJIvcoxUQ6tJiN+z5KW7Nks4zXdazZo+ BrVVk9lfv7C2aaYi9gsj8kJmJpjb17wFq42rPtLSNvesto9v7cJqzSSfAOJvhIDuuf3o OK7egZVLkOWBGAo9fkCHghL+J8bkMmCJpedCBFHd8jx5WgxI7s6LhGaR0zIJ4zWyPGDf d3NGsrOGlumtUJ6Rb9YjXw/8ot7D3xTZY+tLeWuWrfgArGXSRakxQ5XDJQ5E/clvKCPk 4B2Q== X-Forwarded-Encrypted: i=1; AL+hErErXUqy8Ezy1SNsdaqxe+hu7F0ZNIFBmpTquxhU48q8YuZMAJFo4i4f7ZTS1CTrQGz5wtLaB6U=@vger.kernel.org X-Gm-Message-State: APuU4Z8rZk6L9LHh20CMWectpovRPpxGszMV2QPZ59G+1VdybQUwAUlR XrKhhDFanIVmYhsfWUI7lKsVObhb+pYW8ukV5ammiwpBEQlAFbh2ZPOlz1XX+Z1MhIHeiWv5Dgl nJgSk0HIW0A== X-Received: from qvqb1.prod.google.com ([2002:a0c:fb41:0:b0:921:8a:b56]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:4014:b0:91e:9cb2:d528 with SMTP id 6a1803df08f44-92134b88e30mr567417046d6.47.1795963503985; Sun, 29 Nov 2026 06:45:03 -0800 (PST) Date: Sun, 29 Nov 2026 09:45:03 -0500 In-Reply-To: X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications From: willemb@google.com To: Petr Machata , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , netdev@vger.kernel.org Cc: Andrew Lunn , Nikolay Aleksandrov , bridge@lists.linux.dev, Ido Schimmel , Petr Machata , Andy Roulin , mlxsw@nvidia.com Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Petr Machata wrote: > Every netlink message carries a port ID in the nlmsg_pid header field. The > port ID identifies a netlink socket. In a request it is the port ID of the > socket that sent it. When a change that results from a request is > announced to the multicast listeners, the kernel puts the port ID of the > requester in nlmsg_pid of the notification. For changes that the kernel > initiates by itself, such as aging, nlmsg_pid is zero. > This is used by applications that both configure the kernel and listen to > notifications from it. By comparing nlmsg_pid to the port ID of their own > socket, they can tell their own changes apart from those made by someone > else, and ignore the former. Commit 7b8f7a402d4c ("neighbour: fix > nlmsg_pid > in notifications") fixed this for IP neighbours, citing quagga as one such > application. Routes and nexthops report the port ID as well. > For FDB entries, the notifications (RTM_NEWNEIGH and RTM_DELNEIGH with the > AF_BRIDGE family) always carry zero, whoever caused them, so applications > that manage FDB cannot do this sort of filtering. Hence this patchset. > The patchset goes through the following steps: > - FDB notifications are generated in two places. The bridge and VXLAN > drivers send their own from ndo_fdb_add, _del and _del_bulk, but these > NDOs are not given the port ID of the requester. For other drivers that > implement ndo_fdb_add / _del, the rtnetlink core sends a default > notification on their behalf. It has the port ID at hand, but does not > pass it on. > The obvious way to get the port ID to the bridge and VXLAN is to add it > to the NDO prototypes. But ndo_fdb_add and _del already carry many > arguments, and one more would further complicate the already unwieldy > prototypes, as well as require adjustments in every driver. Instead, in > patch #1, convert the prototypes of ndo_fdb_add, _del and _get to take a > new struct ndo_fdb_parms. ndo_fdb_get already has the port ID, but it > shares most of its arguments with the other two, so it makes sense to > treat them alike. > A dedicated structure has the advantage that both callers and callees > can refer to individual arguments by name instead of by position. Any > future additions boil down to a new field in the structure. > In patch #2, have ndo_dflt_fdb_add and ndo_dflt_fdb_del take the > structure as well. That simplifies the drivers that use the helper, > which > can now just pass the structure pointer right through. > In patch #3, move the port ID of ndo_fdb_get from an argument into the > structure and adjust drivers. > - Now that the structure argument is available to the bridge driver, make > use of the fact in patch #4. Instead of unpacking the structure fields > and passing them on one by one, propagate the structure itself further > into the driver. > Then in patch #5, propagate the port ID all the way to where bridge > notifications are generated. > It is tempting to somehow use the parms structure more extensively in > VXLAN as well, but VXLAN has its own large set of protocol-specific > parameters. Passing the structure as such is not going to help that > much. > It looks like VXLAN would ideally need its own VXLAN-specific parms > structure. But since the complexity damage here is limited to VXLAN, > leave the status quo and in patch #6, just add the new parameter. The > patchset is large enough as it is. > - Patch #7 is where the port ID in struct ndo_fdb_parms is initialized > from > the request. With that, notifications that the bridge and VXLAN send as > a > result of adding, replacing and deleting an entry carry the port ID. > Notifications that are not a result of a request still carry zero. > Patch #8 then adds the port ID argument to ndo_fdb_del_bulk, which does > not use the newly-introduced parms structure, and has the bridge and > VXLAN drivers use the now-available port ID for notifications. > Finally, patch #9 converts the rtnetlink fallback helper, so that the > notifications it sends on behalf of drivers that do not emit their own > carry the port ID as well. > - Patches #10 to #13 add a selftest. Patches #10 to #12 extend the > rt-neigh > spec with attributes needed to build FDB delete requests, add the > NLM_F_BULK flag to the YNL Python library and add an RtnlNeighFamily > wrapper to the selftest library. Patch #13 then adds the test itself. > The > test is written in Python with YNL, because the usual shell tools cannot > show nlmsg_pid. > Petr Machata (13): > net: Introduce struct ndo_fdb_parms > net: Pass struct ndo_fdb_parms to ndo_dflt_fdb_{add, del}() > net: Pass portid to ndo_fdb_get through the structure > net: bridge: Pass struct ndo_fdb_parms a bit further > net: bridge: Pass portid through FDB notifications > net: vxlan: Pass portid through FDB notifications > net: rtnetlink: Report port ID in bridge and VXLAN FDB notifications > net: rtnetlink: Report port ID in bulk FDB delete notifications > net: rtnetlink: Report port ID in fallback FDB notifications > netlink: specs: rt-neigh: Extend the delneigh request attributes > tools: ynl: Add NLM_F_BULK > selftests: net: lib: py: Add RtnlNeighFamily > selftests: net: Add a test for port ID in FDB notifications > Documentation/netlink/specs/rt-neigh.yaml | 4 + > drivers/net/ethernet/intel/i40e/i40e_main.c | 29 +- > drivers/net/ethernet/intel/ice/ice_main.c | 43 ++- > drivers/net/ethernet/intel/igb/igb_main.c | 14 +- > drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 14 +- > drivers/net/ethernet/mscc/ocelot_net.c | 19 +- > .../net/ethernet/qlogic/qlcnic/qlcnic_main.c | 38 ++- > drivers/net/macvlan.c | 33 +- > drivers/net/vxlan/vxlan_core.c | 118 +++---- > drivers/net/vxlan/vxlan_private.h | 5 +- > drivers/net/vxlan/vxlan_vnifilter.c | 6 +- > include/linux/netdevice.h | 43 ++- > include/linux/rtnetlink.h | 9 +- > net/bridge/br.c | 2 +- > net/bridge/br_fdb.c | 177 ++++++----- > net/bridge/br_netlink.c | 4 +- > net/bridge/br_private.h | 20 +- > net/bridge/br_sysfs_br.c | 2 +- > net/core/rtnetlink.c | 98 +++--- > tools/net/ynl/pyynl/lib/ynl.py | 2 + > tools/testing/selftests/net/Makefile | 1 + > tools/testing/selftests/net/config | 1 + > .../selftests/net/fdb_notify_portid.py | 297 ++++++++++++++++++ > .../testing/selftests/net/lib/py/__init__.py | 6 +- > tools/testing/selftests/net/lib/py/ynl.py | 10 +- > 25 files changed, 669 insertions(+), 326 deletions(-) > create mode 100755 tools/testing/selftests/net/fdb_notify_portid.py > -- > 2.56.1 This series no longer applies cleanly to current net-next (conflict in net/bridge/br_fdb.c reported by NIPA contest). Please rebase and repost v2 with Nikolay's Reviewed-by carried forward. -- pw-bot: cr