public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [bpf-next v1 1/5] selftests/bpf: use sockaddr_storage instead of addr_port in cls_redirect test
       [not found] <20251115225550.1086693-1-hoyeon.lee@suse.com>
@ 2025-11-15 22:55 ` Hoyeon Lee
  2025-11-18 23:12   ` Martin KaFai Lau
  2025-11-15 22:55 ` [bpf-next v1 2/5] selftests/bpf: use sockaddr_storage instead of sa46 in select_reuseport test Hoyeon Lee
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Hoyeon Lee @ 2025-11-15 22:55 UTC (permalink / raw)
  To: bpf
  Cc: Hoyeon Lee, Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Shuah Khan, linux-kselftest, linux-kernel

The cls_redirect test uses a custom addr_port structure to represent
IPv4/IPv6 addresses and ports. This custom wrapper requires extra
conversion logic and specific helpers such as fill_addr_port(), which
are no longer necessary when using standard socket address structures.

This commit replaces addr_port with the standard sockaddr_storage so
that test handles address families and ports using the native socket
types. This removes the custom helper, eliminates redundant casts,
and simplifies tuple handling without functional changes.

Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com>
---
 .../selftests/bpf/prog_tests/cls_redirect.c   | 95 ++++++-------------
 1 file changed, 30 insertions(+), 65 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/cls_redirect.c b/tools/testing/selftests/bpf/prog_tests/cls_redirect.c
index 34b59f6baca1..9a7d365f9b24 100644
--- a/tools/testing/selftests/bpf/prog_tests/cls_redirect.c
+++ b/tools/testing/selftests/bpf/prog_tests/cls_redirect.c
@@ -22,79 +22,42 @@
 
 static int duration = 0;
 
-struct addr_port {
-	in_port_t port;
-	union {
-		struct in_addr in_addr;
-		struct in6_addr in6_addr;
-	};
-};
-
 struct tuple {
 	int family;
-	struct addr_port src;
-	struct addr_port dst;
+	struct sockaddr_storage src;
+	struct sockaddr_storage dst;
 };
 
-static bool fill_addr_port(const struct sockaddr *sa, struct addr_port *ap)
-{
-	const struct sockaddr_in6 *in6;
-	const struct sockaddr_in *in;
-
-	switch (sa->sa_family) {
-	case AF_INET:
-		in = (const struct sockaddr_in *)sa;
-		ap->in_addr = in->sin_addr;
-		ap->port = in->sin_port;
-		return true;
-
-	case AF_INET6:
-		in6 = (const struct sockaddr_in6 *)sa;
-		ap->in6_addr = in6->sin6_addr;
-		ap->port = in6->sin6_port;
-		return true;
-
-	default:
-		return false;
-	}
-}
 
-static bool set_up_conn(const struct sockaddr *addr, socklen_t len, int type,
+static bool set_up_conn(const struct sockaddr_storage *addr, socklen_t len, int type,
 			int *server, int *conn, struct tuple *tuple)
 {
 	struct sockaddr_storage ss;
 	socklen_t slen = sizeof(ss);
-	struct sockaddr *sa = (struct sockaddr *)&ss;
 
-	*server = start_server_addr(type, (struct sockaddr_storage *)addr, len, NULL);
+	*server = start_server_addr(type, addr, len, NULL);
 	if (*server < 0)
 		return false;
 
-	if (CHECK_FAIL(getsockname(*server, sa, &slen)))
+	if (CHECK_FAIL(getsockname(*server, (struct sockaddr *)&ss, &slen)))
 		goto close_server;
 
-	*conn = connect_to_addr(type, (struct sockaddr_storage *)sa, slen, NULL);
+	*conn = connect_to_addr(type, &ss, slen, NULL);
 	if (*conn < 0)
 		goto close_server;
 
 	/* We want to simulate packets arriving at conn, so we have to
 	 * swap src and dst.
 	 */
-	slen = sizeof(ss);
-	if (CHECK_FAIL(getsockname(*conn, sa, &slen)))
+	slen = sizeof(tuple->dst);
+	if (CHECK_FAIL(getsockname(*conn, (struct sockaddr *)&tuple->dst, &slen)))
 		goto close_conn;
 
-	if (CHECK_FAIL(!fill_addr_port(sa, &tuple->dst)))
+	slen = sizeof(tuple->src);
+	if (CHECK_FAIL(getpeername(*conn, (struct sockaddr *)&tuple->src, &slen)))
 		goto close_conn;
 
-	slen = sizeof(ss);
-	if (CHECK_FAIL(getpeername(*conn, sa, &slen)))
-		goto close_conn;
-
-	if (CHECK_FAIL(!fill_addr_port(sa, &tuple->src)))
-		goto close_conn;
-
-	tuple->family = ss.ss_family;
+	tuple->family = tuple->dst.ss_family;
 	return true;
 
 close_conn:
@@ -110,17 +73,16 @@ static socklen_t prepare_addr(struct sockaddr_storage *addr, int family)
 {
 	struct sockaddr_in *addr4;
 	struct sockaddr_in6 *addr6;
+	memset(addr, 0, sizeof(*addr));
 
 	switch (family) {
 	case AF_INET:
 		addr4 = (struct sockaddr_in *)addr;
-		memset(addr4, 0, sizeof(*addr4));
 		addr4->sin_family = family;
 		addr4->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 		return sizeof(*addr4);
 	case AF_INET6:
 		addr6 = (struct sockaddr_in6 *)addr;
-		memset(addr6, 0, sizeof(*addr6));
 		addr6->sin6_family = family;
 		addr6->sin6_addr = in6addr_loopback;
 		return sizeof(*addr6);
@@ -244,7 +206,11 @@ static void encap_init(encap_headers_t *encap, uint8_t hop_count, uint8_t proto)
 static size_t build_input(const struct test_cfg *test, void *const buf,
 			  const struct tuple *tuple)
 {
-	in_port_t sport = tuple->src.port;
+	struct sockaddr_in6 *src_in6 = (struct sockaddr_in6 *)&tuple->src;
+	struct sockaddr_in6 *dst_in6 = (struct sockaddr_in6 *)&tuple->dst;
+	struct sockaddr_in *src_in = (struct sockaddr_in *)&tuple->src;
+	struct sockaddr_in *dst_in = (struct sockaddr_in *)&tuple->dst;
+	in_port_t sport, dport;
 	encap_headers_t encap;
 	struct iphdr ip;
 	struct ipv6hdr ipv6;
@@ -254,6 +220,9 @@ static size_t build_input(const struct test_cfg *test, void *const buf,
 	uint8_t *p = buf;
 	int proto;
 
+	sport = (tuple->family == AF_INET) ? src_in->sin_port : src_in6->sin6_port;
+	dport = (tuple->family == AF_INET) ? dst_in->sin_port : dst_in6->sin6_port;
+
 	proto = IPPROTO_IPIP;
 	if (tuple->family == AF_INET6)
 		proto = IPPROTO_IPV6;
@@ -277,8 +246,8 @@ static size_t build_input(const struct test_cfg *test, void *const buf,
 			.version = 4,
 			.ttl = IPDEFTTL,
 			.protocol = proto,
-			.saddr = tuple->src.in_addr.s_addr,
-			.daddr = tuple->dst.in_addr.s_addr,
+			.saddr = src_in->sin_addr.s_addr,
+			.daddr = dst_in->sin_addr.s_addr,
 		};
 		p = mempcpy(p, &ip, sizeof(ip));
 		break;
@@ -287,8 +256,8 @@ static size_t build_input(const struct test_cfg *test, void *const buf,
 			.version = 6,
 			.hop_limit = IPDEFTTL,
 			.nexthdr = proto,
-			.saddr = tuple->src.in6_addr,
-			.daddr = tuple->dst.in6_addr,
+			.saddr = src_in6->sin6_addr,
+			.daddr = dst_in6->sin6_addr,
 		};
 		p = mempcpy(p, &ipv6, sizeof(ipv6));
 		break;
@@ -303,18 +272,16 @@ static size_t build_input(const struct test_cfg *test, void *const buf,
 	case TCP:
 		tcp = (struct tcphdr){
 			.source = sport,
-			.dest = tuple->dst.port,
+			.dest = dport,
+			.syn = (test->flags == SYN),
+			.ack = (test->flags == ACK),
 		};
-		if (test->flags == SYN)
-			tcp.syn = true;
-		if (test->flags == ACK)
-			tcp.ack = true;
 		p = mempcpy(p, &tcp, sizeof(tcp));
 		break;
 	case UDP:
 		udp = (struct udphdr){
 			.source = sport,
-			.dest = tuple->dst.port,
+			.dest = dport,
 		};
 		p = mempcpy(p, &udp, sizeof(udp));
 		break;
@@ -339,25 +306,23 @@ static void test_cls_redirect_common(struct bpf_program *prog)
 	LIBBPF_OPTS(bpf_test_run_opts, tattr);
 	int families[] = { AF_INET, AF_INET6 };
 	struct sockaddr_storage ss;
-	struct sockaddr *addr;
 	socklen_t slen;
 	int i, j, err, prog_fd;
 	int servers[__NR_KIND][ARRAY_SIZE(families)] = {};
 	int conns[__NR_KIND][ARRAY_SIZE(families)] = {};
 	struct tuple tuples[__NR_KIND][ARRAY_SIZE(families)];
 
-	addr = (struct sockaddr *)&ss;
 	for (i = 0; i < ARRAY_SIZE(families); i++) {
 		slen = prepare_addr(&ss, families[i]);
 		if (CHECK_FAIL(!slen))
 			goto cleanup;
 
-		if (CHECK_FAIL(!set_up_conn(addr, slen, SOCK_DGRAM,
+		if (CHECK_FAIL(!set_up_conn(&ss, slen, SOCK_DGRAM,
 					    &servers[UDP][i], &conns[UDP][i],
 					    &tuples[UDP][i])))
 			goto cleanup;
 
-		if (CHECK_FAIL(!set_up_conn(addr, slen, SOCK_STREAM,
+		if (CHECK_FAIL(!set_up_conn(&ss, slen, SOCK_STREAM,
 					    &servers[TCP][i], &conns[TCP][i],
 					    &tuples[TCP][i])))
 			goto cleanup;
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bpf-next v1 2/5] selftests/bpf: use sockaddr_storage instead of sa46 in select_reuseport test
       [not found] <20251115225550.1086693-1-hoyeon.lee@suse.com>
  2025-11-15 22:55 ` [bpf-next v1 1/5] selftests/bpf: use sockaddr_storage instead of addr_port in cls_redirect test Hoyeon Lee
