* [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications
@ 2026-11-23 17:59 Petr Machata
2026-11-23 17:59 ` [PATCH net-next 01/13] net: Introduce struct ndo_fdb_parms Petr Machata
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH net-next 01/13] net: Introduce struct ndo_fdb_parms
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 02/13] net: Pass struct ndo_fdb_parms to ndo_dflt_fdb_{add, del}() Petr Machata
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw, Tony Nguyen, Przemek Kitszel,
intel-wired-lan, Vladimir Oltean, UNGLinuxDriver, Shahed Shaikh,
Manish Chopra, GR-Linux-NIC-Dev
The ndo_fdb_add, ndo_fdb_del and ndo_fdb_get callbacks share a growing list
of arguments: device, address, VLAN ID and, for add, the netlink message
flags. A following patch will add another argument to that list: a port ID.
With that addition, the prototypes get unwieldy. Any such change also
prompts updates of the corresponding NDO callbacks in several drivers.
Collect the common arguments in a new struct ndo_fdb_parms, similarly to
how struct neigh_parms is used for ndo_neigh_setup, and pass a pointer to
it instead of these arguments. The ndmsg, nlattr array, the "notified"
flag, extack, and for ndo_fdb_get also the port ID and sequence number,
stay separate arguments.
In rtnl_fdb_del(), the structure is only initialized for non-bulk requests,
which is where the VLAN ID and address are parsed, and the only place where
the callbacks consume it.
With this change, addition of a new parameter then consists of adding a new
field to this struct and a proper initialization, and avoids the NDO update
dance.
No functional change intended.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
CC: Tony Nguyen <anthony.l.nguyen@intel.com>
CC: Przemek Kitszel <przemyslaw.kitszel@intel.com>
CC: intel-wired-lan@lists.osuosl.org
CC: Vladimir Oltean <vladimir.oltean@nxp.com>
CC: UNGLinuxDriver@microchip.com
CC: Shahed Shaikh <shshaikh@marvell.com>
CC: Manish Chopra <manishc@marvell.com>
CC: GR-Linux-NIC-Dev@marvell.com
---
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 | 15 +++--
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 15 +++--
drivers/net/ethernet/mscc/ocelot_net.c | 19 +++---
.../net/ethernet/qlogic/qlcnic/qlcnic_main.c | 40 +++++------
drivers/net/macvlan.c | 33 +++++----
drivers/net/vxlan/vxlan_core.c | 27 ++++----
include/linux/netdevice.h | 38 ++++++-----
net/bridge/br_fdb.c | 67 ++++++++++---------
net/bridge/br_private.h | 14 ++--
net/core/rtnetlink.c | 37 +++++++---
12 files changed, 195 insertions(+), 182 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index abbc71e815ae..c8337bef5dbf 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -13022,28 +13022,24 @@ static int i40e_get_phys_port_id(struct net_device *netdev,
* i40e_ndo_fdb_add - add an entry to the hardware database
* @ndm: the input from the stack
* @tb: pointer to array of nladdr (unused)
- * @dev: the net device pointer
- * @addr: the MAC address entry being added
- * @vid: VLAN ID
- * @flags: instructions from stack about fdb operation
+ * @parms: common FDB parameters
* @notified: whether notification was emitted
* @extack: netlink extended ack, unused currently
*/
static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid,
- u16 flags, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
- struct i40e_netdev_priv *np = netdev_priv(dev);
+ struct i40e_netdev_priv *np = netdev_priv(parms->dev);
struct i40e_pf *pf = np->vsi->back;
int err = 0;
if (!test_bit(I40E_FLAG_SRIOV_ENA, pf->flags))
return -EOPNOTSUPP;
- if (vid) {
- pr_info("%s: vlans aren't supported yet for dev_uc|mc_add()\n", dev->name);
+ if (parms->vid) {
+ pr_info("%s: vlans aren't supported yet for dev_uc|mc_add()\n",
+ parms->dev->name);
return -EINVAL;
}
@@ -13051,19 +13047,20 @@ static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
* ndm_state is given only allow permanent addresses
*/
if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) {
- netdev_info(dev, "FDB only supports static addresses\n");
+ netdev_info(parms->dev, "FDB only supports static addresses\n");
return -EINVAL;
}
- if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr))
- err = dev_uc_add_excl(dev, addr);
- else if (is_multicast_ether_addr(addr))
- err = dev_mc_add_excl(dev, addr);
+ if (is_unicast_ether_addr(parms->addr) ||
+ is_link_local_ether_addr(parms->addr))
+ err = dev_uc_add_excl(parms->dev, parms->addr);
+ else if (is_multicast_ether_addr(parms->addr))
+ err = dev_mc_add_excl(parms->dev, parms->addr);
else
err = -EINVAL;
/* Only return duplicate errors if NLM_F_EXCL is set */
- if (err == -EEXIST && !(flags & NLM_F_EXCL))
+ if (err == -EEXIST && !(parms->flags & NLM_F_EXCL))
err = 0;
return err;
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index c8f06c3d0fdf..396299d5d7bd 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -6108,39 +6108,37 @@ ice_set_tx_maxrate(struct net_device *netdev, int queue_index, u32 maxrate)
* ice_fdb_add - add an entry to the hardware database
* @ndm: the input from the stack
* @tb: pointer to array of nladdr (unused)
- * @dev: the net device pointer
- * @addr: the MAC address entry being added
- * @vid: VLAN ID
- * @flags: instructions from stack about fdb operation
+ * @parms: common FDB parameters
* @notified: whether notification was emitted
* @extack: netlink extended ack
*/
static int
ice_fdb_add(struct ndmsg *ndm, struct nlattr __always_unused *tb[],
- struct net_device *dev, const unsigned char *addr, u16 vid,
- u16 flags, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack __always_unused *extack)
{
int err;
- if (vid) {
- netdev_err(dev, "VLANs aren't supported yet for dev_uc|mc_add()\n");
+ if (parms->vid) {
+ netdev_err(parms->dev,
+ "VLANs aren't supported yet for dev_uc|mc_add()\n");
return -EINVAL;
}
if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) {
- netdev_err(dev, "FDB only supports static addresses\n");
+ netdev_err(parms->dev, "FDB only supports static addresses\n");
return -EINVAL;
}
- if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr))
- err = dev_uc_add_excl(dev, addr);
- else if (is_multicast_ether_addr(addr))
- err = dev_mc_add_excl(dev, addr);
+ if (is_unicast_ether_addr(parms->addr) ||
+ is_link_local_ether_addr(parms->addr))
+ err = dev_uc_add_excl(parms->dev, parms->addr);
+ else if (is_multicast_ether_addr(parms->addr))
+ err = dev_mc_add_excl(parms->dev, parms->addr);
else
err = -EINVAL;
/* Only return duplicate errors if NLM_F_EXCL is set */
- if (err == -EEXIST && !(flags & NLM_F_EXCL))
+ if (err == -EEXIST && !(parms->flags & NLM_F_EXCL))
err = 0;
return err;
@@ -6150,29 +6148,26 @@ ice_fdb_add(struct ndmsg *ndm, struct nlattr __always_unused *tb[],
* ice_fdb_del - delete an entry from the hardware database
* @ndm: the input from the stack
* @tb: pointer to array of nladdr (unused)
- * @dev: the net device pointer
- * @addr: the MAC address entry being added
- * @vid: VLAN ID
+ * @parms: common FDB parameters (device, address, VLAN ID)
* @notified: whether notification was emitted
* @extack: netlink extended ack
*/
static int
ice_fdb_del(struct ndmsg *ndm, __always_unused struct nlattr *tb[],
- struct net_device *dev, const unsigned char *addr,
- __always_unused u16 vid, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
int err;
if (ndm->ndm_state & NUD_PERMANENT) {
- netdev_err(dev, "FDB only supports static addresses\n");
+ netdev_err(parms->dev, "FDB only supports static addresses\n");
return -EINVAL;
}
- if (is_unicast_ether_addr(addr))
- err = dev_uc_del(dev, addr);
- else if (is_multicast_ether_addr(addr))
- err = dev_mc_del(dev, addr);
+ if (is_unicast_ether_addr(parms->addr))
+ err = dev_uc_del(parms->dev, parms->addr);
+ else if (is_multicast_ether_addr(parms->addr))
+ err = dev_mc_del(parms->dev, parms->addr);
else
err = -EINVAL;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index c75d78badf71..42b2fd3ed95c 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -2517,21 +2517,22 @@ static int igb_set_features(struct net_device *netdev,
}
static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid,
- u16 flags, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
/* guarantee we can provide a unique filter for the unicast address */
- if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr)) {
- struct igb_adapter *adapter = netdev_priv(dev);
+ if (is_unicast_ether_addr(parms->addr) ||
+ is_link_local_ether_addr(parms->addr)) {
+ struct igb_adapter *adapter = netdev_priv(parms->dev);
int vfn = adapter->vfs_allocated_count;
- if (netdev_uc_count(dev) >= igb_available_rars(adapter, vfn))
+ if (netdev_uc_count(parms->dev) >=
+ igb_available_rars(adapter, vfn))
return -ENOMEM;
}
- return ndo_dflt_fdb_add(ndm, tb, dev, addr, vid, flags);
+ return ndo_dflt_fdb_add(ndm, tb, parms->dev, parms->addr,
+ parms->vid, parms->flags);
}
#define IGB_MAX_MAC_HDR_LEN 127
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 6458cb2e511e..26d1a7253cf3 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -10603,21 +10603,22 @@ static int ixgbe_set_features(struct net_device *netdev,
}
static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid,
- u16 flags, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
/* guarantee we can provide a unique filter for the unicast address */
- if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr)) {
- struct ixgbe_adapter *adapter = ixgbe_from_netdev(dev);
+ if (is_unicast_ether_addr(parms->addr) ||
+ is_link_local_ether_addr(parms->addr)) {
+ struct ixgbe_adapter *adapter = ixgbe_from_netdev(parms->dev);
u16 pool = VMDQ_P(0);
- if (netdev_uc_count(dev) >= ixgbe_available_rars(adapter, pool))
+ if (netdev_uc_count(parms->dev) >=
+ ixgbe_available_rars(adapter, pool))
return -ENOMEM;
}
- return ndo_dflt_fdb_add(ndm, tb, dev, addr, vid, flags);
+ return ndo_dflt_fdb_add(ndm, tb, parms->dev, parms->addr,
+ parms->vid, parms->flags);
}
/**
diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
index 4d45e136f08f..65f9dee62dc5 100644
--- a/drivers/net/ethernet/mscc/ocelot_net.c
+++ b/drivers/net/ethernet/mscc/ocelot_net.c
@@ -765,30 +765,29 @@ static void ocelot_get_stats64(struct net_device *dev,
}
static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr,
- u16 vid, u16 flags, bool *notified,
- struct netlink_ext_ack *extack)
+ const struct ndo_fdb_parms *parms,
+ bool *notified, struct netlink_ext_ack *extack)
{
- struct ocelot_port_private *priv = netdev_priv(dev);
+ struct ocelot_port_private *priv = netdev_priv(parms->dev);
struct ocelot_port *ocelot_port = &priv->port;
struct ocelot *ocelot = ocelot_port->ocelot;
int port = priv->port.index;
- return ocelot_fdb_add(ocelot, port, addr, vid, ocelot_port->bridge);
+ return ocelot_fdb_add(ocelot, port, parms->addr, parms->vid,
+ ocelot_port->bridge);
}
static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid,
+ const struct ndo_fdb_parms *parms,
bool *notified, struct netlink_ext_ack *extack)
{
- struct ocelot_port_private *priv = netdev_priv(dev);
+ struct ocelot_port_private *priv = netdev_priv(parms->dev);
struct ocelot_port *ocelot_port = &priv->port;
struct ocelot *ocelot = ocelot_port->ocelot;
int port = priv->port.index;
- return ocelot_fdb_del(ocelot, port, addr, vid, ocelot_port->bridge);
+ return ocelot_fdb_del(ocelot, port, parms->addr, parms->vid,
+ ocelot_port->bridge);
}
static int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid,
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 23ae76ca81db..85017de2161b 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -366,24 +366,24 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p)
}
static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *netdev,
- const unsigned char *addr, u16 vid, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
- struct qlcnic_adapter *adapter = netdev_priv(netdev);
+ struct qlcnic_adapter *adapter = netdev_priv(parms->dev);
int err = -EOPNOTSUPP;
if (!adapter->fdb_mac_learn)
- return ndo_dflt_fdb_del(ndm, tb, netdev, addr, vid);
+ return ndo_dflt_fdb_del(ndm, tb, parms->dev, parms->addr,
+ parms->vid);
if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
qlcnic_sriov_check(adapter)) {
- if (is_unicast_ether_addr(addr)) {
- err = dev_uc_del(netdev, addr);
+ if (is_unicast_ether_addr(parms->addr)) {
+ err = dev_uc_del(parms->dev, parms->addr);
if (!err)
- err = qlcnic_nic_del_mac(adapter, addr);
- } else if (is_multicast_ether_addr(addr)) {
- err = dev_mc_del(netdev, addr);
+ err = qlcnic_nic_del_mac(adapter, parms->addr);
+ } else if (is_multicast_ether_addr(parms->addr)) {
+ err = dev_mc_del(parms->dev, parms->addr);
} else {
err = -EINVAL;
}
@@ -392,15 +392,15 @@ static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
}
static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *netdev,
- const unsigned char *addr, u16 vid, u16 flags,
- bool *notified, struct netlink_ext_ack *extack)
+ const struct ndo_fdb_parms *parms, bool *notified,
+ struct netlink_ext_ack *extack)
{
- struct qlcnic_adapter *adapter = netdev_priv(netdev);
+ struct qlcnic_adapter *adapter = netdev_priv(parms->dev);
int err = 0;
if (!adapter->fdb_mac_learn)
- return ndo_dflt_fdb_add(ndm, tb, netdev, addr, vid, flags);
+ return ndo_dflt_fdb_add(ndm, tb, parms->dev, parms->addr,
+ parms->vid, parms->flags);
if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) &&
!qlcnic_sriov_check(adapter)) {
@@ -408,16 +408,16 @@ static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
return -EOPNOTSUPP;
}
- if (ether_addr_equal(addr, adapter->mac_addr))
+ if (ether_addr_equal(parms->addr, adapter->mac_addr))
return err;
- if (is_unicast_ether_addr(addr)) {
- if (netdev_uc_count(netdev) < adapter->ahw->max_uc_count)
- err = dev_uc_add_excl(netdev, addr);
+ if (is_unicast_ether_addr(parms->addr)) {
+ if (netdev_uc_count(parms->dev) < adapter->ahw->max_uc_count)
+ err = dev_uc_add_excl(parms->dev, parms->addr);
else
err = -ENOMEM;
- } else if (is_multicast_ether_addr(addr)) {
- err = dev_mc_add_excl(netdev, addr);
+ } else if (is_multicast_ether_addr(parms->addr)) {
+ err = dev_mc_add_excl(parms->dev, parms->addr);
} else {
err = -EINVAL;
}
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index c7afa736c472..06079c697772 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1054,49 +1054,46 @@ static int macvlan_vlan_rx_kill_vid(struct net_device *dev,
}
static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid,
- u16 flags, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
- struct macvlan_dev *vlan = netdev_priv(dev);
+ struct macvlan_dev *vlan = netdev_priv(parms->dev);
int err = -EINVAL;
/* Support unicast filter only on passthru devices.
* Multicast filter should be allowed on all devices.
*/
- if (!macvlan_passthru(vlan->port) && is_unicast_ether_addr(addr))
+ if (!macvlan_passthru(vlan->port) && is_unicast_ether_addr(parms->addr))
return -EOPNOTSUPP;
- if (flags & NLM_F_REPLACE)
+ if (parms->flags & NLM_F_REPLACE)
return -EOPNOTSUPP;
- if (is_unicast_ether_addr(addr))
- err = dev_uc_add_excl(dev, addr);
- else if (is_multicast_ether_addr(addr))
- err = dev_mc_add_excl(dev, addr);
+ if (is_unicast_ether_addr(parms->addr))
+ err = dev_uc_add_excl(parms->dev, parms->addr);
+ else if (is_multicast_ether_addr(parms->addr))
+ err = dev_mc_add_excl(parms->dev, parms->addr);
return err;
}
static int macvlan_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
- struct macvlan_dev *vlan = netdev_priv(dev);
+ struct macvlan_dev *vlan = netdev_priv(parms->dev);
int err = -EINVAL;
/* Support unicast filter only on passthru devices.
* Multicast filter should be allowed on all devices.
*/
- if (!macvlan_passthru(vlan->port) && is_unicast_ether_addr(addr))
+ if (!macvlan_passthru(vlan->port) && is_unicast_ether_addr(parms->addr))
return -EOPNOTSUPP;
- if (is_unicast_ether_addr(addr))
- err = dev_uc_del(dev, addr);
- else if (is_multicast_ether_addr(addr))
- err = dev_mc_del(dev, addr);
+ if (is_unicast_ether_addr(parms->addr))
+ err = dev_uc_del(parms->dev, parms->addr);
+ else if (is_multicast_ether_addr(parms->addr))
+ err = dev_mc_del(parms->dev, parms->addr);
return err;
}
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index d11028b37472..a9f6bdd52c12 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1241,12 +1241,11 @@ static int vxlan_fdb_parse(struct nlattr *tb[], struct vxlan_dev *vxlan,
/* Add static entry (via netlink) */
static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid, u16 flags,
- bool *notified, struct netlink_ext_ack *extack)
+ const struct ndo_fdb_parms *parms, bool *notified,
+ struct netlink_ext_ack *extack)
{
const struct vxlan_config *cfg;
- struct vxlan_dev *vxlan = netdev_priv(dev);
+ struct vxlan_dev *vxlan = netdev_priv(parms->dev);
/* struct net *net = dev_net(vxlan->dev); */
union vxlan_addr ip;
__be16 port;
@@ -1273,7 +1272,8 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
return -EAFNOSUPPORT;
spin_lock_bh(&vxlan->hash_lock);
- err = vxlan_fdb_update(vxlan, addr, &ip, ndm->ndm_state, flags,
+ err = vxlan_fdb_update(vxlan, parms->addr, &ip, ndm->ndm_state,
+ parms->flags,
port, src_vni, vni, ifindex,
ndm->ndm_flags | NTF_VXLAN_ADDED_BY_USER,
nhid, true, extack);
@@ -1320,11 +1320,10 @@ int __vxlan_fdb_delete(struct vxlan_dev *vxlan,
/* Delete entry (via netlink) */
static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
- struct vxlan_dev *vxlan = netdev_priv(dev);
+ struct vxlan_dev *vxlan = netdev_priv(parms->dev);
union vxlan_addr ip;
__be32 src_vni, vni;
u32 ifindex, nhid;
@@ -1337,8 +1336,8 @@ static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
return err;
spin_lock_bh(&vxlan->hash_lock);
- err = __vxlan_fdb_delete(vxlan, addr, ip, port, src_vni, vni, ifindex,
- true);
+ err = __vxlan_fdb_delete(vxlan, parms->addr, ip, port, src_vni, vni,
+ ifindex, true);
spin_unlock_bh(&vxlan->hash_lock);
if (!err)
@@ -1400,12 +1399,10 @@ static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
static int vxlan_fdb_get(struct sk_buff *skb,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr,
- u16 vid, u32 portid, u32 seq,
+ const struct ndo_fdb_parms *parms, u32 portid, u32 seq,
struct netlink_ext_ack *extack)
{
- struct vxlan_dev *vxlan = netdev_priv(dev);
+ struct vxlan_dev *vxlan = netdev_priv(parms->dev);
const struct vxlan_config *cfg;
struct vxlan_fdb *f;
__be32 vni;
@@ -1420,7 +1417,7 @@ static int vxlan_fdb_get(struct sk_buff *skb,
rcu_read_lock();
- f = vxlan_find_mac_rcu(vxlan, cfg, addr, vni);
+ f = vxlan_find_mac_rcu(vxlan, cfg, parms->addr, vni);
if (!f) {
NL_SET_ERR_MSG(extack, "Fdb entry not found");
err = -ENOENT;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 694b6d29f680..0bfd36057d3a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1087,6 +1087,20 @@ struct netdev_net_notifier {
struct notifier_block *nb;
};
+/**
+ * struct ndo_fdb_parms - parameters for ndo_fdb_{add,del,get}
+ * @dev: device the FDB entry is added to, deleted from or looked up on
+ * @addr: MAC address of the FDB entry
+ * @vid: VLAN ID of the FDB entry, 0 if none
+ * @flags: netlink message flags (NLM_F_*) of the request
+ */
+struct ndo_fdb_parms {
+ struct net_device *dev;
+ const unsigned char *addr;
+ u16 vid;
+ u16 flags;
+};
+
/*
* This structure defines the management hooks for network devices.
* The following hooks can be defined; unless noted otherwise, they are
@@ -1330,17 +1344,15 @@ struct netdev_net_notifier {
* Must return >0 or -errno if it changed dev->features itself.
*
* int (*ndo_fdb_add)(struct ndmsg *ndm, struct nlattr *tb[],
- * struct net_device *dev,
- * const unsigned char *addr, u16 vid, u16 flags,
+ * const struct ndo_fdb_parms *parms,
* bool *notified, struct netlink_ext_ack *extack);
- * Adds an FDB entry to dev for addr.
+ * Adds an FDB entry to parms->dev for parms->addr.
* Callee shall set *notified to true if it sent any appropriate
* notification(s). Otherwise core will send a generic one.
* int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[],
- * struct net_device *dev,
- * const unsigned char *addr, u16 vid
+ * const struct ndo_fdb_parms *parms,
* bool *notified, struct netlink_ext_ack *extack);
- * Deletes the FDB entry from dev corresponding to addr.
+ * Deletes the FDB entry from parms->dev corresponding to parms->addr.
* Callee shall set *notified to true if it sent any appropriate
* notification(s). Otherwise core will send a generic one.
* int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh, struct net_device *dev,
@@ -1614,17 +1626,12 @@ struct net_device_ops {
int (*ndo_fdb_add)(struct ndmsg *ndm,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr,
- u16 vid,
- u16 flags,
+ const struct ndo_fdb_parms *parms,
bool *notified,
struct netlink_ext_ack *extack);
int (*ndo_fdb_del)(struct ndmsg *ndm,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr,
- u16 vid,
+ const struct ndo_fdb_parms *parms,
bool *notified,
struct netlink_ext_ack *extack);
int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh,
@@ -1637,9 +1644,8 @@ struct net_device_ops {
int *idx);
int (*ndo_fdb_get)(struct sk_buff *skb,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr,
- u16 vid, u32 portid, u32 seq,
+ const struct ndo_fdb_parms *parms,
+ u32 portid, u32 seq,
struct netlink_ext_ack *extack);
int (*ndo_mdb_add)(struct net_device *dev,
struct nlattr *tb[],
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index b601245ad923..8ed7af3e410d 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -1146,17 +1146,15 @@ int br_fdb_dump(struct sk_buff *skb,
int br_fdb_get(struct sk_buff *skb,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr,
- u16 vid, u32 portid, u32 seq,
+ const struct ndo_fdb_parms *parms, u32 portid, u32 seq,
struct netlink_ext_ack *extack)
{
- struct net_bridge *br = netdev_priv(dev);
+ struct net_bridge *br = netdev_priv(parms->dev);
struct net_bridge_fdb_entry *f;
int err = 0;
rcu_read_lock();
- f = br_fdb_find_rcu(br, addr, vid);
+ f = br_fdb_find_rcu(br, parms->addr, parms->vid);
if (!f) {
NL_SET_ERR_MSG(extack, "Fdb entry not found");
err = -ENOENT;
@@ -1360,9 +1358,8 @@ static const struct nla_policy br_nda_fdb_pol[NFEA_MAX + 1] = {
/* Add new permanent fdb entry with RTM_NEWNEIGH */
int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid, u16 nlh_flags,
- bool *notified, struct netlink_ext_ack *extack)
+ const struct ndo_fdb_parms *parms, bool *notified,
+ struct netlink_ext_ack *extack)
{
struct nlattr *nfea_tb[NFEA_MAX + 1], *attr;
struct net_bridge_vlan_group *vg;
@@ -1372,26 +1369,27 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
u32 ext_flags = 0;
int err = 0;
- trace_br_fdb_add(ndm, dev, addr, vid, nlh_flags);
+ trace_br_fdb_add(ndm, parms->dev, parms->addr, parms->vid,
+ parms->flags);
if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE))) {
pr_info("bridge: RTM_NEWNEIGH with invalid state %#x\n", ndm->ndm_state);
return -EINVAL;
}
- if (is_zero_ether_addr(addr)) {
+ if (is_zero_ether_addr(parms->addr)) {
pr_info("bridge: RTM_NEWNEIGH with invalid ether address\n");
return -EINVAL;
}
- if (netif_is_bridge_master(dev)) {
- br = netdev_priv(dev);
+ if (netif_is_bridge_master(parms->dev)) {
+ br = netdev_priv(parms->dev);
vg = br_vlan_group(br);
} else {
- p = br_port_get_rtnl(dev);
+ p = br_port_get_rtnl(parms->dev);
if (!p) {
pr_info("bridge: RTM_NEWNEIGH %s not a bridge port\n",
- dev->name);
+ parms->dev->name);
return -EINVAL;
}
br = p->br;
@@ -1416,19 +1414,20 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
memset(nfea_tb, 0, sizeof(struct nlattr *) * (NFEA_MAX + 1));
}
- if (vid) {
- v = br_vlan_find(vg, vid);
+ if (parms->vid) {
+ v = br_vlan_find(vg, parms->vid);
if (!v || !br_vlan_should_use(v)) {
- pr_info("bridge: RTM_NEWNEIGH with unconfigured vlan %d on %s\n", vid, dev->name);
+ pr_info("bridge: RTM_NEWNEIGH with unconfigured vlan %d on %s\n",
+ parms->vid, parms->dev->name);
return -EINVAL;
}
/* VID was specified, so use it. */
- err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v, nfea_tb,
- notified, extack);
+ err = __br_fdb_add(ndm, br, p, parms->addr, parms->flags, v,
+ nfea_tb, notified, extack);
} else {
- err = __br_fdb_add(ndm, br, p, addr, nlh_flags, NULL, nfea_tb,
- notified, extack);
+ err = __br_fdb_add(ndm, br, p, parms->addr, parms->flags,
+ NULL, nfea_tb, notified, extack);
if (err || !vg || !vg->num_vlans)
goto out;
@@ -1439,8 +1438,9 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
list_for_each_entry(v, &vg->vlan_list, vlist) {
if (!br_vlan_should_use(v))
continue;
- err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v,
- nfea_tb, notified, extack);
+ err = __br_fdb_add(ndm, br, p, parms->addr,
+ parms->flags, v, nfea_tb, notified,
+ extack);
if (err)
goto out;
}
@@ -1481,8 +1481,7 @@ static int __br_fdb_delete(struct net_bridge *br,
/* Remove neighbor entry with RTM_DELNEIGH */
int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid, bool *notified,
+ const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack)
{
struct net_bridge_vlan_group *vg;
@@ -1490,34 +1489,36 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
struct net_bridge *br;
int err;
- if (netif_is_bridge_master(dev)) {
- br = netdev_priv(dev);
+ if (netif_is_bridge_master(parms->dev)) {
+ br = netdev_priv(parms->dev);
vg = br_vlan_group(br);
} else {
- p = br_port_get_rtnl(dev);
+ p = br_port_get_rtnl(parms->dev);
if (!p) {
pr_info("bridge: RTM_DELNEIGH %s not a bridge port\n",
- dev->name);
+ parms->dev->name);
return -EINVAL;
}
vg = nbp_vlan_group(p);
br = p->br;
}
- if (vid) {
- err = __br_fdb_delete(br, p, addr, vid, notified);
+ if (parms->vid) {
+ err = __br_fdb_delete(br, p, parms->addr, parms->vid,
+ notified);
} else {
struct net_bridge_vlan *v;
err = -ENOENT;
- err &= __br_fdb_delete(br, p, addr, 0, notified);
+ err &= __br_fdb_delete(br, p, parms->addr, 0, notified);
if (!vg || !vg->num_vlans)
return err;
list_for_each_entry(v, &vg->vlan_list, vlist) {
if (!br_vlan_should_use(v))
continue;
- err &= __br_fdb_delete(br, p, addr, v->vid, notified);
+ err &= __br_fdb_delete(br, p, parms->addr, v->vid,
+ notified);
}
}
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 014d0b8db8c7..0062bbe94d1c 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -1015,17 +1015,17 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
unsigned long flags);
int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
- struct net_device *dev, const unsigned char *addr, u16 vid,
- bool *notified, struct netlink_ext_ack *extack);
+ const struct ndo_fdb_parms *parms, bool *notified,
+ struct netlink_ext_ack *extack);
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,
- bool *notified, struct netlink_ext_ack *extack);
+int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[],
+ const struct ndo_fdb_parms *parms, bool *notified,
+ struct netlink_ext_ack *extack);
int br_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
struct net_device *dev, struct net_device *fdev, int *idx);
-int br_fdb_get(struct sk_buff *skb, struct nlattr *tb[], struct net_device *dev,
- const unsigned char *addr, u16 vid, u32 portid, u32 seq,
+int br_fdb_get(struct sk_buff *skb, struct nlattr *tb[],
+ const struct ndo_fdb_parms *parms, u32 portid, u32 seq,
struct netlink_ext_ack *extack);
int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p);
void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e141340172ce..b1649f1cb33a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4814,6 +4814,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
struct net *net = sock_net(skb->sk);
struct ndmsg *ndm;
struct nlattr *tb[NDA_MAX+1];
+ struct ndo_fdb_parms parms;
struct net_device *dev;
u8 *addr;
u16 vid;
@@ -4852,6 +4853,13 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
if (err)
return err;
+ parms = (struct ndo_fdb_parms) {
+ .dev = dev,
+ .addr = addr,
+ .vid = vid,
+ .flags = nlh->nlmsg_flags,
+ };
+
err = -EOPNOTSUPP;
/* Support fdb on master device the net/bridge default case */
@@ -4861,8 +4869,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
const struct net_device_ops *ops = br_dev->netdev_ops;
bool notified = false;
- err = ops->ndo_fdb_add(ndm, tb, dev, addr, vid,
- nlh->nlmsg_flags, ¬ified, extack);
+ err = ops->ndo_fdb_add(ndm, tb, &parms, ¬ified, extack);
if (err)
goto out;
else
@@ -4874,9 +4881,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
bool notified = false;
if (dev->netdev_ops->ndo_fdb_add)
- err = dev->netdev_ops->ndo_fdb_add(ndm, tb, dev, addr,
- vid,
- nlh->nlmsg_flags,
+ err = dev->netdev_ops->ndo_fdb_add(ndm, tb, &parms,
¬ified, extack);
else
err = ndo_dflt_fdb_add(ndm, tb, dev, addr, vid,
@@ -4927,6 +4932,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
const struct net_device_ops *ops;
struct ndmsg *ndm;
struct nlattr *tb[NDA_MAX+1];
+ struct ndo_fdb_parms parms;
struct net_device *dev;
__u8 *addr = NULL;
int err;
@@ -4966,6 +4972,12 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack);
if (err)
return err;
+
+ parms = (struct ndo_fdb_parms) {
+ .dev = dev,
+ .addr = addr,
+ .vid = vid,
+ };
}
if (dev->type != ARPHRD_ETHER) {
@@ -4984,7 +4996,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
ops = br_dev->netdev_ops;
if (!del_bulk) {
if (ops->ndo_fdb_del)
- err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid,
+ err = ops->ndo_fdb_del(ndm, tb, &parms,
¬ified, extack);
} else {
if (ops->ndo_fdb_del_bulk)
@@ -5004,7 +5016,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
ops = dev->netdev_ops;
if (!del_bulk) {
if (ops->ndo_fdb_del)
- err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid,
+ err = ops->ndo_fdb_del(ndm, tb, &parms,
¬ified, extack);
else
err = ndo_dflt_fdb_del(ndm, tb, dev, addr, vid);
@@ -5327,6 +5339,7 @@ static int rtnl_fdb_get(struct sk_buff *in_skb, struct nlmsghdr *nlh,
const struct net_device_ops *ops = NULL;
struct net *net = sock_net(in_skb->sk);
struct nlattr *tb[NDA_MAX + 1];
+ struct ndo_fdb_parms parms;
struct sk_buff *skb;
int brport_idx = 0;
u8 ndm_flags = 0;
@@ -5404,8 +5417,14 @@ static int rtnl_fdb_get(struct sk_buff *in_skb, struct nlmsghdr *nlh,
if (br_dev)
dev = br_dev;
- err = ops->ndo_fdb_get(skb, tb, dev, addr, vid,
- NETLINK_CB(in_skb).portid,
+
+ parms = (struct ndo_fdb_parms) {
+ .dev = dev,
+ .addr = addr,
+ .vid = vid,
+ };
+
+ err = ops->ndo_fdb_get(skb, tb, &parms, NETLINK_CB(in_skb).portid,
nlh->nlmsg_seq, extack);
if (err)
goto out;
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 02/13] net: Pass struct ndo_fdb_parms to ndo_dflt_fdb_{add, del}()
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
2026-11-23 17:59 ` [PATCH net-next 01/13] net: Introduce struct ndo_fdb_parms Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 03/13] net: Pass portid to ndo_fdb_get through the structure Petr Machata
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw, Tony Nguyen, Przemek Kitszel,
intel-wired-lan, Shahed Shaikh, Manish Chopra, GR-Linux-NIC-Dev
The previous patch converted the ndo_fdb_add, ndo_fdb_del and ndo_fdb_get
callbacks to take their common arguments through struct ndo_fdb_parms. The
default implementations, ndo_dflt_fdb_add() and ndo_dflt_fdb_del(), are
called from those callbacks in several drivers (igb, ixgbe, qlcnic) and
from rtnl_fdb_add() and rtnl_fdb_del() as a fallback. These default
implementations have not been converted, and callers must unpack individual
arguments.
Convert the fallback functions to take the structure as well.
No functional change intended.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
CC: Tony Nguyen <anthony.l.nguyen@intel.com>
CC: Przemek Kitszel <przemyslaw.kitszel@intel.com>
CC: intel-wired-lan@lists.osuosl.org
CC: Shahed Shaikh <shshaikh@marvell.com>
CC: Manish Chopra <manishc@marvell.com>
CC: GR-Linux-NIC-Dev@marvell.com
---
drivers/net/ethernet/intel/igb/igb_main.c | 3 +-
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +-
.../net/ethernet/qlogic/qlcnic/qlcnic_main.c | 6 +--
include/linux/rtnetlink.h | 9 +---
net/core/rtnetlink.c | 42 +++++++++----------
5 files changed, 26 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 42b2fd3ed95c..b2efa0a1fa07 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -2531,8 +2531,7 @@ static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
return -ENOMEM;
}
- return ndo_dflt_fdb_add(ndm, tb, parms->dev, parms->addr,
- parms->vid, parms->flags);
+ return ndo_dflt_fdb_add(ndm, tb, parms);
}
#define IGB_MAX_MAC_HDR_LEN 127
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 26d1a7253cf3..e444ebfe77fa 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -10617,8 +10617,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
return -ENOMEM;
}
- return ndo_dflt_fdb_add(ndm, tb, parms->dev, parms->addr,
- parms->vid, parms->flags);
+ return ndo_dflt_fdb_add(ndm, tb, parms);
}
/**
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 85017de2161b..6c48cdaf25c0 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -373,8 +373,7 @@ static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
int err = -EOPNOTSUPP;
if (!adapter->fdb_mac_learn)
- return ndo_dflt_fdb_del(ndm, tb, parms->dev, parms->addr,
- parms->vid);
+ return ndo_dflt_fdb_del(ndm, tb, parms);
if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) ||
qlcnic_sriov_check(adapter)) {
@@ -399,8 +398,7 @@ static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
int err = 0;
if (!adapter->fdb_mac_learn)
- return ndo_dflt_fdb_add(ndm, tb, parms->dev, parms->addr,
- parms->vid, parms->flags);
+ return ndo_dflt_fdb_add(ndm, tb, parms);
if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) &&
!qlcnic_sriov_check(adapter)) {
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index a54ec40d095c..e963b43bce76 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -211,15 +211,10 @@ extern int ndo_dflt_fdb_dump(struct sk_buff *skb,
int *idx);
extern int ndo_dflt_fdb_add(struct ndmsg *ndm,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr,
- u16 vid,
- u16 flags);
+ const struct ndo_fdb_parms *parms);
extern int ndo_dflt_fdb_del(struct ndmsg *ndm,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr,
- u16 vid);
+ const struct ndo_fdb_parms *parms);
extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
struct net_device *dev, u16 mode,
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index b1649f1cb33a..e7d683952838 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4749,9 +4749,7 @@ static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type,
*/
int ndo_dflt_fdb_add(struct ndmsg *ndm,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid,
- u16 flags)
+ const struct ndo_fdb_parms *parms)
{
int err = -EINVAL;
@@ -4759,27 +4757,28 @@ int ndo_dflt_fdb_add(struct ndmsg *ndm,
* implement its own handler for this.
*/
if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) {
- netdev_info(dev, "default FDB implementation only supports local addresses\n");
+ netdev_info(parms->dev, "default FDB implementation only supports local addresses\n");
return err;
}
if (tb[NDA_FLAGS_EXT]) {
- netdev_info(dev, "invalid flags given to default FDB implementation\n");
+ netdev_info(parms->dev, "invalid flags given to default FDB implementation\n");
return err;
}
- if (vid) {
- netdev_info(dev, "vlans aren't supported yet for dev_uc|mc_add()\n");
+ if (parms->vid) {
+ netdev_info(parms->dev, "vlans aren't supported yet for dev_uc|mc_add()\n");
return err;
}
- if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr))
- err = dev_uc_add_excl(dev, addr);
- else if (is_multicast_ether_addr(addr))
- err = dev_mc_add_excl(dev, addr);
+ if (is_unicast_ether_addr(parms->addr) ||
+ is_link_local_ether_addr(parms->addr))
+ err = dev_uc_add_excl(parms->dev, parms->addr);
+ else if (is_multicast_ether_addr(parms->addr))
+ err = dev_mc_add_excl(parms->dev, parms->addr);
/* Only return duplicate errors if NLM_F_EXCL is set */
- if (err == -EEXIST && !(flags & NLM_F_EXCL))
+ if (err == -EEXIST && !(parms->flags & NLM_F_EXCL))
err = 0;
return err;
@@ -4884,8 +4883,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
err = dev->netdev_ops->ndo_fdb_add(ndm, tb, &parms,
¬ified, extack);
else
- err = ndo_dflt_fdb_add(ndm, tb, dev, addr, vid,
- nlh->nlmsg_flags);
+ err = ndo_dflt_fdb_add(ndm, tb, &parms);
if (!err && !notified) {
rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH,
@@ -4902,8 +4900,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
*/
int ndo_dflt_fdb_del(struct ndmsg *ndm,
struct nlattr *tb[],
- struct net_device *dev,
- const unsigned char *addr, u16 vid)
+ const struct ndo_fdb_parms *parms)
{
int err = -EINVAL;
@@ -4911,14 +4908,15 @@ int ndo_dflt_fdb_del(struct ndmsg *ndm,
* implement its own handler for this.
*/
if (!(ndm->ndm_state & NUD_PERMANENT)) {
- netdev_info(dev, "default FDB implementation only supports local addresses\n");
+ netdev_info(parms->dev, "default FDB implementation only supports local addresses\n");
return err;
}
- if (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr))
- err = dev_uc_del(dev, addr);
- else if (is_multicast_ether_addr(addr))
- err = dev_mc_del(dev, addr);
+ if (is_unicast_ether_addr(parms->addr) ||
+ is_link_local_ether_addr(parms->addr))
+ err = dev_uc_del(parms->dev, parms->addr);
+ else if (is_multicast_ether_addr(parms->addr))
+ err = dev_mc_del(parms->dev, parms->addr);
return err;
}
@@ -5019,7 +5017,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
err = ops->ndo_fdb_del(ndm, tb, &parms,
¬ified, extack);
else
- err = ndo_dflt_fdb_del(ndm, tb, dev, addr, vid);
+ err = ndo_dflt_fdb_del(ndm, tb, &parms);
} else {
/* in case err was cleared by NTF_MASTER call */
err = -EOPNOTSUPP;
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 03/13] net: Pass portid to ndo_fdb_get through the structure
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
2026-11-23 17:59 ` [PATCH net-next 01/13] net: Introduce struct ndo_fdb_parms Petr Machata
2026-11-23 17:59 ` [PATCH net-next 02/13] net: Pass struct ndo_fdb_parms to ndo_dflt_fdb_{add, del}() Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 04/13] net: bridge: Pass struct ndo_fdb_parms a bit further Petr Machata
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw
So far, portid was passed as a separate argument to ndo_fdb_get. In
order to get the portid parameter to ndo_fdb_add and _del, we'll be
adding it to struct ndo_fdb_parms. That will make portid as an
explicit argument redundant.
Make the move from argument to structure member for ndo_fdb_get now as
a self-contained change. Proper support for ndo_fdb_add and _del will
be done next.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/vxlan/vxlan_core.c | 4 ++--
include/linux/netdevice.h | 4 +++-
net/bridge/br_fdb.c | 5 ++---
net/bridge/br_private.h | 2 +-
net/core/rtnetlink.c | 4 ++--
5 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index a9f6bdd52c12..725c6216d56c 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1399,7 +1399,7 @@ static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
static int vxlan_fdb_get(struct sk_buff *skb,
struct nlattr *tb[],
- const struct ndo_fdb_parms *parms, u32 portid, u32 seq,
+ const struct ndo_fdb_parms *parms, u32 seq,
struct netlink_ext_ack *extack)
{
struct vxlan_dev *vxlan = netdev_priv(parms->dev);
@@ -1424,7 +1424,7 @@ static int vxlan_fdb_get(struct sk_buff *skb,
goto errout;
}
- err = vxlan_fdb_info(skb, vxlan, f, portid, seq,
+ err = vxlan_fdb_info(skb, vxlan, f, parms->portid, seq,
RTM_NEWNEIGH, 0, first_remote_rcu(f));
errout:
rcu_read_unlock();
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0bfd36057d3a..233584013fc9 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1093,12 +1093,14 @@ struct netdev_net_notifier {
* @addr: MAC address of the FDB entry
* @vid: VLAN ID of the FDB entry, 0 if none
* @flags: netlink message flags (NLM_F_*) of the request
+ * @portid: netlink port ID of the requester
*/
struct ndo_fdb_parms {
struct net_device *dev;
const unsigned char *addr;
u16 vid;
u16 flags;
+ u32 portid;
};
/*
@@ -1645,7 +1647,7 @@ struct net_device_ops {
int (*ndo_fdb_get)(struct sk_buff *skb,
struct nlattr *tb[],
const struct ndo_fdb_parms *parms,
- u32 portid, u32 seq,
+ u32 seq,
struct netlink_ext_ack *extack);
int (*ndo_mdb_add)(struct net_device *dev,
struct nlattr *tb[],
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 8ed7af3e410d..9e2fdcc5ca9b 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -1146,7 +1146,7 @@ int br_fdb_dump(struct sk_buff *skb,
int br_fdb_get(struct sk_buff *skb,
struct nlattr *tb[],
- const struct ndo_fdb_parms *parms, u32 portid, u32 seq,
+ const struct ndo_fdb_parms *parms, u32 seq,
struct netlink_ext_ack *extack)
{
struct net_bridge *br = netdev_priv(parms->dev);
@@ -1161,8 +1161,7 @@ int br_fdb_get(struct sk_buff *skb,
goto errout;
}
- err = fdb_fill_info(skb, br, f, portid, seq,
- RTM_NEWNEIGH, 0);
+ err = fdb_fill_info(skb, br, f, parms->portid, seq, RTM_NEWNEIGH, 0);
errout:
rcu_read_unlock();
return err;
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 0062bbe94d1c..f4eaaff816b7 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -1025,7 +1025,7 @@ int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[],
int br_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
struct net_device *dev, struct net_device *fdev, int *idx);
int br_fdb_get(struct sk_buff *skb, struct nlattr *tb[],
- const struct ndo_fdb_parms *parms, u32 portid, u32 seq,
+ const struct ndo_fdb_parms *parms, u32 seq,
struct netlink_ext_ack *extack);
int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p);
void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e7d683952838..f31549923848 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -5420,10 +5420,10 @@ static int rtnl_fdb_get(struct sk_buff *in_skb, struct nlmsghdr *nlh,
.dev = dev,
.addr = addr,
.vid = vid,
+ .portid = NETLINK_CB(in_skb).portid,
};
- err = ops->ndo_fdb_get(skb, tb, &parms, NETLINK_CB(in_skb).portid,
- nlh->nlmsg_seq, extack);
+ err = ops->ndo_fdb_get(skb, tb, &parms, nlh->nlmsg_seq, extack);
if (err)
goto out;
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 04/13] net: bridge: Pass struct ndo_fdb_parms a bit further
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (2 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 03/13] net: Pass portid to ndo_fdb_get through the structure Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 05/13] net: bridge: Pass portid through FDB notifications Petr Machata
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw
__br_fdb_add() and fdb_add_entry() take the FDB address, the netlink
message flags and the VLAN ID as separate arguments. All of these are
already available in struct ndo_fdb_parms, which br_fdb_add() receives from
its caller. Just pass the structure instead.
__br_fdb_add() uses the passed-in vlan parameter to decode VID and passes
that on to fdb_add_entry(). Instead, in br_fdb_add(), prime parms->vid to
the right value, so that when __br_fdb_add() passes the parms structure
through to fdb_add_entry(), the latter can just take the VID from there.
This obeys the principle of least surprise: an add-like function that gets
a parms structure has all add-like parameters properly initialized.
It would also be possible to pass struct ndo_fdb_parms to
br_fdb_external_learn_add(), which would replace addr and vid now and
portid later. But that function is also called from switchdev, where the
appropriate structure would have to be created from scratch, which makes
the benefit less clear. In the end, I left it out.
No functional change intended.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
net/bridge/br_fdb.c | 48 +++++++++++++++++++++++----------------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 9e2fdcc5ca9b..45b844a9a1f6 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -1209,7 +1209,7 @@ static bool fdb_update_dst(struct net_bridge_fdb_entry *fdb,
/* Update (create or replace) forwarding database entry */
static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
- const u8 *addr, struct ndmsg *ndm, u16 flags, u16 vid,
+ struct ndmsg *ndm, const struct ndo_fdb_parms *parms,
struct nlattr *nfea_tb[])
{
struct net_bridge_port *source = br_dst_port(dst);
@@ -1242,12 +1242,12 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
return -EINVAL;
}
- fdb = br_fdb_find(br, addr, vid);
+ fdb = br_fdb_find(br, parms->addr, parms->vid);
if (fdb == NULL) {
- if (!(flags & NLM_F_CREATE))
+ if (!(parms->flags & NLM_F_CREATE))
return -ENOENT;
- fdb = fdb_create(br, dst, addr, vid,
+ fdb = fdb_create(br, dst, parms->addr, parms->vid,
BIT(BR_FDB_ADDED_BY_USER));
if (!fdb)
return -ENOMEM;
@@ -1256,7 +1256,7 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
} else {
struct net_bridge_dst old_dst;
- if (flags & NLM_F_EXCL)
+ if (parms->flags & NLM_F_EXCL)
return -EEXIST;
old_dst = br_fdb_dst_read(fdb);
@@ -1271,15 +1271,15 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
if (state & NUD_PERMANENT) {
set_bit(BR_FDB_LOCAL, &fdb->flags);
if (!test_and_set_bit(BR_FDB_STATIC, &fdb->flags))
- fdb_add_hw_addr(br, addr);
+ fdb_add_hw_addr(br, parms->addr);
} else if (state & NUD_NOARP) {
clear_bit(BR_FDB_LOCAL, &fdb->flags);
if (!test_and_set_bit(BR_FDB_STATIC, &fdb->flags))
- fdb_add_hw_addr(br, addr);
+ fdb_add_hw_addr(br, parms->addr);
} else {
clear_bit(BR_FDB_LOCAL, &fdb->flags);
if (test_and_clear_bit(BR_FDB_STATIC, &fdb->flags))
- fdb_del_hw_addr(br, addr);
+ fdb_del_hw_addr(br, parms->addr);
}
modified = true;
@@ -1307,12 +1307,11 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
}
static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
- struct net_bridge_port *p, const unsigned char *addr,
- u16 nlh_flags, struct net_bridge_vlan *vlan,
- struct nlattr *nfea_tb[],
+ struct net_bridge_port *p,
+ const struct ndo_fdb_parms *parms,
+ struct net_bridge_vlan *vlan, struct nlattr *nfea_tb[],
bool *notified, struct netlink_ext_ack *extack)
{
- u16 vid = vlan ? vlan->vid : 0;
struct net_bridge_dst dst;
int err = 0;
@@ -1327,7 +1326,8 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
local_bh_disable();
rcu_read_lock();
- br_fdb_update(br, p, vlan, addr, BIT(BR_FDB_ADDED_BY_USER));
+ br_fdb_update(br, p, vlan, parms->addr,
+ BIT(BR_FDB_ADDED_BY_USER));
rcu_read_unlock();
local_bh_enable();
} else if (ndm->ndm_flags & NTF_EXT_LEARNED) {
@@ -1336,12 +1336,12 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
"FDB entry towards bridge must be permanent");
return -EINVAL;
}
- err = br_fdb_external_learn_add(br, p, addr, vid, false, true);
+ err = br_fdb_external_learn_add(br, p, parms->addr, parms->vid,
+ false, true);
} else {
dst = p && vlan ? br_vlan_to_dst(vlan) : br_port_to_dst(p);
spin_lock_bh(&br->hash_lock);
- err = fdb_add_entry(br, dst, addr, ndm, nlh_flags, vid,
- nfea_tb);
+ err = fdb_add_entry(br, dst, ndm, parms, nfea_tb);
spin_unlock_bh(&br->hash_lock);
}
@@ -1422,11 +1422,11 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
}
/* VID was specified, so use it. */
- err = __br_fdb_add(ndm, br, p, parms->addr, parms->flags, v,
- nfea_tb, notified, extack);
+ err = __br_fdb_add(ndm, br, p, parms, v, nfea_tb, notified,
+ extack);
} else {
- err = __br_fdb_add(ndm, br, p, parms->addr, parms->flags,
- NULL, nfea_tb, notified, extack);
+ err = __br_fdb_add(ndm, br, p, parms, NULL, nfea_tb, notified,
+ extack);
if (err || !vg || !vg->num_vlans)
goto out;
@@ -1435,11 +1435,13 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
* vlan on this port.
*/
list_for_each_entry(v, &vg->vlan_list, vlist) {
+ struct ndo_fdb_parms vparms = *parms;
+
if (!br_vlan_should_use(v))
continue;
- err = __br_fdb_add(ndm, br, p, parms->addr,
- parms->flags, v, nfea_tb, notified,
- extack);
+ vparms.vid = v->vid;
+ err = __br_fdb_add(ndm, br, p, &vparms, v, nfea_tb,
+ notified, extack);
if (err)
goto out;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 05/13] net: bridge: Pass portid through FDB notifications
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (3 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 04/13] net: bridge: Pass struct ndo_fdb_parms a bit further Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 06/13] net: vxlan: " Petr Machata
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw
Add a portid argument to fdb_notify(), fdb_delete(), br_fdb_flush(),
fdb_delete_by_addr_and_port(), __br_fdb_delete() and
br_fdb_external_learn_add(), and use it for the issued RTM_NEWNEIGH /
RTM_DELNEIGH notifications.
Rename br_fdb_update() to __br_fdb_update() and add the portid argument to
that, converting internal callers. br_fdb_update() then becomes a thin
wrapper that just passes zero for portid and retains the prototype for
external callers.
br_fdb_add() and br_fdb_delete() pass on the port ID of the requester. All
other callers (learning, aging, switchdev events, sysfs and
IFLA_BR_FDB_FLUSH handling, as well as br_fdb_delete_bulk()) pass zero, as
before.
As rtnl_fdb_add() and rtnl_fdb_del() do not yet fill in the port ID in
struct ndo_fdb_parms, all notifications are still sent with zero. No
functional change intended.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
net/bridge/br.c | 2 +-
net/bridge/br_fdb.c | 83 +++++++++++++++++++++++-----------------
net/bridge/br_netlink.c | 4 +-
net/bridge/br_private.h | 4 +-
net/bridge/br_sysfs_br.c | 2 +-
5 files changed, 54 insertions(+), 41 deletions(-)
diff --git a/net/bridge/br.c b/net/bridge/br.c
index d9a39ff98868..76feb286acab 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -177,7 +177,7 @@ static int br_switchdev_event(struct notifier_block *unused,
fdb_info = ptr;
err = br_fdb_external_learn_add(br, p, fdb_info->addr,
fdb_info->vid,
- fdb_info->locked, false);
+ fdb_info->locked, 0, false);
if (err) {
err = notifier_from_errno(err);
break;
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 45b844a9a1f6..3712e6db90f0 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -176,7 +176,7 @@ static inline size_t fdb_nlmsg_size(void)
static void fdb_notify(struct net_bridge *br,
const struct net_bridge_fdb_entry *fdb, int type,
- bool swdev_notify)
+ u32 portid, bool swdev_notify)
{
struct net *net = dev_net(br->dev);
struct sk_buff *skb;
@@ -189,7 +189,7 @@ static void fdb_notify(struct net_bridge *br,
if (skb == NULL)
goto errout;
- err = fdb_fill_info(skb, br, fdb, 0, 0, type, 0);
+ err = fdb_fill_info(skb, br, fdb, portid, 0, type, 0);
if (err < 0) {
/* -EMSGSIZE implies BUG in fdb_nlmsg_size() */
WARN_ON(err == -EMSGSIZE);
@@ -313,7 +313,7 @@ static void fdb_del_hw_addr(struct net_bridge *br, const unsigned char *addr)
}
static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f,
- bool swdev_notify)
+ u32 portid, bool swdev_notify)
{
trace_fdb_delete(br, f, br_fdb_dst_port(f));
@@ -325,7 +325,7 @@ static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f,
br_fdb_rht_params);
if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &f->flags))
atomic_dec(&br->fdb_n_learned);
- fdb_notify(br, f, RTM_DELNEIGH, swdev_notify);
+ fdb_notify(br, f, RTM_DELNEIGH, portid, swdev_notify);
kfree_rcu(f, rcu);
}
@@ -366,7 +366,7 @@ static void fdb_delete_local(struct net_bridge *br,
return;
}
- fdb_delete(br, f, true);
+ fdb_delete(br, f, 0, true);
}
void br_fdb_find_delete_local(struct net_bridge *br,
@@ -445,7 +445,7 @@ static int fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,
return 0;
br_warn(br, "adding interface %s with same address as a received packet (addr:%pM, vlan:%u)\n",
source ? source->dev->name : br->dev->name, addr, vid);
- fdb_delete(br, fdb, true);
+ fdb_delete(br, fdb, 0, true);
}
fdb = fdb_create(br, br_port_to_dst(source), addr, vid,
@@ -454,7 +454,7 @@ static int fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,
return -ENOMEM;
fdb_add_hw_addr(br, addr);
- fdb_notify(br, fdb, RTM_NEWNEIGH, true);
+ fdb_notify(br, fdb, RTM_NEWNEIGH, 0, true);
return 0;
}
@@ -569,7 +569,8 @@ void br_fdb_cleanup(struct work_struct *work)
this_timer - now);
else if (!test_and_set_bit(BR_FDB_NOTIFY_INACTIVE,
&f->flags))
- fdb_notify(br, f, RTM_NEWNEIGH, false);
+ fdb_notify(br, f, RTM_NEWNEIGH, 0,
+ false);
}
continue;
}
@@ -579,7 +580,7 @@ void br_fdb_cleanup(struct work_struct *work)
} else {
spin_lock_bh(&br->hash_lock);
if (!hlist_unhashed(&f->fdb_node))
- fdb_delete(br, f, true);
+ fdb_delete(br, f, 0, true);
spin_unlock_bh(&br->hash_lock);
}
}
@@ -711,7 +712,7 @@ static bool __fdb_flush_matches(const struct net_bridge *br,
/* Flush forwarding database entries matching the description */
void br_fdb_flush(struct net_bridge *br,
- const struct net_bridge_fdb_flush_desc *desc)
+ const struct net_bridge_fdb_flush_desc *desc, u32 portid)
{
struct net_bridge_fdb_entry *f;
@@ -722,7 +723,7 @@ void br_fdb_flush(struct net_bridge *br,
spin_lock_bh(&br->hash_lock);
if (!hlist_unhashed(&f->fdb_node))
- fdb_delete(br, f, true);
+ fdb_delete(br, f, portid, true);
spin_unlock_bh(&br->hash_lock);
}
rcu_read_unlock();
@@ -863,7 +864,7 @@ int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
br_debug(br, "flushing port ifindex: %d vlan id: %u flags: 0x%lx flags mask: 0x%lx\n",
desc.port_ifindex, desc.vlan_id, desc.flags, desc.flags_mask);
- br_fdb_flush(br, &desc);
+ br_fdb_flush(br, &desc, 0);
return 0;
}
@@ -918,7 +919,7 @@ void br_fdb_cleanup_by_dst(struct net_bridge *br,
if (test_bit(BR_FDB_LOCAL, &f->flags))
fdb_delete_local(br, p, f);
else
- fdb_delete(br, f, true);
+ fdb_delete(br, f, 0, true);
}
spin_unlock_bh(&br->hash_lock);
}
@@ -1000,7 +1001,7 @@ static void __fdb_update(struct net_bridge *br,
struct net_bridge_fdb_entry *fdb,
struct net_bridge_port *source,
struct net_bridge_dst dst,
- unsigned long flags)
+ unsigned long flags, u32 portid)
{
struct net_bridge_port *old_port;
struct net_bridge_dst old_dst;
@@ -1057,13 +1058,15 @@ static void __fdb_update(struct net_bridge *br,
if (unlikely(fdb_modified)) {
trace_br_fdb_update(br, source, fdb->key.addr.addr,
fdb->key.vlan_id, flags);
- fdb_notify(br, fdb, RTM_NEWNEIGH, true);
+ fdb_notify(br, fdb, RTM_NEWNEIGH, portid, true);
}
}
-void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
- struct net_bridge_vlan *vlan, const unsigned char *addr,
- unsigned long flags)
+static void __br_fdb_update(struct net_bridge *br,
+ struct net_bridge_port *source,
+ struct net_bridge_vlan *vlan,
+ const unsigned char *addr, unsigned long flags,
+ u32 portid)
{
struct net_bridge_dst dst = vlan ? br_vlan_to_dst(vlan) :
br_port_to_dst(source);
@@ -1076,18 +1079,25 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid);
if (likely(fdb)) {
- __fdb_update(br, fdb, source, dst, flags);
+ __fdb_update(br, fdb, source, dst, flags, portid);
} else {
spin_lock(&br->hash_lock);
fdb = fdb_create(br, dst, addr, vid, flags);
if (fdb) {
trace_br_fdb_update(br, source, addr, vid, flags);
- fdb_notify(br, fdb, RTM_NEWNEIGH, true);
+ fdb_notify(br, fdb, RTM_NEWNEIGH, portid, true);
}
spin_unlock(&br->hash_lock);
}
}
+void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
+ struct net_bridge_vlan *vlan, const unsigned char *addr,
+ unsigned long flags)
+{
+ __br_fdb_update(br, source, vlan, addr, flags, 0);
+}
+
/* Dump information about entries, in response to GETNEIGH */
int br_fdb_dump(struct sk_buff *skb,
struct netlink_callback *cb,
@@ -1300,7 +1310,7 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
if (modified) {
if (refresh)
WRITE_ONCE(fdb->updated, jiffies);
- fdb_notify(br, fdb, RTM_NEWNEIGH, true);
+ fdb_notify(br, fdb, RTM_NEWNEIGH, parms->portid, true);
}
return 0;
@@ -1326,8 +1336,8 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
local_bh_disable();
rcu_read_lock();
- br_fdb_update(br, p, vlan, parms->addr,
- BIT(BR_FDB_ADDED_BY_USER));
+ __br_fdb_update(br, p, vlan, parms->addr,
+ BIT(BR_FDB_ADDED_BY_USER), parms->portid);
rcu_read_unlock();
local_bh_enable();
} else if (ndm->ndm_flags & NTF_EXT_LEARNED) {
@@ -1337,7 +1347,7 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
return -EINVAL;
}
err = br_fdb_external_learn_add(br, p, parms->addr, parms->vid,
- false, true);
+ false, parms->portid, true);
} else {
dst = p && vlan ? br_vlan_to_dst(vlan) : br_port_to_dst(p);
spin_lock_bh(&br->hash_lock);
@@ -1453,7 +1463,8 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
static int fdb_delete_by_addr_and_port(struct net_bridge *br,
const struct net_bridge_port *p,
- const u8 *addr, u16 vlan, bool *notified)
+ const u8 *addr, u16 vlan, u32 portid,
+ bool *notified)
{
struct net_bridge_fdb_entry *fdb;
@@ -1461,7 +1472,7 @@ static int fdb_delete_by_addr_and_port(struct net_bridge *br,
if (!fdb || br_fdb_dst_port(fdb) != p)
return -ENOENT;
- fdb_delete(br, fdb, true);
+ fdb_delete(br, fdb, portid, true);
*notified = true;
return 0;
@@ -1469,12 +1480,13 @@ static int fdb_delete_by_addr_and_port(struct net_bridge *br,
static int __br_fdb_delete(struct net_bridge *br,
const struct net_bridge_port *p,
- const unsigned char *addr, u16 vid, bool *notified)
+ const unsigned char *addr, u16 vid, u32 portid,
+ bool *notified)
{
int err;
spin_lock_bh(&br->hash_lock);
- err = fdb_delete_by_addr_and_port(br, p, addr, vid, notified);
+ err = fdb_delete_by_addr_and_port(br, p, addr, vid, portid, notified);
spin_unlock_bh(&br->hash_lock);
return err;
@@ -1506,12 +1518,13 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
if (parms->vid) {
err = __br_fdb_delete(br, p, parms->addr, parms->vid,
- notified);
+ parms->portid, notified);
} else {
struct net_bridge_vlan *v;
err = -ENOENT;
- err &= __br_fdb_delete(br, p, parms->addr, 0, notified);
+ err &= __br_fdb_delete(br, p, parms->addr, 0, parms->portid,
+ notified);
if (!vg || !vg->num_vlans)
return err;
@@ -1519,7 +1532,7 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
if (!br_vlan_should_use(v))
continue;
err &= __br_fdb_delete(br, p, parms->addr, v->vid,
- notified);
+ parms->portid, notified);
}
}
@@ -1600,7 +1613,7 @@ static struct net_bridge_dst br_fdb_resolve_dst(const struct net_bridge_port *p,
int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
const unsigned char *addr, u16 vid, bool locked,
- bool swdev_notify)
+ u32 portid, bool swdev_notify)
{
struct net_bridge_dst dst = br_fdb_resolve_dst(p, vid);
struct net_bridge_fdb_entry *fdb;
@@ -1632,7 +1645,7 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
err = -ENOMEM;
goto err_unlock;
}
- fdb_notify(br, fdb, RTM_NEWNEIGH, swdev_notify);
+ fdb_notify(br, fdb, RTM_NEWNEIGH, portid, swdev_notify);
} else {
struct net_bridge_dst old_dst;
@@ -1671,7 +1684,7 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
atomic_dec(&br->fdb_n_learned);
if (modified)
- fdb_notify(br, fdb, RTM_NEWNEIGH, swdev_notify);
+ fdb_notify(br, fdb, RTM_NEWNEIGH, portid, swdev_notify);
}
err_unlock:
@@ -1691,7 +1704,7 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
fdb = br_fdb_find(br, addr, vid);
if (fdb && test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags))
- fdb_delete(br, fdb, swdev_notify);
+ fdb_delete(br, fdb, 0, swdev_notify);
else
err = -ENOENT;
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 79c4a54990e2..0a1dd507bbff 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1001,7 +1001,7 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[],
.port_ifindex = p->dev->ifindex,
};
- br_fdb_flush(p->br, &desc);
+ br_fdb_flush(p->br, &desc, 0);
}
changed_mask = old_flags ^ flags;
@@ -1431,7 +1431,7 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
.flags_mask = BIT(BR_FDB_STATIC)
};
- br_fdb_flush(br, &desc);
+ br_fdb_flush(br, &desc, 0);
}
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index f4eaaff816b7..67e3288b1e40 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -992,7 +992,7 @@ void br_fdb_fini(void);
int br_fdb_hash_init(struct net_bridge *br);
void br_fdb_hash_fini(struct net_bridge *br);
void br_fdb_flush(struct net_bridge *br,
- const struct net_bridge_fdb_flush_desc *desc);
+ const struct net_bridge_fdb_flush_desc *desc, u32 portid);
void br_fdb_find_delete_local(struct net_bridge *br,
const struct net_bridge_port *p,
const unsigned char *addr, u16 vid);
@@ -1031,7 +1031,7 @@ int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p);
void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p);
int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
const unsigned char *addr, u16 vid,
- bool locked, bool swdev_notify);
+ bool locked, u32 portid, bool swdev_notify);
int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
const unsigned char *addr, u16 vid,
bool swdev_notify);
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index d2993f187f57..3a05764e607a 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -349,7 +349,7 @@ static int set_flush(struct net_bridge *br, unsigned long val,
.flags_mask = BIT(BR_FDB_STATIC)
};
- br_fdb_flush(br, &desc);
+ br_fdb_flush(br, &desc, 0);
return 0;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 06/13] net: vxlan: Pass portid through FDB notifications
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (4 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 05/13] net: bridge: Pass portid through FDB notifications Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 07/13] net: rtnetlink: Report port ID in bridge and VXLAN " Petr Machata
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw
Add a portid argument to __vxlan_fdb_notify(), vxlan_fdb_notify(),
vxlan_fdb_destroy(), vxlan_fdb_dst_destroy(), vxlan_fdb_update() and its
_existing() and _create() helpers, __vxlan_fdb_delete(), vxlan_flush() and
vxlan_fdb_flush_match_remotes(), and use it as the netlink port ID of the
resulting RTM_NEWNEIGH / RTM_DELNEIGH notifications. Where both portid and
swdev_notify are passed, portid comes first: it is part of the message
metadata, similarly to the message type, whereas swdev_notify merely
toggles whether the switchdev notifiers are called.
vxlan_fdb_add() and vxlan_fdb_delete() pass on the port ID of the
requester. All other callers (snooping, device stop, changelink, VNI
filtering, switchdev events, as well as vxlan_fdb_delete_bulk()) pass zero,
as before.
As rtnl_fdb_add() and rtnl_fdb_del() do not yet fill in the port ID in
struct ndo_fdb_parms, all notifications are still sent with zero. No
functional change intended.
I considered passing struct ndo_fdb_parms down to vxlan_fdb_update()
instead of the individual address and flags, but eventually decided against
that. Only vxlan_fdb_add() has the structure at hand, whereas the other
callers would have to construct a throwaway one just to pass the address
and flags. This makes them longer, not shorter, and the callee would still
need most of the VXLAN-specific arguments separately.
Packing the VXLAN-specific parameters (remote IP, port, VNI, ifindex, ...)
into a dedicated VXLAN-specific structure might benefit the VXLAN driver in
a similar way to how it cleaned up the NDO interface. However this was left
out for potential future patchset.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/vxlan/vxlan_core.c | 89 +++++++++++++++--------------
drivers/net/vxlan/vxlan_private.h | 5 +-
drivers/net/vxlan/vxlan_vnifilter.c | 6 +-
3 files changed, 52 insertions(+), 48 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 725c6216d56c..a010eb8f7f28 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -265,7 +265,7 @@ static inline size_t vxlan_nlmsg_size(void)
}
static void __vxlan_fdb_notify(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb,
- struct vxlan_rdst *rd, int type)
+ struct vxlan_rdst *rd, int type, u32 portid)
{
struct net *net = dev_net(vxlan->dev);
struct sk_buff *skb;
@@ -275,7 +275,7 @@ static void __vxlan_fdb_notify(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb,
if (skb == NULL)
goto errout;
- err = vxlan_fdb_info(skb, vxlan, fdb, 0, 0, type, 0, rd);
+ err = vxlan_fdb_info(skb, vxlan, fdb, portid, 0, type, 0, rd);
if (err < 0) {
/* -EMSGSIZE implies BUG in vxlan_nlmsg_size() */
WARN_ON(err == -EMSGSIZE);
@@ -329,8 +329,8 @@ static int vxlan_fdb_switchdev_call_notifiers(struct vxlan_dev *vxlan,
}
static int vxlan_fdb_notify(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb,
- struct vxlan_rdst *rd, int type, bool swdev_notify,
- struct netlink_ext_ack *extack)
+ struct vxlan_rdst *rd, int type, u32 portid,
+ bool swdev_notify, struct netlink_ext_ack *extack)
{
int err;
@@ -349,7 +349,7 @@ static int vxlan_fdb_notify(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb,
}
}
- __vxlan_fdb_notify(vxlan, fdb, rd, type);
+ __vxlan_fdb_notify(vxlan, fdb, rd, type, portid);
return 0;
}
@@ -364,7 +364,7 @@ static void vxlan_ip_miss(struct net_device *dev, union vxlan_addr *ipa)
.remote_vni = cpu_to_be32(VXLAN_N_VID),
};
- vxlan_fdb_notify(vxlan, &f, &remote, RTM_GETNEIGH, true, NULL);
+ vxlan_fdb_notify(vxlan, &f, &remote, RTM_GETNEIGH, 0, true, NULL);
}
static void vxlan_fdb_miss(struct vxlan_dev *vxlan, const u8 eth_addr[ETH_ALEN])
@@ -376,7 +376,7 @@ static void vxlan_fdb_miss(struct vxlan_dev *vxlan, const u8 eth_addr[ETH_ALEN])
memcpy(f.key.eth_addr, eth_addr, ETH_ALEN);
- vxlan_fdb_notify(vxlan, &f, &remote, RTM_GETNEIGH, true, NULL);
+ vxlan_fdb_notify(vxlan, &f, &remote, RTM_GETNEIGH, 0, true, NULL);
}
/* Look up Ethernet address in forwarding table */
@@ -945,7 +945,7 @@ static void vxlan_fdb_free(struct rcu_head *head)
}
static void vxlan_fdb_destroy(struct vxlan_dev *vxlan, struct vxlan_fdb *f,
- bool do_notify, bool swdev_notify)
+ bool do_notify, u32 portid, bool swdev_notify)
{
struct vxlan_rdst *rd;
@@ -955,11 +955,11 @@ static void vxlan_fdb_destroy(struct vxlan_dev *vxlan, struct vxlan_fdb *f,
if (do_notify) {
if (rcu_access_pointer(f->nh))
vxlan_fdb_notify(vxlan, f, NULL, RTM_DELNEIGH,
- swdev_notify, NULL);
+ portid, swdev_notify, NULL);
else
list_for_each_entry(rd, &f->remotes, list)
vxlan_fdb_notify(vxlan, f, rd, RTM_DELNEIGH,
- swdev_notify, NULL);
+ portid, swdev_notify, NULL);
}
hlist_del_init_rcu(&f->fdb_node);
@@ -983,7 +983,7 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,
__be16 port, __be32 vni,
__u32 ifindex, __u16 ndm_flags,
struct vxlan_fdb *f, u32 nhid,
- bool swdev_notify,
+ u32 portid, bool swdev_notify,
struct netlink_ext_ack *extack)
{
__u16 fdb_flags = (ndm_flags & ~NTF_USE);
@@ -1057,7 +1057,7 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,
WRITE_ONCE(f->updated, jiffies);
err = vxlan_fdb_notify(vxlan, f, rd, RTM_NEWNEIGH,
- swdev_notify, extack);
+ portid, swdev_notify, extack);
if (err)
goto err_notify;
}
@@ -1081,7 +1081,7 @@ static int vxlan_fdb_update_create(struct vxlan_dev *vxlan,
__u16 state, __u16 flags,
__be16 port, __be32 src_vni, __be32 vni,
__u32 ifindex, __u16 ndm_flags, u32 nhid,
- bool swdev_notify,
+ u32 portid, bool swdev_notify,
struct netlink_ext_ack *extack)
{
__u16 fdb_flags = (ndm_flags & ~NTF_USE);
@@ -1100,14 +1100,14 @@ static int vxlan_fdb_update_create(struct vxlan_dev *vxlan,
return rc;
rc = vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), RTM_NEWNEIGH,
- swdev_notify, extack);
+ portid, swdev_notify, extack);
if (rc)
goto err_notify;
return 0;
err_notify:
- vxlan_fdb_destroy(vxlan, f, false, false);
+ vxlan_fdb_destroy(vxlan, f, false, 0, false);
return rc;
}
@@ -1117,7 +1117,7 @@ int vxlan_fdb_update(struct vxlan_dev *vxlan,
__u16 state, __u16 flags,
__be16 port, __be32 src_vni, __be32 vni,
__u32 ifindex, __u16 ndm_flags, u32 nhid,
- bool swdev_notify,
+ u32 portid, bool swdev_notify,
struct netlink_ext_ack *extack)
{
struct vxlan_fdb *f;
@@ -1132,23 +1132,26 @@ int vxlan_fdb_update(struct vxlan_dev *vxlan,
return vxlan_fdb_update_existing(vxlan, ip, state, flags, port,
vni, ifindex, ndm_flags, f,
- nhid, swdev_notify, extack);
+ nhid, portid, swdev_notify,
+ extack);
} else {
if (!(flags & NLM_F_CREATE))
return -ENOENT;
return vxlan_fdb_update_create(vxlan, mac, ip, state, flags,
port, src_vni, vni, ifindex,
- ndm_flags, nhid, swdev_notify,
- extack);
+ ndm_flags, nhid, portid,
+ swdev_notify, extack);
}
}
static void vxlan_fdb_dst_destroy(struct vxlan_dev *vxlan, struct vxlan_fdb *f,
- struct vxlan_rdst *rd, bool swdev_notify)
+ struct vxlan_rdst *rd, u32 portid,
+ bool swdev_notify)
{
list_del_rcu(&rd->list);
- vxlan_fdb_notify(vxlan, f, rd, RTM_DELNEIGH, swdev_notify, NULL);
+ vxlan_fdb_notify(vxlan, f, rd, RTM_DELNEIGH, portid, swdev_notify,
+ NULL);
call_rcu(&rd->rcu, vxlan_dst_free);
}
@@ -1276,7 +1279,7 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
parms->flags,
port, src_vni, vni, ifindex,
ndm->ndm_flags | NTF_VXLAN_ADDED_BY_USER,
- nhid, true, extack);
+ nhid, parms->portid, true, extack);
spin_unlock_bh(&vxlan->hash_lock);
if (!err)
@@ -1288,7 +1291,7 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
int __vxlan_fdb_delete(struct vxlan_dev *vxlan,
const unsigned char *addr, union vxlan_addr ip,
__be16 port, __be32 src_vni, __be32 vni,
- u32 ifindex, bool swdev_notify)
+ u32 ifindex, u32 portid, bool swdev_notify)
{
struct vxlan_rdst *rd = NULL;
struct vxlan_fdb *f;
@@ -1308,11 +1311,11 @@ int __vxlan_fdb_delete(struct vxlan_dev *vxlan,
* otherwise destroy the fdb entry
*/
if (rd && !list_is_singular(&f->remotes)) {
- vxlan_fdb_dst_destroy(vxlan, f, rd, swdev_notify);
+ vxlan_fdb_dst_destroy(vxlan, f, rd, portid, swdev_notify);
goto out;
}
- vxlan_fdb_destroy(vxlan, f, true, swdev_notify);
+ vxlan_fdb_destroy(vxlan, f, true, portid, swdev_notify);
out:
return 0;
@@ -1337,7 +1340,7 @@ static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
spin_lock_bh(&vxlan->hash_lock);
err = __vxlan_fdb_delete(vxlan, parms->addr, ip, port, src_vni, vni,
- ifindex, true);
+ ifindex, parms->portid, true);
spin_unlock_bh(&vxlan->hash_lock);
if (!err)
@@ -1480,7 +1483,7 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev,
src_mac, &rdst->remote_ip.sa, &src_ip->sa);
rdst->remote_ip = *src_ip;
- vxlan_fdb_notify(vxlan, f, rdst, RTM_NEWNEIGH, true, NULL);
+ vxlan_fdb_notify(vxlan, f, rdst, RTM_NEWNEIGH, 0, true, NULL);
} else {
/* learned new entry */
spin_lock(&vxlan->hash_lock);
@@ -1493,7 +1496,7 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev,
cfg->dst_port,
vni,
cfg->vni,
- ifindex, NTF_SELF, 0, true, NULL);
+ ifindex, NTF_SELF, 0, 0, true, NULL);
spin_unlock(&vxlan->hash_lock);
}
@@ -2943,7 +2946,7 @@ static void vxlan_cleanup(struct timer_list *t)
netdev_dbg(vxlan->dev, "garbage collect %pM\n",
f->key.eth_addr);
f->state = NUD_STALE;
- vxlan_fdb_destroy(vxlan, f, true, true);
+ vxlan_fdb_destroy(vxlan, f, true, 0, true);
}
spin_unlock(&vxlan->hash_lock);
} else if (time_before(timeout, next_timer)) {
@@ -3138,7 +3141,7 @@ vxlan_fdb_flush_remote_matches(const struct vxlan_fdb_flush_desc *desc,
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)
+ u32 portid, bool *p_destroy_fdb)
{
struct vxlan_rdst *rd, *tmp;
@@ -3151,13 +3154,13 @@ vxlan_fdb_flush_match_remotes(struct vxlan_fdb *f, struct vxlan_dev *vxlan,
return;
}
- vxlan_fdb_dst_destroy(vxlan, f, rd, true);
+ vxlan_fdb_dst_destroy(vxlan, f, rd, portid, true);
}
}
/* Purge the forwarding table */
static void vxlan_flush(struct vxlan_dev *vxlan,
- const struct vxlan_fdb_flush_desc *desc)
+ const struct vxlan_fdb_flush_desc *desc, u32 portid)
{
bool match_remotes = vxlan_fdb_flush_should_match_remotes(desc);
struct vxlan_fdb *f;
@@ -3174,14 +3177,14 @@ static void vxlan_flush(struct vxlan_dev *vxlan,
if (match_remotes) {
bool destroy_fdb = false;
- vxlan_fdb_flush_match_remotes(f, vxlan, desc,
+ vxlan_fdb_flush_match_remotes(f, vxlan, desc, portid,
&destroy_fdb);
if (!destroy_fdb)
goto unlock;
}
- vxlan_fdb_destroy(vxlan, f, true, true);
+ vxlan_fdb_destroy(vxlan, f, true, portid, true);
unlock:
spin_unlock_bh(&vxlan->hash_lock);
}
@@ -3263,7 +3266,7 @@ static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
desc.dst_ip = ip;
}
- vxlan_flush(vxlan, &desc);
+ vxlan_flush(vxlan, &desc, 0);
return 0;
}
@@ -3283,7 +3286,7 @@ static int vxlan_stop(struct net_device *dev)
timer_delete_sync(&vxlan->age_timer);
- vxlan_flush(vxlan, &desc);
+ vxlan_flush(vxlan, &desc, 0);
vxlan_sock_release(vxlan);
return 0;
@@ -4143,7 +4146,7 @@ static int vxlan_dev_create(struct net *net, struct net_device *dev,
cfg->vni,
cfg->vni,
cfg->remote_ifindex,
- NTF_SELF, 0, true, extack);
+ NTF_SELF, 0, 0, true, extack);
spin_unlock_bh(&vxlan->hash_lock);
if (err)
goto unlink;
@@ -4606,7 +4609,7 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
cfg->dst_port,
conf.vni, conf.vni,
conf.remote_ifindex,
- NTF_SELF, 0, true, extack);
+ NTF_SELF, 0, 0, true, extack);
if (err) {
spin_unlock_bh(&vxlan->hash_lock);
if (lowerdev_changed)
@@ -4623,7 +4626,7 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
cfg->vni,
cfg->vni,
cfg->remote_ifindex,
- true);
+ 0, true);
spin_unlock_bh(&vxlan->hash_lock);
/* If vni filtering device, also update default fdb entries of
@@ -4687,7 +4690,7 @@ 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, &desc);
+ vxlan_flush(vxlan, &desc, 0);
list_del(&vxlan->next);
unregister_netdevice_queue(dev, head);
@@ -4961,7 +4964,7 @@ vxlan_fdb_external_learn_add(struct net_device *dev,
fdb_info->remote_vni,
fdb_info->remote_ifindex,
NTF_USE | NTF_SELF | NTF_EXT_LEARNED,
- 0, false, extack);
+ 0, 0, false, extack);
spin_unlock_bh(&vxlan->hash_lock);
return err;
@@ -4987,7 +4990,7 @@ vxlan_fdb_external_learn_del(struct net_device *dev,
fdb_info->vni,
fdb_info->remote_vni,
fdb_info->remote_ifindex,
- false);
+ 0, false);
spin_unlock_bh(&vxlan->hash_lock);
@@ -5045,7 +5048,7 @@ static void vxlan_fdb_nh_flush(struct nexthop *nh)
WARN_ON(!vxlan);
spin_lock_bh(&vxlan->hash_lock);
if (!hlist_unhashed(&fdb->fdb_node))
- vxlan_fdb_destroy(vxlan, fdb, false, false);
+ vxlan_fdb_destroy(vxlan, fdb, false, 0, false);
spin_unlock_bh(&vxlan->hash_lock);
}
rcu_read_unlock();
diff --git a/drivers/net/vxlan/vxlan_private.h b/drivers/net/vxlan/vxlan_private.h
index f0ee85f83732..632e1880c0b9 100644
--- a/drivers/net/vxlan/vxlan_private.h
+++ b/drivers/net/vxlan/vxlan_private.h
@@ -196,13 +196,14 @@ int vxlan_fdb_create(struct vxlan_dev *vxlan,
int __vxlan_fdb_delete(struct vxlan_dev *vxlan,
const unsigned char *addr, union vxlan_addr ip,
__be16 port, __be32 src_vni, __be32 vni,
- u32 ifindex, bool swdev_notify);
+ u32 ifindex, u32 portid, bool swdev_notify);
int vxlan_fdb_update(struct vxlan_dev *vxlan,
const u8 *mac, union vxlan_addr *ip,
__u16 state, __u16 flags,
__be16 port, __be32 src_vni, __be32 vni,
__u32 ifindex, __u16 ndm_flags, u32 nhid,
- bool swdev_notify, struct netlink_ext_ack *extack);
+ u32 portid, bool swdev_notify,
+ struct netlink_ext_ack *extack);
void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
const struct vxlan_config *cfg,
__be32 default_vni, struct vxlan_rdst *rdst, bool did_rsc);
diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_vnifilter.c
index c5cc6cd08545..927b63db3b5b 100644
--- a/drivers/net/vxlan/vxlan_vnifilter.c
+++ b/drivers/net/vxlan/vxlan_vnifilter.c
@@ -550,7 +550,7 @@ int vxlan_update_default_fdb_entry(struct vxlan_dev *vxlan, __be32 vni,
vni,
vni,
new_ifindex,
- NTF_SELF, 0, true, extack);
+ NTF_SELF, 0, 0, true, extack);
if (err && extack) {
spin_unlock_bh(&vxlan->hash_lock);
return err;
@@ -563,7 +563,7 @@ int vxlan_update_default_fdb_entry(struct vxlan_dev *vxlan, __be32 vni,
cfg->dst_port,
vni, vni,
old_ifindex,
- true);
+ 0, true);
}
spin_unlock_bh(&vxlan->hash_lock);
@@ -727,7 +727,7 @@ static void vxlan_vni_delete_group(struct vxlan_dev *vxlan,
cfg->dst_port,
vninode->vni, vninode->vni,
cfg->remote_ifindex,
- true);
+ 0, true);
spin_unlock_bh(&vxlan->hash_lock);
}
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 07/13] net: rtnetlink: Report port ID in bridge and VXLAN FDB notifications
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (5 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 06/13] net: vxlan: " Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 08/13] net: rtnetlink: Report port ID in bulk FDB delete notifications Petr Machata
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw
Commit 7b8f7a402d4c ("neighbour: fix nlmsg_pid in notifications") made
neighbour notifications carry the netlink port ID of the process that
triggered them in nlmsg_pid. Similarly route and nexthop update
notifications carry the port ID. This allows applications to tell
their own changes apart from those made by someone else. For
notifications related to FDB entries, port ID is currently always
zero, which makes this sort of notification filtering impossible.
After the preceding patches, port ID is available for bridge and VXLAN
to use by way of the struct ndo_fdb_parms' portid field, and the two
drivers pass the value through to the notifications. The field itself
however has so far been not initialized by rtnl_fdb_add() and
rtnl_fdb_del().
In this patch do that. With that, the RTM_NEWNEIGH and RTM_DELNEIGH
notifications that bridge and VXLAN FDB send carry the port ID.
Notifications that are not a result of a netlink request, such as
those for learning, aging, or switchdev events, still carry zero.
Bulk deletion (flush) goes through ndo_fdb_del_bulk instead, and is
converted in a separate patch.
Drivers other than bridge and VXLAN, which implement ndo_fdb_add and
ndo_fdb_del but fall back to the default implementations, still
report zero as well. That also is converted in a later patch.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
net/core/rtnetlink.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f31549923848..e0d411c251aa 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4857,6 +4857,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
.addr = addr,
.vid = vid,
.flags = nlh->nlmsg_flags,
+ .portid = NETLINK_CB(skb).portid,
};
err = -EOPNOTSUPP;
@@ -4927,6 +4928,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
{
bool del_bulk = !!(nlh->nlmsg_flags & NLM_F_BULK);
struct net *net = sock_net(skb->sk);
+ u32 portid = NETLINK_CB(skb).portid;
const struct net_device_ops *ops;
struct ndmsg *ndm;
struct nlattr *tb[NDA_MAX+1];
@@ -4975,6 +4977,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
.dev = dev,
.addr = addr,
.vid = vid,
+ .portid = portid,
};
}
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 08/13] net: rtnetlink: Report port ID in bulk FDB delete notifications
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (6 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 07/13] net: rtnetlink: Report port ID in bridge and VXLAN " Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 09/13] net: rtnetlink: Report port ID in fallback FDB notifications Petr Machata
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw
The previous patch made the notifications resulting from adding, replacing
and deleting bridge and VXLAN FDB entries carry the port ID of the
requester in nlmsg_pid. Bulk deletion (flush) does not go through
ndo_fdb_del, and thus does not take struct ndo_fdb_parms, but goes through
ndo_fdb_del_bulk instead, and still reports zero.
Add a port ID argument to ndo_fdb_del_bulk, and pass the port ID of the
requester from rtnl_fdb_del(). The bridge and VXLAN implementations pass it
on to the flush helpers, which already know how to use it.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/vxlan/vxlan_core.c | 4 ++--
include/linux/netdevice.h | 3 ++-
net/bridge/br_fdb.c | 4 ++--
net/bridge/br_private.h | 2 +-
net/core/rtnetlink.c | 6 ++++--
5 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index a010eb8f7f28..c300e0bd9b57 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -3208,7 +3208,7 @@ static const struct nla_policy vxlan_del_bulk_policy[NDA_MAX + 1] = {
NTF_ROUTER)
static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
- struct netlink_ext_ack *extack)
+ u32 portid, struct netlink_ext_ack *extack)
{
struct vxlan_dev *vxlan = netdev_priv(dev);
struct vxlan_fdb_flush_desc desc = {};
@@ -3266,7 +3266,7 @@ static int vxlan_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
desc.dst_ip = ip;
}
- vxlan_flush(vxlan, &desc, 0);
+ vxlan_flush(vxlan, &desc, portid);
return 0;
}
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 233584013fc9..b2846b586a7f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1358,7 +1358,7 @@ struct ndo_fdb_parms {
* Callee shall set *notified to true if it sent any appropriate
* notification(s). Otherwise core will send a generic one.
* int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh, struct net_device *dev,
- * struct netlink_ext_ack *extack);
+ * u32 portid, 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,
* int *idx)
@@ -1638,6 +1638,7 @@ struct net_device_ops {
struct netlink_ext_ack *extack);
int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh,
struct net_device *dev,
+ u32 portid,
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 3712e6db90f0..6b1c067974ff 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -797,7 +797,7 @@ static const struct nla_policy br_fdb_del_bulk_policy[NDA_MAX + 1] = {
};
int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
- struct netlink_ext_ack *extack)
+ u32 portid, struct netlink_ext_ack *extack)
{
struct net_bridge_fdb_flush_desc desc = {};
struct ndmsg *ndm = nlmsg_data(nlh);
@@ -864,7 +864,7 @@ int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
br_debug(br, "flushing port ifindex: %d vlan id: %u flags: 0x%lx flags mask: 0x%lx\n",
desc.port_ifindex, desc.vlan_id, desc.flags, desc.flags_mask);
- br_fdb_flush(br, &desc, 0);
+ br_fdb_flush(br, &desc, portid);
return 0;
}
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 67e3288b1e40..83f2b7728947 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -1018,7 +1018,7 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack);
int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
- struct netlink_ext_ack *extack);
+ u32 portid, struct netlink_ext_ack *extack);
int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[],
const struct ndo_fdb_parms *parms, bool *notified,
struct netlink_ext_ack *extack);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e0d411c251aa..e1607a3232c7 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -5001,7 +5001,8 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
¬ified, extack);
} else {
if (ops->ndo_fdb_del_bulk)
- err = ops->ndo_fdb_del_bulk(nlh, dev, extack);
+ err = ops->ndo_fdb_del_bulk(nlh, dev, portid,
+ extack);
}
if (err)
@@ -5025,7 +5026,8 @@ 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(nlh, dev, extack);
+ err = ops->ndo_fdb_del_bulk(nlh, dev, portid,
+ extack);
}
if (!err) {
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 09/13] net: rtnetlink: Report port ID in fallback FDB notifications
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (7 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 08/13] net: rtnetlink: Report port ID in bulk FDB delete notifications Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 10/13] netlink: specs: rt-neigh: Extend the delneigh request attributes Petr Machata
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw
The previous patch made the bridge and VXLAN drivers report the port ID of
the requester in the FDB notifications that they emit. Other drivers that
implement ndo_fdb_add and ndo_fdb_del, as well as the default
implementations ndo_dflt_fdb_add() and ndo_dflt_fdb_del(), do not send
notifications themselves. Instead rtnl_fdb_add() and rtnl_fdb_del() send
one on their behalf through rtnl_fdb_notify(), and that always uses port ID
of zero.
Pass the port ID of the requester to rtnl_fdb_notify() as well, so that
the notifications sent for these devices carry it in nlmsg_pid just like
the ones from bridge and VXLAN.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
net/core/rtnetlink.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e1607a3232c7..51713666f0e3 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4721,7 +4721,7 @@ static inline size_t rtnl_fdb_nlmsg_size(const struct net_device *dev)
}
static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type,
- u16 ndm_state)
+ u16 ndm_state, u32 portid)
{
struct net *net = dev_net(dev);
struct sk_buff *skb;
@@ -4732,7 +4732,7 @@ static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type,
goto errout;
err = nlmsg_populate_fdb_fill(skb, dev, addr, vid,
- 0, 0, type, NTF_SELF, 0, ndm_state);
+ portid, 0, type, NTF_SELF, 0, ndm_state);
if (err < 0) {
kfree_skb(skb);
goto errout;
@@ -4888,7 +4888,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
if (!err && !notified) {
rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH,
- ndm->ndm_state);
+ ndm->ndm_state, parms.portid);
ndm->ndm_flags &= ~NTF_SELF;
}
}
@@ -5033,7 +5033,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
if (!err) {
if (!del_bulk && !notified)
rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH,
- ndm->ndm_state);
+ ndm->ndm_state, portid);
ndm->ndm_flags &= ~NTF_SELF;
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 10/13] netlink: specs: rt-neigh: Extend the delneigh request attributes
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (8 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 09/13] net: rtnetlink: Report port ID in fallback FDB notifications Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 11/13] tools: ynl: Add NLM_F_BULK Petr Machata
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw, David Ahern, Donald Hunter
The kernel accepts more attributes in an RTM_DELNEIGH request than the
spec lists. FDB deletion identifies the entry by NDA_LLADDR and NDA_VLAN,
and bulk deletion (NLM_F_BULK) filters entries by NDA_NDM_STATE_MASK and
NDA_NDM_FLAGS_MASK.
Add lladdr, vlan, ndm-state-mask and ndm-flags-mask to the request
attributes of delneigh, so that these requests can be built through YNL.
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
CC: David Ahern <dsahern@kernel.org>
CC: Donald Hunter <donald.hunter@gmail.com>
---
Documentation/netlink/specs/rt-neigh.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/netlink/specs/rt-neigh.yaml b/Documentation/netlink/specs/rt-neigh.yaml
index 7929e667cc7a..4dd4e3d997f0 100644
--- a/Documentation/netlink/specs/rt-neigh.yaml
+++ b/Documentation/netlink/specs/rt-neigh.yaml
@@ -380,7 +380,11 @@ operations:
value: 29
attributes:
- dst
+ - lladdr
+ - vlan
- ifindex
+ - ndm-state-mask
+ - ndm-flags-mask
-
name: delneigh-ntf
doc: Notify a neighbour deletion
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 11/13] tools: ynl: Add NLM_F_BULK
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (9 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 10/13] netlink: specs: rt-neigh: Extend the delneigh request attributes Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 12/13] selftests: net: lib: py: Add RtnlNeighFamily Petr Machata
2026-11-23 17:59 ` [PATCH net-next 13/13] selftests: net: Add a test for port ID in FDB notifications Petr Machata
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw, Donald Hunter
Add the NLM_F_BULK flag, which marks a delete request as a bulk delete, to
the netlink flags known to the YNL Python library. It has the same value as
NLM_F_ACK_TLVS, but that one is only used in replies, whereas NLM_F_BULK is
only used in requests.
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
CC: Donald Hunter <donald.hunter@gmail.com>
---
tools/net/ynl/pyynl/lib/ynl.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
index fb5acb8acded..0e9bcd0f2599 100644
--- a/tools/net/ynl/pyynl/lib/ynl.py
+++ b/tools/net/ynl/pyynl/lib/ynl.py
@@ -61,6 +61,8 @@ class Netlink:
NLM_F_CREATE = 0x400
NLM_F_APPEND = 0x800
+ NLM_F_BULK = 0x200
+
NLM_F_CAPPED = 0x100
NLM_F_ACK_TLVS = 0x200
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 12/13] selftests: net: lib: py: Add RtnlNeighFamily
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (10 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 11/13] tools: ynl: Add NLM_F_BULK Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
2026-11-23 17:59 ` [PATCH net-next 13/13] selftests: net: Add a test for port ID in FDB notifications Petr Machata
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw, Shuah Khan, linux-kselftest
Add a YnlFamily wrapper for the rt-neigh spec, next to the ones for
rt-link, rt-addr and rt-route, and export it from lib.py.
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
CC: Shuah Khan <shuah@kernel.org>
CC: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/lib/py/__init__.py | 6 ++++--
tools/testing/selftests/net/lib/py/ynl.py | 10 +++++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/lib/py/__init__.py b/tools/testing/selftests/net/lib/py/__init__.py
index b1696f432c7c..3f7696d06e6f 100644
--- a/tools/testing/selftests/net/lib/py/__init__.py
+++ b/tools/testing/selftests/net/lib/py/__init__.py
@@ -17,7 +17,8 @@ from .utils import CmdExitFailure, fd_read_timeout, cmd, bkg, defer, \
ctl_file_write, wait_file, tool, tc
from .bpf import bpf_map_set, bpf_map_dump, bpf_prog_map_ids
from .ynl import NlError, NlctrlFamily, YnlFamily, \
- EthtoolFamily, NetdevFamily, RtnlFamily, RtnlAddrFamily, RtnlRouteFamily
+ EthtoolFamily, NetdevFamily, RtnlFamily, RtnlNeighFamily, \
+ RtnlAddrFamily, RtnlRouteFamily
from .ynl import NetshaperFamily, DevlinkFamily, GtpFamily, PSPFamily, Netlink
__all__ = ["KSRC",
@@ -36,4 +37,5 @@ __all__ = ["KSRC",
"NetshaperFamily", "DevlinkFamily", "GtpFamily", "PSPFamily",
"NlError",
"YnlFamily", "EthtoolFamily", "NetdevFamily", "RtnlFamily",
- "NlctrlFamily", "RtnlAddrFamily", "RtnlRouteFamily", "Netlink"]
+ "RtnlNeighFamily", "NlctrlFamily", "RtnlAddrFamily",
+ "RtnlRouteFamily", "Netlink"]
diff --git a/tools/testing/selftests/net/lib/py/ynl.py b/tools/testing/selftests/net/lib/py/ynl.py
index 69a6e9d9b390..ac13bf1ff23d 100644
--- a/tools/testing/selftests/net/lib/py/ynl.py
+++ b/tools/testing/selftests/net/lib/py/ynl.py
@@ -29,7 +29,8 @@ except ModuleNotFoundError as e:
__all__ = [
"NlError", "NlPolicy", "Netlink", "YnlFamily", "SPEC_PATH",
- "EthtoolFamily", "RtnlFamily", "RtnlAddrFamily", "RtnlRouteFamily",
+ "EthtoolFamily", "RtnlFamily", "RtnlNeighFamily", "RtnlAddrFamily",
+ "RtnlRouteFamily",
"NetdevFamily", "NetshaperFamily", "NlctrlFamily", "DevlinkFamily",
"GtpFamily", "PSPFamily",
]
@@ -49,6 +50,13 @@ class RtnlFamily(YnlFamily):
super().__init__((SPEC_PATH / Path('rt-link.yaml')).as_posix(),
schema='', recv_size=recv_size)
+class RtnlNeighFamily(YnlFamily):
+ """Netlink interface for neighbour messages."""
+ # pylint: disable=too-few-public-methods
+ def __init__(self, recv_size=0):
+ super().__init__((SPEC_PATH / Path('rt-neigh.yaml')).as_posix(),
+ schema='', recv_size=recv_size)
+
class RtnlAddrFamily(YnlFamily):
def __init__(self, recv_size=0):
super().__init__((SPEC_PATH / Path('rt-addr.yaml')).as_posix(),
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next 13/13] selftests: net: Add a test for port ID in FDB notifications
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
` (11 preceding siblings ...)
2026-11-23 17:59 ` [PATCH net-next 12/13] selftests: net: lib: py: Add RtnlNeighFamily Petr Machata
@ 2026-11-23 17:59 ` Petr Machata
12 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2026-11-23 17:59 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Andrew Lunn, Nikolay Aleksandrov, bridge, Ido Schimmel,
Petr Machata, Andy Roulin, mlxsw, Shuah Khan, linux-kselftest
Add a test that checks that RTM_NEWNEIGH and RTM_DELNEIGH notifications
for FDB entries carry the netlink port ID of the requester in nlmsg_pid.
A listener socket subscribed to the neighbour group receives the
notifications, while two separate requester sockets, A and B, make the
changes. Entries are added through A, replaced through B and deleted
through A, and the port ID seen by the listener is compared to that of the
socket that made the particular change. The following cases are covered:
- bridge: a bridge port (NTF_MASTER) and the bridge device itself
(NTF_SELF), including a bridge with VLAN filtering, where one request
results in several notifications
- VXLAN, including replacing the remote
- macvlan, which does not send notifications by itself and thus exercises
the generic fallback in rtnetlink
- bulk delete (flush) of bridge and VXLAN entries
- bridge entries learned from traffic, which are not a result of a request
and should carry a port ID of zero
The test needs CONFIG_PACKET to send the frame that is learned.
fdb_notify.sh already covers some of the same device setups (bridge, VXLAN,
macvlan), but it checks for duplicate notifications and cannot check the
port ID, as the broadly available tools do not show nlmsg_pid. One option
would be to capture bridge monitor run with strace and parse out key tells.
But that felt like too much of an ugly hack. Another option considered was
netlink capture (nlmon plus tshark), which would add further tool
dependencies, and then, a capture does not say which socket a message was
sent through, which is needed to tell the requester's port ID from someone
else's.
Python with YNL, which the selftests already have, can read nlmsg_pid and
compare it to the requester's socket directly. So instead of extending /
consolidating with fdb_notify.sh, a new test was written.
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
CC: Shuah Khan <shuah@kernel.org>
CC: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/config | 1 +
.../selftests/net/fdb_notify_portid.py | 297 ++++++++++++++++++
3 files changed, 299 insertions(+)
create mode 100755 tools/testing/selftests/net/fdb_notify_portid.py
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index fb0a64662053..fafe30367243 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -35,6 +35,7 @@ TEST_PROGS := \
fcnal-other.sh \
fdb_flush.sh \
fdb_notify.sh \
+ fdb_notify_portid.py \
fib-onlink-tests.sh \
fib_nexthop_multiprefix.sh \
fib_nexthop_nongw.sh \
diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
index dab62cdfa27b..18dfb45fb914 100644
--- a/tools/testing/selftests/net/config
+++ b/tools/testing/selftests/net/config
@@ -126,6 +126,7 @@ CONFIG_NFT_COMPAT=m
CONFIG_NFT_NAT=m
CONFIG_NUMA=y
CONFIG_OPENVSWITCH=m
+CONFIG_PACKET=y
CONFIG_PAGE_POOL_STATS=y
CONFIG_PSAMPLE=m
CONFIG_RPS=y
diff --git a/tools/testing/selftests/net/fdb_notify_portid.py b/tools/testing/selftests/net/fdb_notify_portid.py
new file mode 100755
index 000000000000..b7b398aa8040
--- /dev/null
+++ b/tools/testing/selftests/net/fdb_notify_portid.py
@@ -0,0 +1,297 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""
+Check that FDB notifications carry the netlink port ID of the requester in
+nlmsg_pid. A listener socket subscribed to the neighbour group receives the
+notifications, while separate requester sockets make the changes. The port ID
+the listener sees is expected to match that of the requester socket.
+"""
+
+import socket
+import struct
+from collections import namedtuple
+
+from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_ne, ksft_true
+from lib.py import ksft_busy_wait
+from lib.py import ip, tool
+from lib.py import NetNS, NetNSEnter
+from lib.py import Netlink, RtnlNeighFamily
+
+RTM_NEWNEIGH = 28
+RTM_DELNEIGH = 29
+
+NTF_SELF = 0x02
+NTF_MASTER = 0x04
+
+NUD_NOARP = 0x40
+NUD_PERMANENT = 0x80
+
+ETH_P_EXP1 = 0x88b5 # Local Experimental EtherType 1
+
+Ntf = namedtuple("Ntf", "type portid addr")
+
+
+class Env:
+ """The listener socket, the two requester sockets A and B, and the
+ netlink port IDs of the latter. All sockets live in the given netns."""
+
+ @staticmethod
+ def _socket(ns):
+ with NetNSEnter(ns):
+ rtnl = RtnlNeighFamily()
+ return rtnl
+
+ def __init__(self, ns):
+ self.ns = str(ns)
+
+ self.listener = self._socket(ns)
+ self.listener.include_raw = True
+ self.listener.ntf_subscribe("rtnlgrp-neigh")
+
+ self.a = self._socket(ns)
+ self.a.sock.bind((0, 0))
+
+ self.b = self._socket(ns)
+ self.b.sock.bind((0, 0))
+
+ self.portids = {self.a: self.a.sock.getsockname()[0],
+ self.b: self.b.sock.getsockname()[0]}
+
+ ksft_ne(self.portids[self.a], self.portids[self.b])
+ ksft_ne(self.portids[self.a], 0)
+
+ def ifindex(self, name):
+ """Look up the ifindex of a device in the test netns."""
+ with NetNSEnter(self.ns):
+ return socket.if_nametoindex(name)
+
+ def ntfs(self):
+ """Return the bridge-family notifications received by the listener."""
+ self.listener.check_ntf()
+ ntfs = []
+ while self.listener.async_msg_queue.qsize() > 0:
+ msg = self.listener.async_msg_queue.get()
+ if msg['msg']['ndm-family'] == socket.AF_BRIDGE:
+ ntfs.append(Ntf(msg['raw'].nl_type, msg['raw'].nl_portid,
+ msg['msg']['lladdr']))
+ return ntfs
+
+ def check_ntfs(self, nl_type, addr, requester, count=1):
+ """Expect count notifications for addr, all from the requester."""
+ portids = [n.portid for n in self.ntfs()
+ if n.type == nl_type and n.addr == addr]
+ ksft_eq(portids, [self.portids[requester]] * count,
+ f"nlmsg_pid of {addr} notifications")
+
+
+def fdb_req(ifindex, ndm_flags, attrs):
+ """Build an AF_BRIDGE neighbour request with the given attributes."""
+ return {'ndm-family': socket.AF_BRIDGE, 'ndm-ifindex': ifindex,
+ 'ndm-flags': ndm_flags, **attrs}
+
+
+def test_msg(env, sock, message, message_type,
+ ifindex, addr, ndm_flags, flags, count, attrs):
+ """Send one request through SOCK, and expect COUNT notifications of
+ MESSAGE_TYPE about ADDR carrying the port ID of SOCK."""
+ # pylint: disable=too-many-arguments,too-many-positional-arguments
+ req = fdb_req(ifindex, ndm_flags, attrs | {"lladdr": addr})
+ sock.do(message, req, flags)
+ env.check_ntfs(message_type, addr, sock, count)
+
+
+def add_replace_del(env, ifname, addr, ndm_flags, *, add, rep, dlt, count=1):
+ """Add an entry through socket A, replace it through B, delete through A.
+ ADD, REP and DLT are the attributes of the respective requests. If REP is
+ None, the replace step is skipped."""
+ # pylint: disable=too-many-arguments
+ ifindex = env.ifindex(ifname)
+
+ test_msg(env, env.a, 'newneigh', RTM_NEWNEIGH, ifindex, addr, ndm_flags,
+ flags=[Netlink.NLM_F_CREATE | Netlink.NLM_F_EXCL],
+ count=count, attrs=add)
+
+ if rep is not None:
+ test_msg(env, env.b, 'newneigh', RTM_NEWNEIGH, ifindex, addr, ndm_flags,
+ flags=[Netlink.NLM_F_CREATE | Netlink.NLM_F_REPLACE],
+ count=count, attrs=rep)
+
+ test_msg(env, env.a, 'delneigh', RTM_DELNEIGH, ifindex, addr, ndm_flags,
+ flags=[],
+ count=count, attrs=dlt)
+
+
+def flush(env, ifname, addrs, add, dlt):
+ """Flush all permanent entries through socket A, and check that all the
+ notifications carry the port ID."""
+
+ ifindex = env.ifindex(ifname)
+
+ for addr in addrs:
+ attrs = add | {"ndm-state": NUD_PERMANENT,
+ "lladdr": addr}
+ env.a.do('newneigh', fdb_req(ifindex, NTF_SELF, attrs),
+ flags=[Netlink.NLM_F_CREATE | Netlink.NLM_F_EXCL])
+
+ env.ntfs()
+
+ attrs = dlt | {'ndm-state': NUD_PERMANENT,
+ 'ndm-state-mask': NUD_PERMANENT}
+ env.a.do('delneigh', fdb_req(ifindex, NTF_SELF, attrs),
+ flags=[Netlink.NLM_F_BULK])
+
+ ntfs = [n for n in env.ntfs() if n.type == RTM_DELNEIGH]
+
+ ksft_true({n.addr for n in ntfs} >= set(addrs),
+ "Flush did not notify about all the entries")
+ ksft_eq({n.portid for n in ntfs}, {env.portids[env.a]},
+ "nlmsg_pid of flush notifications")
+
+
+def test_bridge() -> None:
+ """Bridge port and bridge device entries: add, replace, delete."""
+ with NetNS() as ns:
+ env = Env(ns)
+
+ ip("link add br0 up type bridge vlan_default_pvid 0", ns=ns)
+ ip("link add d0 up type dummy", ns=ns)
+ ip("link set dev d0 master br0", ns=ns)
+
+ add_replace_del(env, "d0", "00:11:22:33:44:01", NTF_MASTER,
+ add={"ndm-state": NUD_PERMANENT},
+ rep={"ndm-state": NUD_NOARP},
+ dlt={})
+
+ add_replace_del(env, "br0", "00:11:22:33:44:02", NTF_SELF,
+ add={"ndm-state": NUD_PERMANENT},
+ rep=None,
+ dlt={})
+
+
+def test_bridge_vlan() -> None:
+ """Without a VID given, an entry is added and deleted in every VLAN."""
+ with NetNS() as ns:
+ env = Env(ns)
+
+ ip("link add br0 up type bridge vlan_filtering 1 vlan_default_pvid 0",
+ ns=ns)
+ ip("link add d0 up type dummy", ns=ns)
+ ip("link set dev d0 master br0", ns=ns)
+
+ tool("bridge", "vlan add dev d0 vid 10", ns=ns)
+ tool("bridge", "vlan add dev d0 vid 20", ns=ns)
+
+ # Three notifications: for VID 10 and 20, and for the entry
+ # without VLAN.
+ add_replace_del(env, "d0", "00:11:22:33:44:03", NTF_MASTER, count=3,
+ add={"ndm-state": NUD_PERMANENT},
+ rep=None,
+ dlt={})
+
+
+def test_bridge_flush() -> None:
+ """Bulk delete of bridge entries."""
+ with NetNS() as ns:
+ env = Env(ns)
+ ip("link add br0 up type bridge vlan_default_pvid 0", ns=ns)
+ ip("link add d0 up type dummy", ns=ns)
+ ip("link set dev d0 master br0", ns=ns)
+
+ flush(env, "br0", ["00:11:22:33:44:10",
+ "00:11:22:33:44:11",
+ "00:11:22:33:44:12"],
+ add={},
+ dlt={})
+
+
+def test_bridge_learned() -> None:
+ """Entries that are not a result of a request carry port ID of zero."""
+ with NetNS() as ns:
+ env = Env(ns)
+ ip("link add br0 up type bridge", ns=ns)
+ ip("link add v0 up type veth peer name v1", ns=ns)
+ ip("link set dev v0 master br0", ns=ns)
+ ip("link set dev v1 up", ns=ns)
+
+ addr = "00:11:22:33:44:31"
+ frame = (b"\xff" * 6 + bytes.fromhex(addr.replace(":", "")) +
+ struct.pack("!H", ETH_P_EXP1) + b"\0" * 46)
+ with NetNSEnter(env.ns):
+ tx = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
+ tx.bind(("v1", 0))
+
+ portids = []
+
+ def learned():
+ nonlocal portids
+ tx.send(frame)
+ portids = [n.portid for n in env.ntfs()
+ if n.type == RTM_NEWNEIGH and n.addr == addr]
+ return portids != []
+
+ # Keep sending until the entry is learned: a frame that
+ # arrives while the bridge port is not yet up is dropped
+ # without triggering learning. Once the entry exists, repeated
+ # frames only refresh it and do not generate notifications.
+ ksft_busy_wait(learned, deadline=2)
+
+ ksft_eq(portids, [0], "nlmsg_pid of learned entry")
+
+
+def test_vxlan() -> None:
+ """VXLAN entries: add, replace the remote, delete."""
+ with NetNS() as ns:
+ env = Env(ns)
+ ip("link add vx0 up type vxlan id 2000 dstport 4789", ns=ns)
+
+ add_replace_del(env, "vx0", "00:11:22:33:44:41", NTF_SELF,
+ add={"dst": "192.0.2.1", "ndm-state": NUD_PERMANENT},
+ rep={"dst": "192.0.2.2", "ndm-state": NUD_PERMANENT},
+ dlt={"dst": "192.0.2.2"})
+
+
+def test_vxlan_flush() -> None:
+ """Bulk delete of VXLAN entries."""
+ with NetNS() as ns:
+ env = Env(ns)
+ ip("link add vx0 up type vxlan id 2000 dstport 4789", ns=ns)
+
+ flush(env, "vx0", ["00:11:22:33:44:50",
+ "00:11:22:33:44:51",
+ "00:11:22:33:44:52"],
+ add={"dst": "192.0.2.1"},
+ dlt={"dst": "192.0.2.1"})
+
+
+def test_macvlan() -> None:
+ """The notifications for macvlan, which does not notify by itself, are
+ sent by the generic code in rtnetlink."""
+ with NetNS() as ns:
+ env = Env(ns)
+ ip("link add dd up type dummy", ns=ns)
+ ip("link add mv0 up link dd type macvlan mode passthru", ns=ns)
+
+ # macvlan does not support replace.
+ add_replace_del(env, "mv0", "00:11:22:33:44:61", NTF_SELF,
+ add={"ndm-state": NUD_PERMANENT},
+ rep=None,
+ dlt={})
+
+
+def main() -> None:
+ """Run all the tests."""
+ ksft_run([
+ test_bridge,
+ test_bridge_vlan,
+ test_bridge_flush,
+ test_bridge_learned,
+ test_vxlan,
+ test_vxlan_flush,
+ test_macvlan,
+ ])
+ ksft_exit()
+
+
+if __name__ == "__main__":
+ main()
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-11-23 18:03 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 17:59 [PATCH net-next 00/13] net: Report requester's port ID in FDB notifications Petr Machata
2026-11-23 17:59 ` [PATCH net-next 01/13] net: Introduce struct ndo_fdb_parms Petr Machata
2026-11-23 17:59 ` [PATCH net-next 02/13] net: Pass struct ndo_fdb_parms to ndo_dflt_fdb_{add, del}() Petr Machata
2026-11-23 17:59 ` [PATCH net-next 03/13] net: Pass portid to ndo_fdb_get through the structure Petr Machata
2026-11-23 17:59 ` [PATCH net-next 04/13] net: bridge: Pass struct ndo_fdb_parms a bit further Petr Machata
2026-11-23 17:59 ` [PATCH net-next 05/13] net: bridge: Pass portid through FDB notifications Petr Machata
2026-11-23 17:59 ` [PATCH net-next 06/13] net: vxlan: " Petr Machata
2026-11-23 17:59 ` [PATCH net-next 07/13] net: rtnetlink: Report port ID in bridge and VXLAN " Petr Machata
2026-11-23 17:59 ` [PATCH net-next 08/13] net: rtnetlink: Report port ID in bulk FDB delete notifications Petr Machata
2026-11-23 17:59 ` [PATCH net-next 09/13] net: rtnetlink: Report port ID in fallback FDB notifications Petr Machata
2026-11-23 17:59 ` [PATCH net-next 10/13] netlink: specs: rt-neigh: Extend the delneigh request attributes Petr Machata
2026-11-23 17:59 ` [PATCH net-next 11/13] tools: ynl: Add NLM_F_BULK Petr Machata
2026-11-23 17:59 ` [PATCH net-next 12/13] selftests: net: lib: py: Add RtnlNeighFamily Petr Machata
2026-11-23 17:59 ` [PATCH net-next 13/13] selftests: net: Add a test for port ID in FDB notifications Petr Machata
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox