driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8MTN4
-----------------------------------------------------------------------
In ROH mode, when the IP address of a VLAN device changes, we need to change the MAC address of the VLAN device to maintain the mapping between the IP address, EID, and MAC address. In this way, the ARP fast response in ROH mode can take effect.
Fixes:55901e4aae1e("roh/core: Add support for inetaddr notifier in roh/core") Signed-off-by: Ke Chen chenke54@huawei.com Reviewed-by: Gang Zhang gang.zhang@huawei.com --- drivers/roh/core/core.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/roh/core/core.c b/drivers/roh/core/core.c index 1b8041004be3..9b867f2cc2d5 100644 --- a/drivers/roh/core/core.c +++ b/drivers/roh/core/core.c @@ -3,6 +3,7 @@
#include <linux/pci.h> #include <linux/inetdevice.h> +#include <linux/if_vlan.h>
#include "core_priv.h" #include "core.h" @@ -245,12 +246,26 @@ static int roh_ipv4_event(struct notifier_block *this, unsigned long event, void struct in_ifaddr *ifa = ptr; struct roh_device *device; struct net_device *ndev; + struct sockaddr s_addr; struct sockaddr_in in; int ret;
+ if (event != NETDEV_UP) + return NOTIFY_DONE; + device = container_of(this, struct roh_device, nb); ndev = ifa->ifa_dev->dev; - if (device->netdev != ndev || event != NETDEV_UP) + + if (is_vlan_dev(ndev)) { + if (vlan_dev_real_dev(ndev) == device->netdev) { + s_addr.sa_family = ndev->type; + u64_to_ether_addr(be32_to_cpu(ifa->ifa_address) & 0xffffff, s_addr.sa_data); + dev_set_mac_address(ndev, &s_addr, NULL); + } + return NOTIFY_DONE; + } + + if (device->netdev != ndev) return NOTIFY_DONE;
in.sin_addr.s_addr = ifa->ifa_address;