summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2020-10-28 15:12:20 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2020-10-28 15:22:45 +0100
commit36aa0f15020537389d8cdbf748d5c1bf9f47a358 (patch)
treef5674a13211f12faf4c23703501315b26b38c66a /src
parent4edc838408a34a8958671103e7446ddc2dae918b (diff)
conntrack: allow to filter event by family
This patch allows you to filter event through -f, e.g. conntrack -E -f ipv4 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/conntrack.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/conntrack.c b/src/conntrack.c
index db35b07..66f513b 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -393,7 +393,7 @@ static char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] =
/*CT_DELETE*/ {2,2,2,2,2,2,2,0,0,0,0,2,2,0,2,2,2,2,2,2,0,0,0,2,2,0,0,2,2},
/*CT_GET*/ {3,3,3,3,1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,0,2,0,0,0,0},
/*CT_FLUSH*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
-/*CT_EVENT*/ {2,2,2,2,2,0,0,0,2,0,0,2,2,0,2,0,0,2,2,2,2,2,2,2,2,0,0,2,2},
+/*CT_EVENT*/ {2,2,2,2,2,0,0,0,2,0,0,2,2,0,2,0,2,2,2,2,2,2,2,2,2,0,0,2,2},
/*VERSION*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
/*HELP*/ {0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
/*EXP_LIST*/ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0},
@@ -1425,6 +1425,7 @@ exp_event_sighandler(int s)
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 nf_conntrack *obj = data;
enum nf_conntrack_msg_type type;
@@ -1456,7 +1457,9 @@ static int event_cb(const struct nlmsghdr *nlh, void *data)
if (nfct_nlmsg_parse(nlh, ct) < 0)
goto out;
- if (nfct_filter(obj, ct))
+ if ((filter_family != AF_UNSPEC &&
+ filter_family != nfh->nfgen_family) ||
+ nfct_filter(obj, ct))
goto out;
if (output_mask & _O_XML) {