@ 2025-11-15 22:55 ` Hoyeon Lee
  2025-11-15 22:55 ` [bpf-next v1 3/5] selftests/bpf: move common TCP helpers into bpf_tracing_net.h Hoyeon Lee
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Hoyeon Lee @ 2025-11-15 22:55 UTC (permalink / raw)
  To: bpf
  Cc: Hoyeon Lee, Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Shuah Khan, linux-kselftest, linux-kernel

The select_reuseport selftest uses a custom sa46 union to represent
IPv4 and IPv6 addresses. This custom wrapper requires extra manual
handling for address family and field extraction.

Replace sa46 with sockaddr_storage and update the helper functions to
operate on native socket structures. This simplifies the code and
removes unnecessary custom address-handling logic. No functional
changes intended.

Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com>
---
 .../bpf/prog_tests/select_reuseport.c         | 67 ++++++++++---------
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
index 036d4760d2c1..3dbcc091f16c 100644
--- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
+++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
@@ -41,11 +41,7 @@ static struct bpf_object *obj;
 static __u32 index_zero;
 static int epfd;
 
-static union sa46 {
-	struct sockaddr_in6 v6;
-	struct sockaddr_in v4;
-	sa_family_t family;
-} srv_sa;
+static struct sockaddr_storage srv_sa;
 
 #define RET_IF(condition, tag, format...) ({				\
 	if (CHECK_FAIL(condition)) {					\
@@ -135,24 +131,24 @@ static int prepare_bpf_obj(void)
 	return 0;
 }
 
