| .. | .. |
|---|
| 2 | 2 | # SPDX-License-Identifier: GPL-2.0 |
|---|
| 3 | 3 | |
|---|
| 4 | 4 | ROUTER_NUM_NETIFS=4 |
|---|
| 5 | +: ${TIMEOUT:=20000} # ms |
|---|
| 5 | 6 | |
|---|
| 6 | 7 | router_h1_create() |
|---|
| 7 | 8 | { |
|---|
| 8 | 9 | simple_if_init $h1 192.0.1.1/24 |
|---|
| 9 | | - ip route add 193.0.0.0/8 via 192.0.1.2 dev $h1 |
|---|
| 10 | 10 | } |
|---|
| 11 | 11 | |
|---|
| 12 | 12 | router_h1_destroy() |
|---|
| 13 | 13 | { |
|---|
| 14 | | - ip route del 193.0.0.0/8 via 192.0.1.2 dev $h1 |
|---|
| 15 | 14 | simple_if_fini $h1 192.0.1.1/24 |
|---|
| 16 | 15 | } |
|---|
| 17 | 16 | |
|---|
| .. | .. |
|---|
| 64 | 63 | router_create |
|---|
| 65 | 64 | } |
|---|
| 66 | 65 | |
|---|
| 67 | | -router_offload_validate() |
|---|
| 66 | +wait_for_routes() |
|---|
| 68 | 67 | { |
|---|
| 69 | | - local route_count=$1 |
|---|
| 70 | | - local offloaded_count |
|---|
| 68 | + local t0=$1; shift |
|---|
| 69 | + local route_count=$1; shift |
|---|
| 71 | 70 | |
|---|
| 72 | | - offloaded_count=$(ip route | grep -o 'offload' | wc -l) |
|---|
| 73 | | - [[ $offloaded_count -ge $route_count ]] |
|---|
| 71 | + local t1=$(ip route | grep -o 'offload' | wc -l) |
|---|
| 72 | + local delta=$((t1 - t0)) |
|---|
| 73 | + echo $delta |
|---|
| 74 | + [[ $delta -ge $route_count ]] |
|---|
| 74 | 75 | } |
|---|
| 75 | 76 | |
|---|
| 76 | 77 | router_routes_create() |
|---|
| .. | .. |
|---|
| 90 | 91 | break 3 |
|---|
| 91 | 92 | fi |
|---|
| 92 | 93 | |
|---|
| 93 | | - echo route add 193.${i}.${j}.${k}/32 via \ |
|---|
| 94 | | - 192.0.2.1 dev $rp2 >> $ROUTE_FILE |
|---|
| 94 | + echo route add 193.${i}.${j}.${k}/32 dev $rp2 \ |
|---|
| 95 | + >> $ROUTE_FILE |
|---|
| 95 | 96 | ((count++)) |
|---|
| 96 | 97 | done |
|---|
| 97 | 98 | done |
|---|
| .. | .. |
|---|
| 111 | 112 | { |
|---|
| 112 | 113 | local route_count=$1 |
|---|
| 113 | 114 | local should_fail=$2 |
|---|
| 114 | | - local count=0 |
|---|
| 115 | + local delta |
|---|
| 115 | 116 | |
|---|
| 116 | 117 | RET=0 |
|---|
| 117 | 118 | |
|---|
| 119 | + local t0=$(ip route | grep -o 'offload' | wc -l) |
|---|
| 118 | 120 | router_routes_create $route_count |
|---|
| 121 | + delta=$(busywait "$TIMEOUT" wait_for_routes $t0 $route_count) |
|---|
| 119 | 122 | |
|---|
| 120 | | - router_offload_validate $route_count |
|---|
| 121 | | - check_err_fail $should_fail $? "Offload of $route_count routes" |
|---|
| 123 | + check_err_fail $should_fail $? "Offload routes: Expected $route_count, got $delta." |
|---|
| 122 | 124 | if [[ $RET -ne 0 ]] || [[ $should_fail -eq 1 ]]; then |
|---|
| 123 | 125 | return |
|---|
| 124 | 126 | fi |
|---|
| 125 | | - |
|---|
| 126 | | - tc filter add dev $h2 ingress protocol ip pref 1 flower \ |
|---|
| 127 | | - skip_sw dst_ip 193.0.0.0/8 action drop |
|---|
| 128 | | - |
|---|
| 129 | | - for i in {0..255} |
|---|
| 130 | | - do |
|---|
| 131 | | - for j in {0..255} |
|---|
| 132 | | - do |
|---|
| 133 | | - for k in {0..255} |
|---|
| 134 | | - do |
|---|
| 135 | | - if [[ $count -eq $route_count ]]; then |
|---|
| 136 | | - break 3 |
|---|
| 137 | | - fi |
|---|
| 138 | | - |
|---|
| 139 | | - $MZ $h1 -c 1 -p 64 -a $h1mac -b $rp1mac \ |
|---|
| 140 | | - -A 192.0.1.1 -B 193.${i}.${j}.${k} \ |
|---|
| 141 | | - -t ip -q |
|---|
| 142 | | - ((count++)) |
|---|
| 143 | | - done |
|---|
| 144 | | - done |
|---|
| 145 | | - done |
|---|
| 146 | | - |
|---|
| 147 | | - tc_check_packets "dev $h2 ingress" 1 $route_count |
|---|
| 148 | | - check_err $? "Offload mismatch" |
|---|
| 149 | | - |
|---|
| 150 | | - tc filter del dev $h2 ingress protocol ip pref 1 flower \ |
|---|
| 151 | | - skip_sw dst_ip 193.0.0.0/8 action drop |
|---|
| 152 | 127 | |
|---|
| 153 | 128 | router_routes_destroy |
|---|
| 154 | 129 | } |
|---|