From: Jesse Gross Date: Fri, 25 May 2012 18:16:54 +0000 (-0700) Subject: datapath: Backport net_warn_ratelimited() and friends. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b10e452a96295c4f0a117f5fae4f55bca5f6b58;p=openvswitch datapath: Backport net_warn_ratelimited() and friends. Signed-off-by: Jesse Gross --- diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk index 819247b0..8ce61157 100644 --- a/datapath/linux/Modules.mk +++ b/datapath/linux/Modules.mk @@ -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 index 00000000..5665e2ee --- /dev/null +++ b/datapath/linux/compat/include/linux/net.h @@ -0,0 +1,31 @@ +#ifndef __LINUX_NET_WRAPPER_H +#define __LINUX_NET_WRAPPER_H 1 + +#include_next + +#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