From patchwork Sat May 16 20:15:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruben Wisniewski X-Patchwork-Id: 4385 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=46.38.231.10; helo=we70a.netcup.net; envelope-from=ruben@freifunk-nrw.de; receiver=b.a.t.m.a.n@lists.open-mesh.org Received: from we70a.netcup.net (we70a.netcup.net [46.38.231.10]) by open-mesh.org (Postfix) with ESMTPS id 92E0960155B for ; Sat, 16 May 2015 22:15:40 +0200 (CEST) Received: from i3.local (unknown [77.87.49.91]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by we70a.netcup.net (Postfix) with ESMTPSA id 4CBD747466 for ; Sat, 16 May 2015 22:15:40 +0200 (CEST) Date: Sat, 16 May 2015 22:15:37 +0200 From: Ruben Wisniewski To: b.a.t.m.a.n@lists.open-mesh.org Message-ID: <20150516221537.2a6fad9a@i3.local> Organization: Verbund freier Netzwerke NRW e.V. X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Subject: [B.A.T.M.A.N.] Patch which fixes a uint32overflow ; fix algorithm which was unintented changed on 2014 update 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: Sat, 16 May 2015 20:15:40 -0000 Changelog * fix overflow of uint32-value while multiplying * restore algorithm to origin calculation which expect kbit/s values Signed-off-by: Ruben Wisniewsi --- net/batman-adv/gateway_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index bb01586..6f00584 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -153,7 +153,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) struct batadv_neigh_node *router; struct batadv_neigh_ifinfo *router_ifinfo; struct batadv_gw_node *gw_node, *curr_gw = NULL; - uint32_t max_gw_factor = 0, tmp_gw_factor = 0; + uint64_t max_gw_factor = 0, tmp_gw_factor = 0; uint32_t gw_divisor; uint8_t max_tq = 0; uint8_t tq_avg; @@ -185,7 +185,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) switch (atomic_read(&bat_priv->gw_sel_class)) { case 1: /* fast connection */ tmp_gw_factor = tq_avg * tq_avg; - tmp_gw_factor *= gw_node->bandwidth_down; + tmp_gw_factor *= gw_node->bandwidth_down * 100; tmp_gw_factor *= 100 * 100; tmp_gw_factor /= gw_divisor;