aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2023-03-20 19:10:34 +0100
committerStefano Brivio <sbrivio@redhat.com>2023-03-21 14:18:54 +0100
commit418f75ac378088f30d8f8d9a9709b72bfb5859e4 (patch)
tree825a1ddda68117b9f3c08af80a4c47eaa1b11c6c
parentdd2349661933c4e9756e524ae9465f38b53b7557 (diff)
downloadpasst-418f75ac378088f30d8f8d9a9709b72bfb5859e4.tar
passt-418f75ac378088f30d8f8d9a9709b72bfb5859e4.tar.gz
passt-418f75ac378088f30d8f8d9a9709b72bfb5859e4.tar.bz2
passt-418f75ac378088f30d8f8d9a9709b72bfb5859e4.tar.lz
passt-418f75ac378088f30d8f8d9a9709b72bfb5859e4.tar.xz
passt-418f75ac378088f30d8f8d9a9709b72bfb5859e4.tar.zst
passt-418f75ac378088f30d8f8d9a9709b72bfb5859e4.zip
pasta: fix tcp port forwarding in auto mode
The logic in tcp_timer() was inverted. fwd_out should expose the host ports in the ns. Therfore it must read the ports on the host and then bind them in the netns. The same for fwd_in which checks ports in the ns and then exposes them on the host. Note that this only fixes tcp ports, udp does not seems to work at all right now with the auto mode. Signed-off-by: Paul Holzinger <pholzing@redhat.com> Fixes: 1128fa03fe73 ("Improve types and names for port forwarding configuration") Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tcp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/tcp.c b/tcp.c
index 0214087..0d0ad13 100644
--- a/tcp.c
+++ b/tcp.c
@@ -89,7 +89,7 @@
* No port translation is needed for connections initiated remotely or by the
* local host: source port from socket is reused while establishing connections
* to the guest.
- *
+ *
* For connections initiated by the guest, it's not possible to force the same
* source port as connections are established by the host kernel: that's the
* only port translation needed.
@@ -173,7 +173,7 @@
* new socket is created and mapped in connection tracking table, setting
* MSS and window clamping from header and option of the observed SYN segment
*
- *
+ *
* Aging and timeout
* -----------------
*
@@ -560,7 +560,7 @@ static struct tcp6_l2_flags_buf_t {
#endif
struct tap_hdr taph; /* 14 2 */
struct ipv6hdr ip6h; /* 32 20 */
- struct tcphdr th /* 72 */ __attribute__ ((aligned(4))); /* 60 */
+ struct tcphdr th /* 72 */ __attribute__ ((aligned(4))); /* 60 */
char opts[OPT_MSS_LEN + OPT_WS_LEN + 1];
#ifdef __AVX2__
} __attribute__ ((packed, aligned(32)))
@@ -3308,14 +3308,14 @@ void tcp_timer(struct ctx *c, const struct timespec *ts)
struct tcp_port_detect_arg detect_arg = { c, 0 };
struct tcp_port_rebind_arg rebind_arg = { c, 0 };
- if (c->tcp.fwd_in.mode == FWD_AUTO) {
+ if (c->tcp.fwd_out.mode == FWD_AUTO) {
detect_arg.detect_in_ns = 0;
tcp_port_detect(&detect_arg);
rebind_arg.bind_in_ns = 1;
NS_CALL(tcp_port_rebind, &rebind_arg);
}
- if (c->tcp.fwd_out.mode == FWD_AUTO) {
+ if (c->tcp.fwd_in.mode == FWD_AUTO) {
detect_arg.detect_in_ns = 1;
NS_CALL(tcp_port_detect, &detect_arg);
rebind_arg.bind_in_ns = 0;