Lines Matching +full:local +full:- +full:pid
2 # SPDX-License-Identifier: GPL-2.0
7 declare -A NETIFS=(
42 # Constants for netdevice bring-up:
46 # Like INTERFACE_TIMEOUT, but default for ad-hoc waiting in testing scripts.
83 # Whether the machine is "slow" -- i.e. might be incapable of running tests
85 # e.g. a low-power board.
89 # Find netifs by test-specified driver name
93 local dev=$1; shift
94 local driver_path="/sys/class/net/$dev/device/driver"
96 if [[ -L $driver_path ]]; then
103 local ifnames=`ip -j link show | jq -r ".[].ifname"`
104 local count=0
108 local driver_name=`driver_name_get $ifname`
109 if [[ ! -z $driver_name && $driver_name == $NETIF_FIND_DRIVER ]]; then
121 declare -A NETIFS
125 net_forwarding_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
127 if [[ -f $net_forwarding_dir/forwarding.config ]]; then
138 tc -j &> /dev/null
139 if [[ $? -ne 0 ]]; then
147 local dev=$1; shift
151 if [[ $? -ne 0 ]]; then
162 local dev=$1; shift
166 if [[ $? -ne 0 ]]; then
177 local dev=$1; shift
178 local ret;
184 if [[ $? -ne 0 ]]; then
185 echo "SKIP: iproute2 too old; tc-flower is missing extended MPLS support"
189 tc -j filter show dev $dev ingress protocol mpls_uc | jq . &> /dev/null
194 if [[ $ret -ne 0 ]]; then
195 echo "SKIP: iproute2 too old; tc-flower produces invalid json output for extended MPLS filters"
203 if [[ $? -ne 0 ]]; then
212 if [[ $? -ne 0 ]]; then
220 tc actions help 2>&1 | grep -q hw_stats
221 if [[ $? -ne 0 ]]; then
229 tc qdisc add dev lo mqprio help 2>&1 | grep -q "fp "
230 if [[ $? -ne 0 ]]; then
238 ethtool --help 2>&1| grep lanes &> /dev/null
239 if [[ $? -ne 0 ]]; then
247 ethtool --help 2>&1| grep -- '--show-mm' &> /dev/null
248 if [[ $? -ne 0 ]]; then
256 ethtool --help 2>&1| grep -- '--all-groups' &> /dev/null
257 if [[ $? -ne 0 ]]; then
265 local dev=$1; shift
266 local grp=$1; shift
268 [ 0 -ne $(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null \
274 if ! bridge -d link show | grep -q " locked"; then
282 if ! bridge -d link show | grep -q "mab"; then
288 if [[ "$(id -u)" -ne 0 ]]; then
295 local dev=$1; shift
296 local expected=$1; shift
297 local driver_name=`driver_name_get $dev`
312 local version="$(msend -v)"
313 local major
316 major=$(echo $version | cut -d. -f1)
318 if [ $major -lt 3 ]; then
345 while [[ $# -gt 0 ]]; do
346 if [[ "$count" -eq "0" ]]; then
348 declare -A NETIFS
358 if [[ ! -v NUM_NETIFS ]]; then
377 local i
380 local j=$((i+1))
382 if [ -z ${NETIFS[p$i]} ]; then
388 if [[ $? -ne 0 ]]; then
391 if [[ $? -ne 0 ]]; then
411 declare -A MAC_ADDR_ORIG
414 local new_addr=
415 local dev=
421 MAC_ADDR_ORIG["$dev"]=$(ip -j link show dev $dev | jq -e '.[].address')
430 local dev=
448 if [[ $? -ne 0 ]]; then
465 local arr=("$@")
469 if [[ $cur -gt $max ]]; then
479 local addr=$1; shift
480 local word
481 local flag
485 if [ "$1" == "-v" ]; then
495 "$@" | grep -q "Link detected: yes"
500 "$@" | grep -q offload
505 "$@" | grep -q trap
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; shift
546 local i
563 local dev=$1; shift
564 local timeout=${1:-$WAIT_TIMEOUT}; shift
588 ip -4 rule add pref 32765 table local
589 ip -4 rule del pref 0
590 ip -6 rule add pref 32765 table local
591 ip -6 rule del pref 0
596 ip -6 rule add pref 0 table local
597 ip -6 rule del pref 32765
598 ip -4 rule add pref 0 table local
599 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
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
728 local name=$1; shift
729 local type=$1; shift
730 local local=$1; shift
731 local remote=$1; shift
734 local $local remote $remote "$@"
740 local name=$1; shift
747 local if_name=$1; shift
748 local vid=$1; shift
749 local vrf=$1; shift
750 local ips=("${@}")
751 local name=$if_name.$vid
763 local if_name=$1; shift
764 local vid=$1; shift
765 local name=$if_name.$vid
772 local if_name=$1; shift
773 local mode=$1; shift
776 $TEAMD -t $if_name -d -c '{"runner": {"name": "'$mode'"}}'
787 local if_name=$1; shift
789 $TEAMD -t $if_name -k
794 local if_name=$1
796 ip -j link show dev $if_name | jq -r '.[]["master"]'
801 local if_name=$1; shift
802 local dir=$1; shift
803 local stat=$1; shift
805 ip -j -s link show dev $if_name \
821 local dev=$1; shift
822 local stat=$1; shift
824 ethtool -S $dev | grep "^ *$stat:" | head -n 1 | cut -d: -f2
829 local dev=$1; shift
830 local grp=$1; shift
831 local name=$1; shift
832 local src=$1; shift
834 ethtool --json -S $dev --groups $grp -- --src $src | \
840 local dev=$1; shift
841 local handle=$1; shift
842 local selector=$1; shift
844 tc -j -s qdisc show dev "$dev" \
850 local dev=$1; shift
851 local parent=$1; shift
852 local selector=$1; shift
854 tc -j -s qdisc show dev "$dev" invisible \
860 local dev=$1; shift
861 local stat=$1; shift
863 cat /proc/net/dev_snmp6/$dev | grep "^$stat" | cut -f2
868 local suite=$1; shift
869 local if_name=$1; shift
870 local dir=$1; shift
871 local stat=$1; shift
873 ip -j stats show dev $if_name group offload subgroup $suite |
879 local key=$1; shift
880 local group_id=$1; shift
881 local member_id=$1; shift
883 ip -j -s -s nexthop show id $group_id |
884 jq --argjson member_id "$member_id" --arg key "$key" \
890 local group_id=$1; shift
891 local member_id=$1; shift
898 local group_id=$1; shift
899 local member_id=$1; shift
906 local speed=$1; shift
921 local t0=$1; shift
922 local t1=$1; shift
923 local interval=$1; shift
925 echo $((8 * (t1 - t0) / interval))
930 local t0=$1; shift
931 local t1=$1; shift
932 local interval=$1; shift
934 echo $(((t1 - t0) / interval))
939 local addr="$1"
940 local order="$((1 << 40))"
941 local val=0
942 local byte
957 local val=$1
958 local byte
959 local i
961 for ((i = 40; i >= 0; i -= 8)); do
964 if [ $i -ne 0 ]; then
972 local if_name=$1
974 ip -j addr show dev $if_name | \
975 jq -r '.[]["addr_info"][] | select(.scope == "link").local' | \
976 head -1
981 local bridge=$1
982 local ageing_time
985 ageing_time=$(ip -j -d link show dev $bridge \
990 declare -A SYSCTL_ORIG
993 local key=$1; shift
995 SYSCTL_ORIG[$key]=$(sysctl -n $key)
1000 local key=$1; shift
1001 local value=$1; shift
1004 sysctl -qw $key="$value"
1009 local key=$1; shift
1011 sysctl -qw $key="${SYSCTL_ORIG[$key]}"
1032 declare -A MTU_ORIG
1035 local dev=$1; shift
1036 local mtu=$1; shift
1038 MTU_ORIG["$dev"]=$(ip -j link show dev $dev | jq -e '.[].mtu')
1044 local dev=$1; shift
1051 local num_netifs=${1:-$NUM_NETIFS}
1054 ethtool -k ${NETIFS[p$i]} \
1055 | grep "hw-tc-offload: on" &> /dev/null
1056 if [[ $? -ne 0 ]]; then
1066 local dev=$1; shift
1067 local direction=$1; shift
1069 # Some devices may not support or need in-hardware trapping of traffic
1070 # (e.g. the veth pairs that this library creates for non-existent
1082 local dev=$1; shift
1083 local direction=$1; shift
1090 local add_del=$1; shift
1091 local pref=$1; shift
1092 local vsuf=$1; shift
1093 local tundev=$1; shift
1094 local filter=$1; shift
1104 local tundev=$1; shift
1105 local filter=$1; shift
1112 local tundev=$1; shift
1113 local filter=$1; shift
1120 local tundev=$1; shift
1121 local filter=$1; shift
1128 local tundev=$1; shift
1129 local filter=$1; shift
1136 local add_del=$1; shift
1137 local pref=$1; shift
1138 local dev=$1; shift
1139 local filter=$1; shift
1149 local dev=$1; shift
1150 local filter=$1; shift
1157 local dev=$1; shift
1158 local filter=$1; shift
1165 local add_del=$1; shift
1166 local dev=$1; shift
1167 local base=$1; shift
1168 local dscp;
1179 local dev=$1; shift
1180 local base=$1; shift
1187 local dev=$1; shift
1188 local base=$1; shift
1195 local dev=$1; shift
1196 local base=$1; shift
1199 local dscp=$((base + prio))
1200 local t=$(tc_rule_stats_get $dev $((dscp + 100)))
1207 local dev=$1; shift
1224 local desc="$1"
1225 local weight_rp12=$2
1226 local weight_rp13=$3
1227 local packets_rp12=$4
1228 local packets_rp13=$5
1229 local weights_ratio packets_ratio diff
1233 if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
1235 | bc -l)
1238 | bc -l)
1241 if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then
1248 if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
1250 | bc -l)
1253 | bc -l)
1256 diff=$(echo $weights_ratio - $packets_ratio | bc -l)
1257 diff=${diff#-}
1259 test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0
1267 local name=$1; shift
1269 ip netns exec $name bash <<-EOF
1281 local if_name=$1
1282 local dip=$2
1283 local args=$3
1284 local vrf_name
1288 $PING $args -c $PING_COUNT -i 0.1 \
1289 -w $PING_TIMEOUT $dip &> /dev/null
1312 local if_name=$1
1313 local dip=$2
1314 local args=$3
1315 local vrf_name
1319 $PING6 $args -c $PING_COUNT -i 0.1 \
1320 -w $PING_TIMEOUT $dip &> /dev/null
1343 local bridge=$1
1344 local br_port1=$2 # Connected to `host1_if`.
1345 local host1_if=$3
1346 local host2_if=$4
1347 local mac=de:ad:be:ef:13:37
1348 local ageing_time
1352 bridge -j fdb show br $bridge brport $br_port1 \
1353 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1366 $MZ $host2_if -c 1 -p 64 -b $mac -t ip -q
1369 tc -j -s filter show dev $host1_if ingress \
1370 | jq -e ".[] | select(.options.handle == 101) \
1374 $MZ $host1_if -c 1 -p 64 -a $mac -t ip -q
1377 bridge -j fdb show br $bridge brport $br_port1 \
1378 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1381 $MZ $host2_if -c 1 -p 64 -b $mac -t ip -q
1384 tc -j -s filter show dev $host1_if ingress \
1385 | jq -e ".[] | select(.options.handle == 101) \
1390 # record was aged-out.
1394 bridge -j fdb show br $bridge brport $br_port1 \
1395 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1400 $MZ $host1_if -c 1 -p 64 -a $mac -t ip -q
1403 bridge -j fdb show br $bridge brport $br_port1 \
1404 | jq -e ".[] | select(.mac == \"$mac\")" &> /dev/null
1420 local should_flood=$1
1421 local mac=$2
1422 local ip=$3
1423 local host1_if=$4
1424 local host2_if=$5
1425 local err=0
1434 $MZ $host1_if -c 1 -p 64 -b $mac -B $ip -t ip -q
1437 tc -j -s filter show dev $host2_if ingress \
1438 | jq -e ".[] | select(.options.handle == 101) \
1440 if [[ $? -ne 0 && $should_flood == "true" || \
1441 $? -eq 0 && $should_flood == "false" ]]; then
1454 local br_port=$1
1455 local host1_if=$2
1456 local host2_if=$3
1457 local mac=de:ad:be:ef:13:37
1458 local ip=192.0.2.100
1477 local br_port=$1
1478 local host1_if=$2
1479 local host2_if=$3
1480 local mac=01:00:5e:00:00:01
1481 local ip=239.0.0.1
1501 local br_port=$1
1502 local host1_if=$2
1503 local host2_if=$3
1511 local pktsize=$1; shift
1512 local proto=$1; shift
1513 local h_in=$1; shift # Where the traffic egresses the host
1514 local sip=$1; shift
1515 local dip=$1; shift
1516 local dmac=$1; shift
1517 local -a mz_args=("$@")
1519 $MZ $h_in -p $pktsize -A $sip -B $dip -c 0 \
1520 -a own -b $dmac -t "$proto" -q "${mz_args[@]}" &
1526 local pktsize=$1; shift
1527 local h_in=$1; shift
1528 local sip=$1; shift
1529 local dip=$1; shift
1530 local dmac=$1; shift
1531 local -a mz_args=("$@")
1539 local pktsize=$1; shift
1540 local h_in=$1; shift
1541 local sip=$1; shift
1542 local dip=$1; shift
1543 local dmac=$1; shift
1544 local -a mz_args=("$@")
1552 local h_in=$1; shift
1553 local sip=$1; shift
1554 local dip=$1; shift
1555 local dmac=$1; shift
1556 local -a mz_args=("$@")
1564 local h_in=$1; shift
1565 local sip=$1; shift
1566 local dip=$1; shift
1567 local dmac=$1; shift
1568 local -a mz_args=("$@")
1576 local pid=${1-%%}; shift
1578 kill_process "$pid"
1581 declare -A cappid
1582 declare -A capfile
1583 declare -A capout
1587 local if_name=$1; shift
1588 local ns=$1; shift
1593 if [ -z $ns ]; then
1599 if [ -z $SUDO_USER ] ; then
1602 capuser="-Z $SUDO_USER"
1605 $ns_cmd tcpdump $TCPDUMP_EXTRA_FLAGS -e -n -Q in -i $if_name \
1606 -s 65535 -B 32768 $capuser -w ${capfile[$if_name]} \
1615 local if_name=$1
1616 local pid=${cappid[$if_name]}
1618 $ns_cmd kill "$pid" && wait "$pid"
1624 local if_name=$1
1631 local if_name=$1
1633 tcpdump -e -n -r ${capfile[$if_name]} 2>&1
1639 local mac=$1
1640 local src_ip=$2
1641 local ip=$3
1642 local host1_if=$4
1643 local host2_if=$5
1644 local seen=0
1645 local tc_proto="ip"
1646 local mz_v6arg=""
1649 if [[ ! $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
1651 mz_v6arg="-6"
1660 $MZ $host1_if $mz_v6arg -c 1 -p 64 -b $mac -A $src_ip -B $ip -t udp "dp=4096,sp=2048" -q
1663 tc -j -s filter show dev $host2_if ingress \
1664 | jq -e ".[] | select(.options.handle == 101) \
1666 if [[ $? -eq 0 ]]; then
1678 local report=$1; shift
1679 local slist=("$@")
1680 local sarg=""
1685 bridge -j -d -s mdb show dev br0 \
1686 | jq -e ".[].mdb[] | \
1691 bridge -j -d -s mdb show dev br0 \
1692 | jq -e ".[].mdb[] | \
1700 local should_fwd=$1; shift
1701 local sources=("$@")
1704 local retval=0
1708 if [ $should_fwd -eq 1 ]; then
1718 local is_blocked=$1; shift
1719 local sources=("$@")
1720 local should_fail=1
1722 if [ $is_blocked -eq 1 ]; then
1727 bridge -j -d -s mdb show dev br0 \
1728 | jq -e ".[].mdb[] | \
1735 bridge -j -d -s mdb show dev br0 \
1736 | jq -e ".[].mdb[] | \
1745 local if_name=$1
1746 local group=$2
1747 local vrf_name=$(master_name_get $if_name)
1753 mreceive -g $group -I $if_name > /dev/null 2>&1 &
1766 local if_name=$1
1767 local groups=$2
1768 local vrf_name=$(master_name_get $if_name)
1771 msend -g $groups -I $if_name -c 1 > /dev/null 2>&1
1776 local ifs=("$@")
1778 local table_name="$MCD_TABLE_NAME"
1779 local smcroutedir
1780 local pid
1781 local if
1782 local i
1787 smcroutedir=$(mktemp -d)
1788 defer rm -rf "$smcroutedir"
1805 "$MCD" -N -I "$table_name" -f "$smcroutedir/$table_name.conf" \
1806 -P "$smcroutedir/$table_name.pid"
1807 busywait "$BUSYWAIT_TIMEOUT" test -e "$smcroutedir/$table_name.pid"
1808 pid=$(cat "$smcroutedir/$table_name.pid")
1809 defer kill_process "$pid"
1814 local table_name="$MCD_TABLE_NAME"
1816 "$MC_CLI" -I "$table_name" "$@"
1821 local mtype=$1; shift
1822 local ip=${1-ip}; shift
1833 local mpid=$1; shift
1834 local tmpfile=$1; shift
1835 local el=$1; shift
1836 local what=$1; shift
1840 local lines=`grep '^\w' $tmpfile | wc -l`
1841 test $lines -eq $el
1843 rm -rf $tmpfile
1848 local dev=$1; shift
1849 local type=$1; shift
1850 local make_suitable=$1; shift
1851 local make_unsuitable=$1; shift
1852 local ip=${1-ip}; shift
1857 local ipmout=$(start_ip_monitor stats "$ip")
1862 local ipmout=$(start_ip_monitor stats "$ip")
1867 local ipmout=$(start_ip_monitor stats "$ip")
1872 local ipmout=$(start_ip_monitor stats "$ip")
1881 local IP=$1; shift
1888 # expanded, and each 16-bit group is padded with zeroes to be 4 hexadecimal
1890 # individual bytes of each 16-bit group.
1893 local IP=$1; shift
1894 local bytesep=$1; shift
1896 local cvt_ip=${IP/::/_}
1897 local colons=${cvt_ip//[^:]/}
1898 local allcol=:::::::
1899 # IP where :: -> the appropriate number of colons:
1900 local allcol_ip=${cvt_ip/_/${allcol:${#colons}}}
1911 local IP=$1; shift
1918 local u16=$1; shift
1923 # Given a mausezahn-formatted payload (colon-separated bytes given as %02x),
1924 # possibly with a keyword CHECKSUM stashed where a 16-bit checksum should be,
1929 local payload=$1; shift
1948 echo "FFFF r - p" # Bit-flip and print.
1956 local payload=$1; shift
1957 local checksum=$1; shift
1959 local ckbytes=$(u16_to_bytes $checksum)
1966 local payload=$1; shift
1969 sed 's/:/\n/g' | wc -l
1974 local GRP=$1; shift
1975 local sources=("$@")
1977 local igmpv3
1978 local nsources=$(u16_to_bytes ${#sources[@]})
1982 )"22:"$( : Type - Membership Report
1987 )"01:"$( : Record Type - IS_IN
1993 echo -n :
1996 local checksum=$(payload_template_calc_checksum "$igmpv3")
2003 local GRP=$1; shift
2005 local payload=$(:
2006 )"17:"$( : Type - Leave Group
2007 )"00:"$( : Max Resp Time - not meaningful
2011 local checksum=$(payload_template_calc_checksum "$payload")
2018 local SIP=$1; shift
2019 local GRP=$1; shift
2020 local sources=("$@")
2022 local hbh
2023 local icmpv6
2024 local nsources=$(u16_to_bytes ${#sources[@]})
2027 )"3a:"$( : Next Header - ICMPv6
2033 )"8f:"$( : Type - MLDv2 Report
2038 )"01:"$( : Record Type - IS_IN
2044 echo -n :
2048 local len=$(u16_to_bytes $(payload_template_nbytes $icmpv6))
2049 local sudohdr=$(:
2052 )"${len}:"$( : Upper-layer length
2053 )"00:3a:"$( : Zero and next-header
2055 local checksum=$(payload_template_calc_checksum ${sudohdr}${icmpv6})
2062 local SIP=$1; shift
2063 local GRP=$1; shift
2065 local hbh
2066 local icmpv6
2069 )"3a:"$( : Next Header - ICMPv6
2075 )"84:"$( : Type - MLDv1 Done
2078 )"00:00:"$( : Max Resp Delay - not meaningful
2083 local len=$(u16_to_bytes $(payload_template_nbytes $icmpv6))
2084 local sudohdr=$(:
2087 )"${len}:"$( : Upper-layer length
2088 )"00:3a:"$( : Zero and next-header
2090 local checksum=$(payload_template_calc_checksum ${sudohdr}${icmpv6})
2097 local reason1="$1"; shift
2098 local reason2="$1"; shift
2099 local caller=${FUNCNAME[1]}
2100 local src=${BASH_SOURCE[1]}
2102 if systemctl is-active --quiet lldpad; then
2104 cat >/dev/stderr <<-EOF
2114 if [[ -z $ALLOW_LLDPAD ]]; then
2115 cat >/dev/stderr <<-EOF
2119 non-empty string.
2131 local v=$1; shift
2133 echo $((v > 0 ? v : -v))
2138 local dev=$1; shift
2139 local mac_addr=$(mac_get $dev)
2140 local tmp=$(ether_addr_to_u64 $mac_addr)
2141 local promisc
2144 ip link add link $dev name macvlan-tmp type macvlan mode private
2145 ip link set macvlan-tmp address $(u64_to_ether_addr $((tmp + 1)))
2146 ip link set macvlan-tmp up
2148 promisc=$(ip -j -d link show dev $dev | jq -r '.[].promiscuity')
2150 ip link del macvlan-tmp