linuxptp/SOURCES/linuxptp-zerolength.patch

38 lines
1.2 KiB
Diff
Raw Normal View History

2021-11-09 09:51:38 +00:00
commit 9633ab52460f58c92c6daa35e9d24e4ce9c5ab1c
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Tue Feb 23 11:01:43 2021 +0100
2020-11-03 11:58:21 +00:00
2021-11-09 09:51:38 +00:00
sk: Don't return error for zero-length messages.
2020-11-03 11:58:21 +00:00
2021-11-09 09:51:38 +00:00
The recvmsg() call can return zero for a zero-length UDP message, which
should be handled as a bad message and not a fault of the port. This was
addressed in commit 6b61ba29c78e ("Avoid fault when receiving zero
length packets"), but later regressed in commit a6e0b83bd503
("sk: Convey transmit path errors to the caller.").
2020-11-03 11:58:21 +00:00
2021-11-09 09:51:38 +00:00
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Fixes: a6e0b83bd503 ("sk: Convey transmit path errors to the caller.")
2020-11-03 11:58:21 +00:00
diff --git a/sk.c b/sk.c
2021-11-09 09:51:38 +00:00
index c9ef4d2..8be0708 100644
2020-11-03 11:58:21 +00:00
--- a/sk.c
+++ b/sk.c
2021-11-09 09:51:38 +00:00
@@ -391,7 +391,7 @@ int sk_receive(int fd, void *buf, int buflen,
if (!ts) {
memset(&hwts->ts, 0, sizeof(hwts->ts));
- return cnt < 1 ? -errno : cnt;
+ return cnt < 0 ? -errno : cnt;
2020-11-03 11:58:21 +00:00
}
2021-11-09 09:51:38 +00:00
switch (hwts->type) {
@@ -407,7 +407,7 @@ int sk_receive(int fd, void *buf, int buflen,
hwts->ts = timespec_to_tmv(ts[1]);
break;
}
- return cnt < 1 ? -errno : cnt;
+ return cnt < 0 ? -errno : cnt;
}
2020-11-03 11:58:21 +00:00
2021-11-09 09:51:38 +00:00
int sk_set_priority(int fd, int family, uint8_t dscp)