From patchwork Wed Jun 4 19:53:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Gaul?= X-Patchwork-Id: 4056 Return-Path: Received: from mail.d00d3.net (production.d00d3.net [78.46.110.204]) by open-mesh.org (Postfix) with ESMTPS id DB81660072B for ; Wed, 4 Jun 2014 21:53:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.d00d3.net (Postfix) with ESMTP id 66C2F938001; Wed, 4 Jun 2014 21:53:56 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.d00d3.net Received: from mail.d00d3.net ([127.0.0.1]) by localhost (mail.d00d3.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ITsPsxx86_6m; Wed, 4 Jun 2014 21:53:56 +0200 (CEST) Received: from multitude.alien.c-base.org (unknown [91.102.9.98]) by mail.d00d3.net (Postfix) with ESMTPSA id EE13F7FC602; Wed, 4 Jun 2014 21:53:55 +0200 (CEST) X-DKIM: Sendmail DKIM Filter v2.8.2 mail.d00d3.net EE13F7FC602 From: =?UTF-8?q?Andr=C3=A9=20Gaul?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 4 Jun 2014 21:53:36 +0200 Message-Id: <1401911616-18318-1-git-send-email-gaul@web-yard.de> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 05 Jun 2014 05:28:03 +0200 Cc: =?UTF-8?q?Andr=C3=A9=20Gaul?= Subject: [B.A.T.M.A.N.] [PATCH] remove unnecessary logspam X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2014 19:53:57 -0000 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 --- main.h | 16 ++++++++++++---- routing.c | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/main.h b/main.h index 87e7196..df57639 100644 --- a/main.h +++ b/main.h @@ -239,21 +239,29 @@ enum batadv_dbg_level { int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) __printf(2, 3); -#define batadv_dbg(type, bat_priv, fmt, arg...) \ +/* possibly ratelimited debug output */ +#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \ do { \ - if (atomic_read(&bat_priv->log_level) & type) \ + if (atomic_read(&bat_priv->log_level) & type && \ + (!ratelimited || net_ratelimit())) \ batadv_debug_log(bat_priv, fmt, ## arg);\ } \ while (0) #else /* !CONFIG_BATMAN_ADV_DEBUG */ -__printf(3, 4) -static inline void batadv_dbg(int type __always_unused, +__printf(4, 5) +static inline void _batadv_dbg(int type __always_unused, struct batadv_priv *bat_priv __always_unused, + int ratelimited __always_unused, const char *fmt __always_unused, ...) { } #endif +#define batadv_dbg(type, bat_priv, arg...) \ + _batadv_dbg(type, bat_priv, 0, ## arg) +#define batadv_dbg_ratelimited(type, bat_priv, arg...) \ + _batadv_dbg(type, bat_priv, 1, ## arg) + #define batadv_info(net_dev, fmt, arg...) \ do { \ struct net_device *_netdev = (net_dev); \ diff --git a/routing.c b/routing.c index 3514153..c679c6f 100644 --- a/routing.c +++ b/routing.c @@ -706,7 +706,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) { if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, ethhdr->h_dest, vid)) - net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, + batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv, "Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n", unicast_packet->dest, @@ -752,7 +752,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, */ if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, ethhdr->h_dest, vid)) { - net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, bat_priv, + batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv, "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n", unicast_packet->dest, ethhdr->h_dest, old_ttvn, curr_ttvn);