• Amit Cohen's avatar
    mlxsw: Avoid warning during ip6gre device removal · 810c2f0a
    Amit Cohen authored
    IPv6 addresses which are used for tunnels are stored in a hash table
    with reference counting. When a new GRE tunnel is configured, the driver
    is notified and configures it in hardware.
    
    Currently, any change in the tunnel is not applied in the driver. It
    means that if the remote address is changed, the driver is not aware of
    this change and the first address will be used.
    
    This behavior results in a warning [1] in scenarios such as the
    following:
    
     # ip link add name gre1 type ip6gre local 2000::3 remote 2000::fffe tos inherit ttl inherit
     # ip link set name gre1 type ip6gre local 2000::3 remote 2000::ffff ttl inherit
     # ip link delete gre1
    
    The change of the address is not applied in the driver. Currently, the
    driver uses the remote address which is stored in the 'parms' of the
    overlay device. When the tunnel is removed, the new IPv6 address is
    used, the driver tries to release it, but as it is not aware of the
    change, this address is not configured and it warns about releasing non
    existing IPv6 address.
    
    Fix it by using the IPv6 address which is cached in the IPIP entry, this
    address is the last one that the driver used, so even in cases such the
    above, the first address will be released, without any warning.
    
    [1]:
    
    WARNING: CPU: 1 PID: 2197 at drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2920 mlxsw_sp_ipv6_addr_put+0x146/0x220 [mlxsw_spectrum]
    ...
    CPU: 1 PID: 2197 Comm: ip Not tainted 5.17.0-rc8-custom-95062-gc1e5ded51a9a #84
    Hardware name: Mellanox Technologies Ltd. MSN4700/VMOD0010, BIOS 5.11 07/12/2021
    RIP: 0010:mlxsw_sp_ipv6_addr_put+0x146/0x220 [mlxsw_spectrum]
    ...
    Call Trace:
     <TASK>
     mlxsw_sp2_ipip_rem_addr_unset_gre6+0xf1/0x120 [mlxsw_spectrum]
     mlxsw_sp_netdevice_ipip_ol_event+0xdb/0x640 [mlxsw_spectrum]
     mlxsw_sp_netdevice_event+0xc4/0x850 [mlxsw_spectrum]
     raw_notifier_call_chain+0x3c/0x50
     call_netdevice_notifiers_info+0x2f/0x80
     unregister_netdevice_many+0x311/0x6d0
     rtnl_dellink+0x136/0x360
     rtnetlink_rcv_msg+0x12f/0x380
     netlink_rcv_skb+0x49/0xf0
     netlink_unicast+0x233/0x340
     netlink_sendmsg+0x202/0x440
     ____sys_sendmsg+0x1f3/0x220
     ___sys_sendmsg+0x70/0xb0
     __sys_sendmsg+0x54/0xa0
     do_syscall_64+0x35/0x80
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    Fixes: e846efe2 ("mlxsw: spectrum: Add hash table for IPv6 address mapping")
    Reported-by: default avatarMaksym Yaremchuk <maksymy@nvidia.com>
    Signed-off-by: default avatarAmit Cohen <amcohen@nvidia.com>
    Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Link: https://lore.kernel.org/r/20220511115747.238602-1-idosch@nvidia.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    810c2f0a
spectrum_ipip.c 19.9 KB