Skip to content

Commit 23c4ec1

Browse files
André Gaulordex
authored andcommitted
batman-adv: remove unnecessary logspam
This patch removes unnecessary logspam which resulted from superfluous calls to net_ratelimit(). With the supplied patch, net_ratelimit() is called after the loglevel has been checked. Signed-off-by: André Gaul <gaul@web-yard.de> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
1 parent 0185dda commit 23c4ec1

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎net/batman-adv/main.h‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,29 @@ enum batadv_dbg_level {
238238
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
239239
__printf(2, 3);
240240

241-
#define batadv_dbg(type, bat_priv, fmt, arg...) \
241+
/* possibly ratelimited debug output */
242+
#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \
242243
do { \
243-
if (atomic_read(&bat_priv->log_level) & type) \
244+
if (atomic_read(&bat_priv->log_level) & type && \
245+
(!ratelimited || net_ratelimit())) \
244246
batadv_debug_log(bat_priv, fmt, ## arg);\
245247
} \
246248
while (0)
247249
#else /* !CONFIG_BATMAN_ADV_DEBUG */
248-
__printf(3, 4)
249-
static inline void batadv_dbg(int type __always_unused,
250-
struct batadv_priv *bat_priv __always_unused,
251-
const char *fmt __always_unused, ...)
250+
__printf(4, 5)
251+
static inline void _batadv_dbg(int type __always_unused,
252+
struct batadv_priv *bat_priv __always_unused,
253+
int ratelimited __always_unused,
254+
const char *fmt __always_unused, ...)
252255
{
253256
}
254257
#endif
255258

259+
#define batadv_dbg(type, bat_priv, arg...) \
260+
_batadv_dbg(type, bat_priv, 0, ## arg)
261+
#define batadv_dbg_ratelimited(type, bat_priv, arg...) \
262+
_batadv_dbg(type, bat_priv, 1, ## arg)
263+
256264
#define batadv_info(net_dev, fmt, arg...) \
257265
do { \
258266
struct net_device *_netdev = (net_dev); \

‎net/batman-adv/routing.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,11 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
706706
if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) {
707707
if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
708708
ethhdr->h_dest, vid))
709-
net_ratelimited_function(batadv_dbg, BATADV_DBG_TT,
710-
bat_priv,
711-
"Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n",
712-
unicast_packet->dest,
713-
ethhdr->h_dest);
709+
batadv_dbg_ratelimited(BATADV_DBG_TT,
710+
bat_priv,
711+
"Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n",
712+
unicast_packet->dest,
713+
ethhdr->h_dest);
714714
/* at this point the mesh destination should have been
715715
* substituted with the originator address found in the global
716716
* table. If not, let the packet go untouched anyway because
@@ -752,10 +752,10 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
752752
*/
753753
if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
754754
ethhdr->h_dest, vid)) {
755-
net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, bat_priv,
756-
"Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n",
757-
unicast_packet->dest, ethhdr->h_dest,
758-
old_ttvn, curr_ttvn);
755+
batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv,
756+
"Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n",
757+
unicast_packet->dest, ethhdr->h_dest,
758+
old_ttvn, curr_ttvn);
759759
return 1;
760760
}
761761

0 commit comments

Comments
 (0)