From patchwork Mon Apr 25 09:18:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 934 Return-Path: Received: from rivolta.investici.org (rivolta.investici.org [78.46.89.173]) by open-mesh.org (Postfix) with ESMTPS id 36645154248 for ; Mon, 25 Apr 2011 11:18:31 +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 D40DB10A1D1; Mon, 25 Apr 2011 09:18:29 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.6.0 rivolta.investici.org D40DB10A1D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1303723110; bh=6kh0z0iQ33sCSduPWqRtTzAOGNfOqXNnup1dzA YBZso=; h=From:To:Cc:Subject:Date:Message-Id; b=DNhDSCu9qMGlHHbHcZ0 jfYr5lsgVINChC3L5L+oB+DmaCBkf2xfIK/HwUW0KokH2X21faIijHTogBfR8+7tGb1 1Lylu5My2sNBDhz4yaM8mZGiaV7qTFTNTxV1Y/nazKmWzpzQ4u0xZuzsl9g/LQ0CBUB U69xrT8OxZYV7zejQM= From: Antonio Quartulli To: "B.A.T.M.A.N" Date: Mon, 25 Apr 2011 11:18:23 +0200 Message-Id: <1303723103-29582-1-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.3.4 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: gw_node_update() now adds a new gw_node if no curr_gw is 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 09:18:32 -0000 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. Signed-off-by: Antonio Quartulli --- gateway_client.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gateway_client.c b/gateway_client.c index 2acd7a6..db4468c 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -311,10 +311,10 @@ 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); + rcu_read_lock(); if (!curr_gw) - goto out; + goto gw_node_add; - rcu_read_lock(); hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { if (gw_node->orig_node != orig_node) continue; @@ -340,6 +340,7 @@ void gw_node_update(struct bat_priv *bat_priv, goto unlock; } +gw_node_add: if (new_gwflags == 0) goto unlock; @@ -350,7 +351,7 @@ deselect: gw_deselect(bat_priv); unlock: rcu_read_unlock(); -out: + if (curr_gw) gw_node_free_ref(curr_gw); }