From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top, jmaloy@redhat.com
Subject: Re: [PATCH v7 22/27] udp: Remove obsolete splice tracking
Date: Wed, 10 Jul 2024 23:36:06 +0200 [thread overview]
Message-ID: <20240710233606.06e57ee9@elisabeth> (raw)
In-Reply-To: <20240705020724.3447719-23-david@gibson.dropbear.id.au>
On Fri, 5 Jul 2024 12:07:19 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> Now that spliced datagrams are managed via the flow table, remove
> UDP_ACT_SPLICE_NS and UDP_ACT_SPLICE_INIT which are no longer used. With
> those removed, the 'ts' field in udp_splice_port is also no longer used.
> struct udp_splice_port now contains just a socket fd, so replace it with
> a plain int in udp_splice_ns[] and udp_splice_init[]. The latter are still
> used for tracking of automatic port forwarding.
>
> Finally, the 'splice' field of union udp_epoll_ref is no longer used so
> remove it as well.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> udp.c | 65 +++++++++++++++++------------------------------------------
> udp.h | 3 +--
> 2 files changed, 19 insertions(+), 49 deletions(-)
>
> diff --git a/udp.c b/udp.c
> index f4c696db..a4eb6d0f 100644
> --- a/udp.c
> +++ b/udp.c
> @@ -136,27 +136,15 @@ struct udp_tap_port {
> time_t ts;
> };
>
> -/**
> - * struct udp_splice_port - Bound socket for spliced communication
> - * @sock: Socket bound to index port
> - * @ts: Activity timestamp
> - */
> -struct udp_splice_port {
> - int sock;
> - time_t ts;
> -};
> -
> /* Port tracking, arrays indexed by packet source port (host order) */
> static struct udp_tap_port udp_tap_map [IP_VERSIONS][NUM_PORTS];
>
> /* "Spliced" sockets indexed by bound port (host order) */
> -static struct udp_splice_port udp_splice_ns [IP_VERSIONS][NUM_PORTS];
> -static struct udp_splice_port udp_splice_init[IP_VERSIONS][NUM_PORTS];
> +static int udp_splice_ns [IP_VERSIONS][NUM_PORTS];
> +static int udp_splice_init[IP_VERSIONS][NUM_PORTS];
>
> enum udp_act_type {
> UDP_ACT_TAP,
> - UDP_ACT_SPLICE_NS,
> - UDP_ACT_SPLICE_INIT,
> UDP_ACT_TYPE_MAX,
> };
>
> @@ -246,8 +234,8 @@ void udp_portmap_clear(void)
>
> for (i = 0; i < NUM_PORTS; i++) {
> udp_tap_map[V4][i].sock = udp_tap_map[V6][i].sock = -1;
> - udp_splice_ns[V4][i].sock = udp_splice_ns[V6][i].sock = -1;
> - udp_splice_init[V4][i].sock = udp_splice_init[V6][i].sock = -1;
> + udp_splice_ns[V4][i] = udp_splice_ns[V6][i] = -1;
> + udp_splice_init[V4][i] = udp_splice_init[V6][i] = -1;
> }
> }
>
> @@ -1050,8 +1038,7 @@ int udp_tap_handler(struct ctx *c, uint8_t pif,
> int udp_sock_init(const struct ctx *c, int ns, sa_family_t af,
> const void *addr, const char *ifname, in_port_t port)
> {
> - union udp_epoll_ref uref = { .splice = (c->mode == MODE_PASTA),
> - .orig = true, .port = port };
> + union udp_epoll_ref uref = { .orig = true, .port = port };
> int s, r4 = FD_REF_MAX + 1, r6 = FD_REF_MAX + 1;
>
> if (ns)
> @@ -1067,12 +1054,12 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af,
> ifname, port, uref.u32);
>
> udp_tap_map[V4][port].sock = s < 0 ? -1 : s;
> - udp_splice_init[V4][port].sock = s < 0 ? -1 : s;
> + udp_splice_init[V4][port] = s < 0 ? -1 : s;
> } else {
> r4 = s = sock_l4(c, AF_INET, EPOLL_TYPE_UDP,
> &in4addr_loopback,
> ifname, port, uref.u32);
> - udp_splice_ns[V4][port].sock = s < 0 ? -1 : s;
> + udp_splice_ns[V4][port] = s < 0 ? -1 : s;
> }
> }
>
> @@ -1084,12 +1071,12 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af,
> ifname, port, uref.u32);
>
> udp_tap_map[V6][port].sock = s < 0 ? -1 : s;
> - udp_splice_init[V6][port].sock = s < 0 ? -1 : s;
> + udp_splice_init[V6][port] = s < 0 ? -1 : s;
> } else {
> r6 = s = sock_l4(c, AF_INET6, EPOLL_TYPE_UDP,
> &in6addr_loopback,
> ifname, port, uref.u32);
> - udp_splice_ns[V6][port].sock = s < 0 ? -1 : s;
> + udp_splice_ns[V6][port] = s < 0 ? -1 : s;
> }
> }
>
> @@ -1130,7 +1117,6 @@ static void udp_splice_iov_init(void)
> static void udp_timer_one(struct ctx *c, int v6, enum udp_act_type type,
> in_port_t port, const struct timespec *now)
> {
> - struct udp_splice_port *sp;
> struct udp_tap_port *tp;
> int *sockp = NULL;
>
> @@ -1143,20 +1129,6 @@ static void udp_timer_one(struct ctx *c, int v6, enum udp_act_type type,
> tp->flags = 0;
> }
>
> - break;
> - case UDP_ACT_SPLICE_INIT:
> - sp = &udp_splice_init[v6 ? V6 : V4][port];
> -
> - if (now->tv_sec - sp->ts > UDP_CONN_TIMEOUT)
> - sockp = &sp->sock;
> -
> - break;
> - case UDP_ACT_SPLICE_NS:
> - sp = &udp_splice_ns[v6 ? V6 : V4][port];
> -
> - if (now->tv_sec - sp->ts > UDP_CONN_TIMEOUT)
> - sockp = &sp->sock;
> -
> break;
> default:
> return;
> @@ -1184,20 +1156,19 @@ static void udp_port_rebind(struct ctx *c, bool outbound)
> = outbound ? c->udp.fwd_out.f.map : c->udp.fwd_in.f.map;
> const uint8_t *rmap
> = outbound ? c->udp.fwd_in.f.map : c->udp.fwd_out.f.map;
> - struct udp_splice_port (*socks)[NUM_PORTS]
> - = outbound ? udp_splice_ns : udp_splice_init;
> + int (*socks)[NUM_PORTS] = outbound ? udp_splice_ns : udp_splice_init;
Nit: this should be moved up now, before the declaration of 'fmap'.
> unsigned port;
>
> for (port = 0; port < NUM_PORTS; port++) {
> if (!bitmap_isset(fmap, port)) {
> - if (socks[V4][port].sock >= 0) {
> - close(socks[V4][port].sock);
> - socks[V4][port].sock = -1;
> + if (socks[V4][port] >= 0) {
> + close(socks[V4][port]);
> + socks[V4][port] = -1;
> }
>
> - if (socks[V6][port].sock >= 0) {
> - close(socks[V6][port].sock);
> - socks[V6][port].sock = -1;
> + if (socks[V6][port] >= 0) {
> + close(socks[V6][port]);
> + socks[V6][port] = -1;
> }
>
> continue;
> @@ -1207,8 +1178,8 @@ static void udp_port_rebind(struct ctx *c, bool outbound)
> if (bitmap_isset(rmap, port))
> continue;
>
> - if ((c->ifi4 && socks[V4][port].sock == -1) ||
> - (c->ifi6 && socks[V6][port].sock == -1))
> + if ((c->ifi4 && socks[V4][port] == -1) ||
> + (c->ifi6 && socks[V6][port] == -1))
> udp_sock_init(c, outbound, AF_UNSPEC, NULL, NULL, port);
> }
> }
> diff --git a/udp.h b/udp.h
> index db5e546e..310f42fd 100644
> --- a/udp.h
> +++ b/udp.h
> @@ -36,8 +36,7 @@ union udp_epoll_ref {
> struct {
> in_port_t port;
> uint8_t pif;
> - bool splice:1,
> - orig:1,
> + bool orig:1,
The comment to the union should be updated, removing 'splice'. While at
it, I guess you could also drop 'bound' (removed in 851723924356 ("udp:
Remove the @bound field from union udp_epoll_ref"), but the comment wasn't
updated).
--
Stefano
next prev parent reply other threads:[~2024-07-10 21:36 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-05 2:06 [PATCH v7 00/27] Unified flow table David Gibson
2024-07-05 2:06 ` [PATCH v7 01/27] flow: Common address information for initiating side David Gibson
2024-07-05 2:06 ` [PATCH v7 02/27] flow: Common address information for target side David Gibson
2024-07-10 21:30 ` Stefano Brivio
2024-07-11 0:19 ` David Gibson
2024-07-05 2:07 ` [PATCH v7 03/27] tcp, flow: Remove redundant information, repack connection structures David Gibson
2024-07-05 2:07 ` [PATCH v7 04/27] tcp: Obtain guest address from flowside David Gibson
2024-07-05 2:07 ` [PATCH v7 05/27] tcp: Manage outbound address via flow table David Gibson
2024-07-05 2:07 ` [PATCH v7 06/27] tcp: Simplify endpoint validation using flowside information David Gibson
2024-07-05 2:07 ` [PATCH v7 07/27] tcp_splice: Eliminate SPLICE_V6 flag David Gibson
2024-07-05 2:07 ` [PATCH v7 08/27] tcp, flow: Replace TCP specific hash function with general flow hash David Gibson
2024-07-05 2:07 ` [PATCH v7 09/27] flow, tcp: Generalise TCP hash table to general flow hash table David Gibson
2024-07-05 2:07 ` [PATCH v7 10/27] tcp: Re-use flow hash for initial sequence number generation David Gibson
2024-07-05 2:07 ` [PATCH v7 11/27] icmp: Remove redundant id field from flow table entry David Gibson
2024-07-05 2:07 ` [PATCH v7 12/27] icmp: Obtain destination addresses from the flowsides David Gibson
2024-07-05 2:07 ` [PATCH v7 13/27] icmp: Look up ping flows using flow hash David Gibson
2024-07-05 2:07 ` [PATCH v7 14/27] icmp: Eliminate icmp_id_map David Gibson
2024-07-05 2:07 ` [PATCH v7 15/27] flow: Helper to create sockets based on flowside David Gibson
2024-07-10 21:32 ` Stefano Brivio
2024-07-11 0:21 ` David Gibson
2024-07-11 0:27 ` David Gibson
2024-07-05 2:07 ` [PATCH v7 16/27] icmp: Manage outbound socket address via flow table David Gibson
2024-07-05 2:07 ` [PATCH v7 17/27] flow, tcp: Flow based NAT and port forwarding for TCP David Gibson
2024-07-05 2:07 ` [PATCH v7 18/27] flow, icmp: Use general flow forwarding rules for ICMP David Gibson
2024-07-05 2:07 ` [PATCH v7 19/27] fwd: Update flow forwarding logic for UDP David Gibson
2024-07-08 21:26 ` Stefano Brivio
2024-07-09 0:19 ` David Gibson
2024-07-05 2:07 ` [PATCH v7 20/27] udp: Create flows for datagrams from originating sockets David Gibson
2024-07-09 22:32 ` Stefano Brivio
2024-07-09 23:59 ` David Gibson
2024-07-10 21:35 ` Stefano Brivio
2024-07-11 4:26 ` David Gibson
2024-07-11 8:20 ` Stefano Brivio
2024-07-11 22:58 ` David Gibson
2024-07-12 8:21 ` Stefano Brivio
2024-07-15 4:06 ` David Gibson
2024-07-15 16:37 ` Stefano Brivio
2024-07-17 0:49 ` David Gibson
2024-07-05 2:07 ` [PATCH v7 21/27] udp: Handle "spliced" datagrams with per-flow sockets David Gibson
2024-07-09 22:32 ` Stefano Brivio
2024-07-10 0:23 ` David Gibson
2024-07-10 17:13 ` Stefano Brivio
2024-07-11 1:30 ` David Gibson
2024-07-11 8:23 ` Stefano Brivio
2024-07-11 2:48 ` David Gibson
2024-07-12 13:34 ` Stefano Brivio
2024-07-15 4:32 ` David Gibson
2024-07-05 2:07 ` [PATCH v7 22/27] udp: Remove obsolete splice tracking David Gibson
2024-07-10 21:36 ` Stefano Brivio [this message]
2024-07-11 0:43 ` David Gibson
2024-07-05 2:07 ` [PATCH v7 23/27] udp: Find or create flows for datagrams from tap interface David Gibson
2024-07-10 21:36 ` Stefano Brivio
2024-07-11 0:45 ` David Gibson
2024-07-05 2:07 ` [PATCH v7 24/27] udp: Direct datagrams from host to guest via flow table David Gibson
2024-07-10 21:37 ` Stefano Brivio
2024-07-11 0:46 ` David Gibson
2024-07-05 2:07 ` [PATCH v7 25/27] udp: Remove obsolete socket tracking David Gibson
2024-07-05 2:07 ` [PATCH v7 26/27] udp: Remove rdelta port forwarding maps David Gibson
2024-07-05 2:07 ` [PATCH v7 27/27] udp: Rename UDP listening sockets David Gibson
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=20240710233606.06e57ee9@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=jmaloy@redhat.com \
--cc=passt-dev@passt.top \
/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).