]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
netfilter: ctnetlink: export nf_conntrack_max
authorFlorent Fourcot <florent.fourcot@wifirst.fr>
Sun, 6 May 2018 14:30:14 +0000 (16:30 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 6 May 2018 22:04:02 +0000 (00:04 +0200)
IPCTNL_MSG_CT_GET_STATS netlink command allow to monitor current number
of conntrack entries. However, if one wants to compare it with the
maximum (and detect exhaustion), the only solution is currently to read
sysctl value.

This patch add nf_conntrack_max value in netlink message, and simplify
monitoring for application built on netlink API.

Signed-off-by: Florent Fourcot <florent.fourcot@wifirst.fr>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/uapi/linux/netfilter/nfnetlink_conntrack.h
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_netlink.c

index 77987111cab0c2a01d2126e95ad40c64b18b4549..1d41810d17e2caffc6c7c31e586300d02da6947e 100644 (file)
@@ -262,6 +262,7 @@ enum ctattr_stats_cpu {
 enum ctattr_stats_global {
        CTA_STATS_GLOBAL_UNSPEC,
        CTA_STATS_GLOBAL_ENTRIES,
+       CTA_STATS_GLOBAL_MAX_ENTRIES,
        __CTA_STATS_GLOBAL_MAX,
 };
 #define CTA_STATS_GLOBAL_MAX (__CTA_STATS_GLOBAL_MAX - 1)
index 41ff04ee2554a31fa1a0ffd132f1f9268854cbfb..60544172700846a731786c318adbab3a1cb3bf35 100644 (file)
@@ -186,6 +186,7 @@ unsigned int nf_conntrack_htable_size __read_mostly;
 EXPORT_SYMBOL_GPL(nf_conntrack_htable_size);
 
 unsigned int nf_conntrack_max __read_mostly;
+EXPORT_SYMBOL_GPL(nf_conntrack_max);
 seqcount_t nf_conntrack_generation __read_mostly;
 static unsigned int nf_conntrack_hash_rnd __read_mostly;
 
index 4c1d0c5bc26800a87c4af6f47942a61be633524a..d807b8770be3e27d1ae258086e8387a272720c60 100644 (file)
@@ -2205,6 +2205,9 @@ ctnetlink_stat_ct_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
        if (nla_put_be32(skb, CTA_STATS_GLOBAL_ENTRIES, htonl(nr_conntracks)))
                goto nla_put_failure;
 
+       if (nla_put_be32(skb, CTA_STATS_GLOBAL_MAX_ENTRIES, htonl(nf_conntrack_max)))
+               goto nla_put_failure;
+
        nlmsg_end(skb, nlh);
        return skb->len;