mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-28 07:13:34 +00:00
selftests: net: fix timestamp not arriving in cmsg_time.sh
On slow machines the SND timestamp sometimes doesn't arrive before we quit. The test only waits as long as the packet delay, so it's easy for a race condition to happen. Double the wait but do a bit of polling, once the SND timestamp arrives there's no point to wait any longer. This fixes the "TXTIME abs" failures on debug kernels, like: Case ICMPv4 - TXTIME abs returned '', expected 'OK' Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://lore.kernel.org/r/20240510005705.43069-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
b49bd37f0b
commit
2d3b8dfd82
1 changed files with 15 additions and 5 deletions
|
@ -333,16 +333,17 @@ static const char *cs_ts_info2str(unsigned int info)
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static unsigned long
|
||||||
cs_read_cmsg(int fd, struct msghdr *msg, char *cbuf, size_t cbuf_sz)
|
cs_read_cmsg(int fd, struct msghdr *msg, char *cbuf, size_t cbuf_sz)
|
||||||
{
|
{
|
||||||
struct sock_extended_err *see;
|
struct sock_extended_err *see;
|
||||||
struct scm_timestamping *ts;
|
struct scm_timestamping *ts;
|
||||||
|
unsigned long ts_seen = 0;
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
int i, err;
|
int i, err;
|
||||||
|
|
||||||
if (!opt.ts.ena)
|
if (!opt.ts.ena)
|
||||||
return;
|
return 0;
|
||||||
msg->msg_control = cbuf;
|
msg->msg_control = cbuf;
|
||||||
msg->msg_controllen = cbuf_sz;
|
msg->msg_controllen = cbuf_sz;
|
||||||
|
|
||||||
|
@ -396,8 +397,11 @@ cs_read_cmsg(int fd, struct msghdr *msg, char *cbuf, size_t cbuf_sz)
|
||||||
printf(" %5s ts%d %lluus\n",
|
printf(" %5s ts%d %lluus\n",
|
||||||
cs_ts_info2str(see->ee_info),
|
cs_ts_info2str(see->ee_info),
|
||||||
i, rel_time);
|
i, rel_time);
|
||||||
|
ts_seen |= 1 << see->ee_info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ts_seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ca_set_sockopts(int fd)
|
static void ca_set_sockopts(int fd)
|
||||||
|
@ -509,10 +513,16 @@ int main(int argc, char *argv[])
|
||||||
err = ERN_SUCCESS;
|
err = ERN_SUCCESS;
|
||||||
|
|
||||||
if (opt.ts.ena) {
|
if (opt.ts.ena) {
|
||||||
/* Make sure all timestamps have time to loop back */
|
unsigned long seen;
|
||||||
usleep(opt.txtime.delay);
|
int i;
|
||||||
|
|
||||||
cs_read_cmsg(fd, &msg, cbuf, sizeof(cbuf));
|
/* Make sure all timestamps have time to loop back */
|
||||||
|
for (i = 0; i < 40; i++) {
|
||||||
|
seen = cs_read_cmsg(fd, &msg, cbuf, sizeof(cbuf));
|
||||||
|
if (seen & (1 << SCM_TSTAMP_SND))
|
||||||
|
break;
|
||||||
|
usleep(opt.txtime.delay / 20);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err_out:
|
err_out:
|
||||||
|
|
Loading…
Reference in a new issue