-static void sa46_init_loopback(union sa46 *sa, sa_family_t family)
+static void ss_init_loopback(struct sockaddr_storage *sa, sa_family_t family)
 {
 	memset(sa, 0, sizeof(*sa));
-	sa->family = family;
-	if (sa->family == AF_INET6)
-		sa->v6.sin6_addr = in6addr_loopback;
+	sa->ss_family = family;
+	if (sa->ss_family == AF_INET6)
+		((struct sockaddr_in6 *)sa)->sin6_addr = in6addr_loopback;
 	else
-		sa->v4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+		((struct sockaddr_in *)sa)->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 }
 
-static void sa46_init_inany(union sa46 *sa, sa_family_t family)
+static void ss_init_inany(struct sockaddr_storage *sa, sa_family_t family)
 {
 	memset(sa, 0, sizeof(*sa));
-	sa->family = family;
-	if (sa->family == AF_INET6)
-		sa->v6.sin6_addr = in6addr_any;
+	sa->ss_family = family;
+	if (sa->ss_family == AF_INET6)
+		((struct sockaddr_in6 *)sa)->sin6_addr = in6addr_any;
 	else
-		sa->v4.sin_addr.s_addr = INADDR_ANY;
+		((struct sockaddr_in *)sa)->sin_addr.s_addr = INADDR_ANY;
 }
 
 static int read_int_sysctl(const char *sysctl)
