| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 |
|
| 9 | ALL_TESTS="
|
| 10 | kci_test_mcast_addr_notification
|
| 11 | kci_test_anycast_addr_notification
|
| 12 | "
|
| 13 |
|
| 14 | source lib.sh
|
| 15 | test_dev="test-dummy1"
|
| 16 |
|
| 17 | kci_test_mcast_addr_notification()
|
| 18 | {
|
| 19 | RET=0
|
| 20 | local tmpfile
|
| 21 | local monitor_pid
|
| 22 | local match_result
|
| 23 |
|
| 24 | tmpfile=$(mktemp)
|
| 25 | defer rm "$tmpfile"
|
| 26 |
|
| 27 | ip monitor maddr > $tmpfile &
|
| 28 | monitor_pid=$!
|
| 29 | defer kill_process "$monitor_pid"
|
| 30 |
|
| 31 | sleep 1
|
| 32 |
|
| 33 | if [ ! -e "/proc/$monitor_pid" ]; then
|
| 34 | RET=$ksft_skip
|
| 35 | log_test "mcast addr notification: iproute2 too old"
|
| 36 | return $RET
|
| 37 | fi
|
| 38 |
|
| 39 | ip link add name "$test_dev" type dummy
|
| 40 | check_err $? "failed to add dummy interface"
|
| 41 | ip link set "$test_dev" up
|
| 42 | check_err $? "failed to set dummy interface up"
|
| 43 | ip link del dev "$test_dev"
|
| 44 | check_err $? "Failed to delete dummy interface"
|
| 45 | sleep 1
|
| 46 |
|
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | match_result=$(grep -cE "$test_dev.*(224.0.0.1|ff02::1)" "$tmpfile")
|
| 53 | if [ "$match_result" -ne 4 ]; then
|
| 54 | RET=$ksft_fail
|
| 55 | fi
|
| 56 | log_test "mcast addr notification: Expected 4 matches, got $match_result"
|
| 57 | return $RET
|
| 58 | }
|
| 59 |
|
| 60 | kci_test_anycast_addr_notification()
|
| 61 | {
|
| 62 | RET=0
|
| 63 | local tmpfile
|
| 64 | local monitor_pid
|
| 65 | local match_result
|
| 66 |
|
| 67 | tmpfile=$(mktemp)
|
| 68 | defer rm "$tmpfile"
|
| 69 |
|
| 70 | ip monitor acaddress > "$tmpfile" &
|
| 71 | monitor_pid=$!
|
| 72 | defer kill_process "$monitor_pid"
|
| 73 | sleep 1
|
| 74 |
|
| 75 | if [ ! -e "/proc/$monitor_pid" ]; then
|
| 76 | RET=$ksft_skip
|
| 77 | log_test "anycast addr notification: iproute2 too old"
|
| 78 | return "$RET"
|
| 79 | fi
|
| 80 |
|
| 81 | ip link add name "$test_dev" type dummy
|
| 82 | check_err $? "failed to add dummy interface"
|
| 83 | ip link set "$test_dev" up
|
| 84 | check_err $? "failed to set dummy interface up"
|
| 85 | sysctl -qw net.ipv6.conf."$test_dev".forwarding=1
|
| 86 | ip link del dev "$test_dev"
|
| 87 | check_err $? "Failed to delete dummy interface"
|
| 88 | sleep 1
|
| 89 |
|
| 90 | |
| 91 | |
| 92 | |
| 93 | match_result=$(grep -cE "$test_dev.*(fe80::)" "$tmpfile")
|
| 94 | if [ "$match_result" -ne 2 ]; then
|
| 95 | RET=$ksft_fail
|
| 96 | fi
|
| 97 | log_test "anycast addr notification: Expected 2 matches, got $match_result"
|
| 98 | return "$RET"
|
| 99 | }
|
| 100 |
|
| 101 | |
| 102 | if [ "$(id -u)" -ne 0 ];then
|
| 103 | RET=$ksft_skip
|
| 104 | log_test "need root privileges"
|
| 105 | exit $RET
|
| 106 | fi
|
| 107 |
|
| 108 | require_command ip
|
| 109 |
|
| 110 | tests_run
|
| 111 |
|
| 112 | exit $EXIT_STATUS
|