selftests/bpf: Add netkit tests for mac address
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 24 May 2024 16:36:18 +0000 (18:36 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 25 May 2024 17:48:57 +0000 (10:48 -0700)
This adds simple tests around setting MAC addresses in the different
netkit modes.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20240524163619.26001-3-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/tc_netkit.c

index 15ee7b2fc4106428b3210de62df53a6c125060ec..18b2e969a456733dfe206a1b11caf1a4d4298cad 100644 (file)
@@ -73,6 +73,16 @@ static int create_netkit(int mode, int policy, int peer_policy, int *ifindex,
                         "up primary");
        ASSERT_OK(system("ip addr add dev " netkit_name " 10.0.0.1/24"),
                         "addr primary");
+
+       if (mode == NETKIT_L3) {
+               ASSERT_EQ(system("ip link set dev " netkit_name
+                                " addr ee:ff:bb:cc:aa:dd 2> /dev/null"), 512,
+                                "set hwaddress");
+       } else {
+               ASSERT_OK(system("ip link set dev " netkit_name
+                                " addr ee:ff:bb:cc:aa:dd"),
+                                "set hwaddress");
+       }
        if (same_netns) {
                ASSERT_OK(system("ip link set dev " netkit_peer " up"),
                                 "up peer");