aboutgitcodebugslistschat
path: root/tcp.h
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-10-10 19:00:43 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-10-15 02:10:36 +0200
commitd0dd0242a69f4ae5be4f46030bf321eb6867b2f8 (patch)
treeeeae2c283b9b2ea9e92e282188fcb995464a8af3 /tcp.h
parenteab9d8d5d60be45d88de0c15d975f1ce93fc4400 (diff)
downloadpasst-d0dd0242a69f4ae5be4f46030bf321eb6867b2f8.tar
passt-d0dd0242a69f4ae5be4f46030bf321eb6867b2f8.tar.gz
passt-d0dd0242a69f4ae5be4f46030bf321eb6867b2f8.tar.bz2
passt-d0dd0242a69f4ae5be4f46030bf321eb6867b2f8.tar.lz
passt-d0dd0242a69f4ae5be4f46030bf321eb6867b2f8.tar.xz
passt-d0dd0242a69f4ae5be4f46030bf321eb6867b2f8.tar.zst
passt-d0dd0242a69f4ae5be4f46030bf321eb6867b2f8.zip
tcp, tcp_splice: Fix port remapping for inbound, spliced connections
In pasta mode, when we receive a new inbound connection, we need to select a socket that was created in the namespace to proceed and connect() it to its final destination. The existing condition might pick a wrong socket, though, if the destination port is remapped, because we'll check the bitmap of inbound ports using the remapped port (stored in the epoll reference) as index, and not the original port. Instead of using the port bitmap for this purpose, store this information in the epoll reference itself, by adding a new 'outbound' bit, that's set if the listening socket was created the namespace, and unset otherwise. Then, use this bit to pick a socket on the right side. Suggested-by: David Gibson <david@gibson.dropbear.id.au> Fixes: 33482d5bf293 ("passt: Add PASTA mode, major rework") Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tcp.h')
-rw-r--r--tcp.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/tcp.h b/tcp.h
index 7ba7ab7..72e7815 100644
--- a/tcp.h
+++ b/tcp.h
@@ -34,6 +34,7 @@ void tcp_update_l2_buf(const unsigned char *eth_d, const unsigned char *eth_s,
* union tcp_epoll_ref - epoll reference portion for TCP connections
* @listen: Set if this file descriptor is a listening socket
* @splice: Set if descriptor is associated to a spliced connection
+ * @outbound: Listening socket maps to outbound, spliced connection
* @v6: Set for IPv6 sockets or connections
* @timer: Reference is a timerfd descriptor for connection
* @index: Index of connection in table, or port for bound sockets
@@ -43,6 +44,7 @@ union tcp_epoll_ref {
struct {
uint32_t listen:1,
splice:1,
+ outbound:1,
v6:1,
timer:1,
index:20;