Skip to content

Commit ca88260

Browse files
wdebruijdavem330
authored andcommitted
selftests/net: report etf errors correctly
The ETF qdisc can queue skbs that it could not pace on the errqueue. Address a few issues in the selftest - recv buffer size was too small, and incorrectly calculated - compared errno to ee_code instead of ee_errno - missed invalid request error type v2: - fix a few checkpatch --strict indentation warnings Fixes: ea6a547 ("selftests/net: make so_txtime more robust to timer variance") Signed-off-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5948378 commit ca88260

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

tools/testing/selftests/net/so_txtime.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
#include <inttypes.h>
1616
#include <linux/net_tstamp.h>
1717
#include <linux/errqueue.h>
18+
#include <linux/if_ether.h>
1819
#include <linux/ipv6.h>
19-
#include <linux/tcp.h>
20+
#include <linux/udp.h>
2021
#include <stdbool.h>
2122
#include <stdlib.h>
2223
#include <stdio.h>
@@ -140,8 +141,8 @@ static void do_recv_errqueue_timeout(int fdt)
140141
{
141142
char control[CMSG_SPACE(sizeof(struct sock_extended_err)) +
142143
CMSG_SPACE(sizeof(struct sockaddr_in6))] = {0};
143-
char data[sizeof(struct ipv6hdr) +
144-
sizeof(struct tcphdr) + 1];
144+
char data[sizeof(struct ethhdr) + sizeof(struct ipv6hdr) +
145+
sizeof(struct udphdr) + 1];
145146
struct sock_extended_err *err;
146147
struct msghdr msg = {0};
147148
struct iovec iov = {0};
@@ -159,6 +160,8 @@ static void do_recv_errqueue_timeout(int fdt)
159160
msg.msg_controllen = sizeof(control);
160161

161162
while (1) {
163+
const char *reason;
164+
162165
ret = recvmsg(fdt, &msg, MSG_ERRQUEUE);
163166
if (ret == -1 && errno == EAGAIN)
164167
break;
@@ -176,14 +179,30 @@ static void do_recv_errqueue_timeout(int fdt)
176179
err = (struct sock_extended_err *)CMSG_DATA(cm);
177180
if (err->ee_origin != SO_EE_ORIGIN_TXTIME)
178181
error(1, 0, "errqueue: origin 0x%x\n", err->ee_origin);
179-
if (err->ee_code != ECANCELED)
180-
error(1, 0, "errqueue: code 0x%x\n", err->ee_code);
182+
183+
switch (err->ee_errno) {
184+
case ECANCELED:
185+
if (err->ee_code != SO_EE_CODE_TXTIME_MISSED)
186+
error(1, 0, "errqueue: unknown ECANCELED %u\n",
187+
err->ee_code);
188+
reason = "missed txtime";
189+
break;
190+
case EINVAL:
191+
if (err->ee_code != SO_EE_CODE_TXTIME_INVALID_PARAM)
192+
error(1, 0, "errqueue: unknown EINVAL %u\n",
193+
err->ee_code);
194+
reason = "invalid txtime";
195+
break;
196+
default:
197+
error(1, 0, "errqueue: errno %u code %u\n",
198+
err->ee_errno, err->ee_code);
199+
};
181200

182201
tstamp = ((int64_t) err->ee_data) << 32 | err->ee_info;
183202
tstamp -= (int64_t) glob_tstart;
184203
tstamp /= 1000 * 1000;
185-
fprintf(stderr, "send: pkt %c at %" PRId64 "ms dropped\n",
186-
data[ret - 1], tstamp);
204+
fprintf(stderr, "send: pkt %c at %" PRId64 "ms dropped: %s\n",
205+
data[ret - 1], tstamp, reason);
187206

188207
msg.msg_flags = 0;
189208
msg.msg_controllen = sizeof(control);

0 commit comments

Comments
 (0)