Avoid fault when receiving zero length packets
The manpage for recvmsg says -1 will be returned on error, Zero indicates an "orderly shutdown", presumably only in case of stream sockets. Further, UNIX Network Programming, Vol 1 says ".. a return value of 0 from recvfrom is acceptable for a datagram protocol" Such packets have been observed in the wild, aimed at PTP's multicast address and port, possibly related to malformed management queries. Patch to properly check return from recvmesg and not trigger the fault codepath. Instead, such packets are treated as "Bad Message" the same as non-zero but still too-short UDP payloads. Signed-off-by: David Mirabito <davidjm@arista.com>master
parent
1b7a1e2cda
commit
6b61ba29c7
2
port.c
2
port.c
|
@ -2563,7 +2563,7 @@ static enum fsm_event bc_event(struct port *p, int fd_index)
|
|||
msg->hwts.type = p->timestamping;
|
||||
|
||||
cnt = transport_recv(p->trp, fd, msg);
|
||||
if (cnt <= 0) {
|
||||
if (cnt < 0) {
|
||||
pr_err("port %hu: recv message failed", portnum(p));
|
||||
msg_put(msg);
|
||||
return EV_FAULT_DETECTED;
|
||||
|
|
Loading…
Reference in New Issue