Skip to contentSkip to conversation

selftest: net: Use port outside of the default ip_local_ports in csum.c.

PATCH In review Kuniyuki Iwashima 3 participants 4 messages Apr 10 – Apr 12

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftest: net: Use port outside of the default ip_local_ports in csum.c.

csum.c binds a socket on a fixed port in init_net to test the csum offload feature between two machines.

In our testbed, the test sometimes fails with -EADDRINUSE.

bind r: Address already in use
bind dgram 6: Address already in use

The fixed ports (33000, 33001, 34000) are all within the default ip_local_ports range (32768 ~ 60999), and other processes may happen to be using them.

Let's use ports outside of the default ip_local_ports range to deflake the test.

  # cat /etc/services | grep -E "(13000|13001|13002)" | echo no service
  no service
  # rpm -qf /etc/services
  setup-2.15.0-28.fc44.noarch

We could add an option to specify ports if needed.

---
 tools/testing/selftests/net/lib/csum.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/net/lib/csum.c +3 -3
index e28884ce3ab3..4e044689bc37 100644
@@ -105,9 +105,9 @@ static char *cfg_mac_src;
 static int cfg_proto = IPPROTO_UDP;
 static int cfg_payload_char = 'a';
 static int cfg_payload_len = 100;
-static uint16_t cfg_port_dst = 34000;
-static uint16_t cfg_port_src = 33000;
-static uint16_t cfg_port_src_encap = 33001;
+static uint16_t cfg_port_dst = 13000;
+static uint16_t cfg_port_src = 13001;
+static uint16_t cfg_port_src_encap = 13002;
 static unsigned int cfg_random_seed;
 static int cfg_rcvbuf = 1 << 22;	/* be able to queue large cfg_num_pkt */
 static bool cfg_send_pfpacket;
Signature · 1 line
2.53.0.1213.gd9a14994de-goog
#1 lore raw
Quoted 33 lines · Kuniyuki Iwashima

csum.c binds a socket on a fixed port in init_net to test the csum offload feature between two machines.

In our testbed, the test sometimes fails with -EADDRINUSE.

bind r: Address already in use
bind dgram 6: Address already in use

The fixed ports (33000, 33001, 34000) are all within the default ip_local_ports range (32768 ~ 60999), and other processes may happen to be using them.

Let's use ports outside of the default ip_local_ports range to deflake the test.

  # cat /etc/services | grep -E "(13000|13001|13002)" | echo no service
  no service
  # rpm -qf /etc/services
  setup-2.15.0-28.fc44.noarch

We could add an option to specify ports if needed.

---
 tools/testing/selftests/net/lib/csum.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/net/lib/csum.c +0 -0
index e28884ce3ab3..4e044689bc37 100644

tools/testing/selftests/net/lib/csum.c static char *cfg_mac_src; · line 108

Quoted 4 lines
tools/testing/selftests/net/lib/csum.c +0 -1
@@ -105,9 +105,9 @@ static char *cfg_mac_src;
 static int cfg_proto = IPPROTO_UDP;
 static int cfg_payload_char = 'a';
 static int cfg_payload_len = 100;
-static uint16_t cfg_port_dst = 34000;

This is paired with wait_port_listen(3400, .. in
tools/testing/selftests/drivers/net/hw/csum.py

It is also used in tools/testing/selftests/drivers/net/hw/tso.py, which uses rand_port to select a port.

Probably more robust to indeed add an option to specify a port, and in all callers use rand_port(s).

Quoted 11 lines
tools/testing/selftests/net/lib/csum.c +3 -2
-static uint16_t cfg_port_src = 33000;
-static uint16_t cfg_port_src_encap = 33001;
+static uint16_t cfg_port_dst = 13000;
+static uint16_t cfg_port_src = 13001;
+static uint16_t cfg_port_src_encap = 13002;
 static unsigned int cfg_random_seed;
 static int cfg_rcvbuf = 1 << 22;	/* be able to queue large cfg_num_pkt */
 static bool cfg_send_pfpacket;
Signature · 1 line
2.53.0.1213.gd9a14994de-goog
maintainer
#2 lore raw
Quoted 4 lines · On Sat, 11 Apr 2026 15:18:56 -0400 Willem de Bruijn wrote:
Quoted 4 lines
tools/testing/selftests/net/lib/csum.c +0 -0
index e28884ce3ab3..4e044689bc37 100644
Quoted 8 lines

tools/testing/selftests/net/lib/csum.c static char *cfg_mac_src; · line 108

Quoted 5 lines
tools/testing/selftests/net/lib/csum.c +0 -1
@@ -105,9 +105,9 @@ static char *cfg_mac_src;
 static int cfg_proto = IPPROTO_UDP;
 static int cfg_payload_char = 'a';
 static int cfg_payload_len = 100;
-static uint16_t cfg_port_dst = 34000;  

This is paired with wait_port_listen(3400, .. in
tools/testing/selftests/drivers/net/hw/csum.py

FWIW I can confirm that this caused the HW testing in NIPA to fail the csum test since Friday.

#3 lore raw
Quoted 15 lines · Jakub Kicinski
Quoted 4 lines · On Sat, 11 Apr 2026 15:18:56 -0400 Willem de Bruijn wrote:
Quoted 4 lines
tools/testing/selftests/net/lib/csum.c +0 -0
index e28884ce3ab3..4e044689bc37 100644
Quoted 8 lines

tools/testing/selftests/net/lib/csum.c static char *cfg_mac_src; · line 108

Quoted 5 lines
tools/testing/selftests/net/lib/csum.c +0 -1
@@ -105,9 +105,9 @@ static char *cfg_mac_src;
 static int cfg_proto = IPPROTO_UDP;
 static int cfg_payload_char = 'a';
 static int cfg_payload_len = 100;
-static uint16_t cfg_port_dst = 34000;

This is paired with wait_port_listen(3400, .. in
tools/testing/selftests/drivers/net/hw/csum.py

Quoted 2 lines

FWIW I can confirm that this caused the HW testing in NIPA to fail the csum test since Friday.

Sorry, I'll cover that part and try the port option.