netfilter: qtaguid: rate limit some of the printks
authorJP Abgrall <jpa@google.com>
Mon, 8 Apr 2013 22:09:26 +0000 (15:09 -0700)
committerJohn Stultz <john.stultz@linaro.org>
Tue, 16 Feb 2016 21:51:29 +0000 (13:51 -0800)
Some of the printks are in the packet handling path.
We now ratelimit the very unlikely errors to avoid
kmsg spamming.

Signed-off-by: JP Abgrall <jpa@google.com>
net/netfilter/xt_qtaguid.c

index 992a6e044902a8e5ef9eb9459b3a67e5b96db9ad..4ec6d23876c5913e21d7e0491d9c243d19d0bf41 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter/xt_qtaguid.h>
+#include <linux/ratelimit.h>
 #include <linux/skbuff.h>
 #include <linux/workqueue.h>
 #include <net/addrconf.h>
@@ -1328,12 +1329,12 @@ static void iface_stat_update_from_skb(const struct sk_buff *skb,
        }
 
        if (unlikely(!el_dev)) {
-               pr_err("qtaguid[%d]: %s(): no par->in/out?!!\n",
-                      par->hooknum, __func__);
+               pr_err_ratelimited("qtaguid[%d]: %s(): no par->in/out?!!\n",
+                                  par->hooknum, __func__);
                BUG();
        } else if (unlikely(!el_dev->name)) {
-               pr_err("qtaguid[%d]: %s(): no dev->name?!!\n",
-                      par->hooknum, __func__);
+               pr_err_ratelimited("qtaguid[%d]: %s(): no dev->name?!!\n",
+                                  par->hooknum, __func__);
                BUG();
        } else {
                proto = ipx_proto(skb, par);
@@ -1416,8 +1417,8 @@ static void if_tag_stat_update(const char *ifname, uid_t uid,
 
        iface_entry = get_iface_entry(ifname);
        if (!iface_entry) {
-               pr_err("qtaguid: iface_stat: stat_update() %s not found\n",
-                      ifname);
+               pr_err_ratelimited("qtaguid: iface_stat: stat_update() "
+                                  "%s not found\n", ifname);
                return;
        }
        /* It is ok to process data when an iface_entry is inactive */