conntrack: allow to filter event by family
Pablo Neira Ayuso
maintainerPATCH 1/1 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 <[email protected]>
--- src/conntrack.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
src/conntrack.c +5 -2
@@ -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) {
Signature · 1 line
2.20.1