]>
Commit | Line | Data |
---|---|---|
fe27c4d0 GKH |
1 | From 8e618aad5348b6e6c5a90e8d97ea643197963b20 Mon Sep 17 00:00:00 2001 |
2 | From: Tilman Schmidt <tilman@imap.cc> | |
3 | Date: Wed, 25 Apr 2012 13:02:19 +0000 | |
4 | Subject: isdn/gigaset: ratelimit CAPI message dumps | |
5 | ||
6 | From: Tilman Schmidt <tilman@imap.cc> | |
7 | ||
8 | commit 8e618aad5348b6e6c5a90e8d97ea643197963b20 upstream. | |
9 | ||
10 | Introduce a global ratelimit for CAPI message dumps to protect | |
11 | against possible log flood. | |
12 | Drop the ratelimit for ignored messages which is now covered by the | |
13 | global one. | |
14 | ||
15 | Signed-off-by: Tilman Schmidt <tilman@imap.cc> | |
16 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
17 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
18 | ||
19 | --- | |
20 | drivers/isdn/gigaset/capi.c | 22 +++++++++------------- | |
21 | 1 file changed, 9 insertions(+), 13 deletions(-) | |
22 | ||
23 | --- a/drivers/isdn/gigaset/capi.c | |
24 | +++ b/drivers/isdn/gigaset/capi.c | |
25 | @@ -14,6 +14,7 @@ | |
26 | #include "gigaset.h" | |
27 | #include <linux/proc_fs.h> | |
28 | #include <linux/seq_file.h> | |
29 | +#include <linux/ratelimit.h> | |
30 | #include <linux/isdn/capilli.h> | |
31 | #include <linux/isdn/capicmd.h> | |
32 | #include <linux/isdn/capiutil.h> | |
33 | @@ -222,10 +223,14 @@ get_appl(struct gigaset_capi_ctr *iif, u | |
34 | static inline void dump_cmsg(enum debuglevel level, const char *tag, _cmsg *p) | |
35 | { | |
36 | #ifdef CONFIG_GIGASET_DEBUG | |
37 | + /* dump at most 20 messages in 20 secs */ | |
38 | + static DEFINE_RATELIMIT_STATE(msg_dump_ratelimit, 20 * HZ, 20); | |
39 | _cdebbuf *cdb; | |
40 | ||
41 | if (!(gigaset_debuglevel & level)) | |
42 | return; | |
43 | + if (!___ratelimit(&msg_dump_ratelimit, tag)) | |
44 | + return; | |
45 | ||
46 | cdb = capi_cmsg2str(p); | |
47 | if (cdb) { | |
48 | @@ -2058,12 +2063,6 @@ static void do_reset_b3_req(struct gigas | |
49 | } | |
50 | ||
51 | /* | |
52 | - * dump unsupported/ignored messages at most twice per minute, | |
53 | - * some apps send those very frequently | |
54 | - */ | |
55 | -static unsigned long ignored_msg_dump_time; | |
56 | - | |
57 | -/* | |
58 | * unsupported CAPI message handler | |
59 | */ | |
60 | static void do_unsupported(struct gigaset_capi_ctr *iif, | |
61 | @@ -2072,8 +2071,7 @@ static void do_unsupported(struct gigase | |
62 | { | |
63 | /* decode message */ | |
64 | capi_message2cmsg(&iif->acmsg, skb->data); | |
65 | - if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000)) | |
66 | - dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg); | |
67 | + dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg); | |
68 | send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState); | |
69 | } | |
70 | ||
71 | @@ -2084,11 +2082,9 @@ static void do_nothing(struct gigaset_ca | |
72 | struct gigaset_capi_appl *ap, | |
73 | struct sk_buff *skb) | |
74 | { | |
75 | - if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000)) { | |
76 | - /* decode message */ | |
77 | - capi_message2cmsg(&iif->acmsg, skb->data); | |
78 | - dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg); | |
79 | - } | |
80 | + /* decode message */ | |
81 | + capi_message2cmsg(&iif->acmsg, skb->data); | |
82 | + dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg); | |
83 | dev_kfree_skb_any(skb); | |
84 | } | |
85 |