Skip to content

Introduce NETDEV_PRE_CHANGEADDR

Petr Machata netdev 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13net: dev: Add extack argument to dev_set_mac_address()drivers/net/bonding/bond_alb.c drivers/net/bonding/bond_main.c drivers/net/hyperv/netvsc_drv.c +10 more+29 -240 replies
2/13net: dev: Add NETDEV_PRE_CHANGEADDRinclude/linux/netdevice.h net/core/dev.c+8 -10 replies
3/13net: dev: Issue NETDEV_PRE_CHANGEADDRinclude/linux/netdevice.h net/core/dev.c net/core/dev_addr_lists.c+29 -00 replies
4/13net: bridge: Issue NETDEV_PRE_CHANGEADDRnet/bridge/br_if.c+9 -00 replies
5/13net: bridge: Handle NETDEV_PRE_CHANGEADDR from portsnet/bridge/br.c+13 -00 replies
6/13net: ipvlan: Issue NETDEV_PRE_CHANGEADDRdrivers/net/ipvlan/ipvlan_main.c+14 -00 replies
7/13net: bonding: Give bond_set_dev_addr() a return valuedrivers/net/bonding/bond_main.c+15 -80 replies
8/13net: bonding: Issue NETDEV_PRE_CHANGEADDRdrivers/net/bonding/bond_main.c+6 -00 replies
9/13mlxsw: spectrum_router: Generalize mlxsw_sp_netdevice_router_port_event()drivers/net/ethernet/mellanox/mlxsw/spectrum.c drivers/net/ethernet/mellanox/mlxsw/spectrum.h drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c+30 -120 replies
10/13mlxsw: spectrum: Add mlxsw_sp.mac_maskdrivers/net/ethernet/mellanox/mlxsw/spectrum.c drivers/net/ethernet/mellanox/mlxsw/spectrum.h+10 -00 replies
11/13mlxsw: spectrum_router: Veto unsupported RIF MAC addressesdrivers/net/ethernet/mellanox/mlxsw/spectrum.c drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c+52 -10 replies
12/13selftests: mlxsw: Test RIF MAC vetoingtools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh+91 -00 replies
13/13selftests: mlxsw: Test FID RIF MAC vetoingtools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh+79 -00 replies

Reviews trailers per patch

11 of 13 patches have a Reviewed-by or Acked-by.

PatchJiri PirkoIdo Schimmel
1/13A-b R-b
2/13A-b R-b
3/13A-b R-b
4/13A-b R-b
5/13A-b R-b
6/13A-b R-b
7/13A-b R-b
8/13A-b R-b
9/13A-b R-b
10/13A-b R-b
11/13A-b R-b
12/13
13/13

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH net-next 00/13] Introduce NETDEV_PRE_CHANGEADDR

Spectrum devices have a limitation that all router interfaces need to have the same address prefix. In Spectrum-1, the requirement is for the initial 38 bits of all RIFs to be the same, in Spectrum-2 the limit is 36 bits. Currently violations of this requirement are not diagnosed. At the same time, if the condition is not upheld, the mismatched MAC address ends up overwriting the common prefix, and all RIF MAC addresses silently change to the new prefix.

It is therefore desirable to be able at least to diagnose the issue, and better to reject attempts to change MAC addresses in ways that is incompatible with the device.

Currently MAC address changes are notified through emission of NETDEV_CHANGEADDR, which is done after the change. Extending this message to allow vetoing is certainly possible, but several other notification types have instead adopted a simple two-stage approach:
first a "pre" notification is sent to make sure all interested parties are OK with the change that's about to be done. Then the change is done, and afterwards a "post" notification is sent.

This dual approach is easier to use: when the change is vetoed, nothing has changed yet, and it's therefore unnecessary to roll anything back. Therefore this patchset introduces it for NETDEV_CHANGEADDR as well.

One prominent path to emitting NETDEV_CHANGEADDR is through dev_set_mac_address(). Therefore in patch #1, give this function an extack argument, so that a textual reason for rejection (or a warning) can be communicated back to the user.

In patch #2, add the new notification type. In patch #3, have dev.c emit the notification for instances of dev_addr change, or addition of an address to dev_addrs list.

In patches #4 and #5, extend the bridge driver to handle and emit the new notifier.

In patch #6, change IPVLAN to emit the new notifier.

Likewise for bonding driver in patches #7 and #8. Note that the team driver doesn't need this treatment, as it goes through dev_set_mac_address().

In patches #9, #10 and #11 adapt mlxsw to veto MAC addresses on router interfaces, if they violate the requirement that all RIF MAC addresses have the same prefix.

Finally in patches #12 and #13, add a test for vetoing of a direct change of a port device MAC, and indirect change of a bridge MAC.

Petr Machata (13):
net: dev: Add extack argument to dev_set_mac_address()
net: dev: Add NETDEV_PRE_CHANGEADDR
net: dev: Issue NETDEV_PRE_CHANGEADDR
net: bridge: Issue NETDEV_PRE_CHANGEADDR
net: bridge: Handle NETDEV_PRE_CHANGEADDR from ports
net: ipvlan: Issue NETDEV_PRE_CHANGEADDR
net: bonding: Give bond_set_dev_addr() a return value
net: bonding: Issue NETDEV_PRE_CHANGEADDR
mlxsw: spectrum_router: Generalize
mlxsw_sp_netdevice_router_port_event()
mlxsw: spectrum: Add mlxsw_sp.mac_mask
mlxsw: spectrum_router: Veto unsupported RIF MAC addresses
selftests: mlxsw: Test RIF MAC vetoing
selftests: mlxsw: Test FID RIF MAC vetoing

 drivers/net/bonding/bond_alb.c                     |   9 +-
 drivers/net/bonding/bond_main.c                    |  44 ++++--
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     |  15 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h     |   4 +-
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  |  86 +++++++++--
 drivers/net/hyperv/netvsc_drv.c                    |   4 +-
 drivers/net/ipvlan/ipvlan_main.c                   |  14 ++
 drivers/net/macvlan.c                              |   4 +-
 drivers/net/tap.c                                  |   2 +-
 drivers/net/team/team.c                            |   2 +-
 drivers/net/tun.c                                  |   2 +-
 drivers/usb/gadget/function/u_ether.c              |   2 +-
 include/linux/netdevice.h                          |  13 +-
 net/bridge/br.c                                    |  13 ++
 net/bridge/br_if.c                                 |   9 ++
 net/core/dev.c                                     |  29 +++-
 net/core/dev_addr_lists.c                          |   3 +
 net/core/dev_ioctl.c                               |   2 +-
 net/core/rtnetlink.c                               |   2 +-
 net/ieee802154/nl-phy.c                            |   2 +-
 .../selftests/drivers/net/mlxsw/rtnetlink.sh       | 170 +++++++++++++++++++++
 21 files changed, 385 insertions(+), 46 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh
Signature · 1 line
2.4.11