From db1fe773a3eacbf2b3ce0b3333f1684291fa5c2d Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sun, 25 Apr 2021 13:34:04 +0200 Subject: 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 --- util.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index cc96a1a..acd62a9 100644 --- a/util.c +++ b/util.c @@ -25,6 +25,7 @@ #include #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; -- cgit v1.2.3