From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>,
passt-dev@passt.top, Laurent Vivier <lvivier@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v2 2/5] udp: Set pif in epoll reference for ephemeral host sockets
Date: Wed, 28 Feb 2024 16:39:26 +1100 [thread overview]
Message-ID: <20240228053929.1570254-3-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20240228053929.1570254-1-david@gibson.dropbear.id.au>
The udp_epoll_ref contains a field for the pif to which the socket belongs.
We fill this in for permanent sockets created with udp_sock_init() and for
spliced sockets, however, we omit it for ephemeral sockets created for
tap originated flows.
This is a bug, although we currently get away with it, because we don't
consult that field for such flows. Correctly fill it in.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
udp.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/udp.c b/udp.c
index 3d44f81e..d992acd0 100644
--- a/udp.c
+++ b/udp.c
@@ -868,7 +868,10 @@ int udp_tap_handler(struct ctx *c, uint8_t pif,
src, dst, udp_tap_map[V4][src].sock);
if ((s = udp_tap_map[V4][src].sock) < 0) {
struct in_addr bind_addr = IN4ADDR_ANY_INIT;
- union udp_epoll_ref uref = { .port = src };
+ union udp_epoll_ref uref = {
+ .port = src,
+ .pif = PIF_HOST,
+ };
const char *bind_if = NULL;
if (!IN6_IS_ADDR_LOOPBACK(&s_in.sin_addr))
@@ -916,7 +919,11 @@ int udp_tap_handler(struct ctx *c, uint8_t pif,
}
if ((s = udp_tap_map[V6][src].sock) < 0) {
- union udp_epoll_ref uref = { .v6 = 1, .port = src };
+ union udp_epoll_ref uref = {
+ .v6 = 1,
+ .port = src,
+ .pif = PIF_HOST,
+ };
const char *bind_if = NULL;
if (!IN6_IS_ADDR_LOOPBACK(&s_in6.sin6_addr))
--
@@ -868,7 +868,10 @@ int udp_tap_handler(struct ctx *c, uint8_t pif,
src, dst, udp_tap_map[V4][src].sock);
if ((s = udp_tap_map[V4][src].sock) < 0) {
struct in_addr bind_addr = IN4ADDR_ANY_INIT;
- union udp_epoll_ref uref = { .port = src };
+ union udp_epoll_ref uref = {
+ .port = src,
+ .pif = PIF_HOST,
+ };
const char *bind_if = NULL;
if (!IN6_IS_ADDR_LOOPBACK(&s_in.sin_addr))
@@ -916,7 +919,11 @@ int udp_tap_handler(struct ctx *c, uint8_t pif,
}
if ((s = udp_tap_map[V6][src].sock) < 0) {
- union udp_epoll_ref uref = { .v6 = 1, .port = src };
+ union udp_epoll_ref uref = {
+ .v6 = 1,
+ .port = src,
+ .pif = PIF_HOST,
+ };
const char *bind_if = NULL;
if (!IN6_IS_ADDR_LOOPBACK(&s_in6.sin6_addr))
--
2.43.2
next prev parent reply other threads:[~2024-02-28 5:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 5:39 [PATCH v2 0/5] Assorted small fixes for UDP David Gibson
2024-02-28 5:39 ` [PATCH v2 1/5] udp: Don't attempt to translate a 0.0.0.0 source address David Gibson
2024-02-28 5:39 ` David Gibson [this message]
2024-02-28 5:39 ` [PATCH v2 3/5] udp: Small streamline to udp_update_hdr4() David Gibson
2024-02-28 5:39 ` [PATCH v2 4/5] udp: Fix incorrect usage of IPv6 state in IPv4 path David Gibson
2024-02-28 5:39 ` [PATCH v2 5/5] udp: Remove unnecessary test for unspecified addr_out David Gibson
2024-02-29 8:10 ` [PATCH v2 0/5] Assorted small fixes for UDP Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240228053929.1570254-3-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).