diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-04-25 13:34:04 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-04-29 17:15:26 +0200 |
commit | db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d (patch) | |
tree | 72c07fb27d823acb1f48ca70284a7298c1060d4d /util.c | |
parent | 48afbe321eddfb68966a4436884c022e64c3e166 (diff) | |
download | passt-db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d.tar passt-db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d.tar.gz passt-db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d.tar.bz2 passt-db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d.tar.lz passt-db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d.tar.xz passt-db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d.tar.zst passt-db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d.zip |
tcp: Avoid SO_ACCEPTCONN getsockopt() by noting listening/data sockets numbers
...the rest is reshuffling existing macros to use the bits we need in
TCP code.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 19 |
1 files changed, 5 insertions, 14 deletions
@@ -25,6 +25,7 @@ #include <stdarg.h> #include "passt.h" +#include "util.h" #define logfn(name, level) \ void name(const char *format, ...) { \ @@ -189,20 +190,10 @@ int sock_l4_add(struct ctx *c, int v, uint16_t proto, uint16_t port) return -1; } -#define CHECK_SET_MIN_MAX(ipproto, proto_ctx, fd) \ - if (proto == (ipproto)) { \ - if (fd < c->proto_ctx.fd_min) \ - c->proto_ctx.fd_min = (fd); \ - if (fd > c->proto_ctx.fd_max) \ - c->proto_ctx.fd_max = (fd); \ - } - - CHECK_SET_MIN_MAX(IPPROTO_ICMP, icmp, fd); - CHECK_SET_MIN_MAX(IPPROTO_ICMPV6, icmp, fd); - CHECK_SET_MIN_MAX(IPPROTO_TCP, tcp, fd); - CHECK_SET_MIN_MAX(IPPROTO_UDP, udp, fd); - -#undef CHECK_SET_MIN_MAX + CHECK_SET_MIN_MAX_PROTO_FD(proto, IPPROTO_ICMP, icmp, fd); + CHECK_SET_MIN_MAX_PROTO_FD(proto, IPPROTO_ICMPV6, icmp, fd); + CHECK_SET_MIN_MAX_PROTO_FD(proto, IPPROTO_TCP, tcp, fd); + CHECK_SET_MIN_MAX_PROTO_FD(proto, IPPROTO_UDP, udp, fd); if (proto == IPPROTO_ICMP || proto == IPPROTO_ICMPV6) goto epoll_add; |