Commit cec2500d authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_router: Re-increase scale of IPv6 nexthop groups

As explained in commit fc25996e ("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: default avatarIdo Schimmel <idosch@mellanox.com>
Reported-by: default avatarAlex Veber <alexve@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Tested-by: default avatarAlex Veber <alexve@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c290d1ab
...@@ -2999,6 +2999,7 @@ static u32 mlxsw_sp_nexthop_group_hash_obj(const void *data, u32 len, u32 seed) ...@@ -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++) { for (i = 0; i < nh_grp->count; i++) {
nh = &nh_grp->nexthops[i]; nh = &nh_grp->nexthops[i];
val ^= jhash(&nh->ifindex, sizeof(nh->ifindex), seed); val ^= jhash(&nh->ifindex, sizeof(nh->ifindex), seed);
val ^= jhash(&nh->gw_addr, sizeof(nh->gw_addr), seed);
} }
return jhash(&val, sizeof(val), seed); return jhash(&val, sizeof(val), seed);
default: default:
...@@ -3012,11 +3013,14 @@ mlxsw_sp_nexthop6_group_hash(struct mlxsw_sp_fib6_entry *fib6_entry, u32 seed) ...@@ -3012,11 +3013,14 @@ mlxsw_sp_nexthop6_group_hash(struct mlxsw_sp_fib6_entry *fib6_entry, u32 seed)
{ {
unsigned int val = fib6_entry->nrt6; unsigned int val = fib6_entry->nrt6;
struct mlxsw_sp_rt6 *mlxsw_sp_rt6; struct mlxsw_sp_rt6 *mlxsw_sp_rt6;
struct net_device *dev;
list_for_each_entry(mlxsw_sp_rt6, &fib6_entry->rt6_list, list) { 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(&dev->ifindex, sizeof(dev->ifindex), seed);
val ^= jhash(gw, sizeof(*gw), seed);
} }
return jhash(&val, sizeof(val), seed); return jhash(&val, sizeof(val), seed);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment