Lines Matching +full:local +full:- +full:mac +full:- +full:address
2 # SPDX-License-Identifier: GPL-2.0
37 if [[ -f $relative_path/forwarding.config ]]; then
41 # Kselftest framework requirement - SKIP code is 4.
46 local timeout=$1; shift
48 local start_time="$(date -u +%s%3N)"
51 local out
53 local ret=$?
55 echo -n "$out"
59 local current_time="$(date -u +%s%3N)"
60 if ((current_time - start_time > timeout)); then
61 echo -n "$out"
72 tc -j &> /dev/null
73 if [[ $? -ne 0 ]]; then
82 local dev=$1; shift
86 if [[ $? -ne 0 ]]; then
97 local dev=$1; shift
98 local ret;
104 if [[ $? -ne 0 ]]; then
105 echo "SKIP: iproute2 too old; tc-flower is missing extended MPLS support"
109 tc -j filter show dev $dev ingress protocol mpls_uc | jq . &> /dev/null
114 if [[ $ret -ne 0 ]]; then
115 echo "SKIP: iproute2 too old; tc-flower produces invalid json output for extended MPLS filters"
123 if [[ $? -ne 0 ]]; then
132 if [[ $? -ne 0 ]]; then
140 tc actions help 2>&1 | grep -q hw_stats
141 if [[ $? -ne 0 ]]; then
149 tc qdisc add dev lo mqprio help 2>&1 | grep -q "fp "
150 if [[ $? -ne 0 ]]; then
158 ethtool --help 2>&1| grep lanes &> /dev/null
159 if [[ $? -ne 0 ]]; then
167 ethtool --help 2>&1| grep -- '--show-mm' &> /dev/null
168 if [[ $? -ne 0 ]]; then
169 echo "SKIP: ethtool too old; it is missing MAC Merge layer support"
176 ethtool --help 2>&1| grep -- '--all-groups' &> /dev/null
177 if [[ $? -ne 0 ]]; then
185 local dev=$1; shift
186 local grp=$1; shift
188 [ 0 -ne $(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null \
194 if ! bridge -d link show | grep -q " locked"; then
202 if ! bridge -d link show | grep -q "mab"; then
210 local kind=$(ip -j -d link show dev ${NETIFS[p1]} |
211 jq -r '.[].linkinfo.info_kind')
219 if [[ "$(id -u)" -ne 0 ]]; then
230 local cmd=$1; shift
232 if [[ ! -x "$(command -v "$cmd")" ]]; then
251 if [[ ! -v NUM_NETIFS ]]; then
261 while [[ $# -gt 0 ]]; do
262 if [[ "$count" -eq "0" ]]; then
264 declare -A NETIFS
276 local i
279 local j=$((i+1))
281 if [ -z ${NETIFS[p$i]} ]; then
287 if [[ $? -ne 0 ]]; then
290 if [[ $? -ne 0 ]]; then
310 declare -A MAC_ADDR_ORIG
313 local new_addr=
314 local dev=
320 MAC_ADDR_ORIG["$dev"]=$(ip -j link show dev $dev | jq -e '.[].address')
323 ip link set dev $dev address $new_addr
329 local dev=
333 ip link set dev $dev address ${MAC_ADDR_ORIG["$dev"]}
347 if [[ $? -ne 0 ]]; then
358 # Per-test return value. Clear at the beginning of each test.
363 local err=$1
364 local msg=$2
366 if [[ $RET -eq 0 && $err -ne 0 ]]; then
374 local err=$1
375 local msg=$2
377 if [[ $RET -eq 0 && $err -eq 0 ]]; then
385 local should_fail=$1; shift
386 local err=$1; shift
387 local what=$1; shift
398 local test_name=$1
399 local opt_str=$2
401 if [[ $# -eq 2 ]]; then
405 if [[ $RET -ne 0 ]]; then
407 printf "TEST: %-60s [FAIL]\n" "$test_name $opt_str"
408 if [[ ! -z "$retmsg" ]]; then
419 printf "TEST: %-60s [ OK ]\n" "$test_name $opt_str"
425 local test_name=$1
426 local opt_str=$2
428 printf "TEST: %-60s [SKIP]\n" "$test_name $opt_str"
434 local msg=$1
447 local arr=("$@")
451 if [[ $cur -gt $max ]]; then
461 local addr=$1; shift
462 local word
463 local flag
467 if [ "$1" == "-v" ]; then
477 "$@" | grep -q "Link detected: yes"
482 "$@" | grep -q offload
487 "$@" | grep -q trap
492 local expr=$1; shift
493 local current=$("$@")
501 local timeout=$1; shift
502 local delta=$1; shift
504 local base=$("$@")
510 local dev=$1; shift
511 local wait_time=${1:-$WAIT_TIME}; shift
524 local dev=$1; shift
525 local max_iterations=${1:-$WAIT_TIMEOUT}; shift
526 local wait_time=${1:-$WAIT_TIME}; shift
527 local i
532 if [[ $? -ne 0 ]]; then
545 local num_netifs=${1:-$NUM_NETIFS}
546 local i
558 local cmd=$1
559 local jq_exp=$2
560 local jq_opts=$3
561 local ret
562 local output
567 if [[ $ret -ne 0 ]]; then
570 output=$(echo $output | jq -r $jq_opts "$jq_exp")
572 if [[ $ret -ne 0 ]]; then
576 # return success only in case of non-empty output
577 [ ! -z "$output" ]
594 ip -4 rule add pref 32765 table local
595 ip -4 rule del pref 0
596 ip -6 rule add pref 32765 table local
597 ip -6 rule del pref 0
602 ip -6 rule add pref 0 table local
603 ip -6 rule del pref 32765
604 ip -4 rule add pref 0 table local
605 ip -4 rule del pref 32765
609 declare -A __TB_IDS
613 local vrf_name=$1
622 local vrf_name=$1
629 local vrf_name=$1
630 local tb_id
636 ip -4 route add table $tb_id unreachable default metric 4278198272
637 ip -6 route add table $tb_id unreachable default metric 4278198272
642 local vrf_name=$1
643 local tb_id
648 ip -6 route del table $tb_id unreachable default metric 4278198272
649 ip -4 route del table $tb_id unreachable default metric 4278198272
655 local if_name=$1
656 local add_del=$2
657 local array
664 ip address $add_del $addrstr dev $if_name
670 local if_name=$1; shift
671 local vrf_name=$1; shift
672 local addrs=("${@}")
682 local if_name=$1; shift
683 local addrs=("${@}")
693 local if_name=$1
694 local vrf_name
695 local array
708 local if_name=$1
709 local vrf_name
710 local array
722 local name=$1; shift
723 local type=$1; shift
724 local local=$1; shift
725 local remote=$1; shift
728 local $local remote $remote "$@"
734 local name=$1; shift
741 local if_name=$1; shift
742 local vid=$1; shift
743 local vrf=$1; shift
744 local ips=("${@}")
745 local name=$if_name.$vid
757 local if_name=$1; shift
758 local vid=$1; shift
759 local name=$if_name.$vid
766 local if_name=$1; shift
767 local mode=$1; shift
770 $TEAMD -t $if_name -d -c '{"runner": {"name": "'$mode'"}}'
781 local if_name=$1; shift
783 $TEAMD -t $if_name -k
788 local if_name=$1
790 ip -j link show dev $if_name | jq -r '.[]["master"]'
795 local if_name=$1; shift
796 local dir=$1; shift
797 local stat=$1; shift
799 ip -j -s link show dev $if_name \
815 local dev=$1; shift
816 local pref=$1; shift
817 local dir=$1; shift
818 local selector=${1:-.packets}; shift
820 tc -j -s filter show dev $dev ${dir:-ingress} pref $pref \
826 local id=$1; shift
827 local handle=$1; shift
828 local selector=${1:-.packets}; shift
829 local netns=${1:-""}; shift
831 tc $netns -j -s filter show $id \
838 local dev=$1; shift
839 local stat=$1; shift
841 ethtool -S $dev | grep "^ *$stat:" | head -n 1 | cut -d: -f2
846 local dev=$1; shift
847 local grp=$1; shift
848 local name=$1; shift
849 local src=$1; shift
851 ethtool --json -S $dev --groups $grp -- --src $src | \
857 local dev=$1; shift
858 local handle=$1; shift
859 local selector=$1; shift
861 tc -j -s qdisc show dev "$dev" \
867 local dev=$1; shift
868 local parent=$1; shift
869 local selector=$1; shift
871 tc -j -s qdisc show dev "$dev" invisible \
877 local dev=$1; shift
878 local stat=$1; shift
880 cat /proc/net/dev_snmp6/$dev | grep "^$stat" | cut -f2
885 local suite=$1; shift
886 local if_name=$1; shift
887 local dir=$1; shift
888 local stat=$1; shift
890 ip -j stats show dev $if_name group offload subgroup $suite |
896 local speed=$1; shift
911 local t0=$1; shift
912 local t1=$1; shift
913 local interval=$1; shift
915 echo $((8 * (t1 - t0) / interval))
920 local t0=$1; shift
921 local t1=$1; shift
922 local interval=$1; shift
924 echo $(((t1 - t0) / interval))
929 local if_name=$1
931 ip -j link show dev $if_name | jq -r '.[]["address"]'
936 local if_name=$1
938 ip -j addr show dev $if_name | \
939 jq -r '.[]["addr_info"][] | select(.scope == "link").local' | \
940 head -1
945 local bridge=$1
946 local ageing_time
949 ageing_time=$(ip -j -d link show dev $bridge \
954 declare -A SYSCTL_ORIG
957 local key=$1; shift
958 local value=$1; shift
960 SYSCTL_ORIG[$key]=$(sysctl -n $key)
961 sysctl -qw $key="$value"
966 local key=$1; shift
968 sysctl -qw $key="${SYSCTL_ORIG[$key]}"
983 declare -A MTU_ORIG
986 local dev=$1; shift
987 local mtu=$1; shift
989 MTU_ORIG["$dev"]=$(ip -j link show dev $dev | jq -e '.[].mtu')
995 local dev=$1; shift
1002 local num_netifs=${1:-$NUM_NETIFS}
1005 ethtool -k ${NETIFS[p$i]} \
1006 | grep "hw-tc-offload: on" &> /dev/null
1007 if [[ $? -ne 0 ]]; then
1017 local dev=$1; shift
1018 local direction=$1; shift
1020 # Some devices may not support or need in-hardware trapping of traffic
1021 # (e.g. the veth pairs that this library creates for non-existent
1033 local dev=$1; shift
1034 local direction=$1; shift
1041 # For slow-path testing, we need to install a trap to get to
1057 local add_del=$1; shift
1058 local pref=$1; shift
1059 local vsuf=$1; shift
1060 local tundev=$1; shift
1061 local filter=$1; shift
1091 local add_del=$1; shift
1092 local pref=$1; shift
1093 local dev=$1; shift
1094 local filter=$1; shift
1114 local add_del=$1; shift
1115 local dev=$1; shift
1116 local base=$1; shift
1117 local dscp;
1128 local dev=$1; shift
1129 local base=$1; shift
1136 local dev=$1; shift
1137 local base=$1; shift
1144 local dev=$1; shift
1145 local base=$1; shift
1148 local dscp=$((base + prio))
1149 local t=$(tc_rule_stats_get $dev $((dscp + 100)))
1156 local dev=$1; shift
1167 local current_test
1169 for current_test in ${TESTS:-$ALL_TESTS}; do
1176 local desc="$1"
1177 local weight_rp12=$2
1178 local weight_rp13=$3
1179 local packets_rp12=$4
1180 local packets_rp13=$5
1181 local weights_ratio packets_ratio diff
1185 if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
1187 | bc -l)
1190 | bc -l)
1193 if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then
1200 if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
1202 | bc -l)
1205 | bc -l)
1208 diff=$(echo $weights_ratio - $packets_ratio | bc -l)
1209 diff=${diff#-}
1211 test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0
1219 local name=$1; shift
1221 ip netns exec $name bash <<-EOF
1233 local if_name=$1
1234 local dip=$2
1235 local args=$3
1236 local vrf_name
1240 $PING $args $dip -c $PING_COUNT -i 0.1 \
1241 -w $PING_TIMEOUT &> /dev/null
1264 local if_name=$1
1265 local dip=$2
1266 local args=$3
1267 local vrf_name
1271 $PING6 $args $dip -c $PING_COUNT -i 0.1 \
1272 -w $PING_TIMEOUT &> /dev/null
1295 local bridge=$1
1296 local br_port1=$2 # Connected to `host1_if`.
1297 local host1_if=$3
1298 local host2_if=$4
1299 local mac=de:ad:be:ef:13:37
1300 local ageing_time
1304 bridge -j fdb show br $bridge brport $br_port1 \
1305 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1316 flower dst_mac $mac action drop
1318 $MZ $host2_if -c 1 -p 64 -b $mac -t ip -q
1321 tc -j -s filter show dev $host1_if ingress \
1322 | jq -e ".[] | select(.options.handle == 101) \
1326 $MZ $host1_if -c 1 -p 64 -a $mac -t ip -q
1329 bridge -j fdb show br $bridge brport $br_port1 \
1330 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1333 $MZ $host2_if -c 1 -p 64 -b $mac -t ip -q
1336 tc -j -s filter show dev $host1_if ingress \
1337 | jq -e ".[] | select(.options.handle == 101) \
1342 # record was aged-out.
1346 bridge -j fdb show br $bridge brport $br_port1 \
1347 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1352 $MZ $host1_if -c 1 -p 64 -a $mac -t ip -q
1355 bridge -j fdb show br $bridge brport $br_port1 \
1356 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1372 local should_flood=$1
1373 local mac=$2
1374 local ip=$3
1375 local host1_if=$4
1376 local host2_if=$5
1377 local err=0
1384 flower dst_mac $mac action drop
1386 $MZ $host1_if -c 1 -p 64 -b $mac -B $ip -t ip -q
1389 tc -j -s filter show dev $host2_if ingress \
1390 | jq -e ".[] | select(.options.handle == 101) \
1392 if [[ $? -ne 0 && $should_flood == "true" || \
1393 $? -eq 0 && $should_flood == "false" ]]; then
1406 local br_port=$1
1407 local host1_if=$2
1408 local host2_if=$3
1409 local mac=de:ad:be:ef:13:37
1410 local ip=192.0.2.100
1416 flood_test_do false $mac $ip $host1_if $host2_if
1421 flood_test_do true $mac $ip $host1_if $host2_if
1429 local br_port=$1
1430 local host1_if=$2
1431 local host2_if=$3
1432 local mac=01:00:5e:00:00:01
1433 local ip=239.0.0.1
1439 flood_test_do false $mac $ip $host1_if $host2_if
1444 flood_test_do true $mac $ip $host1_if $host2_if
1453 local br_port=$1
1454 local host1_if=$2
1455 local host2_if=$3
1463 local pktsize=$1; shift
1464 local proto=$1; shift
1465 local h_in=$1; shift # Where the traffic egresses the host
1466 local sip=$1; shift
1467 local dip=$1; shift
1468 local dmac=$1; shift
1470 $MZ $h_in -p $pktsize -A $sip -B $dip -c 0 \
1471 -a own -b $dmac -t "$proto" -q "$@" &
1477 local pktsize=$1; shift
1484 local pktsize=$1; shift
1505 declare -A cappid
1506 declare -A capfile
1507 declare -A capout
1511 local if_name=$1; shift
1512 local ns=$1; shift
1517 if [ -z $ns ]; then
1523 if [ -z $SUDO_USER ] ; then
1526 capuser="-Z $SUDO_USER"
1529 $ns_cmd tcpdump $TCPDUMP_EXTRA_FLAGS -e -n -Q in -i $if_name \
1530 -s 65535 -B 32768 $capuser -w ${capfile[$if_name]} \
1539 local if_name=$1
1540 local pid=${cappid[$if_name]}
1548 local if_name=$1
1555 local if_name=$1
1557 tcpdump -e -n -r ${capfile[$if_name]} 2>&1
1563 local mac=$1
1564 local src_ip=$2
1565 local ip=$3
1566 local host1_if=$4
1567 local host2_if=$5
1568 local seen=0
1569 local tc_proto="ip"
1570 local mz_v6arg=""
1572 # basic check to see if we were passed an IPv4 address, if not assume IPv6
1573 if [[ ! $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
1575 mz_v6arg="-6"
1582 flower ip_proto udp dst_mac $mac action drop
1584 $MZ $host1_if $mz_v6arg -c 1 -p 64 -b $mac -A $src_ip -B $ip -t udp "dp=4096,sp=2048" -q
1587 tc -j -s filter show dev $host2_if ingress \
1588 | jq -e ".[] | select(.options.handle == 101) \
1590 if [[ $? -eq 0 ]]; then
1602 local report=$1; shift
1603 local slist=("$@")
1604 local sarg=""
1607 sarg="${sarg} and .source_list[].address == \"$src\""
1609 bridge -j -d -s mdb show dev br0 \
1610 | jq -e ".[].mdb[] | \
1615 bridge -j -d -s mdb show dev br0 \
1616 | jq -e ".[].mdb[] | \
1624 local should_fwd=$1; shift
1625 local sources=("$@")
1628 local retval=0
1632 if [ $should_fwd -eq 1 ]; then
1642 local is_blocked=$1; shift
1643 local sources=("$@")
1644 local should_fail=1
1646 if [ $is_blocked -eq 1 ]; then
1651 bridge -j -d -s mdb show dev br0 \
1652 | jq -e ".[].mdb[] | \
1655 select(.address == \"$src\") |
1659 bridge -j -d -s mdb show dev br0 \
1660 | jq -e ".[].mdb[] | \
1669 local if_name=$1
1670 local group=$2
1671 local vrf_name=$(master_name_get $if_name)
1674 # IP multicast group and adding the L2 address to the device's
1675 # MAC filtering table
1677 mreceive -g $group -I $if_name > /dev/null 2>&1 &
1690 local if_name=$1
1691 local groups=$2
1692 local vrf_name=$(master_name_get $if_name)
1695 msend -g $groups -I $if_name -c 1 > /dev/null 2>&1
1700 local mtype=$1; shift
1701 local ip=${1-ip}; shift
1712 local mpid=$1; shift
1713 local tmpfile=$1; shift
1714 local el=$1; shift
1715 local what=$1; shift
1719 local lines=`grep '^\w' $tmpfile | wc -l`
1720 test $lines -eq $el
1722 rm -rf $tmpfile
1727 local dev=$1; shift
1728 local type=$1; shift
1729 local make_suitable=$1; shift
1730 local make_unsuitable=$1; shift
1731 local ip=${1-ip}; shift
1736 local ipmout=$(start_ip_monitor stats "$ip")
1741 local ipmout=$(start_ip_monitor stats "$ip")
1746 local ipmout=$(start_ip_monitor stats "$ip")
1751 local ipmout=$(start_ip_monitor stats "$ip")
1760 local IP=$1; shift
1766 # Convert a given IPv6 address, `IP' such that the :: token, if present, is
1767 # expanded, and each 16-bit group is padded with zeroes to be 4 hexadecimal
1769 # individual bytes of each 16-bit group.
1772 local IP=$1; shift
1773 local bytesep=$1; shift
1775 local cvt_ip=${IP/::/_}
1776 local colons=${cvt_ip//[^:]/}
1777 local allcol=:::::::
1778 # IP where :: -> the appropriate number of colons:
1779 local allcol_ip=${cvt_ip/_/${allcol:${#colons}}}
1790 local IP=$1; shift
1797 local u16=$1; shift
1802 # Given a mausezahn-formatted payload (colon-separated bytes given as %02x),
1803 # possibly with a keyword CHECKSUM stashed where a 16-bit checksum should be,
1808 local payload=$1; shift
1827 echo "FFFF r - p" # Bit-flip and print.
1835 local payload=$1; shift
1836 local checksum=$1; shift
1838 local ckbytes=$(u16_to_bytes $checksum)
1845 local payload=$1; shift
1848 sed 's/:/\n/g' | wc -l
1853 local GRP=$1; shift
1854 local sources=("$@")
1856 local igmpv3
1857 local nsources=$(u16_to_bytes ${#sources[@]})
1861 )"22:"$( : Type - Membership Report
1866 )"01:"$( : Record Type - IS_IN
1869 )"$(ipv4_to_bytes $GRP):"$( : Multicast Address
1872 echo -n :
1875 local checksum=$(payload_template_calc_checksum "$igmpv3")
1882 local GRP=$1; shift
1884 local payload=$(:
1885 )"17:"$( : Type - Leave Group
1886 )"00:"$( : Max Resp Time - not meaningful
1888 )"$(ipv4_to_bytes $GRP)"$( : Group Address
1890 local checksum=$(payload_template_calc_checksum "$payload")
1897 local SIP=$1; shift
1898 local GRP=$1; shift
1899 local sources=("$@")
1901 local hbh
1902 local icmpv6
1903 local nsources=$(u16_to_bytes ${#sources[@]})
1906 )"3a:"$( : Next Header - ICMPv6
1912 )"8f:"$( : Type - MLDv2 Report
1917 )"01:"$( : Record Type - IS_IN
1920 )"$(ipv6_to_bytes $GRP):"$( : Multicast address
1923 echo -n :
1927 local len=$(u16_to_bytes $(payload_template_nbytes $icmpv6))
1928 local sudohdr=$(:
1930 )"$(ipv6_to_bytes $GRP):"$( : DIP is multicast address
1931 )"${len}:"$( : Upper-layer length
1932 )"00:3a:"$( : Zero and next-header
1934 local checksum=$(payload_template_calc_checksum ${sudohdr}${icmpv6})
1941 local SIP=$1; shift
1942 local GRP=$1; shift
1944 local hbh
1945 local icmpv6
1948 )"3a:"$( : Next Header - ICMPv6
1954 )"84:"$( : Type - MLDv1 Done
1957 )"00:00:"$( : Max Resp Delay - not meaningful
1959 )"$(ipv6_to_bytes $GRP):"$( : Multicast address
1962 local len=$(u16_to_bytes $(payload_template_nbytes $icmpv6))
1963 local sudohdr=$(:
1965 )"$(ipv6_to_bytes $GRP):"$( : DIP is multicast address
1966 )"${len}:"$( : Upper-layer length
1967 )"00:3a:"$( : Zero and next-header
1969 local checksum=$(payload_template_calc_checksum ${sudohdr}${icmpv6})
1976 local reason1="$1"; shift
1977 local reason2="$1"; shift
1979 if systemctl is-active --quiet lldpad; then
1981 cat >/dev/stderr <<-EOF
1991 if [[ -z $ALLOW_LLDPAD ]]; then
1992 cat >/dev/stderr <<-EOF
1996 non-empty string.