diff options
author | /C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org> | 2007-05-18 19:33:40 +0000 |
---|---|---|
committer | /C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org> | 2007-05-18 19:33:40 +0000 |
commit | 2932c6b8e6952ae84b221b854b43810c61e5c8fa (patch) | |
tree | 1ee7f364f74f2dff2b462ab01868a74fd87f1403 /src/sync-nack.c | |
parent | 34d1c62cd414a6d3321d9a51fc6e1d61f36da2f0 (diff) | |
download | conntrack-tools-2932c6b8e6952ae84b221b854b43810c61e5c8fa.tar.gz conntrack-tools-2932c6b8e6952ae84b221b854b43810c61e5c8fa.zip |
- remove dead code sync-mode.c
- flush nack queue in the conntrackd -f path
- do not increase add_fail counter for EEXIST errors
- cleanup sync-nack code
- improve mcast_recv_netmsg: sanity check before checksumming!
Diffstat (limited to 'src/sync-nack.c')
-rw-r--r-- | src/sync-nack.c | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/src/sync-nack.c b/src/sync-nack.c index 288dba4..73f6dc2 100644 --- a/src/sync-nack.c +++ b/src/sync-nack.c @@ -43,37 +43,24 @@ struct cache_nack { static void cache_nack_add(struct us_conntrack *u, void *data) { struct cache_nack *cn = data; - INIT_LIST_HEAD(&cn->head); - list_add(&cn->head, &queue); } -static void cache_nack_update(struct us_conntrack *u, void *data) +static void cache_nack_del(struct us_conntrack *u, void *data) { struct cache_nack *cn = data; - if (cn->head.next != LIST_POISON1 && - cn->head.prev != LIST_POISON2) - list_del(&cn->head); + if (cn->head.next == &cn->head && + cn->head.prev == &cn->head) + return; - INIT_LIST_HEAD(&cn->head); - list_add(&cn->head, &queue); -} - -static void cache_nack_destroy(struct us_conntrack *u, void *data) -{ - struct cache_nack *cn = data; - - if (cn->head.next != LIST_POISON1 && - cn->head.prev != LIST_POISON2) - list_del(&cn->head); + list_del(&cn->head); } static struct cache_extra cache_nack_extra = { .size = sizeof(struct cache_nack), .add = cache_nack_add, - .update = cache_nack_update, - .destroy = cache_nack_destroy + .destroy = cache_nack_del }; static int nack_init() @@ -200,7 +187,9 @@ static void queue_resend(struct cache *c, unsigned int from, unsigned int to) } mcast_send_netmsg(STATE_SYNC(mcast_client), buf); - STATE_SYNC(mcast_sync)->post_send(net, u); + STATE_SYNC(mcast_sync)->post_send(NFCT_T_UPDATE, + net, + u); dp("(newseq=%u)\n", *seq); } } @@ -224,6 +213,7 @@ static void queue_empty(struct cache *c, unsigned int from, unsigned int to) debug_ct(u->ct, "ack received: empty queue"); dp("queue: deleting from queue (seq=%u)\n", cn->seq); list_del(&cn->head); + INIT_LIST_HEAD(&cn->head); } } unlock(); @@ -272,28 +262,35 @@ static int nack_pre_recv(const struct nlnetwork *net) return 0; } -static void nack_post_send(const struct nlnetwork *net, struct us_conntrack *u) +static void nack_post_send(int type, + const struct nlnetwork *net, + struct us_conntrack *u) { - unsigned int size = sizeof(struct nlnetwork); - struct nlmsghdr *nlh = (struct nlmsghdr *) ((void *) net + size); - - if (NFNL_MSG_TYPE(ntohs(nlh->nlmsg_type)) == IPCTNL_MSG_CT_DELETE) { - buffer_add(STATE_SYNC(buffer), net, - ntohl(nlh->nlmsg_len) + size); - } else if (u != NULL) { - unsigned int *seq; - struct list_head *n; - struct cache_nack *cn; - - cn = (struct cache_nack *) + unsigned int size = sizeof(struct nlnetwork); + struct nlmsghdr *nlh = (struct nlmsghdr *) ((void *) net + size); + struct cache_nack *cn; + + size += ntohl(nlh->nlmsg_len); + + switch(type) { + case NFCT_T_NEW: + case NFCT_T_UPDATE: + cn = (struct cache_nack *) cache_get_extra(STATE_SYNC(internal), u); - cn->seq = ntohl(net->seq); - if (cn->head.next != LIST_POISON1 && - cn->head.prev != LIST_POISON2) - list_del(&cn->head); + if (cn->head.next == &cn->head && + cn->head.prev == &cn->head) + goto insert; + + list_del(&cn->head); INIT_LIST_HEAD(&cn->head); +insert: + cn->seq = ntohl(net->seq); list_add(&cn->head, &queue); + break; + case NFCT_T_DESTROY: + buffer_add(STATE_SYNC(buffer), net, size); + break; } } |