This patch fixes the behavior of the net_ratelimited helper so
that "callback suppressed" messages are printed to the log buffer
specified when the helper is called.
Fixes c6be5cb8ae5b0 ("ve: network rate-limited VE logging helpers introduced")
Signed-off-by: Aleksei Oladko <[email protected]>
---
include/linux/net.h | 11 +++++++++--
net/core/utils.c | 6 ++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/linux/net.h b/include/linux/net.h
index c4f22d935208..3f3bbe9f149d 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -265,6 +265,7 @@ struct socket *sockfd_lookup(int fd, int *err);
struct socket *sock_from_file(struct file *file);
#define sockfd_put(sock) fput(sock->file)
int net_ratelimit(void);
+int ve_net_ratelimit(int dst);
#define net_ratelimited_function(function, ...) \
do { \
@@ -272,6 +273,12 @@ do {
\
function(__VA_ARGS__); \
} while (0)
+#define ve_net_ratelimited_function(function, dst, ...) \
+do { \
+ if (ve_net_ratelimit(dst)) \
+ function(dst, __VA_ARGS__); \
+} while (0)
+
#define net_emerg_ratelimited(fmt, ...) \
net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__)
#define net_alert_ratelimited(fmt, ...) \
@@ -305,9 +312,9 @@ do {
\
#endif
#define net_velog_ratelimited(fmt, ...) \
- net_ratelimited_function(ve_printk, VE_LOG, fmt, ##__VA_ARGS__)
+ ve_net_ratelimited_function(ve_printk, VE_LOG, fmt, ##__VA_ARGS__)
#define net_veboth_ratelimited(fmt, ...) \
- net_ratelimited_function(ve_printk, VE_LOG_BOTH, fmt, ##__VA_ARGS__)
+ ve_net_ratelimited_function(ve_printk, VE_LOG_BOTH, fmt, ##__VA_ARGS__)
#define net_get_random_once(buf, nbytes) \
get_random_once((buf), (nbytes))
diff --git a/net/core/utils.c b/net/core/utils.c
index 27f4cffaae05..cffc3bc44baa 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -41,6 +41,12 @@ int net_ratelimit(void)
}
EXPORT_SYMBOL(net_ratelimit);
+int ve_net_ratelimit(int dst)
+{
+ return ve_ratelimit(dst, &net_ratelimit_state);
+}
+EXPORT_SYMBOL(ve_net_ratelimit);
+
/*
* Convert an ASCII string to binary IP.
* This is outside of net/ipv4/ because various code that uses IP addresses
--
2.43.0
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel