aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/util.c b/util.c
index cc96a1a..acd62a9 100644
--- a/util.c
+++ b/util.c
@@ -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;