mirror of
https://passt.top/passt
synced 2025-05-20 00:15:34 +02:00
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>
This commit is contained in:
parent
e6f81e5578
commit
485b5fb8f9
7 changed files with 55 additions and 45 deletions
8
passt.c
8
passt.c
|
@ -56,7 +56,8 @@
|
|||
char pkt_buf[PKT_BUF_BYTES] __attribute__ ((aligned(PAGE_SIZE)));
|
||||
|
||||
char *epoll_type_str[EPOLL_TYPE_MAX + 1] = {
|
||||
[EPOLL_TYPE_TCP] = "TCP socket",
|
||||
[EPOLL_TYPE_TCP] = "connected TCP socket",
|
||||
[EPOLL_TYPE_TCP_LISTEN] = "listening TCP socket",
|
||||
[EPOLL_TYPE_TCP_TIMER] = "TCP timer",
|
||||
[EPOLL_TYPE_UDP] = "UDP socket",
|
||||
[EPOLL_TYPE_ICMP] = "ICMP socket",
|
||||
|
@ -323,7 +324,10 @@ loop:
|
|||
break;
|
||||
case EPOLL_TYPE_TCP:
|
||||
if (!c.no_tcp)
|
||||
tcp_sock_handler(&c, ref, eventmask, &now);
|
||||
tcp_sock_handler(&c, ref, eventmask);
|
||||
break;
|
||||
case EPOLL_TYPE_TCP_LISTEN:
|
||||
tcp_listen_handler(&c, ref, &now);
|
||||
break;
|
||||
case EPOLL_TYPE_TCP_TIMER:
|
||||
tcp_timer_handler(&c, ref);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue