aboutgitcodebugslistschat
path: root/util.h
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-03-15 01:07:02 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-03-28 17:11:40 +0200
commite5eefe77435a8958681a92546c46e3c05b93ac7b (patch)
treed7aa652a67fdca4f2213471e33f66c8284ca9489 /util.h
parentde0961c01c2dc2983cdd90c7c26515cddfcc08d2 (diff)
downloadpasst-e5eefe77435a8958681a92546c46e3c05b93ac7b.tar
passt-e5eefe77435a8958681a92546c46e3c05b93ac7b.tar.gz
passt-e5eefe77435a8958681a92546c46e3c05b93ac7b.tar.bz2
passt-e5eefe77435a8958681a92546c46e3c05b93ac7b.tar.lz
passt-e5eefe77435a8958681a92546c46e3c05b93ac7b.tar.xz
passt-e5eefe77435a8958681a92546c46e3c05b93ac7b.tar.zst
passt-e5eefe77435a8958681a92546c46e3c05b93ac7b.zip
tcp: Refactor to use events instead of states, split out spliced implementation
Using events and flags instead of states makes the implementation much more straightforward: actions are mostly centered on events that occurred on the connection rather than states. An example is given by the ESTABLISHED_SOCK_FIN_SENT and FIN_WAIT_1_SOCK_FIN abominations: we don't actually care about which side started closing the connection to handle closing of connection halves. Split out the spliced implementation, as it has very little in common with the "regular" TCP path. Refactor things here and there to improve clarity. Add helpers to trace where resets and flag settings come from. No functional changes intended. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.h')
-rw-r--r--util.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/util.h b/util.h
index e314c71..3073f58 100644
--- a/util.h
+++ b/util.h
@@ -37,7 +37,8 @@ void trace_init(int enable);
#define ROUND_DOWN(x, y) ((x) & ~((y) - 1))
#define ROUND_UP(x, y) (((x) + (y) - 1) & ~((y) - 1))
-#define BITMAP_BIT(n) (1UL << (n) % (sizeof(long) * 8))
+#define BIT(n) (1UL << (n))
+#define BITMAP_BIT(n) (BIT((n) % (sizeof(long) * 8)))
#define BITMAP_WORD(n) (n / (sizeof(long) * 8))
#define SWAP(a, b) \
@@ -208,3 +209,4 @@ void drop_caps(void);
int ns_enter(struct ctx *c);
void write_pidfile(int fd, pid_t pid);
int __daemon(int pidfile_fd, int devnull_fd);
+int fls(unsigned long x);