summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-12-08 11:09:02 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-12-08 11:09:02 +0100
commitbf6cfeb1dc6652eaff1b7c4edda45e15f5abf361 (patch)
tree936fa6dfa0aaabff35b3cd0a287f0623dfc04093
parent29b5df53bcbef17722ab2b389f3352c4e86b4795 (diff)
downloadconntrack-tools-bf6cfeb1dc6652eaff1b7c4edda45e15f5abf361.tar.gz
conntrack-tools-bf6cfeb1dc6652eaff1b7c4edda45e15f5abf361.zip
network: remove length parameter of mcast_buffered_send_netmsg()
This patch simplifies mcast_buffered_send_netmsg() by removing the length parameter. Instead, we use the length field in the nethdr to know the message size to be sent. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/network.h2
-rw-r--r--src/network.c5
-rw-r--r--src/sync-alarm.c2
-rw-r--r--src/sync-ftfw.c4
-rw-r--r--src/sync-mode.c2
-rw-r--r--src/sync-notrack.c4
6 files changed, 9 insertions, 10 deletions
diff --git a/include/network.h b/include/network.h
index b64753c..1195303 100644
--- a/include/network.h
+++ b/include/network.h
@@ -76,7 +76,7 @@ struct mcast_conf;
int mcast_buffered_init(int mtu);
void mcast_buffered_destroy(void);
-int mcast_buffered_send_netmsg(struct mcast_sock *m, void *data, size_t len);
+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)
diff --git a/src/network.c b/src/network.c
index 2f83d3b..a6ecb7e 100644
--- a/src/network.c
+++ b/src/network.c
@@ -108,10 +108,9 @@ void mcast_buffered_destroy(void)
}
/* return 0 if it is not sent, otherwise return 1 */
-int mcast_buffered_send_netmsg(struct mcast_sock *m, void *data, size_t len)
+int mcast_buffered_send_netmsg(struct mcast_sock *m, const struct nethdr *net)
{
- int ret = 0;
- struct nethdr *net = data;
+ int ret = 0, len = ntohs(net->len);
retry:
if (tx_buflen + len < tx_buflenmax) {
diff --git a/src/sync-alarm.c b/src/sync-alarm.c
index 4473af2..377af16 100644
--- a/src/sync-alarm.c
+++ b/src/sync-alarm.c
@@ -41,7 +41,7 @@ static void refresher(struct alarm_block *a, void *data)
net = BUILD_NETMSG(u->ct, NFCT_Q_UPDATE);
len = prepare_send_netmsg(STATE_SYNC(mcast_client), net);
- mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len);
+ mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net);
}
static void cache_alarm_add(struct us_conntrack *u, void *data)
diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c
index abba1fe..293f9ab 100644
--- a/src/sync-ftfw.c
+++ b/src/sync-ftfw.c
@@ -495,7 +495,7 @@ static int tx_queue_xmit(void *data1, const void *data2)
dp("tx_queue sq: %u fl:%u len:%u\n",
ntohl(net->seq), net->flags, ntohs(net->len));
- mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len);
+ mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net);
HDR_NETWORK2HOST(net);
if (IS_DATA(net) || IS_ACK(net) || IS_NACK(net))
@@ -518,7 +518,7 @@ static int tx_list_xmit(struct list_head *i, struct us_conntrack *u, int type)
list_del_init(i);
tx_list_len--;
- ret = mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len);
+ ret = mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net);
ftfw_send(net, u);
return ret;
diff --git a/src/sync-mode.c b/src/sync-mode.c
index 98867b2..ac9d3f3 100644
--- a/src/sync-mode.c
+++ b/src/sync-mode.c
@@ -406,7 +406,7 @@ static void mcast_send_sync(struct us_conntrack *u, int query)
if (STATE_SYNC(sync)->send)
STATE_SYNC(sync)->send(net, u);
- mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len);
+ mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net);
}
static int purge_step(void *data1, void *data2)
diff --git a/src/sync-notrack.c b/src/sync-notrack.c
index c7ac9b5..c5ea1e6 100644
--- a/src/sync-notrack.c
+++ b/src/sync-notrack.c
@@ -157,7 +157,7 @@ static int tx_queue_xmit(void *data1, const void *data2)
struct nethdr *net = data1;
size_t len = prepare_send_netmsg(STATE_SYNC(mcast_client), net);
- mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len);
+ mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net);
queue_del(tx_queue, net);
return 0;
@@ -172,7 +172,7 @@ static int tx_list_xmit(struct list_head *i, struct us_conntrack *u, int type)
list_del_init(i);
tx_list_len--;
- ret = mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len);
+ ret = mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net);
return ret;
}