From patchwork Sun May 8 18:52:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 982 Return-Path: Received: from contumacia.investici.org (contumacia.investici.org [178.255.144.35]) by open-mesh.org (Postfix) with ESMTPS id D515D1541D4 for ; Sun, 8 May 2011 20:53:11 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@autistici.org; dkim-adsp=pass Received: from [178.255.144.35] (contumacia [178.255.144.35]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 96172E8830; Sun, 8 May 2011 18:53:09 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 contumacia.investici.org 96172E8830 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1304880789; bh=Q0YeD2gIaDr66xVjbofHZHzqEA8xcJqA+vp05cmwkpM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Ij892GYv7yD4eCPAd4SsMsvdIw9ef5agbQGk10xhW5zJF/qa8pHTSfv/BeOI5Kz02 rwpZm02aFRMjgNFOiPoy2vfCTtDu0O7s4pi0AlCi/wUyZ+ADI5QYt9M7BkvUm7Tch3 FDUc0C5riPa7wQvVXAX/Dzi1uR9dgIN21F0gBrc8= From: Antonio Quartulli To: "B.A.T.M.A.N" Date: Sun, 8 May 2011 20:52:57 +0200 Message-Id: <1304880777-19702-1-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1304583702-23969-1-git-send-email-ordex@autistici.org> References: <1304583702-23969-1-git-send-email-ordex@autistici.org> Subject: [B.A.T.M.A.N.] [PATCHv2] batman-adv: move neigh_node->if_incoming->if_status check in find_router() 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: Sun, 08 May 2011 18:53:12 -0000 Every time that find_router() is invoked, if_status has to be compared with IF_ACTIVE. Moving this comparison inside find_router() will avoid to write it each time. Signed-off-by: Antonio Quartulli --- In this version the reference counting of 'router' has been corrected. routing.c | 3 +++ unicast.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routing.c b/routing.c index bb1c3ec..8c403ce 100644 --- a/routing.c +++ b/routing.c @@ -1240,6 +1240,9 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, router = find_ifalter_router(primary_orig_node, recv_if); return_router: + if (router && router->if_incoming->if_status != IF_ACTIVE) + goto err_unlock; + rcu_read_unlock(); return router; err_unlock: diff --git a/unicast.c b/unicast.c index 19c3daf..bab6076 100644 --- a/unicast.c +++ b/unicast.c @@ -314,9 +314,6 @@ find_router: if (!neigh_node) goto out; - if (neigh_node->if_incoming->if_status != IF_ACTIVE) - goto out; - if (my_skb_head_push(skb, sizeof(struct unicast_packet)) < 0) goto out;