aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-02-12 17:06:58 +1100
committerStefano Brivio <sbrivio@redhat.com>2024-02-14 03:24:23 +0100
commit927cb84fffed22dc3906baa33111f918bd1a622a (patch)
treef72f18cc5f38dd9538079235c167fbcafb251a96
parent96ad5c5acdde30c43066d6d7fa846d9a2a47fb8f (diff)
downloadpasst-927cb84fffed22dc3906baa33111f918bd1a622a.tar
passt-927cb84fffed22dc3906baa33111f918bd1a622a.tar.gz
passt-927cb84fffed22dc3906baa33111f918bd1a622a.tar.bz2
passt-927cb84fffed22dc3906baa33111f918bd1a622a.tar.lz
passt-927cb84fffed22dc3906baa33111f918bd1a622a.tar.xz
passt-927cb84fffed22dc3906baa33111f918bd1a622a.tar.zst
passt-927cb84fffed22dc3906baa33111f918bd1a622a.zip
udp: udp_sock_init_ns() partially duplicats udp_port_rebind_outbound()
Usually automatically forwarded UDP outbound ports are set up by udp_port_rebind_outbound() called from udp_timer(). However, the very first time they're created and bound is by udp_sock_init_ns() called from udp_init(). udp_sock_init_ns() is essentially an unnecessary cut down version of udp_port_rebind_outbound(), so we can jusat remove it. Doing so does require moving udp_init() below udp_port_rebind_outbound()'s definition. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--udp.c73
1 files changed, 25 insertions, 48 deletions
diff --git a/udp.c b/udp.c
index b240185..933f24b 100644
--- a/udp.c
+++ b/udp.c
@@ -1042,29 +1042,6 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af,
}
/**
- * udp_sock_init_ns() - Bind sockets in namespace for outbound connections
- * @arg: Execution context
- *
- * Return: 0
- */
-int udp_sock_init_ns(void *arg)
-{
- const struct ctx *c = (const struct ctx *)arg;
- unsigned dst;
-
- ns_enter(c);
-
- for (dst = 0; dst < NUM_PORTS; dst++) {
- if (!bitmap_isset(c->udp.fwd_out.f.map, dst))
- continue;
-
- udp_sock_init(c, 1, AF_UNSPEC, NULL, NULL, dst);
- }
-
- return 0;
-}
-
-/**
* udp_splice_iov_init() - Set up buffers and descriptors for recvmmsg/sendmmsg
*/
static void udp_splice_iov_init(void)
@@ -1091,31 +1068,6 @@ static void udp_splice_iov_init(void)
}
/**
- * udp_init() - Initialise per-socket data, and sockets in namespace
- * @c: Execution context
- *
- * Return: 0
- */
-int udp_init(struct ctx *c)
-{
- if (c->ifi4)
- udp_sock4_iov_init(c);
-
- if (c->ifi6)
- udp_sock6_iov_init(c);
-
- udp_invert_portmap(&c->udp.fwd_in);
- udp_invert_portmap(&c->udp.fwd_out);
-
- if (c->mode == MODE_PASTA) {
- udp_splice_iov_init();
- NS_CALL(udp_sock_init_ns, c);
- }
-
- return 0;
-}
-
-/**
* udp_timer_one() - Handler for timed events on one port
* @c: Execution context
* @v6: Set for IPv6 connections
@@ -1272,3 +1224,28 @@ v6:
goto v6;
}
}
+
+/**
+ * udp_init() - Initialise per-socket data, and sockets in namespace
+ * @c: Execution context
+ *
+ * Return: 0
+ */
+int udp_init(struct ctx *c)
+{
+ if (c->ifi4)
+ udp_sock4_iov_init(c);
+
+ if (c->ifi6)
+ udp_sock6_iov_init(c);
+
+ udp_invert_portmap(&c->udp.fwd_in);
+ udp_invert_portmap(&c->udp.fwd_out);
+
+ if (c->mode == MODE_PASTA) {
+ udp_splice_iov_init();
+ NS_CALL(udp_port_rebind_outbound, c);
+ }
+
+ return 0;
+}