|
8 | 8 |
|
9 | 9 | ALL_TESTS="
|
10 | 10 | kci_test_mcast_addr_notification
|
| 11 | + kci_test_anycast_addr_notification |
11 | 12 | "
|
12 | 13 |
|
13 | 14 | source lib.sh
|
| 15 | +test_dev="test-dummy1" |
14 | 16 |
|
15 | 17 | kci_test_mcast_addr_notification()
|
16 | 18 | {
|
17 | 19 | RET=0
|
18 | 20 | local tmpfile
|
19 | 21 | local monitor_pid
|
20 | 22 | local match_result
|
21 |
| - local test_dev="test-dummy1" |
22 | 23 |
|
23 | 24 | tmpfile=$(mktemp)
|
24 | 25 | defer rm "$tmpfile"
|
@@ -56,6 +57,47 @@ kci_test_mcast_addr_notification()
|
56 | 57 | return $RET
|
57 | 58 | }
|
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 | + # There should be 2 line matches as follows. |
| 91 | + # 9: dummy2 inet6 any fe80:: scope global |
| 92 | + # Deleted 9: dummy2 inet6 any fe80:: scope global |
| 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 | + |
59 | 101 | #check for needed privileges
|
60 | 102 | if [ "$(id -u)" -ne 0 ];then
|
61 | 103 | RET=$ksft_skip
|
|
0 commit comments