We can splice TCP connections in pasta mode if and only if they originate from localhost. Currently we separate the two cases by having separate listening sockets: one listens on the host address for non-spliceable connections, the other listens on the loopback address for spliceable connections. As well as requiring twice as many listening sockets, this has the drawback of meaning that passt and pasta behaviour differ subtley but surprisingly: by default passt inbound port forwards will listen on the unspecified address, but for pasta they will be changed to listen on the host's interface address. In fact we don't need to do this. We can defer the decision about whether to splice a connection until after we've accepted it, by testing the peer address to see if it is local. At least, in principle we can. This series deals with a number of complications on the way to accomplishing that. CAVEAT: The current draft increases the size of tcp_conn above its current 64 bytes, which is likely to push it into a second cache line on some machines. This is fixable, but doing so is fiddly, and I'm still working on it. David Gibson (14): style: Minor corrections to function comments tcp: Remove unused TCP_MAX_SOCKS constant tcp: Better helpers for converting between connection pointer and index tcp_splice: Helpers for converting from index to/from tcp_splice_conn tcp: Move connection state structures into a shared header tcp: Add connection union type tcp: Improved helpers to update connections after moving tcp: Unify spliced and non-spliced connection tables tcp: Unify tcp_defer_handler and tcp_splice_defer_handler() tcp: Partially unify tcp_timer() and tcp_splice_timer() tcp: Unify the IN_EPOLL flag tcp: Separate helpers to create ns listening sockets tcp: Unify part of spliced and non-spliced conn_from_sock path tcp: Use the same sockets to listen for spliced and non-spliced connections Makefile | 3 +- conf.c | 12 +- tap.c | 6 +- tcp.c | 661 +++++++++++++++++++++++---------------------------- tcp.h | 7 +- tcp_conn.h | 208 ++++++++++++++++ tcp_splice.c | 292 +++++++++-------------- tcp_splice.h | 4 +- 8 files changed, 625 insertions(+), 568 deletions(-) create mode 100644 tcp_conn.h -- 2.38.1