Skip to content

Commit 2c94b53

Browse files
Tim Binghamdavem330
authored andcommitted
net: Implement net_dbg_ratelimited() for CONFIG_DYNAMIC_DEBUG case
Prior to commit d92cff8 ("net_dbg_ratelimited: turn into no-op when !DEBUG") the implementation of net_dbg_ratelimited() was buggy for both the DEBUG and CONFIG_DYNAMIC_DEBUG cases. The bug was that net_ratelimit() was being called and, despite returning true, nothing was being printed to the console. This resulted in messages like the following - "net_ratelimit: %d callbacks suppressed" with no other output nearby. After commit d92cff8 ("net_dbg_ratelimited: turn into no-op when !DEBUG") the bug is fixed for the DEBUG case. However, there's no output at all for CONFIG_DYNAMIC_DEBUG case. This patch restores debug output (if enabled) for the CONFIG_DYNAMIC_DEBUG case. Add a definition of net_dbg_ratelimited() for the CONFIG_DYNAMIC_DEBUG case. The implementation takes care to check that dynamic debugging is enabled before calling net_ratelimit(). Fixes: d92cff8 ("net_dbg_ratelimited: turn into no-op when !DEBUG") Signed-off-by: Tim Bingham <tbingham@akamai.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent efe7905 commit 2c94b53

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

include/linux/net.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,15 @@ do { \
246246
net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
247247
#define net_info_ratelimited(fmt, ...) \
248248
net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
249-
#if defined(DEBUG)
249+
#if defined(CONFIG_DYNAMIC_DEBUG)
250+
#define net_dbg_ratelimited(fmt, ...) \
251+
do { \
252+
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
253+
if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
254+
net_ratelimit()) \
255+
__dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \
256+
} while (0)
257+
#elif defined(DEBUG)
250258
#define net_dbg_ratelimited(fmt, ...) \
251259
net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
252260
#else

0 commit comments

Comments
 (0)