Skip to content

Commit

Permalink
selftests: mlxsw: Test unresolved neigh trap with resilient nexthop g…
Browse files Browse the repository at this point in the history
…roups

The number of nexthop buckets in a resilient nexthop group never
changes, so when the gateway address of a nexthop cannot be resolved,
the nexthop buckets are programmed to trap packets to the CPU in order
to trigger resolution. For example:

 # ip nexthop add id 1 via 198.51.100.1 dev swp3
 # ip nexthop add id 10 group 1 type resilient buckets 32
 # ip nexthop bucket get id 10 index 0
 id 10 index 0 idle_time 1.44 nhid 1 trap

Where 198.51.100.1 is a made-up IP.

Test that in this case packets are indeed trapped to the CPU via the
unresolved neigh trap.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ido Schimmel authored and David S. Miller committed Mar 24, 2021
1 parent 03490a8 commit 8615847
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,44 @@ __invalid_nexthop_test()
log_test "Unresolved neigh: nexthop does not exist: $desc"
}

__invalid_nexthop_bucket_test()
{
local desc=$1; shift
local dip=$1; shift
local via_add=$1; shift
local trap_name="unresolved_neigh"

RET=0

# Check that route to nexthop that does not exist triggers
# unresolved_neigh
ip nexthop add id 1 via $via_add dev $rp2
ip nexthop add id 10 group 1 type resilient buckets 32
ip route add $dip nhid 10

t0_packets=$(devlink_trap_rx_packets_get $trap_name)
ping_do $h1 $dip
t1_packets=$(devlink_trap_rx_packets_get $trap_name)

if [[ $t0_packets -eq $t1_packets ]]; then
check_err 1 "Trap counter did not increase"
fi

ip route del $dip nhid 10
ip nexthop del id 10
ip nexthop del id 1
log_test "Unresolved neigh: nexthop bucket does not exist: $desc"
}

unresolved_neigh_test()
{
__host_miss_test "IPv4" 198.51.100.1
__host_miss_test "IPv6" 2001:db8:2::1
__invalid_nexthop_test "IPv4" 198.51.100.1 198.51.100.3 24 198.51.100.4
__invalid_nexthop_test "IPv6" 2001:db8:2::1 2001:db8:2::3 64 \
2001:db8:2::4
__invalid_nexthop_bucket_test "IPv4" 198.51.100.1 198.51.100.4
__invalid_nexthop_bucket_test "IPv6" 2001:db8:2::1 2001:db8:2::4
}

vrf_without_routes_create()
Expand Down

0 comments on commit 8615847

Please sign in to comment.