* [PATCH 1/2] netfilter: ctnetlink: use expect instead of master tuple in get operation
@ 2011-12-18 0:34 pablo
2011-12-18 0:34 ` [PATCH 2/2] netfilter: ctnetlink: support individual atomic-get-and-reset of counters pablo
0 siblings, 1 reply; 2+ messages in thread
From: pablo @ 2011-12-18 0:34 UTC (permalink / raw)
To: netfilter-devel; +Cc: kaber, jengelh, kadlec
From: Pablo Neira Ayuso <pablo@netfilter.org>
Use the expect tuple (if possible) instead of the master tuple for
the get operation. If two or more expectations come from the same
master, the returned expectation may not be the one that user-space
is requesting.
This is how it works for the expect deletion operation.
Although I think that nobody has been seriously using this. We
accept both possibilities, using the expect tuple if possible.
I decided to do it like this to avoid breaking backward
compatibility.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_netlink.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index ef21b22..81a0f11 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1847,7 +1847,9 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
if (err < 0)
return err;
- if (cda[CTA_EXPECT_MASTER])
+ if (cda[CTA_EXPECT_TUPLE])
+ err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
+ else if (cda[CTA_EXPECT_MASTER])
err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_MASTER, u3);
else
return -EINVAL;
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] netfilter: ctnetlink: support individual atomic-get-and-reset of counters
2011-12-18 0:34 [PATCH 1/2] netfilter: ctnetlink: use expect instead of master tuple in get operation pablo
@ 2011-12-18 0:34 ` pablo
0 siblings, 0 replies; 2+ messages in thread
From: pablo @ 2011-12-18 0:34 UTC (permalink / raw)
To: netfilter-devel; +Cc: kaber, jengelh, kadlec
From: Pablo Neira Ayuso <pablo@netfilter.org>
This allows to use the get operation to atomically get-and-reset
counters.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_netlink.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 81a0f11..4b6b570 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1011,6 +1011,17 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
if (err < 0)
goto out;
+ if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO) {
+ struct nf_conn_counter *acct;
+
+ acct = nf_conn_acct_find(ct);
+ if (acct) {
+ atomic64_set(&acct[IP_CT_DIR_ORIGINAL].bytes, 0);
+ atomic64_set(&acct[IP_CT_DIR_ORIGINAL].packets, 0);
+ atomic64_set(&acct[IP_CT_DIR_REPLY].bytes, 0);
+ atomic64_set(&acct[IP_CT_DIR_REPLY].packets, 0);
+ }
+ }
return 0;
free:
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-18 0:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-18 0:34 [PATCH 1/2] netfilter: ctnetlink: use expect instead of master tuple in get operation pablo
2011-12-18 0:34 ` [PATCH 2/2] netfilter: ctnetlink: support individual atomic-get-and-reset of counters pablo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).