Lines Matching +full:local +full:- +full:mac +full:- +full:address

2 # SPDX-License-Identifier: GPL-2.0
29 if [[ -f $relative_path/forwarding.config ]]; then
38 tc -j &> /dev/null
39 if [[ $? -ne 0 ]]; then
48 if [[ $? -ne 0 ]]; then
57 if [[ $? -ne 0 ]]; then
65 tc actions help 2>&1 | grep -q hw_stats
66 if [[ $? -ne 0 ]]; then
72 if [[ "$(id -u)" -ne 0 ]]; then
83 local cmd=$1; shift
85 if [[ ! -x "$(command -v "$cmd")" ]]; then
94 if [[ ! -v NUM_NETIFS ]]; then
104 while [[ $# -gt 0 ]]; do
105 if [[ "$count" -eq "0" ]]; then
107 declare -A NETIFS
119 local i
122 local j=$((i+1))
125 if [[ $? -ne 0 ]]; then
128 if [[ $? -ne 0 ]]; then
154 if [[ $? -ne 0 ]]; then
165 # Per-test return value. Clear at the beginning of each test.
170 local err=$1
171 local msg=$2
173 if [[ $RET -eq 0 && $err -ne 0 ]]; then
181 local err=$1
182 local msg=$2
184 if [[ $RET -eq 0 && $err -eq 0 ]]; then
192 local should_fail=$1; shift
193 local err=$1; shift
194 local what=$1; shift
205 local test_name=$1
206 local opt_str=$2
208 if [[ $# -eq 2 ]]; then
212 if [[ $RET -ne 0 ]]; then
214 printf "TEST: %-60s [FAIL]\n" "$test_name $opt_str"
215 if [[ ! -z "$retmsg" ]]; then
226 printf "TEST: %-60s [ OK ]\n" "$test_name $opt_str"
232 local msg=$1
239 local timeout=$1; shift
241 local start_time="$(date -u +%s%3N)"
244 local out
246 local ret=$?
248 echo -n "$out"
252 local current_time="$(date -u +%s%3N)"
253 if ((current_time - start_time > timeout)); then
254 echo -n "$out"
268 local addr=$1; shift
269 local word
270 local flag
274 if [ "$1" == "-v" ]; then
284 "$@" | grep -q offload
289 local expr=$1; shift
290 local current=$("$@")
298 local timeout=$1; shift
299 local delta=$1; shift
301 local base=$("$@")
307 local dev=$1; shift
308 local wait_time=${1:-$WAIT_TIME}; shift
321 local dev=$1; shift
322 local max_iterations=${1:-$WAIT_TIMEOUT}; shift
323 local wait_time=${1:-$WAIT_TIME}; shift
324 local i
329 if [[ $? -ne 0 ]]; then
342 local num_netifs=${1:-$NUM_NETIFS}
343 local i
355 local cmd=$1
356 local jq_exp=$2
357 local jq_opts=$3
358 local ret
359 local output
364 if [[ $ret -ne 0 ]]; then
367 output=$(echo $output | jq -r $jq_opts "$jq_exp")
369 if [[ $ret -ne 0 ]]; then
373 # return success only in case of non-empty output
374 [ ! -z "$output" ]
379 local dev=$1; shift
381 while lldptool -t -i $dev -V APP -c app | grep -Eq "pending|unknown"; do
393 # weirdness as newly-added APP rules conflict with the old ones,
408 ip -4 rule add pref 32765 table local
409 ip -4 rule del pref 0
410 ip -6 rule add pref 32765 table local
411 ip -6 rule del pref 0
416 ip -6 rule add pref 0 table local
417 ip -6 rule del pref 32765
418 ip -4 rule add pref 0 table local
419 ip -4 rule del pref 32765
423 declare -A __TB_IDS
427 local vrf_name=$1
436 local vrf_name=$1
443 local vrf_name=$1
444 local tb_id
450 ip -4 route add table $tb_id unreachable default metric 4278198272
451 ip -6 route add table $tb_id unreachable default metric 4278198272
456 local vrf_name=$1
457 local tb_id
462 ip -6 route del table $tb_id unreachable default metric 4278198272
463 ip -4 route del table $tb_id unreachable default metric 4278198272
469 local if_name=$1
470 local add_del=$2
471 local array
478 ip address $add_del $addrstr dev $if_name
484 local if_name=$1; shift
485 local vrf_name=$1; shift
486 local addrs=("${@}")
496 local if_name=$1; shift
497 local addrs=("${@}")
507 local if_name=$1
508 local vrf_name
509 local array
522 local if_name=$1
523 local vrf_name
524 local array
536 local name=$1; shift
537 local type=$1; shift
538 local local=$1; shift
539 local remote=$1; shift
542 local $local remote $remote "$@"
548 local name=$1; shift
555 local if_name=$1; shift
556 local vid=$1; shift
557 local vrf=$1; shift
558 local ips=("${@}")
559 local name=$if_name.$vid
571 local if_name=$1; shift
572 local vid=$1; shift
573 local name=$if_name.$vid
580 local if_name=$1; shift
581 local mode=$1; shift
584 $TEAMD -t $if_name -d -c '{"runner": {"name": "'$mode'"}}'
595 local if_name=$1; shift
597 $TEAMD -t $if_name -k
602 local if_name=$1
604 ip -j link show dev $if_name | jq -r '.[]["master"]'
609 local if_name=$1; shift
610 local dir=$1; shift
611 local stat=$1; shift
613 ip -j -s link show dev $if_name \
629 local dev=$1; shift
630 local pref=$1; shift
631 local dir=$1; shift
632 local selector=${1:-.packets}; shift
634 tc -j -s filter show dev $dev ${dir:-ingress} pref $pref \
640 local id=$1; shift
641 local handle=$1; shift
642 local selector=${1:-.packets}; shift
644 tc -j -s filter show $id \
651 local dev=$1; shift
652 local stat=$1; shift
654 ethtool -S $dev | grep "^ *$stat:" | head -n 1 | cut -d: -f2
659 local dev=$1; shift
660 local handle=$1; shift
661 local selector=$1; shift
663 tc -j -s qdisc show dev "$dev" \
669 local dev=$1; shift
670 local parent=$1; shift
671 local selector=$1; shift
673 tc -j -s qdisc show dev "$dev" invisible \
679 local speed=$1; shift
694 local t0=$1; shift
695 local t1=$1; shift
696 local interval=$1; shift
698 echo $((8 * (t1 - t0) / interval))
703 local if_name=$1
705 ip -j link show dev $if_name | jq -r '.[]["address"]'
710 local bridge=$1
711 local ageing_time
714 ageing_time=$(ip -j -d link show dev $bridge \
719 declare -A SYSCTL_ORIG
722 local key=$1; shift
723 local value=$1; shift
725 SYSCTL_ORIG[$key]=$(sysctl -n $key)
726 sysctl -qw $key=$value
731 local key=$1; shift
733 sysctl -qw $key=${SYSCTL_ORIG["$key"]}
748 declare -A MTU_ORIG
751 local dev=$1; shift
752 local mtu=$1; shift
754 MTU_ORIG["$dev"]=$(ip -j link show dev $dev | jq -e '.[].mtu')
760 local dev=$1; shift
767 local num_netifs=${1:-$NUM_NETIFS}
770 ethtool -k ${NETIFS[p$i]} \
771 | grep "hw-tc-offload: on" &> /dev/null
772 if [[ $? -ne 0 ]]; then
782 local dev=$1; shift
783 local direction=$1; shift
785 # Some devices may not support or need in-hardware trapping of traffic
786 # (e.g. the veth pairs that this library creates for non-existent
798 local dev=$1; shift
799 local direction=$1; shift
806 # For slow-path testing, we need to install a trap to get to
822 local add_del=$1; shift
823 local pref=$1; shift
824 local vsuf=$1; shift
825 local tundev=$1; shift
826 local filter=$1; shift
856 local add_del=$1; shift
857 local pref=$1; shift
858 local dev=$1; shift
859 local filter=$1; shift
879 local add_del=$1; shift
880 local dev=$1; shift
881 local base=$1; shift
882 local dscp;
893 local dev=$1; shift
894 local base=$1; shift
901 local dev=$1; shift
902 local base=$1; shift
909 local dev=$1; shift
910 local base=$1; shift
913 local dscp=$((base + prio))
914 local t=$(tc_rule_stats_get $dev $((dscp + 100)))
921 local dev=$1; shift
932 local current_test
934 for current_test in ${TESTS:-$ALL_TESTS}; do
941 local desc="$1"
942 local weight_rp12=$2
943 local weight_rp13=$3
944 local packets_rp12=$4
945 local packets_rp13=$5
946 local weights_ratio packets_ratio diff
950 if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
952 | bc -l)
955 | bc -l)
958 if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then
965 if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
967 | bc -l)
970 | bc -l)
973 diff=$(echo $weights_ratio - $packets_ratio | bc -l)
974 diff=${diff#-}
976 test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0
984 local name=$1; shift
986 ip netns exec $name bash <<-EOF
998 local if_name=$1
999 local dip=$2
1000 local args=$3
1001 local vrf_name
1005 $PING $args $dip -c 10 -i 0.1 -w $PING_TIMEOUT &> /dev/null
1019 local if_name=$1
1020 local dip=$2
1021 local args=$3
1022 local vrf_name
1026 $PING6 $args $dip -c 10 -i 0.1 -w $PING_TIMEOUT &> /dev/null
1040 local bridge=$1
1041 local br_port1=$2 # Connected to `host1_if`.
1042 local host1_if=$3
1043 local host2_if=$4
1044 local mac=de:ad:be:ef:13:37
1045 local ageing_time
1049 bridge -j fdb show br $bridge brport $br_port1 \
1050 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1060 flower dst_mac $mac action drop
1062 $MZ $host2_if -c 1 -p 64 -b $mac -t ip -q
1065 tc -j -s filter show dev $host1_if ingress \
1066 | jq -e ".[] | select(.options.handle == 101) \
1070 $MZ $host1_if -c 1 -p 64 -a $mac -t ip -q
1073 bridge -j fdb show br $bridge brport $br_port1 \
1074 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1077 $MZ $host2_if -c 1 -p 64 -b $mac -t ip -q
1080 tc -j -s filter show dev $host1_if ingress \
1081 | jq -e ".[] | select(.options.handle == 101) \
1086 # record was aged-out.
1090 bridge -j fdb show br $bridge brport $br_port1 \
1091 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1096 $MZ $host1_if -c 1 -p 64 -a $mac -t ip -q
1099 bridge -j fdb show br $bridge brport $br_port1 \
1100 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1115 local should_flood=$1
1116 local mac=$2
1117 local ip=$3
1118 local host1_if=$4
1119 local host2_if=$5
1120 local err=0
1126 flower dst_mac $mac action drop
1128 $MZ $host1_if -c 1 -p 64 -b $mac -B $ip -t ip -q
1131 tc -j -s filter show dev $host2_if ingress \
1132 | jq -e ".[] | select(.options.handle == 101) \
1134 if [[ $? -ne 0 && $should_flood == "true" || \
1135 $? -eq 0 && $should_flood == "false" ]]; then
1147 local br_port=$1
1148 local host1_if=$2
1149 local host2_if=$3
1150 local mac=de:ad:be:ef:13:37
1151 local ip=192.0.2.100
1157 flood_test_do false $mac $ip $host1_if $host2_if
1162 flood_test_do true $mac $ip $host1_if $host2_if
1170 local br_port=$1
1171 local host1_if=$2
1172 local host2_if=$3
1173 local mac=01:00:5e:00:00:01
1174 local ip=239.0.0.1
1180 flood_test_do false $mac $ip $host1_if $host2_if
1185 flood_test_do true $mac $ip $host1_if $host2_if
1194 local br_port=$1
1195 local host1_if=$2
1196 local host2_if=$3
1204 local proto=$1; shift
1205 local h_in=$1; shift # Where the traffic egresses the host
1206 local sip=$1; shift
1207 local dip=$1; shift
1208 local dmac=$1; shift
1210 $MZ $h_in -p 8000 -A $sip -B $dip -c 0 \
1211 -a own -b $dmac -t "$proto" -q "$@" &
1233 local if_name=$1; shift
1234 local ns=$1; shift
1239 if [ -z $ns ]; then
1245 if [ -z $SUDO_USER ] ; then
1248 capuser="-Z $SUDO_USER"
1251 $ns_cmd tcpdump -e -n -Q in -i $if_name \
1252 -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
1271 tcpdump -e -n -r $capfile 2>&1