From 420470004059c81f7ba83d655e6d27c921c652d2 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Wed, 8 Sep 2021 14:02:24 +0200 Subject: conntrack: add support for chaintoolong stat counter While at it, also fix up commit 5ec55c2a0a264 ("conntrack: add support for CLASH_RESOLVED counter"). The intention was to also print unknown statistic counters provided the attributes are of type u32, but mnl_attr_type_valid() needs the correct max-attr number for this to work. With this fix in place, conntrack -S shows: cpu=3 found=0 inv[..] clash_resolve=0 unknown1=8200 on a modified kernel. Signed-off-by: Florian Westphal --- src/conntrack.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/conntrack.c b/src/conntrack.c index ef7f604..9e2fa25 100644 --- a/src/conntrack.c +++ b/src/conntrack.c @@ -2486,12 +2486,14 @@ nfct_mnl_get(uint16_t subsys, uint16_t type, mnl_cb_t cb, uint8_t family) return mnl_cb_run(buf, res, nlh->nlmsg_seq, sock.portid, cb, NULL); } +#define UNKNOWN_STATS_NUM 4 + static int nfct_stats_attr_cb(const struct nlattr *attr, void *data) { const struct nlattr **tb = data; int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, CTA_STATS_MAX) < 0) + if (mnl_attr_type_valid(attr, CTA_STATS_MAX + UNKNOWN_STATS_NUM) < 0) return MNL_CB_OK; if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) { @@ -2503,8 +2505,6 @@ static int nfct_stats_attr_cb(const struct nlattr *attr, void *data) return MNL_CB_OK; } -#define UNKNOWN_STATS_NUM 4 - static int nfct_stats_cb(const struct nlmsghdr *nlh, void *data) { struct nlattr *tb[CTA_STATS_MAX + UNKNOWN_STATS_NUM + 1] = {}; @@ -2524,6 +2524,7 @@ static int nfct_stats_cb(const struct nlmsghdr *nlh, void *data) [CTA_STATS_ERROR] = "error", [CTA_STATS_SEARCH_RESTART] = "search_restart", [CTA_STATS_CLASH_RESOLVE] = "clash_resolve", + [CTA_STATS_CHAIN_TOOLONG] = "chaintoolong", /* leave at end. Allows to show counters supported * by newer kernel with older conntrack-tools release. -- cgit v1.2.3