@@ -228,7 +224,7 @@ static void check_data(int type, sa_family_t family, const struct cmd *cmd,
 		       int cli_fd)
 {
 	struct data_check expected = {}, result;
-	union sa46 cli_sa;
+	struct sockaddr_storage cli_sa;
 	socklen_t addrlen;
 	int err;
 
@@ -251,26 +247,32 @@ static void check_data(int type, sa_family_t family, const struct cmd *cmd,
 	}
 
 	if (family == AF_INET6) {
+		struct sockaddr_in6 *srv_v6 = (struct sockaddr_in6 *)&srv_sa;
+		struct sockaddr_in6 *cli_v6 = (struct sockaddr_in6 *)&cli_sa;
+
 		expected.eth_protocol = htons(ETH_P_IPV6);
-		expected.bind_inany = !srv_sa.v6.sin6_addr.s6_addr32[3] &&
-			!srv_sa.v6.sin6_addr.s6_addr32[2] &&
-			!srv_sa.v6.sin6_addr.s6_addr32[1] &&
-			!srv_sa.v6.sin6_addr.s6_addr32[0];
+		expected.bind_inany = !srv_v6->sin6_addr.s6_addr32[3] &&
+			!srv_v6->sin6_addr.s6_addr32[2] &&
+			!srv_v6->sin6_addr.s6_addr32[1] &&
+			!srv_v6->sin6_addr.s6_addr32[0];
 
-		memcpy(&expected.skb_addrs[0], cli_sa.v6.sin6_addr.s6_addr32,
-		       sizeof(cli_sa.v6.sin6_addr));
+		memcpy(&expected.skb_addrs[0], cli_v6->sin6_addr.s6_addr32,
+		       sizeof(cli_v6->sin6_addr));
 		memcpy(&expected.skb_addrs[4], &in6addr_loopback,
 		       sizeof(in6addr_loopback));
-		expected.skb_ports[0] = cli_sa.v6.sin6_port;
-		expected.skb_ports[1] = srv_sa.v6.sin6_port;
+		expected.skb_ports[0] = cli_v6->sin6_port;
+		expected.skb_ports[1] = srv_v6->sin6_port;
 	} else {
+		struct sockaddr_in *srv_v4 = (struct sockaddr_in *)&srv_sa;
+		struct sockaddr_in *cli_v4 = (struct sockaddr_in *)&cli_sa;
+
 		expected.eth_protocol = htons(ETH_P_IP);
-		expected.bind_inany = !srv_sa.v4.sin_addr.s_addr;
+		expected.bind_inany = !srv_v4->sin_addr.s_addr;
 
-		expected.skb_addrs[0] = cli_sa.v4.sin_addr.s_addr;
+		expected.skb_addrs[0] = cli_v4->sin_addr.s_addr;
 		expected.skb_addrs[1] = htonl(INADDR_LOOPBACK);
-		expected.skb_ports[0] = cli_sa.v4.sin_port;
-		expected.skb_ports[1] = srv_sa.v4.sin_port;
+		expected.skb_ports[0] = cli_v4->sin_port;
+		expected.skb_ports[1] = srv_v4->sin_port;
 	}
 
 	if (memcmp(&result, &expected, offsetof(struct data_check,
@@ -364,16 +366,15 @@ static void check_results(void)
 static int send_data(int type, sa_family_t family, void *data, size_t len,
 		     enum result expected)
 {
-	union sa46 cli_sa;
+	struct sockaddr_storage cli_sa;
 	int fd, err;
 
 	fd = socket(family, type, 0);
 	RET_ERR(fd == -1, "socket()", "fd:%d errno:%d\n", fd, errno);
 
-	sa46_init_loopback(&cli_sa, family);
+	ss_init_loopback(&cli_sa, family);
 	err = bind(fd, (struct sockaddr *)&cli_sa, sizeof(cli_sa));
 	RET_ERR(fd == -1, "bind(cli_sa)", "err:%d errno:%d\n", err, errno);
-
 	err = sendto(fd, data, len, MSG_FASTOPEN, (struct sockaddr *)&srv_sa,
 		     sizeof(srv_sa));
 	RET_ERR(err != len && expected >= PASS,
@@ -589,9 +590,9 @@ static void prepare_sk_fds(int type, sa_family_t family, bool inany)
 	socklen_t addrlen;
 
 	if (inany)
-		sa46_init_inany(&srv_sa, family);
+		ss_init_inany(&srv_sa, family);
 	else
-		sa46_init_loopback(&srv_sa, family);
+		ss_init_loopback(&srv_sa, family);
 	addrlen = sizeof(srv_sa);
 
 	/*
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bpf-next v1 3/5] selftests/bpf: move common TCP helpers into bpf_tracing_net.h
       [not found] <20251115225550.1086693-1-hoyeon.lee@suse.com>
  2025-11-15 22:55 ` [bpf-next v1 1/5] selftests/bpf: use sockaddr_storage instead of addr_port in cls_redirect test Hoyeon Lee
  2025-11-15 22:55 ` [bpf-next v1 2/5] selftests/bpf: use sockaddr_storage instead of sa46 in select_reuseport test Hoyeon Lee
@ 2025-11-15 22:55 ` Hoyeon Lee
  2025-11-15 22:55 ` [bpf-next v1 4/5] selftests/bpf: replace TCP CC string comparisons with bpf_strncmp Hoyeon Lee
  2025-11-15 22:55 ` [bpf-next v1 5/5] selftests/bpf: propagate LLVM toolchain to runqslower build Hoyeon Lee
  4 siblings, 0 replies; 10+ messages in thread
From: Hoyeon Lee @ 2025-11-15 22:55 UTC (permalink / raw)
  To: bpf
  Cc: Hoyeon Lee, Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Shuah Khan, Shubham Sharma, Saket Kumar Bhaskar, Jason Xing,
	Jordan Rife, linux-kselftest, linux-kernel

Some BPF selftests contain identical copies of the min(), max(),
before(), and after() helpers. These repeated snippets are the same
across the tests and do not need to be defined separately.

Move these helpers into bpf_tracing_net.h so they can be shared by
TCP related BPF programs. This removes repeated code and keeps the
helpers in a single place.

Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com>
---
 tools/testing/selftests/bpf/progs/bpf_cc_cubic.c      |  9 ---------
 tools/testing/selftests/bpf/progs/bpf_cubic.c         |  7 -------
 tools/testing/selftests/bpf/progs/bpf_dctcp.c         |  6 ------
 tools/testing/selftests/bpf/progs/bpf_tracing_net.h   | 11 +++++++++++
 .../selftests/bpf/progs/tcp_ca_write_sk_pacing.c      |  2 --
 5 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/bpf_cc_cubic.c b/tools/testing/selftests/bpf/progs/bpf_cc_cubic.c
index 4e51785e7606..9af19dfe4e80 100644
--- a/tools/testing/selftests/bpf/progs/bpf_cc_cubic.c
+++ b/tools/testing/selftests/bpf/progs/bpf_cc_cubic.c
@@ -22,10 +22,6 @@
 #define TCP_PACING_CA_RATIO (120)
 #define TCP_REORDERING (12)
 
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#define after(seq2, seq1) before(seq1, seq2)
-
 extern void cubictcp_init(struct sock *sk) __ksym;
 extern void cubictcp_cwnd_event(struct sock *sk, enum tcp_ca_event event) __ksym;
 extern __u32 cubictcp_recalc_ssthresh(struct sock *sk) __ksym;
@@ -34,11 +30,6 @@ extern __u32 tcp_reno_undo_cwnd(struct sock *sk) __ksym;
 extern void cubictcp_acked(struct sock *sk, const struct ack_sample *sample) __ksym;
 extern void cubictcp_cong_avoid(struct sock *sk, __u32 ack, __u32 acked) __ksym;
 
-static bool before(__u32 seq1, __u32 seq2)
-{
-	return (__s32)(seq1-seq2) < 0;
-}
-
 static __u64 div64_u64(__u64 dividend, __u64 divisor)
 {
 	return dividend / divisor;
diff --git a/tools/testing/selftests/bpf/progs/bpf_cubic.c b/tools/testing/selftests/bpf/progs/bpf_cubic.c
index f089faa97ae6..46fb2b37d3a7 100644
--- a/tools/testing/selftests/bpf/progs/bpf_cubic.c
+++ b/tools/testing/selftests/bpf/progs/bpf_cubic.c
@@ -20,13 +20,6 @@
 char _license[] SEC("license") = "GPL";
 
 #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) > (b) ? (a) : (b))
-static bool before(__u32 seq1, __u32 seq2)
-{
-	return (__s32)(seq1-seq2) < 0;
-}
-#define after(seq2, seq1) 	before(seq1, seq2)
 
 extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked) __ksym;
 extern void tcp_cong_avoid_ai(struct tcp_sock *tp, __u32 w, __u32 acked) __ksym;
diff --git a/tools/testing/selftests/bpf/progs/bpf_dctcp.c b/tools/testing/selftests/bpf/progs/bpf_dctcp.c
index 32c511bcd60b..1cc83140849f 100644
--- a/tools/testing/selftests/bpf/progs/bpf_dctcp.c
+++ b/tools/testing/selftests/bpf/progs/bpf_dctcp.c
@@ -13,16 +13,10 @@
 #ifndef EBUSY
 #define EBUSY 16
 #endif
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) > (b) ? (a) : (b))
 #define min_not_zero(x, y) ({			\
 	typeof(x) __x = (x);			\
 	typeof(y) __y = (y);			\
 	__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
-static bool before(__u32 seq1, __u32 seq2)
-{
-	return (__s32)(seq1-seq2) < 0;
-}
 
 char _license[] SEC("license") = "GPL";
 
diff --git a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
index 17db400f0e0d..39e98e16c113 100644
--- a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
+++ b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
@@ -5,6 +5,17 @@
 #include <vmlinux.h>
 #include <bpf/bpf_core_read.h>
 
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#define max(a, b) ((a) > (b) ? (a) : (b))
+
+static inline bool before(__u32 seq1, __u32 seq2)
+{
+	return (__s32)(seq1 - seq2) < 0;
+}
+
+#define after(seq2, seq1) before(seq1, seq2)
+
+
 #define AF_INET			2
 #define AF_INET6		10
 
diff --git a/tools/testing/selftests/bpf/progs/tcp_ca_write_sk_pacing.c b/tools/testing/selftests/bpf/progs/tcp_ca_write_sk_pacing.c
index a58b5194fc89..022291f21dfb 100644
--- a/tools/testing/selftests/bpf/progs/tcp_ca_write_sk_pacing.c
+++ b/tools/testing/selftests/bpf/progs/tcp_ca_write_sk_pacing.c
@@ -8,8 +8,6 @@ char _license[] SEC("license") = "GPL";
 
 #define USEC_PER_SEC 1000000UL
 
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
 static unsigned int tcp_left_out(const struct tcp_sock *tp)
 {
 	return tp->sacked_out + tp->lost_out;
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bpf-next v1 4/5] selftests/bpf: replace TCP CC string comparisons with bpf_strncmp
       [not found] <20251115225550.1086693-1-hoyeon.lee@suse.com>
                   ` (2 preceding siblings ...)
  2025-11-15 22:55 ` [bpf-next v1 3/5] selftests/bpf: move common TCP helpers into bpf_tracing_net.h Hoyeon Lee
@ 2025-11-15 22:55 ` Hoyeon Lee
  2025-11-15 22:55 ` [bpf-next v1 5/5] selftests/bpf: propagate LLVM toolchain to runqslower build Hoyeon Lee
  4 siblings, 0 replies; 10+ messages in thread
From: Hoyeon Lee @ 2025-11-15 22:55 UTC (permalink / raw)
  To: bpf
  Cc: Hoyeon Lee, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Shuah Khan, linux-kselftest, linux-kernel

The connect4_prog and bpf_iter_setsockopt tests duplicate the same
open-coded TCP congestion control string comparison logic. Since
bpf_strncmp() provides the same functionality, use it instead to
avoid repeated open-coded loops.

This change applies only to functional BPF tests and does not affect
the verifier performance benchmarks (veristat.cfg). No functional
changes intended.

Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com>
---
 .../selftests/bpf/progs/bpf_iter_setsockopt.c | 17 ++-------------
 .../selftests/bpf/progs/connect4_prog.c       | 21 +++++++------------
 2 files changed, 10 insertions(+), 28 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_setsockopt.c b/tools/testing/selftests/bpf/progs/bpf_iter_setsockopt.c
index 774d4dbe8189..a8aa5a71d846 100644
--- a/tools/testing/selftests/bpf/progs/bpf_iter_setsockopt.c
+++ b/tools/testing/selftests/bpf/progs/bpf_iter_setsockopt.c
@@ -18,23 +18,10 @@
 
 unsigned short reuse_listen_hport = 0;
 unsigned short listen_hport = 0;
-char cubic_cc[TCP_CA_NAME_MAX] = "bpf_cubic";
+const char cubic_cc[] = "bpf_cubic";
 char dctcp_cc[TCP_CA_NAME_MAX] = "bpf_dctcp";
 bool random_retry = false;
 
-static bool tcp_cc_eq(const char *a, const char *b)
-{
-	int i;
-
-	for (i = 0; i < TCP_CA_NAME_MAX; i++) {
-		if (a[i] != b[i])
-			return false;
-		if (!a[i])
-			break;
-	}
-
-	return true;
-}
 
 SEC("iter/tcp")
 int change_tcp_cc(struct bpf_iter__tcp *ctx)
@@ -58,7 +45,7 @@ int change_tcp_cc(struct bpf_iter__tcp *ctx)
 			   cur_cc, sizeof(cur_cc)))
 		return 0;
 
-	if (!tcp_cc_eq(cur_cc, cubic_cc))
+	if (bpf_strncmp(cur_cc, TCP_CA_NAME_MAX, cubic_cc))
 		return 0;
 
 	if (random_retry && bpf_get_prandom_u32() % 4 == 1)
diff --git a/tools/testing/selftests/bpf/progs/connect4_prog.c b/tools/testing/selftests/bpf/progs/connect4_prog.c
index 9e9ebf27b878..9d158cfad981 100644
--- a/tools/testing/selftests/bpf/progs/connect4_prog.c
+++ b/tools/testing/selftests/bpf/progs/connect4_prog.c
@@ -34,6 +34,9 @@
 #define SOL_TCP 6
 #endif
 
+const char reno[] = "reno";
+const char cubic[] = "cubic";
+
 __attribute__ ((noinline)) __weak
 int do_bind(struct bpf_sock_addr *ctx)
 {
@@ -50,35 +53,27 @@ int do_bind(struct bpf_sock_addr *ctx)
 }
 
 static __inline int verify_cc(struct bpf_sock_addr *ctx,
-			      char expected[TCP_CA_NAME_MAX])
+			      const char expected[])
 {
 	char buf[TCP_CA_NAME_MAX];
-	int i;
 
 	if (bpf_getsockopt(ctx, SOL_TCP, TCP_CONGESTION, &buf, sizeof(buf)))
 		return 1;
 
-	for (i = 0; i < TCP_CA_NAME_MAX; i++) {
-		if (buf[i] != expected[i])
-			return 1;
-		if (buf[i] == 0)
-			break;
-	}
+	if (bpf_strncmp(buf, TCP_CA_NAME_MAX, expected))
+		return 1;
 
 	return 0;
 }
 
 static __inline int set_cc(struct bpf_sock_addr *ctx)
 {
-	char reno[TCP_CA_NAME_MAX] = "reno";
-	char cubic[TCP_CA_NAME_MAX] = "cubic";
-
-	if (bpf_setsockopt(ctx, SOL_TCP, TCP_CONGESTION, &reno, sizeof(reno)))
+	if (bpf_setsockopt(ctx, SOL_TCP, TCP_CONGESTION, (void *)reno, sizeof(reno)))
 		return 1;
 	if (verify_cc(ctx, reno))
 		return 1;
 
-	if (bpf_setsockopt(ctx, SOL_TCP, TCP_CONGESTION, &cubic, sizeof(cubic)))
+	if (bpf_setsockopt(ctx, SOL_TCP, TCP_CONGESTION, (void *)cubic, sizeof(cubic)))
 		return 1;
 	if (verify_cc(ctx, cubic))
 		return 1;
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bpf-next v1 5/5] selftests/bpf: propagate LLVM toolchain to runqslower build
       [not found] <20251115225550.1086693-1-hoyeon.lee@suse.com>
                   ` (3 preceding siblings ...)
  2025-11-15 22:55 ` [bpf-next v1 4/5] selftests/bpf: replace TCP CC string comparisons with bpf_strncmp Hoyeon Lee
@ 2025-11-15 22:55 ` Hoyeon Lee
  2025-11-17  6:04   ` Yonghong Song
  4 siblings, 1 reply; 10+ messages in thread
From: Hoyeon Lee @ 2025-11-15 22:55 UTC (permalink / raw)
  To: bpf
  Cc: Hoyeon Lee, Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Shuah Khan, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, linux-kselftest, linux-kernel, llvm

The selftests/bpf invokes a nested make when building runqslower, but
LLVM toolchain version (clang/llvm-strip) is not propagated. As a
result, runqslower is built with system default clang, not respecting
specified LLVM version.

    # LLVM=-21 make -C tools/testing/selftests/bpf
    ...
    make feature_display=0 -C /bpf/tools/bpf/runqslower                        \
        OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/runqslower/        \
        BPFOBJ_OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/libbpf/     \
        BPFOBJ=/bpf/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.a    \
        BPF_INCLUDE=/bpf/tools/testing/selftests/bpf/tools/include             \
        BPFTOOL_OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/bpftool/   \
        VMLINUX_BTF=/sys/kernel/btf/vmlinux BPF_TARGET_ENDIAN=--target=bpfel   \
        EXTRA_CFLAGS='-g -O0  ' EXTRA_LDFLAGS=' ' &&                           \
        cp  /bpf/tools/testing/selftests/bpf/tools/build/runqslower/runqslower \
            /bpf/tools/testing/selftests/bpf/runqslower
    clang -g -O2 --target=bpfel -I/bpf/tools/testing/selftests/bpf/tools/build/runqslower/ \
          -I/bpf/tools/testing/selftests/bpf/tools/include -I/bpf/tools/include/uapi       \
          -c runqslower.bpf.c -o /bpf/tools/testing/selftests/bpf/tools/build/runqslower/runqslower.bpf.o && \
          llvm-strip -g /bpf/tools/testing/selftests/bpf/tools/build/runqslower//runqslower.bpf.o
    /bin/sh: 1: clang: not found

Explicitly propagate CLANG and LLVM_STRIP to the runqslower sub-make so
that the LLVM toolchain selection from lib.mk is preserved.

Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com>
---
 tools/testing/selftests/bpf/Makefile | 1 +
 tools/testing/selftests/lib.mk       | 1 +
 2 files changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 34ea23c63bd5..79ab69920dca 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -306,6 +306,7 @@ endif
 
 $(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) $(RUNQSLOWER_OUTPUT)
 	$(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower	       \
+		    CLANG=$(CLANG) LLVM_STRIP=$(LLVM_STRIP)		       \
 		    OUTPUT=$(RUNQSLOWER_OUTPUT) VMLINUX_BTF=$(VMLINUX_BTF)     \
 		    BPFTOOL_OUTPUT=$(HOST_BUILD_DIR)/bpftool/		       \
 		    BPFOBJ_OUTPUT=$(BUILD_DIR)/libbpf/			       \
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index a448fae57831..f14255b2afbd 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -8,6 +8,7 @@ LLVM_SUFFIX := $(LLVM)
 endif
 
 CLANG := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
+LLVM_STRIP := $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
 
 CLANG_TARGET_FLAGS_arm          := arm-linux-gnueabi
 CLANG_TARGET_FLAGS_arm64        := aarch64-linux-gnu
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [bpf-next v1 5/5] selftests/bpf: propagate LLVM toolchain to runqslower build
  2025-11-15 22:55 ` [bpf-next v1 5/5] selftests/bpf: propagate LLVM toolchain to runqslower build Hoyeon Lee
@ 2025-11-17  6:04   ` Yonghong Song
  2025-11-17  6:37     ` Hoyeon Lee
  0 siblings, 1 reply; 10+ messages in thread
From: Yonghong Song @ 2025-11-17  6:04 UTC (permalink / raw)
  To: Hoyeon Lee, bpf
  Cc: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-kselftest, linux-kernel, llvm



On 11/15/25 2:55 PM, Hoyeon Lee wrote:
> The selftests/bpf invokes a nested make when building runqslower, but
> LLVM toolchain version (clang/llvm-strip) is not propagated. As a
> result, runqslower is built with system default clang, not respecting
> specified LLVM version.
>
>      # LLVM=-21 make -C tools/testing/selftests/bpf
>      ...
>      make feature_display=0 -C /bpf/tools/bpf/runqslower                        \
>          OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/runqslower/        \
>          BPFOBJ_OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/libbpf/     \
>          BPFOBJ=/bpf/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.a    \
>          BPF_INCLUDE=/bpf/tools/testing/selftests/bpf/tools/include             \
>          BPFTOOL_OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/bpftool/   \
>          VMLINUX_BTF=/sys/kernel/btf/vmlinux BPF_TARGET_ENDIAN=--target=bpfel   \
>          EXTRA_CFLAGS='-g -O0  ' EXTRA_LDFLAGS=' ' &&                           \
>          cp  /bpf/tools/testing/selftests/bpf/tools/build/runqslower/runqslower \
>              /bpf/tools/testing/selftests/bpf/runqslower
>      clang -g -O2 --target=bpfel -I/bpf/tools/testing/selftests/bpf/tools/build/runqslower/ \
>            -I/bpf/tools/testing/selftests/bpf/tools/include -I/bpf/tools/include/uapi       \
>            -c runqslower.bpf.c -o /bpf/tools/testing/selftests/bpf/tools/build/runqslower/runqslower.bpf.o && \
>            llvm-strip -g /bpf/tools/testing/selftests/bpf/tools/build/runqslower//runqslower.bpf.o
>      /bin/sh: 1: clang: not found

I tried with LLVM=-20 make -C tools/testing/selftests/bpf in my system and
there is no build error.

Also could you try with command line
    make -C tools/testing/selftests/bpf LLVM=1
for clang build kernel or selftests, LLVM=1 is recommended as it
encodes a bunch of clang command lines:
   CC              = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
   LD              = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
   AR              = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
   NM              = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
   OBJCOPY         = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
   OBJDUMP         = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
   READELF         = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
   STRIP           = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)




>
> Explicitly propagate CLANG and LLVM_STRIP to the runqslower sub-make so
> that the LLVM toolchain selection from lib.mk is preserved.
>
> Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com>
> ---
>   tools/testing/selftests/bpf/Makefile | 1 +
>   tools/testing/selftests/lib.mk       | 1 +
>   2 files changed, 2 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 34ea23c63bd5..79ab69920dca 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -306,6 +306,7 @@ endif
>   
>   $(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) $(RUNQSLOWER_OUTPUT)
>   	$(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower	       \
> +		    CLANG=$(CLANG) LLVM_STRIP=$(LLVM_STRIP)		       \
>   		    OUTPUT=$(RUNQSLOWER_OUTPUT) VMLINUX_BTF=$(VMLINUX_BTF)     \
>   		    BPFTOOL_OUTPUT=$(HOST_BUILD_DIR)/bpftool/		       \
>   		    BPFOBJ_OUTPUT=$(BUILD_DIR)/libbpf/			       \
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index a448fae57831..f14255b2afbd 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -8,6 +8,7 @@ LLVM_SUFFIX := $(LLVM)
>   endif
>   
>   CLANG := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
> +LLVM_STRIP := $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
>   
>   CLANG_TARGET_FLAGS_arm          := arm-linux-gnueabi
>   CLANG_TARGET_FLAGS_arm64        := aarch64-linux-gnu


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [bpf-next v1 5/5] selftests/bpf: propagate LLVM toolchain to runqslower build
  2025-11-17  6:04   ` Yonghong Song
@ 2025-11-17  6:37     ` Hoyeon Lee
  0 siblings, 0 replies; 10+ messages in thread
From: Hoyeon Lee @ 2025-11-17  6:37 UTC (permalink / raw)
  To: Yonghong Song
  Cc: bpf, Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-kselftest, linux-kernel, llvm

On Mon, Nov 17, 2025 at 3:04 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>
>
>
> On 11/15/25 2:55 PM, Hoyeon Lee wrote:
> > The selftests/bpf invokes a nested make when building runqslower, but
> > LLVM toolchain version (clang/llvm-strip) is not propagated. As a
> > result, runqslower is built with system default clang, not respecting
> > specified LLVM version.
> >
> >      # LLVM=-21 make -C tools/testing/selftests/bpf
> >      ...
> >      make feature_display=0 -C /bpf/tools/bpf/runqslower                        \
> >          OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/runqslower/        \
> >          BPFOBJ_OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/libbpf/     \
> >          BPFOBJ=/bpf/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.a    \
> >          BPF_INCLUDE=/bpf/tools/testing/selftests/bpf/tools/include             \
> >          BPFTOOL_OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/bpftool/   \
> >          VMLINUX_BTF=/sys/kernel/btf/vmlinux BPF_TARGET_ENDIAN=--target=bpfel   \
> >          EXTRA_CFLAGS='-g -O0  ' EXTRA_LDFLAGS=' ' &&                           \
> >          cp  /bpf/tools/testing/selftests/bpf/tools/build/runqslower/runqslower \
> >              /bpf/tools/testing/selftests/bpf/runqslower
> >      clang -g -O2 --target=bpfel -I/bpf/tools/testing/selftests/bpf/tools/build/runqslower/ \
> >            -I/bpf/tools/testing/selftests/bpf/tools/include -I/bpf/tools/include/uapi       \
> >            -c runqslower.bpf.c -o /bpf/tools/testing/selftests/bpf/tools/build/runqslower/runqslower.bpf.o && \
> >            llvm-strip -g /bpf/tools/testing/selftests/bpf/tools/build/runqslower//runqslower.bpf.o
> >      /bin/sh: 1: clang: not found
>
> I tried with LLVM=-20 make -C tools/testing/selftests/bpf in my system and
> there is no build error.
>
> Also could you try with command line
>     make -C tools/testing/selftests/bpf LLVM=1
> for clang build kernel or selftests, LLVM=1 is recommended as it
> encodes a bunch of clang command lines:
>    CC              = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
>    LD              = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
>    AR              = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
>    NM              = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
>    OBJCOPY         = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
>    OBJDUMP         = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
>    READELF         = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
>    STRIP           = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
>
>
Thanks for the review.

Just to clarify, the issue is not the build failure itself. The error
"clang: not found" only appeared because I intentionally did not set
update-alternatives to avoid falling back to the system default compiler.

The real issue is that the runqslower sub-make invokes "clang" instead
of "clang-21" when LLVM=-21 is specified. This shows that the selected
LLVM toolchain version is not being propagated into the nested build.

LLVM=1 works well for general builds, but in this case the intention is
to verify that a specific LLVM version is consistently applied across
all sub-makes. That propagation does not currently happen, and the patch
addresses exactly that.

Thanks again for taking a look.
>
>
> >
> > Explicitly propagate CLANG and LLVM_STRIP to the runqslower sub-make so
> > that the LLVM toolchain selection from lib.mk is preserved.
> >
> > Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com>
> > ---
> >   tools/testing/selftests/bpf/Makefile | 1 +
> >   tools/testing/selftests/lib.mk       | 1 +
> >   2 files changed, 2 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index 34ea23c63bd5..79ab69920dca 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -306,6 +306,7 @@ endif
> >
> >   $(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) $(RUNQSLOWER_OUTPUT)
> >       $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower            \
> > +                 CLANG=$(CLANG) LLVM_STRIP=$(LLVM_STRIP)                    \
> >                   OUTPUT=$(RUNQSLOWER_OUTPUT) VMLINUX_BTF=$(VMLINUX_BTF)     \
> >                   BPFTOOL_OUTPUT=$(HOST_BUILD_DIR)/bpftool/                  \
> >                   BPFOBJ_OUTPUT=$(BUILD_DIR)/libbpf/                         \
> > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> > index a448fae57831..f14255b2afbd 100644
> > --- a/tools/testing/selftests/lib.mk
> > +++ b/tools/testing/selftests/lib.mk
> > @@ -8,6 +8,7 @@ LLVM_SUFFIX := $(LLVM)
> >   endif
> >
> >   CLANG := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
> > +LLVM_STRIP := $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
> >
> >   CLANG_TARGET_FLAGS_arm          := arm-linux-gnueabi
> >   CLANG_TARGET_FLAGS_arm64        := aarch64-linux-gnu
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [bpf-next v1 1/5] selftests/bpf: use sockaddr_storage instead of addr_port in cls_redirect test
  2025-11-15 22:55 ` [bpf-next v1 1/5] selftests/bpf: use sockaddr_storage instead of addr_port in cls_redirect test Hoyeon Lee
@ 2025-11-18 23:12   ` Martin KaFai Lau
  2025-11-19  3:09     ` Hoyeon Lee
  0 siblings, 1 reply; 10+ messages in thread
From: Martin KaFai Lau @ 2025-11-18 23:12 UTC (permalink / raw)
  To: Hoyeon Lee
  Cc: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan,
	linux-kselftest, linux-kernel, bpf

On 11/15/25 2:55 PM, Hoyeon Lee wrote:

>   struct tuple {
>   	int family;

The "family" is not needed either. Just use the ss_family from src or 
dst. The 'struct tuple' can be removed also?

I'm on the fence about whether this "struct sockaddr_storage" change is 
worth the code churn. Are patch 1 and 2 the only tests that need this
change?

Patch 3 and 4 make sense. Patch 3 and 4 are applied.

Please post patch 5 as a separate patch on its own.

> -	struct addr_port src;
> -	struct addr_port dst;
> +	struct sockaddr_storage src;
> +	struct sockaddr_storage dst;
>   };


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [bpf-next v1 1/5] selftests/bpf: use sockaddr_storage instead of addr_port in cls_redirect test
  2025-11-18 23:12   ` Martin KaFai Lau
@ 2025-11-19  3:09     ` Hoyeon Lee
  2025-11-19 16:57       ` Martin KaFai Lau
  0 siblings, 1 reply; 10+ messages in thread
From: Hoyeon Lee @ 2025-11-19  3:09 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan,
	linux-kselftest, linux-kernel, bpf

On Wed, Nov 19, 2025 at 8:12 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>
> On 11/15/25 2:55 PM, Hoyeon Lee wrote:
>
> >   struct tuple {
> >       int family;
>
> The "family" is not needed either. Just use the ss_family from src or
> dst. The 'struct tuple' can be removed also?
>
> I'm on the fence about whether this "struct sockaddr_storage" change is
> worth the code churn. Are patch 1 and 2 the only tests that need this
> change?
>

Thanks for the feedback.

Yes, patches 1 and 2 are the only tests that use a custom address/port
representation. These are the last remaining cases, and no further
changes are needed elsewhere. The code churn is fully contained within
these two patches.

For the “family” field, agreed. ss_family is sufficient, and the tuple
wrapper can be removed. If you're okay with that direction, I can drop
the family field and resend patches 1 and 2 with that cleanup applied.

> Patch 3 and 4 make sense. Patch 3 and 4 are applied.
>
> Please post patch 5 as a separate patch on its own.
>

Thanks for applying patches 3 and 4. I will send patch 5 separately as
requested.

Thanks again for your time.


> > -     struct addr_port src;
> > -     struct addr_port dst;
> > +     struct sockaddr_storage src;
> > +     struct sockaddr_storage dst;
> >   };
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [bpf-next v1 1/5] selftests/bpf: use sockaddr_storage instead of addr_port in cls_redirect test
  2025-11-19  3:09     ` Hoyeon Lee
@ 2025-11-19 16:57       ` Martin KaFai Lau
  0 siblings, 0 replies; 10+ messages in thread
From: Martin KaFai Lau @ 2025-11-19 16:57 UTC (permalink / raw)
  To: Hoyeon Lee
  Cc: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan,
	linux-kselftest, linux-kernel, bpf

On 11/18/25 7:09 PM, Hoyeon Lee wrote:
> For the “family” field, agreed. ss_family is sufficient, and the tuple
> wrapper can be removed. If you're okay with that direction, I can drop
> the family field and resend patches 1 and 2 with that cleanup applied.

Please re-spin patch 1 and 2 with the 'struct tuple' cleanup. The 
patch's title should have "PATCH bpf-next v???". Take a look at other 
patches posted in the mailing list.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-11-19 16:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20251115225550.1086693-1-hoyeon.lee@suse.com>
2025-11-15 22:55 ` [bpf-next v1 1/5] selftests/bpf: use sockaddr_storage instead of addr_port in cls_redirect test Hoyeon Lee
2025-11-18 23:12   ` Martin KaFai Lau
2025-11-19  3:09     ` Hoyeon Lee
2025-11-19 16:57       ` Martin KaFai Lau
2025-11-15 22:55 ` [bpf-next v1 2/5] selftests/bpf: use sockaddr_storage instead of sa46 in select_reuseport test Hoyeon Lee
2025-11-15 22:55 ` [bpf-next v1 3/5] selftests/bpf: move common TCP helpers into bpf_tracing_net.h Hoyeon Lee
2025-11-15 22:55 ` [bpf-next v1 4/5] selftests/bpf: replace TCP CC string comparisons with bpf_strncmp Hoyeon Lee
2025-11-15 22:55 ` [bpf-next v1 5/5] selftests/bpf: propagate LLVM toolchain to runqslower build Hoyeon Lee
2025-11-17  6:04   ` Yonghong Song
2025-11-17  6:37     ` Hoyeon Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox