From: David S. Miller Date: Fri, 14 Dec 2018 02:41:39 +0000 (-0800) Subject: Merge branch 'Introduce-NETDEV_PRE_CHANGEADDR' X-Git-Tag: for-linus-20190104~82^2~103 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=522185d5cb40fafeab807c1ff5ec4ad3a4688b0d;p=linux-2.6-block.git Merge branch 'Introduce-NETDEV_PRE_CHANGEADDR' Petr Machata says: ==================== 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. ==================== Signed-off-by: David S. Miller --- 522185d5cb40fafeab807c1ff5ec4ad3a4688b0d