From 595cf123d853d5dce5fde465f3a6f0b17c095b87 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 13 May 2014 17:15:22 -0700 Subject: [PATCH] 3.4-stable patches added patches: net-add-net_ratelimited_function-and-net_-level-_ratelimited-macros.patch --- ...n-and-net_-level-_ratelimited-macros.patch | 64 +++++++++++++++++++ queue-3.4/series | 1 + 2 files changed, 65 insertions(+) create mode 100644 queue-3.4/net-add-net_ratelimited_function-and-net_-level-_ratelimited-macros.patch diff --git a/queue-3.4/net-add-net_ratelimited_function-and-net_-level-_ratelimited-macros.patch b/queue-3.4/net-add-net_ratelimited_function-and-net_-level-_ratelimited-macros.patch new file mode 100644 index 00000000000..55b4d0bca14 --- /dev/null +++ b/queue-3.4/net-add-net_ratelimited_function-and-net_-level-_ratelimited-macros.patch @@ -0,0 +1,64 @@ +From 3a3bfb61e64476ff1e4ac3122cb6dec9c79b795c Mon Sep 17 00:00:00 2001 +From: Joe Perches +Date: Sun, 13 May 2012 21:56:25 +0000 +Subject: net: Add net_ratelimited_function and net__ratelimited macros + +From: Joe Perches + +commit 3a3bfb61e64476ff1e4ac3122cb6dec9c79b795c upstream. + +__ratelimit() can be considered an inverted bool test because +it returns true when not ratelimited. Several tests in the +kernel tree use this __ratelimit() function incorrectly. + +No net_ratelimit uses are incorrect currently though. + +Most uses of net_ratelimit are to log something via printk or +pr_. + +In order to minimize the uses of net_ratelimit, and to start +standardizing the code style used for __ratelimit() and net_ratelimit(), +add a net_ratelimited_function() macro and net__ratelimited() +logging macros similar to pr__ratelimited that use the global +net_ratelimit instead of a static per call site "struct ratelimit_state". + +Signed-off-by: Joe Perches +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/net.h | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +--- a/include/linux/net.h ++++ b/include/linux/net.h +@@ -259,6 +259,29 @@ extern struct socket *sockfd_lookup(int + #define sockfd_put(sock) fput(sock->file) + extern int net_ratelimit(void); + ++#define net_ratelimited_function(function, ...) \ ++do { \ ++ if (net_ratelimit()) \ ++ function(__VA_ARGS__); \ ++} while (0) ++ ++#define net_emerg_ratelimited(fmt, ...) \ ++ net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__) ++#define net_alert_ratelimited(fmt, ...) \ ++ net_ratelimited_function(pr_alert, fmt, ##__VA_ARGS__) ++#define net_crit_ratelimited(fmt, ...) \ ++ net_ratelimited_function(pr_crit, fmt, ##__VA_ARGS__) ++#define net_err_ratelimited(fmt, ...) \ ++ net_ratelimited_function(pr_err, fmt, ##__VA_ARGS__) ++#define net_notice_ratelimited(fmt, ...) \ ++ net_ratelimited_function(pr_notice, fmt, ##__VA_ARGS__) ++#define net_warn_ratelimited(fmt, ...) \ ++ net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__) ++#define net_info_ratelimited(fmt, ...) \ ++ net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__) ++#define net_dbg_ratelimited(fmt, ...) \ ++ net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__) ++ + #define net_random() random32() + #define net_srandom(seed) srandom32((__force u32)seed) + diff --git a/queue-3.4/series b/queue-3.4/series index 4768694c1f4..d9064f43680 100644 --- a/queue-3.4/series +++ b/queue-3.4/series @@ -2,5 +2,6 @@ scsi-megaraid-missing-bounds-check-in-mimd_to_kioc.patch n_tty-Fix-n_tty_write-crash-when-echoing-in-raw-mode.patch blktrace-fix-accounting-of-partially-completed-requests.patch netfilter-nf_conntrack-reserve-two-bytes-for-nf_ct_ext-len.patch +net-add-net_ratelimited_function-and-net_-level-_ratelimited-macros.patch netfilter-can-t-fail-and-free-after-table-replacement.patch tracepoint-do-not-waste-memory-on-mods-with-no-tracepoints.patch -- 2.47.3