From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: joseph.j.conley@gmail.com
Subject: [PATCH conntrack-tools] conntrack: send mark filter to kernel iff set
Date: Fri, 23 Dec 2016 15:53:47 +0100 [thread overview]
Message-ID: <1482504827-14047-1-git-send-email-pablo@netfilter.org> (raw)
Do not set a mark filter to ctnetlink if the user doesn't explicitly
specify this.
Fixes: aa925010951e ("conntrack: allow to filter by mark from kernel-space")
Reported-by: Joseph Conley <joseph.j.conley@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/conntrack.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/conntrack.c b/src/conntrack.c
index ff030fe54e10..682afa68784e 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -79,6 +79,7 @@ static struct {
/* Allow to filter by mark from kernel-space. */
struct nfct_filter_dump_mark filter_mark_kernel;
+ bool filter_mark_kernel_set;
/* Allows filtering by ctlabels */
struct nfct_bitmask *label;
@@ -2374,6 +2375,7 @@ int main(int argc, char *argv[])
parse_u32_mask(optarg, &tmpl.mark);
tmpl.filter_mark_kernel.val = tmpl.mark.value;
tmpl.filter_mark_kernel.mask = tmpl.mark.mask;
+ tmpl.filter_mark_kernel_set = true;
break;
case 'l':
case '<':
@@ -2523,11 +2525,14 @@ int main(int argc, char *argv[])
if (filter_dump == NULL)
exit_error(OTHER_PROBLEM, "OOM");
- nfct_filter_dump_set_attr(filter_dump, NFCT_FILTER_DUMP_MARK,
- &tmpl.filter_mark_kernel);
- nfct_filter_dump_set_attr_u8(filter_dump,
- NFCT_FILTER_DUMP_L3NUM,
- family);
+ if (tmpl.filter_mark_kernel_set) {
+ nfct_filter_dump_set_attr(filter_dump,
+ NFCT_FILTER_DUMP_MARK,
+ &tmpl.filter_mark_kernel);
+ nfct_filter_dump_set_attr_u8(filter_dump,
+ NFCT_FILTER_DUMP_L3NUM,
+ family);
+ }
if (options & CT_OPT_ZERO)
res = nfct_query(cth, NFCT_Q_DUMP_FILTER_RESET,
@@ -2626,11 +2631,14 @@ int main(int argc, char *argv[])
if (filter_dump == NULL)
exit_error(OTHER_PROBLEM, "OOM");
- nfct_filter_dump_set_attr(filter_dump, NFCT_FILTER_DUMP_MARK,
- &tmpl.filter_mark_kernel);
- nfct_filter_dump_set_attr_u8(filter_dump,
- NFCT_FILTER_DUMP_L3NUM,
- family);
+ if (tmpl.filter_mark_kernel_set) {
+ nfct_filter_dump_set_attr(filter_dump,
+ NFCT_FILTER_DUMP_MARK,
+ &tmpl.filter_mark_kernel);
+ nfct_filter_dump_set_attr_u8(filter_dump,
+ NFCT_FILTER_DUMP_L3NUM,
+ family);
+ }
res = nfct_query(cth, NFCT_Q_DUMP_FILTER, filter_dump);
--
2.1.4
reply other threads:[~2016-12-23 14:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1482504827-14047-1-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=joseph.j.conley@gmail.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).