]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mlxsw: spectrum_router: Re-increase scale of IPv6 nexthop groups
authorIdo Schimmel <idosch@mellanox.com>
Sun, 19 Apr 2020 07:01:05 +0000 (10:01 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Apr 2020 18:57:33 +0000 (11:57 -0700)
As explained in commit 23387fe9ce6b ("mlxsw: spectrum_router: Increase
scale of IPv6 nexthop groups"), each nexthop group is hashed by XOR-ing
the interface indexes of all the member nexthop devices.

To avoid many different nexthop groups ending up using the same key, the
above commit started hashing the interface indexes themselves before
they are XOR-ed.

However, in cases in which there are many nexthop groups that all use
the same nexthop device and only differ in the gateway IP, we can still
end up in a situation in which all the groups are using the same key.
This eventually leads to -EBUSY error from rhashtable during insertion.

Improve the situation by also making the gateway IP part of the key.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reported-by: Alex Veber <alexve@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Tested-by: Alex Veber <alexve@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index d5bca1be3ef53e664ae89fbac4831de37859accd..71aee491461992e370c04c576eefaac66de1c56e 100644 (file)
@@ -2999,6 +2999,7 @@ static u32 mlxsw_sp_nexthop_group_hash_obj(const void *data, u32 len, u32 seed)
                for (i = 0; i < nh_grp->count; i++) {
                        nh = &nh_grp->nexthops[i];
                        val ^= jhash(&nh->ifindex, sizeof(nh->ifindex), seed);
+                       val ^= jhash(&nh->gw_addr, sizeof(nh->gw_addr), seed);
                }
                return jhash(&val, sizeof(val), seed);
        default:
@@ -3012,11 +3013,14 @@ mlxsw_sp_nexthop6_group_hash(struct mlxsw_sp_fib6_entry *fib6_entry, u32 seed)
 {
        unsigned int val = fib6_entry->nrt6;
        struct mlxsw_sp_rt6 *mlxsw_sp_rt6;
-       struct net_device *dev;
 
        list_for_each_entry(mlxsw_sp_rt6, &fib6_entry->rt6_list, list) {
-               dev = mlxsw_sp_rt6->rt->fib6_nh->fib_nh_dev;
+               struct fib6_nh *fib6_nh = mlxsw_sp_rt6->rt->fib6_nh;
+               struct net_device *dev = fib6_nh->fib_nh_dev;
+               struct in6_addr *gw = &fib6_nh->fib_nh_gw6;
+
                val ^= jhash(&dev->ifindex, sizeof(dev->ifindex), seed);
+               val ^= jhash(gw, sizeof(*gw), seed);
        }
 
        return jhash(&val, sizeof(val), seed);