udp: Don't drop zero-length outbound UDP packets
udp_tap_handler() currently skips outbound packets if they have a payload length of zero. This is not correct, since in a datagram protocol zero length packets still have meaning. Adjust this to correctly forward the zero-length packets by using a msghdr with msg_iovlen == 0. Bugzilla: https://bugs.passt.top/show_bug.cgi?id=19 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
484652c632
commit
af9c98af5f
1 changed files with 10 additions and 7 deletions
17
udp.c
17
udp.c
|
@ -1075,17 +1075,20 @@ int udp_tap_handler(struct ctx *c, int af, const void *addr,
|
|||
uh_send = packet_get(p, i, 0, sizeof(*uh), &len);
|
||||
if (!uh_send)
|
||||
return p->count;
|
||||
if (!len)
|
||||
continue;
|
||||
|
||||
m[i].iov_base = (char *)(uh_send + 1);
|
||||
m[i].iov_len = len;
|
||||
|
||||
mm[i].msg_hdr.msg_name = sa;
|
||||
mm[i].msg_hdr.msg_namelen = sl;
|
||||
|
||||
mm[i].msg_hdr.msg_iov = m + i;
|
||||
mm[i].msg_hdr.msg_iovlen = 1;
|
||||
if (len) {
|
||||
m[i].iov_base = (char *)(uh_send + 1);
|
||||
m[i].iov_len = len;
|
||||
|
||||
mm[i].msg_hdr.msg_iov = m + i;
|
||||
mm[i].msg_hdr.msg_iovlen = 1;
|
||||
} else {
|
||||
mm[i].msg_hdr.msg_iov = NULL;
|
||||
mm[i].msg_hdr.msg_iovlen = 0;
|
||||
}
|
||||
|
||||
mm[i].msg_hdr.msg_control = NULL;
|
||||
mm[i].msg_hdr.msg_controllen = 0;
|
||||
|
|
Loading…
Reference in a new issue