Skip to content

Commit

Permalink
selftests/bpf: Add netkit tests for mac address and mtu
Browse files Browse the repository at this point in the history
This adds two simple tests around setting MAC addresses in the different
netkit modes as well as syncing MTUs.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
borkmann committed May 24, 2024
1 parent 7778ab1 commit 61bd155
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/tc_netkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ 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");

ASSERT_OK(system("ip link set dev " netkit_name " mtu 4000"),
"set mtu");
ASSERT_OK(system("ip link show dev " netkit_peer " | grep 4000 > /dev/null"),
"get mtu");
ASSERT_OK(system("ip link set dev " netkit_peer " mtu 1500"),
"set mtu");
ASSERT_OK(system("ip link show dev " netkit_peer " | grep 4000 > /dev/null"),
"get mtu");

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");
Expand Down

0 comments on commit 61bd155

Please sign in to comment.