From patchwork Mon Apr 25 20:43:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 916 Return-Path: Received: from rivolta.investici.org (rivolta.investici.org [78.46.89.173]) by open-mesh.org (Postfix) with ESMTPS id 8E823154248 for ; Mon, 25 Apr 2011 22:43:55 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@autistici.org; dkim-adsp=pass Received: from [78.46.89.173] (rivolta [78.46.89.173]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 9738F10A448; Mon, 25 Apr 2011 20:43:52 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.6.0 rivolta.investici.org 9738F10A448 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1303764233; bh=hy8Sdlf+Of8n+41yhSj3gPNNRuMGlz9b0lABdj i11To=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=UtAhECktagWkCSxCwQI6fnzus9Kx+zhudcm31TTPKIRiTHVfjF9p15Hv/0mcQJSxs uI/T+y3KYEKidQPHSmj7lz/KOUPnoCxFm2mRmlOvc92jf+BhFcvidlBFTqKQnT1xdE/ KCIH/dWTXlqNtcoiAjIIy238E9K0i7RkkHSrajQ= From: Antonio Quartulli To: "B.A.T.M.A.N" Date: Mon, 25 Apr 2011 22:43:43 +0200 Message-Id: <1303764223-5031-1-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1303723103-29582-1-git-send-email-ordex@autistici.org> References: <1303723103-29582-1-git-send-email-ordex@autistici.org> Subject: [B.A.T.M.A.N.] [PATCHv3] batman-adv: fix gw_node_update() and gw_election() selected X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 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, 25 Apr 2011 20:43:57 -0000 This is a regression from 8ffdea813e32cee3c60be36fb9e6a5e077e51ea0 - gw_node_update() doesn't add a new gw_node in case of empty curr_gw. This means that at the beginning no gw_node is added, leading to an empty gateway list. - gw_election() is terminating in case of curr_gw == NULL. It has to terminate in case of curr_gw != NULL Signed-off-by: Antonio Quartulli --- gateway_client.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gateway_client.c b/gateway_client.c index 2acd7a6..4b4f71b 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -127,7 +127,7 @@ void gw_election(struct bat_priv *bat_priv) return; curr_gw = gw_get_selected_gw_node(bat_priv); - if (!curr_gw) + if (curr_gw) goto out; rcu_read_lock(); @@ -311,8 +311,6 @@ void gw_node_update(struct bat_priv *bat_priv, struct gw_node *gw_node, *curr_gw; curr_gw = gw_get_selected_gw_node(bat_priv); - if (!curr_gw) - goto out; rcu_read_lock(); hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { @@ -350,7 +348,7 @@ deselect: gw_deselect(bat_priv); unlock: rcu_read_unlock(); -out: + if (curr_gw) gw_node_free_ref(curr_gw); }