diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-06-14 11:51:08 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-06-14 12:11:46 +0200 |
commit | 7e87bd98ac0cf58d9cf2328b933dbbb74f300c15 (patch) | |
tree | 637cb590c51012aca0c01309731688a9966f0f57 /udp.c | |
parent | ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608 (diff) | |
download | passt-7e87bd98ac0cf58d9cf2328b933dbbb74f300c15.tar passt-7e87bd98ac0cf58d9cf2328b933dbbb74f300c15.tar.gz passt-7e87bd98ac0cf58d9cf2328b933dbbb74f300c15.tar.bz2 passt-7e87bd98ac0cf58d9cf2328b933dbbb74f300c15.tar.lz passt-7e87bd98ac0cf58d9cf2328b933dbbb74f300c15.tar.xz passt-7e87bd98ac0cf58d9cf2328b933dbbb74f300c15.tar.zst passt-7e87bd98ac0cf58d9cf2328b933dbbb74f300c15.zip |
udp: Move management of udp[46]_localname into udp_splice_send()
Mostly, udp_sock_handler() is independent of how the datagrams it processes
will be forwarded (tap or splice). However, it also updates the msg_name
fields for spliced sends, which doesn't really make sense here. Move it
into udp_splice_send() which is all about spliced sends. This does
potentially mean we'll update the field to the same value several times,
but we're going to need this in future anyway: with the extensions the
flow table allows, it might not be the same value each time after all.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp.c')
-rw-r--r-- | udp.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -522,9 +522,11 @@ static unsigned udp_splice_send(const struct ctx *c, size_t start, size_t n, if (uref.v6) { mmh_recv = udp6_l2_mh_sock; mmh_send = udp6_mh_splice; + udp6_localname.sin6_port = htons(dst); } else { mmh_recv = udp4_l2_mh_sock; mmh_send = udp4_mh_splice; + udp4_localname.sin_port = htons(dst); } do { @@ -796,13 +798,10 @@ void udp_buf_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t eve else if (ref.udp.pif == PIF_HOST) dstport += c->udp.fwd_in.f.delta[dstport]; - if (v6) { + if (v6) mmh_recv = udp6_l2_mh_sock; - udp6_localname.sin6_port = htons(dstport); - } else { + else mmh_recv = udp4_l2_mh_sock; - udp4_localname.sin_port = htons(dstport); - } n = recvmmsg(ref.fd, mmh_recv, n, 0, NULL); if (n <= 0) |