aboutgitcodebugslistschat
path: root/tcp.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-24 19:08:17 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-24 14:48:35 +0200
commit163dc5f18899808e97b92ddae0314928c903bb4b (patch)
treed2e8984fe9f1b77fbdf5e878173a666c7a66f801 /tcp.h
parent1128fa03fe73092dc68f30d0550283f0897d1f89 (diff)
downloadpasst-163dc5f18899808e97b92ddae0314928c903bb4b.tar
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.gz
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.bz2
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.lz
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.xz
passt-163dc5f18899808e97b92ddae0314928c903bb4b.tar.zst
passt-163dc5f18899808e97b92ddae0314928c903bb4b.zip
Consolidate port forwarding configuration into a common structure
The configuration for how to forward ports in and out of the guest/ns is divided between several different variables. For each connect direction and protocol we have a mode in the udp/tcp context structure, a bitmap of which ports to forward also in the context structure and an array of deltas to apply if the outward facing and inward facing port numbers are different. This last is a separate global variable, rather than being in the context structure, for no particular reason. UDP also requires an additional array which has the reverse mapping used for return packets. Consolidate these into a re-used substructure in the context structure. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tcp.h')
-rw-r--r--tcp.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/tcp.h b/tcp.h
index ed797d9..502b096 100644
--- a/tcp.h
+++ b/tcp.h
@@ -29,8 +29,8 @@ void tcp_defer_handler(struct ctx *c);
void tcp_sock_set_bufsize(const struct ctx *c, int s);
void tcp_update_l2_buf(const unsigned char *eth_d, const unsigned char *eth_s,
const uint32_t *ip_da);
-void tcp_remap_to_tap(in_port_t port, in_port_t delta);
-void tcp_remap_to_init(in_port_t port, in_port_t delta);
+void tcp_remap_to_tap(struct ctx *c, in_port_t port, in_port_t delta);
+void tcp_remap_to_init(struct ctx *c, in_port_t port, in_port_t delta);
/**
* union tcp_epoll_ref - epoll reference portion for TCP connections
@@ -58,9 +58,8 @@ union tcp_epoll_ref {
* @conn_count: Count of connections (not spliced) in connection table
* @splice_conn_count: Count of spliced connections in connection table
* @port_to_tap: Ports bound host-side, packets to tap or spliced
- * @fwd_mode_in: Port forwarding mode for inbound packets
- * @port_to_init: Ports bound namespace-side, spliced to init
- * @fwd_mode_out: Port forwarding mode for outbound packets
+ * @fwd_in: Port forwarding configuration for inbound packets
+ * @fwd_out: Port forwarding configuration for outbound packets
* @timer_run: Timestamp of most recent timer run
* @kernel_snd_wnd: Kernel reports sending window (with commit 8f7baad7f035)
* @pipe_size: Size of pipes for spliced connections
@@ -69,10 +68,8 @@ struct tcp_ctx {
uint64_t hash_secret[2];
int conn_count;
int splice_conn_count;
- uint8_t port_to_tap [PORT_BITMAP_SIZE];
- enum port_fwd_mode fwd_mode_in;
- uint8_t port_to_init [PORT_BITMAP_SIZE];
- enum port_fwd_mode fwd_mode_out;
+ struct port_fwd fwd_in;
+ struct port_fwd fwd_out;
struct timespec timer_run;
#ifdef HAS_SND_WND
int kernel_snd_wnd;