diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-12-13 17:24:27 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-12-13 17:24:27 +0100 |
commit | 74455dae1d095178b09ea3f1b1e8b005076e7a94 (patch) | |
tree | c1d559d89e972ee6e115c333093ca8a961cce1e6 | |
parent | 3de8d91c1fa7cadf68108c0c9c03193ac5e82a73 (diff) | |
download | conntrack-tools-74455dae1d095178b09ea3f1b1e8b005076e7a94.tar.gz conntrack-tools-74455dae1d095178b09ea3f1b1e8b005076e7a94.zip |
network: do more strict message type checking
This patch adds more strict checking in the message type. We add a
new message type NET_T_CTL for control messages.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | include/network.h | 12 | ||||
-rw-r--r-- | src/network.c | 2 | ||||
-rw-r--r-- | src/sync-ftfw.c | 1 | ||||
-rw-r--r-- | src/sync-notrack.c | 1 |
4 files changed, 10 insertions, 6 deletions
diff --git a/include/network.h b/include/network.h index b6722bd..f9756db 100644 --- a/include/network.h +++ b/include/network.h @@ -22,6 +22,7 @@ enum nethdr_type { NET_T_STATE_UPD, NET_T_STATE_DEL, NET_T_STATE_MAX = NET_T_STATE_DEL, + NET_T_CTL = 10, }; int nethdr_align(int len); @@ -95,11 +96,12 @@ void mcast_buffered_destroy(void); int mcast_buffered_send_netmsg(struct mcast_sock *m, const struct nethdr *net); ssize_t mcast_buffered_pending_netmsg(struct mcast_sock *m); -#define IS_DATA(x) ((x->flags & ~(NET_F_HELLO | NET_F_HELLO_BACK)) == 0) -#define IS_ACK(x) (x->flags & NET_F_ACK) -#define IS_NACK(x) (x->flags & NET_F_NACK) -#define IS_RESYNC(x) (x->flags & NET_F_RESYNC) -#define IS_ALIVE(x) (x->flags & NET_F_ALIVE) +#define IS_DATA(x) (x->type <= NET_T_STATE_MAX && \ + (x->flags & ~(NET_F_HELLO | NET_F_HELLO_BACK)) == 0) +#define IS_ACK(x) (x->type == NET_T_CTL && x->flags & NET_F_ACK) +#define IS_NACK(x) (x->type == NET_T_CTL && x->flags & NET_F_NACK) +#define IS_RESYNC(x) (x->type == NET_T_CTL && x->flags & NET_F_RESYNC) +#define IS_ALIVE(x) (x->type == NET_T_CTL && x->flags & NET_F_ALIVE) #define IS_CTL(x) IS_ACK(x) || IS_NACK(x) || IS_RESYNC(x) || IS_ALIVE(x) #define IS_HELLO(x) (x->flags & NET_F_HELLO) #define IS_HELLO_BACK(x)(x->flags & NET_F_HELLO_BACK) diff --git a/src/network.c b/src/network.c index 34992ec..98df5ea 100644 --- a/src/network.c +++ b/src/network.c @@ -58,7 +58,7 @@ void nethdr_set(struct nethdr *net, int type) void nethdr_set_ack(struct nethdr *net) { - __nethdr_set(net, NETHDR_ACK_SIZ, 0); + __nethdr_set(net, NETHDR_ACK_SIZ, NET_T_CTL); } static size_t tx_buflenmax; diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c index 749ccac..014cebd 100644 --- a/src/sync-ftfw.c +++ b/src/sync-ftfw.c @@ -97,6 +97,7 @@ static struct cache_extra cache_ftfw_extra = { static void tx_queue_add_ctlmsg(uint32_t flags, uint32_t from, uint32_t to) { struct nethdr_ack ack = { + .type = NET_T_CTL, .flags = flags, .from = from, .to = to, diff --git a/src/sync-notrack.c b/src/sync-notrack.c index 8e6601a..700e272 100644 --- a/src/sync-notrack.c +++ b/src/sync-notrack.c @@ -61,6 +61,7 @@ static struct cache_extra cache_notrack_extra = { static void tx_queue_add_ctlmsg(uint32_t flags, uint32_t from, uint32_t to) { struct nethdr_ack ack = { + .type = NET_T_CTL, .flags = flags, .from = from, .to = to, |