diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-07-05 20:43:59 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-07-05 15:26:09 +0200 |
commit | 74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a (patch) | |
tree | cc0a026b427dcde9d2dc870bb972ef5e9bedb9e8 /tcp.c | |
parent | b625ed5feebaac457311fe5299c3ee99dab5503a (diff) | |
download | passt-74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a.tar passt-74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a.tar.gz passt-74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a.tar.bz2 passt-74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a.tar.lz passt-74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a.tar.xz passt-74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a.tar.zst passt-74c1c5efcfec9fcdb6efe0c8d377af2a7d8e4b0a.zip |
util: sock_l4() determine protocol from epoll type rather than the reverse
sock_l4() creates a socket of the given IP protocol number, and adds it to
the epoll state. Currently it determines the correct tag for the epoll
data based on the protocol. However, we have some future cases where we
might want different semantics, and therefore epoll types, for sockets of
the same protocol. So, change sock_l4() to take the epoll type as an
explicit parameter, and determine the protocol from that.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r-- | tcp.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -2467,7 +2467,7 @@ static int tcp_sock_init_af(const struct ctx *c, sa_family_t af, in_port_t port, }; int s; - s = sock_l4(c, af, IPPROTO_TCP, addr, ifname, port, tref.u32); + s = sock_l4(c, af, EPOLL_TYPE_TCP_LISTEN, addr, ifname, port, tref.u32); if (c->tcp.fwd_in.mode == FWD_AUTO) { if (af == AF_INET || af == AF_UNSPEC) @@ -2531,8 +2531,8 @@ static void tcp_ns_sock_init4(const struct ctx *c, in_port_t port) ASSERT(c->mode == MODE_PASTA); - s = sock_l4(c, AF_INET, IPPROTO_TCP, &in4addr_loopback, NULL, port, - tref.u32); + s = sock_l4(c, AF_INET, EPOLL_TYPE_TCP_LISTEN, &in4addr_loopback, + NULL, port, tref.u32); if (s >= 0) tcp_sock_set_bufsize(c, s); else @@ -2557,8 +2557,8 @@ static void tcp_ns_sock_init6(const struct ctx *c, in_port_t port) ASSERT(c->mode == MODE_PASTA); - s = sock_l4(c, AF_INET6, IPPROTO_TCP, &in6addr_loopback, NULL, port, - tref.u32); + s = sock_l4(c, AF_INET6, EPOLL_TYPE_TCP_LISTEN, &in6addr_loopback, + NULL, port, tref.u32); if (s >= 0) tcp_sock_set_bufsize(c, s); else |