1
0
mirror of https://passt.top/passt synced 2024-07-04 08:52:40 +00:00

udp: Set pif in epoll reference for ephemeral host sockets

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>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2024-02-28 16:39:26 +11:00 committed by Stefano Brivio
parent 720d777a69
commit bc2d0d381c

11
udp.c
View File

@ -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))