From d3d2bee2d9ebd565e006f213c76cfa316b5e5ab1 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Tue, 25 Aug 2015 14:22:41 +0200 Subject: conntrack: add zone attribute to tuple This patch adds the front-end to the recent ctnetlink interface changes that add the zone attribute into the tuple. Signed-off-by: Daniel Borkmann Signed-off-by: Pablo Neira Ayuso --- src/conntrack/snprintf_default.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/conntrack/snprintf_default.c') diff --git a/src/conntrack/snprintf_default.c b/src/conntrack/snprintf_default.c index 24e2f28..06466b1 100644 --- a/src/conntrack/snprintf_default.c +++ b/src/conntrack/snprintf_default.c @@ -171,6 +171,13 @@ int __snprintf_proto(char *buf, return size; } +static int +__snprintf_tuple_zone(char *buf, unsigned int len, const char *pfx, + const struct __nfct_tuple *tuple) +{ + return (snprintf(buf, len, "zone-%s=%u ", pfx, tuple->zone)); +} + static int __snprintf_status_assured(char *buf, unsigned int len, const struct nf_conntrack *ct) @@ -396,6 +403,11 @@ int __snprintf_conntrack_default(char *buf, ret = __snprintf_proto(buf+offset, len, &ct->head.orig); BUFFER_SIZE(ret, size, len, offset); + if (test_bit(ATTR_ORIG_ZONE, ct->head.set)) { + ret = __snprintf_tuple_zone(buf+offset, len, "orig", &ct->head.orig); + BUFFER_SIZE(ret, size, len, offset); + } + if (test_bit(ATTR_ORIG_COUNTER_PACKETS, ct->head.set) && test_bit(ATTR_ORIG_COUNTER_BYTES, ct->head.set)) { ret = __snprintf_counters(buf+offset, len, ct, __DIR_ORIG); @@ -414,6 +426,11 @@ int __snprintf_conntrack_default(char *buf, ret = __snprintf_proto(buf+offset, len, &ct->repl); BUFFER_SIZE(ret, size, len, offset); + if (test_bit(ATTR_REPL_ZONE, ct->head.set)) { + ret = __snprintf_tuple_zone(buf+offset, len, "reply", &ct->repl); + BUFFER_SIZE(ret, size, len, offset); + } + if (test_bit(ATTR_REPL_COUNTER_PACKETS, ct->head.set) && test_bit(ATTR_REPL_COUNTER_BYTES, ct->head.set)) { ret = __snprintf_counters(buf+offset, len, ct, __DIR_REPL); -- cgit v1.2.3