From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: [PATCH v2 2/3] udp: Don't drop zero-length outbound UDP packets Date: Tue, 13 Sep 2022 16:37:44 +1000 Message-ID: <20220913063745.3657546-3-david@gibson.dropbear.id.au> In-Reply-To: <20220913063745.3657546-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4071058635363169543==" --===============4071058635363169543== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 =3D=3D 0. Bugzilla: https://bugs.passt.top/show_bug.cgi?id=3D19 Signed-off-by: David Gibson --- udp.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/udp.c b/udp.c index 864e7b2..0b4e134 100644 --- a/udp.c +++ b/udp.c @@ -1075,17 +1075,20 @@ int udp_tap_handler(struct ctx *c, int af, const void= *addr, uh_send =3D packet_get(p, i, 0, sizeof(*uh), &len); if (!uh_send) return p->count; - if (!len) - continue; - - m[i].iov_base =3D (char *)(uh_send + 1); - m[i].iov_len =3D len; =20 mm[i].msg_hdr.msg_name =3D sa; mm[i].msg_hdr.msg_namelen =3D sl; =20 - mm[i].msg_hdr.msg_iov =3D m + i; - mm[i].msg_hdr.msg_iovlen =3D 1; + if (len) { + m[i].iov_base =3D (char *)(uh_send + 1); + m[i].iov_len =3D len; + + mm[i].msg_hdr.msg_iov =3D m + i; + mm[i].msg_hdr.msg_iovlen =3D 1; + } else { + mm[i].msg_hdr.msg_iov =3D NULL; + mm[i].msg_hdr.msg_iovlen =3D 0; + } =20 mm[i].msg_hdr.msg_control =3D NULL; mm[i].msg_hdr.msg_controllen =3D 0; --=20 2.37.3 --===============4071058635363169543==--