From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: mikhail.sennikovskii@cloud.ionos.com
Subject: [PATCH conntrack 3/6] conntrack: pass cmd to nfct_filter()
Date: Mon, 15 Mar 2021 17:49:26 +0100 [thread overview]
Message-ID: <20210315164929.23608-3-pablo@netfilter.org> (raw)
In-Reply-To: <20210315164929.23608-1-pablo@netfilter.org>
Pass the command object to the userspace filter routine.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/conntrack.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/conntrack.c b/src/conntrack.c
index 31630eb1f926..79053b7482c6 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -1640,9 +1640,11 @@ filter_network(const struct nf_conntrack *ct)
}
static int
-nfct_filter(struct nf_conntrack *obj, struct nf_conntrack *ct,
+nfct_filter(struct ct_cmd *cmd, struct nf_conntrack *ct,
const struct ct_tmpl *tmpl)
{
+ struct nf_conntrack *obj = cmd->tmpl.ct;
+
if (filter_nat(obj, ct) ||
filter_mark(ct, tmpl) ||
filter_label(ct, tmpl) ||
@@ -1854,9 +1856,8 @@ static int event_cb(const struct nlmsghdr *nlh, void *data)
{
struct nfgenmsg *nfh = mnl_nlmsg_get_payload(nlh);
unsigned int op_type = NFCT_O_DEFAULT;
- struct ct_cmd *cmd = data;
- struct nf_conntrack *obj = cmd->tmpl.ct;
enum nf_conntrack_msg_type type;
+ struct ct_cmd *cmd = data;
unsigned int op_flags = 0;
struct nf_conntrack *ct;
char buf[1024];
@@ -1886,7 +1887,7 @@ static int event_cb(const struct nlmsghdr *nlh, void *data)
if ((filter_family != AF_UNSPEC &&
filter_family != nfh->nfgen_family) ||
- nfct_filter(obj, ct, cur_tmpl))
+ nfct_filter(cmd, ct, cur_tmpl))
goto out;
if (output_mask & _O_SAVE) {
@@ -1941,13 +1942,12 @@ static int dump_cb(enum nf_conntrack_msg_type type,
struct nf_conntrack *ct,
void *data)
{
- struct ct_cmd *cmd = data;
- struct nf_conntrack *obj = cmd->tmpl.ct;
unsigned int op_type = NFCT_O_DEFAULT;
unsigned int op_flags = 0;
+ struct ct_cmd *cmd = data;
char buf[1024];
- if (nfct_filter(obj, ct, cur_tmpl))
+ if (nfct_filter(cmd, ct, cur_tmpl))
return NFCT_CB_CONTINUE;
if (output_mask & _O_SAVE) {
@@ -1983,14 +1983,13 @@ static int delete_cb(enum nf_conntrack_msg_type type,
struct nf_conntrack *ct,
void *data)
{
- struct ct_cmd *cmd = data;
- struct nf_conntrack *obj = cmd->tmpl.ct;
unsigned int op_type = NFCT_O_DEFAULT;
unsigned int op_flags = 0;
+ struct ct_cmd *cmd = data;
char buf[1024];
int res;
- if (nfct_filter(obj, ct, cur_tmpl))
+ if (nfct_filter(cmd, ct, cur_tmpl))
return NFCT_CB_CONTINUE;
res = nfct_query(ith, NFCT_Q_DESTROY, ct);
--
2.20.1
next prev parent reply other threads:[~2021-03-15 16:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 16:49 [PATCH conntrack 1/6] conntrack: pass command object to callbacks Pablo Neira Ayuso
2021-03-15 16:49 ` [PATCH conntrack 2/6] conntrack: pass ct_cmd to nfct_filter_init() Pablo Neira Ayuso
2021-03-15 16:49 ` Pablo Neira Ayuso [this message]
2021-03-15 16:49 ` [PATCH conntrack 4/6] conntrack: pass cmd to filter nat, mark and network functions Pablo Neira Ayuso
2021-03-15 16:49 ` [PATCH conntrack 5/6] conntrack: move options flag to ct_cmd object Pablo Neira Ayuso
2021-03-15 16:49 ` [PATCH conntrack 6/6] conntrack: add function to print command stats Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210315164929.23608-3-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=mikhail.sennikovskii@cloud.ionos.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).