Skip to content

Commit 60400cd

Browse files
iii-iMartin KaFai Lau
authored and
Martin KaFai Lau
committed
selftests/bpf: Set MACs during veth creation in tc_redirect
tc_redirect/tc_redirect_dtime fails intermittently on some systems with: (network_helpers.c:303: errno: Operation now in progress) Failed to connect to server The problem is that on these systems systemd-networkd and systemd-udevd are installed in the default configuration, which includes: /usr/lib/systemd/network/99-default.link /usr/lib/udev/rules.d/80-net-setup-link.rules These configs instruct systemd to change MAC addresses of newly created interfaces, which includes the ones created by BPF selftests. In this particular case it causes SYN+ACK packets to be dropped, because they get the PACKET_OTHERHOST type - the fact that this causes a connect() on a blocking socket to return -EINPROGRESS looks like a bug, which needs to be investigated separately. systemd won't change the MAC address if the kernel reports that it was already set by userspace; the NET_ADDR_SET check in link_generate_new_hw_addr() is responsible for this. In order to eliminate the race window between systemd and the test, set MAC addresses during link creation. Ignore checkpatch's "quoted string split across lines" warning, since it points to a command line, and not a user-visible message. Signed-off-by: Ilya Leoshkevich <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent b9c09fb commit 60400cd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tools/testing/selftests/bpf/prog_tests/tc_redirect.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656

5757
#define MAC_DST_FWD "00:11:22:33:44:55"
5858
#define MAC_DST "00:22:33:44:55:66"
59+
#define MAC_SRC_FWD "00:33:44:55:66:77"
60+
#define MAC_SRC "00:44:55:66:77:88"
5961

6062
#define IFADDR_STR_LEN 18
6163
#define PING_ARGS "-i 0.2 -c 3 -w 10 -q"
@@ -207,11 +209,10 @@ static int netns_setup_links_and_routes(struct netns_setup_result *result)
207209
int err;
208210

209211
if (result->dev_mode == MODE_VETH) {
210-
SYS(fail, "ip link add src type veth peer name src_fwd");
211-
SYS(fail, "ip link add dst type veth peer name dst_fwd");
212-
213-
SYS(fail, "ip link set dst_fwd address " MAC_DST_FWD);
214-
SYS(fail, "ip link set dst address " MAC_DST);
212+
SYS(fail, "ip link add src address " MAC_SRC " type veth "
213+
"peer name src_fwd address " MAC_SRC_FWD);
214+
SYS(fail, "ip link add dst address " MAC_DST " type veth "
215+
"peer name dst_fwd address " MAC_DST_FWD);
215216
} else if (result->dev_mode == MODE_NETKIT) {
216217
err = create_netkit(NETKIT_L3, "src", "src_fwd");
217218
if (!ASSERT_OK(err, "create_ifindex_src"))

0 commit comments

Comments
 (0)