Skip to contentSkip to conversation

skbuff: Fix applications not being woken for errors

PATCH Applied Vinicius Costa Gomes 2 participants 3 messages Mar 16, 2018

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

v3 cover skbuff: Fix applications not being woken for errors

Hi,

Changes from v2:
- As the skbuff fix got applied into the net tree, removing from this series (didn't change the subject to avoid causing any more confusion);

Changes from v1:
- Fixed comments from Willem de Bruijn, about the order of the options passed to getopt();
- Added Reviewed-by and Fixes tags to patch (2);

Changes from the RFC:
- tweaked commit messages;

Original cover letter:

This is actually a "bug report"-RFC instead of the more usual "new feature"-RFC.

We are developing an application that uses TX hardware timestamping to make some measurements, and during development Randy Witt initially reported that the application poll() never unblocked when TX hardware timestamping was enabled.

After some investigation, it turned out the problem wasn't only exclusive to hardware timestamping, and could be reproduced with software timestamping.

Applying patch (1), and running txtimestamp like this, for example:

$ ./txtimestamp -u -4 192.168.1.71 -c 1000 -D -l 1000 -F

('-u' to use UDP only, '-4' for ipv4 only, '-c 1000' to send 1000 packets for each test, '-D' to remove the delay between packets, '-l 1000' to set the payload to 1000 bytes, '-F' for configuring poll() to wait forever)

will cause the application to become stuck in the poll() call in most of the times. (Note: I couldn't reproduce the issue running against an address that is routed through loopback.)

Another interesting fact is that if the POLLIN event is added to the poll() .events, poll() no longer becomes stuck, and more interestingly the returned event in .revents is only POLLERR.

After a few debugging sessions, we got to 'sock_queue_err_skb()' and how it notifies applications of the error just enqueued. Changing it to use 'sk->sk_error_report()', fixes the issue for hardware and software timestamping. That is patch (2).

The "solution" proposed in patch (2) looks like too big a hammer, if it's not, then it seems that this problem existed since a long time ago (pre git) and was uncommon for folks to reach the necessary conditions to trigger it (my hypothesis is that only triggers when the error is reported from a different task context than the application).

Am I missing something here?

Cheers,

Vinicius Costa Gomes (1):
selftests/txtimestamp: Add more configurable parameters

 .../selftests/networking/timestamping/txtimestamp.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

--
2.16.2

#1 lore raw

PATCH v3 1/1 selftests/txtimestamp: Add more configurable parameters

Add a way to configure if poll() should wait forever for an event, the number of packets that should be sent for each and if there should be any delay between packets.

---
 .../selftests/networking/timestamping/txtimestamp.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
tools/testing/selftests/networking/timestamping/txtimestamp.c +18 -3
index 5df07047ca86..81a98a240456 100644
@@ -68,9 +68,11 @@ static int cfg_num_pkts = 4;
 static int do_ipv4 = 1;
 static int do_ipv6 = 1;
 static int cfg_payload_len = 10;
+static int cfg_poll_timeout = 100;
 static bool cfg_show_payload;
 static bool cfg_do_pktinfo;
 static bool cfg_loop_nodata;
+static bool cfg_no_delay;
 static uint16_t dest_port = 9000;
 
 static struct sockaddr_in daddr;
@@ -171,7 +173,7 @@ static void __poll(int fd)
 
 	memset(&pollfd, 0, sizeof(pollfd));
 	pollfd.fd = fd;
-	ret = poll(&pollfd, 1, 100);
+	ret = poll(&pollfd, 1, cfg_poll_timeout);
 	if (ret != 1)
 		error(1, errno, "poll");
 }
@@ -371,7 +373,8 @@ static void do_test(int family, unsigned int opt)
 			error(1, errno, "send");
 
 		/* wait for all errors to be queued, else ACKs arrive OOO */
-		usleep(50 * 1000);
+		if (!cfg_no_delay)
+			usleep(50 * 1000);
 
 		__poll(fd);
 
@@ -392,6 +395,9 @@ static void __attribute__((noreturn)) usage(const char *filepath)
 			"  -4:   only IPv4\n"
 			"  -6:   only IPv6\n"
 			"  -h:   show this message\n"
+			"  -c N: number of packets for each test\n"
+			"  -D:   no delay between packets\n"
+			"  -F:   poll() waits forever for an event\n"
 			"  -I:   request PKTINFO\n"
 			"  -l N: send N bytes at a time\n"
 			"  -n:   set no-payload option\n"
@@ -409,7 +415,7 @@ static void parse_opt(int argc, char **argv)
 	int proto_count = 0;
 	char c;
 
-	while ((c = getopt(argc, argv, "46hIl:np:rRux")) != -1) {
+	while ((c = getopt(argc, argv, "46c:DFhIl:np:rRux")) != -1) {
 		switch (c) {
 		case '4':
 			do_ipv6 = 0;
@@ -417,6 +423,15 @@ static void parse_opt(int argc, char **argv)
 		case '6':
 			do_ipv4 = 0;
 			break;
+		case 'c':
+			cfg_num_pkts = strtoul(optarg, NULL, 10);
+			break;
+		case 'D':
+			cfg_no_delay = true;
+			break;
+		case 'F':
+			cfg_poll_timeout = -1;
+			break;
 		case 'I':
 			cfg_do_pktinfo = true;
 			break;
Signature · 1 line
2.16.2
maintainer Applied
#2 lore raw

Re: [PATCH net-next v3 1/1] selftests/txtimestamp: Add more configurable parameters

From: Vinicius Costa Gomes <[email protected]>
Date: Fri, 16 Mar 2018 10:41:14 -0700

Quoted 5 lines

Add a way to configure if poll() should wait forever for an event, the number of packets that should be sent for each and if there should be any delay between packets.

Applied, thank you.