aboutgitcodebugslistschat
path: root/passt.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-08-11 15:12:27 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-08-13 17:30:15 +0200
commit485b5fb8f97c203a9842639fc708f32458be0c18 (patch)
treeb7c860898048933ead9495d84541b5d1dd49cfc5 /passt.h
parente6f81e55788bc6ede5e98a83820263e394455ba9 (diff)
downloadpasst-485b5fb8f97c203a9842639fc708f32458be0c18.tar
passt-485b5fb8f97c203a9842639fc708f32458be0c18.tar.gz
passt-485b5fb8f97c203a9842639fc708f32458be0c18.tar.bz2
passt-485b5fb8f97c203a9842639fc708f32458be0c18.tar.lz
passt-485b5fb8f97c203a9842639fc708f32458be0c18.tar.xz
passt-485b5fb8f97c203a9842639fc708f32458be0c18.tar.zst
passt-485b5fb8f97c203a9842639fc708f32458be0c18.zip
epoll: Split handling of listening TCP sockets into their own handler
tcp_sock_handler() handles both listening TCP sockets, and connected TCP sockets, but what it needs to do in those cases has essentially nothing in common. Therefore, give listening sockets their own epoll_type value and dispatch directly to their own handler from the top level. Furthermore, the two handlers need essentially entirely different information from the reference: we re-(ab)used the index field in the tcp_epoll_ref to indicate the port for the listening socket, but that's not the same meaning. So, switch listening sockets to their own reference type which we can lay out as we please. That lets us remove the listen and outbound fields from the normal (connected) tcp_epoll_ref, reducing it to just the connection table index. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'passt.h')
-rw-r--r--passt.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/passt.h b/passt.h
index fc1efdb..a625d48 100644
--- a/passt.h
+++ b/passt.h
@@ -47,8 +47,10 @@ union epoll_ref;
enum epoll_type {
/* Special value to indicate an invalid type */
EPOLL_TYPE_NONE = 0,
- /* TCP sockets */
+ /* Connected TCP sockets */
EPOLL_TYPE_TCP,
+ /* Listening TCP sockets */
+ EPOLL_TYPE_TCP_LISTEN,
/* timerfds used for TCP timers */
EPOLL_TYPE_TCP_TIMER,
/* UDP sockets */
@@ -69,7 +71,8 @@ enum epoll_type {
* union epoll_ref - Breakdown of reference for epoll fd bookkeeping
* @type: Type of fd (tells us what to do with events)
* @fd: File descriptor number (implies < 2^24 total descriptors)
- * @tcp: TCP-specific reference part
+ * @tcp: TCP-specific reference part (connected sockets)
+ * @tcp_listen: TCP-specific reference part (listening sockets)
* @udp: UDP-specific reference part
* @icmp: ICMP-specific reference part
* @data: Data handled by protocol handlers
@@ -83,6 +86,7 @@ union epoll_ref {
int32_t fd:FD_REF_BITS;
union {
union tcp_epoll_ref tcp;
+ union tcp_listen_epoll_ref tcp_listen;
union udp_epoll_ref udp;
union icmp_epoll_ref icmp;
uint32_t data;