From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202512 header.b=UPc9J4m/; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 098E25A0626 for ; Thu, 15 Jan 2026 09:50:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1768467049; bh=8ZEzRd2eae8IJLZAMO+K0Lc1ur1k6m6r1hqAnSFupBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UPc9J4m/ZGRcOqLOLkIGViZ7fHCnE7g1tjeKW2WsY3o4yAW8EDTjzn5cszu+wFxx2 Q1DayKVmFA83RiLlc/1A+VTc7h+U5vNNRQLg3+Gc4s/ZmuPm6FX2VoPMd1VGgitvve CCiPZT3vhyWVuOs38DkIJ3STPL/trw8oHNzKYNiu82fFHoODDfLaRaWkE8kVs9UJT4 HsIWZvHkZxvFDvJ6JcpDWuNf8A2DnXmi4Hq4tNSZxDSsK288Yegi9P4hTI9jYJFBSE 4Rgexi3SvkpCH3IhCy2n9vbO6HcNNJy/nvYAmLVVLXepPJ+jASKIi/b6mL/qXeaMK0 Lq7aKiaDawOmA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dsGsj3r5nz4wML; Thu, 15 Jan 2026 19:50:49 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v4 08/14] tcp, udp: Remove old auto-forwarding socket arrays Date: Thu, 15 Jan 2026 19:50:39 +1100 Message-ID: <20260115085045.3309818-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115085045.3309818-1-david@gibson.dropbear.id.au> References: <20260115085045.3309818-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: GM5WWZDZ4IIEALAJUY66NXPRGYCDQHW7 X-Message-ID-Hash: GM5WWZDZ4IIEALAJUY66NXPRGYCDQHW7 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Now that we've moved listening socket management to the new forwarding table data structure, the existing arrays of socket fds are maintained, but never consulted. Remove them. Signed-off-by: David Gibson --- conf.c | 1 - tcp.c | 24 ------------------------ udp.c | 30 ------------------------------ udp.h | 1 - 4 files changed, 56 deletions(-) diff --git a/conf.c b/conf.c index 0f283dc9..ce6c0127 100644 --- a/conf.c +++ b/conf.c @@ -2061,7 +2061,6 @@ void conf(struct ctx *c, int argc, char **argv) * settings */ fwd_probe_ephemeral(); - udp_portmap_clear(); optind = 0; do { name = getopt_long(argc, argv, optstring, options, NULL); diff --git a/tcp.c b/tcp.c index fed90f9b..a7fbff5d 100644 --- a/tcp.c +++ b/tcp.c @@ -412,10 +412,6 @@ static const char *tcp_flag_str[] __attribute((__unused__)) = { "ACK_FROM_TAP_DUE", "ACK_FROM_TAP_BLOCKS", "SYN_RETRIED", }; -/* Listening sockets, used for automatic port forwarding in pasta mode only */ -static int tcp_sock_init_ext [NUM_PORTS][IP_VERSIONS]; -static int tcp_sock_ns [NUM_PORTS][IP_VERSIONS]; - /* Table of our guest side addresses with very low RTT (assumed to be local to * the host), LRU */ @@ -2688,8 +2684,6 @@ int tcp_listen(const struct ctx *c, uint8_t pif, .port = port, .pif = pif, }; - const struct fwd_ports *fwd; - int (*socks)[IP_VERSIONS]; int s; ASSERT(!c->no_tcp); @@ -2709,25 +2703,9 @@ int tcp_listen(const struct ctx *c, uint8_t pif, return -EAFNOSUPPORT; } - if (pif == PIF_HOST) { - fwd = &c->tcp.fwd_in; - socks = tcp_sock_init_ext; - } else { - ASSERT(pif == PIF_SPLICE); - fwd = &c->tcp.fwd_out; - socks = tcp_sock_ns; - } - s = pif_sock_l4(c, EPOLL_TYPE_TCP_LISTEN, pif, addr, ifname, port, ref.u32); - if (fwd->mode == FWD_AUTO) { - if (!addr || inany_v4(addr)) - socks[port][V4] = s < 0 ? -1 : s; - if (!addr || !inany_v4(addr)) - socks[port][V6] = s < 0 ? -1 : s; - } - return s; } @@ -2869,8 +2847,6 @@ int tcp_init(struct ctx *c) memset(init_sock_pool4, 0xff, sizeof(init_sock_pool4)); memset(init_sock_pool6, 0xff, sizeof(init_sock_pool6)); - memset(tcp_sock_init_ext, 0xff, sizeof(tcp_sock_init_ext)); - memset(tcp_sock_ns, 0xff, sizeof(tcp_sock_ns)); tcp_sock_refill_init(c); diff --git a/udp.c b/udp.c index a1ebd652..afb85dfc 100644 --- a/udp.c +++ b/udp.c @@ -124,10 +124,6 @@ - sizeof(struct udphdr) \ - sizeof(struct ipv6hdr)) -/* "Spliced" sockets indexed by bound port (host order) */ -static int udp_splice_ns [IP_VERSIONS][NUM_PORTS]; -static int udp_splice_init[IP_VERSIONS][NUM_PORTS]; - /* Static buffers */ /* UDP header and data for inbound messages */ @@ -193,19 +189,6 @@ static struct mmsghdr udp_mh_splice [UDP_MAX_FRAMES]; /* IOVs for L2 frames */ static struct iovec udp_l2_iov [UDP_MAX_FRAMES][UDP_NUM_IOVS]; -/** - * udp_portmap_clear() - Clear UDP port map before configuration - */ -void udp_portmap_clear(void) -{ - unsigned i; - - for (i = 0; i < NUM_PORTS; i++) { - udp_splice_ns[V4][i] = udp_splice_ns[V6][i] = -1; - udp_splice_init[V4][i] = udp_splice_init[V6][i] = -1; - } -} - /** * udp_update_l2_buf() - Update L2 buffers with Ethernet and IPv4 addresses * @eth_d: Ethernet destination address, NULL if unchanged @@ -1145,18 +1128,10 @@ int udp_listen(const struct ctx *c, uint8_t pif, .pif = pif, .port = port, }; - int (*socks)[NUM_PORTS]; int s; ASSERT(!c->no_udp); - if (pif == PIF_HOST) { - socks = udp_splice_init; - } else { - ASSERT(pif == PIF_SPLICE); - socks = udp_splice_ns; - } - if (!c->ifi4) { if (!addr) /* Restrict to v6 only */ @@ -1175,11 +1150,6 @@ int udp_listen(const struct ctx *c, uint8_t pif, s = pif_sock_l4(c, EPOLL_TYPE_UDP_LISTEN, pif, addr, ifname, port, ref.u32); - if (!addr || inany_v4(addr)) - socks[V4][port] = s < 0 ? -1 : s; - if (!addr || !inany_v4(addr)) - socks[V6][port] = s < 0 ? -1 : s; - return s; } diff --git a/udp.h b/udp.h index 73efe036..3c6f90a9 100644 --- a/udp.h +++ b/udp.h @@ -6,7 +6,6 @@ #ifndef UDP_H #define UDP_H -void udp_portmap_clear(void); void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, const struct timespec *now); void udp_sock_handler(const struct ctx *c, union epoll_ref ref, -- 2.52.0