Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4source lib.sh
5
6ALL_TESTS="
7 test_dup_bridge
8 test_dup_vxlan_self
9 test_dup_vxlan_master
10 test_dup_macvlan_self
11 test_dup_macvlan_master
12"
13
14do_test_dup()
15{
16 local op=$1; shift
17 local what=$1; shift
18 local tmpf
19
20 RET=0
21
22 tmpf=$(mktemp)
23 defer rm "$tmpf"
24
25 defer_scope_push
26 bridge monitor fdb &> "$tmpf" &
27 defer kill_process $!
28
29 sleep 0.5
30 bridge fdb "$op" 00:11:22:33:44:55 vlan 1 "$@"
31 sleep 0.5
32 defer_scope_pop
33
34 local count=$(grep -c -e 00:11:22:33:44:55 $tmpf)
35 ((count == 1))
36 check_err $? "Got $count notifications, expected 1"
37
38 log_test "$what $op: Duplicate notifications"
39}
40
41test_dup_bridge()
42{
43 ip_link_add br up type bridge vlan_filtering 1
44 do_test_dup add "bridge" dev br self
45 do_test_dup del "bridge" dev br self
46}
47
48test_dup_vxlan_self()
49{
50 ip_link_add br up type bridge vlan_filtering 1
51 ip_link_add vx up type vxlan id 2000 dstport 4789
52 ip_link_set_master vx br
53
54 do_test_dup add "vxlan" dev vx self dst 192.0.2.1
55 do_test_dup del "vxlan" dev vx self dst 192.0.2.1
56}
57
58test_dup_vxlan_master()
59{
60 ip_link_add br up type bridge vlan_filtering 1
61 ip_link_add vx up type vxlan id 2000 dstport 4789
62 ip_link_set_master vx br
63
64 do_test_dup add "vxlan master" dev vx master
65 do_test_dup del "vxlan master" dev vx master
66}
67
68test_dup_macvlan_self()
69{
70 ip_link_add dd up type dummy
71 ip_link_add mv up link dd type macvlan mode passthru
72
73 do_test_dup add "macvlan self" dev mv self
74 do_test_dup del "macvlan self" dev mv self
75}
76
77test_dup_macvlan_master()
78{
79 ip_link_add br up type bridge vlan_filtering 1
80 ip_link_add dd up type dummy
81 ip_link_add mv up link dd type macvlan mode passthru
82 ip_link_set_master mv br
83
84 do_test_dup add "macvlan master" dev mv self
85 do_test_dup del "macvlan master" dev mv self
86}
87
88cleanup()
89{
90 defer_scopes_cleanup
91}
92
93trap cleanup EXIT
94tests_run
95
96exit $EXIT_STATUS