datapath: Backport net_warn_ratelimited() and friends.
authorJesse Gross <jesse@nicira.com>
Fri, 25 May 2012 18:16:54 +0000 (11:16 -0700)
committerJesse Gross <jesse@nicira.com>
Fri, 25 May 2012 18:17:34 +0000 (11:17 -0700)
Signed-off-by: Jesse Gross <jesse@nicira.com>
datapath/linux/Modules.mk
datapath/linux/compat/include/linux/net.h [new file with mode: 0644]

index 819247b03ac5bca0f331b25b9c548b08fdd2b276..8ce61157983ceaf877df1878c5e883214babc9cc 100644 (file)
@@ -37,6 +37,7 @@ openvswitch_headers += \
        linux/compat/include/linux/lockdep.h \
        linux/compat/include/linux/log2.h \
        linux/compat/include/linux/mutex.h \
+       linux/compat/include/linux/net.h \
        linux/compat/include/linux/netdevice.h \
        linux/compat/include/linux/netfilter_bridge.h \
        linux/compat/include/linux/netfilter_ipv4.h \
diff --git a/datapath/linux/compat/include/linux/net.h b/datapath/linux/compat/include/linux/net.h
new file mode 100644 (file)
index 0000000..5665e2e
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef __LINUX_NET_WRAPPER_H
+#define __LINUX_NET_WRAPPER_H 1
+
+#include_next <linux/net.h>
+
+#ifndef net_ratelimited_function
+#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__)
+#endif
+
+#endif