From patchwork Mon Jun 9 17:14:19 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: 4077 Return-Path: Received-SPF: Permerror (SPF Permanent Error: Unknown mechanism found: redirect:mail.d00d3.net) identity=mailfrom; client-ip=78.46.110.204; helo=mail.d00d3.net; envelope-from=gaul@web-yard.de; receiver=b.a.t.m.a.n@lists.open-mesh.org X-Greylist: delayed 318 seconds by postgrey-1.34 at open-mesh.org; Mon, 09 Jun 2014 19:19:44 CEST Received: from mail.d00d3.net (production.d00d3.net [78.46.110.204]) by open-mesh.org (Postfix) with ESMTPS id CD9866009CE for ; Mon, 9 Jun 2014 19:19:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.d00d3.net (Postfix) with ESMTP id B4B1D7FC9CE; Mon, 9 Jun 2014 19:14:25 +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 DsUHVr2Ptyon; Mon, 9 Jun 2014 19:14:25 +0200 (CEST) Received: from multitude.lan (unknown [IPv6:2001:470:6d:7bd:b5d1:7e8c:5782:45f4]) by mail.d00d3.net (Postfix) with ESMTPSA id 4731A7FC9B1; Mon, 9 Jun 2014 19:14:25 +0200 (CEST) X-DKIM: Sendmail DKIM Filter v2.8.2 mail.d00d3.net 4731A7FC9B1 From: =?UTF-8?q?Andr=C3=A9=20Gaul?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 9 Jun 2014 19:14:19 +0200 Message-Id: <1402334059-28681-1-git-send-email-gaul@web-yard.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <53957653.5000406@meshcoding.com> References: <53957653.5000406@meshcoding.com> MIME-Version: 1.0 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: Mon, 09 Jun 2014 17:19:45 -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 | 20 ++++++++++++++------ routing.c | 18 +++++++++--------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/main.h b/main.h index 87e7196..4bb500b 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, - struct batadv_priv *bat_priv __always_unused, - const char *fmt __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..35f76f2 100644 --- a/routing.c +++ b/routing.c @@ -706,11 +706,11 @@ 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, - bat_priv, - "Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n", - unicast_packet->dest, - ethhdr->h_dest); + batadv_dbg_ratelimited(BATADV_DBG_TT, + bat_priv, + "Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n", + unicast_packet->dest, + ethhdr->h_dest); /* at this point the mesh destination should have been * substituted with the originator address found in the global * 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, */ if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, ethhdr->h_dest, vid)) { - net_ratelimited_function(batadv_dbg, 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); + 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); return 1; }