From patchwork Thu May 5 08:21:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 991 Return-Path: Received: from contumacia.investici.org (contumacia.investici.org [178.255.144.35]) by open-mesh.org (Postfix) with ESMTPS id 61816154214 for ; Thu, 5 May 2011 10:21:48 +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 3818DE832C; Thu, 5 May 2011 08:21:44 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 contumacia.investici.org 3818DE832C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1304583706; bh=rp0CiU/AnG282DO1u+TWANB/e2DxiMGImOR0GTVDk/c=; h=From:To:Cc:Subject:Date:Message-Id; b=OxJWNQfuPyXmtcsMxBerYNx8J1Njxf/jsocx55fY612rZyCvxD7tLcywN/VpdXRf0 +3ikXLGNAUqk9MkFlPfwNCDan7bjjc3kcUj9WfbdartcnD2h3ihucu31fWzgx44hxf AXmyKUymHQzBZ6gWETvAbrETljhSUhkkyspUJUIY= From: Antonio Quartulli To: "B.A.T.M.A.N" Date: Thu, 5 May 2011 10:21:42 +0200 Message-Id: <1304583702-23969-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: 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: Thu, 05 May 2011 08:21:48 -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 --- routing.c | 4 +++- unicast.c | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/routing.c b/routing.c index 49f5715..c875164 100644 --- a/routing.c +++ b/routing.c @@ -1237,7 +1237,6 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, /* find the orig_node which has the primary interface. might * even be the same as our router_orig in many cases */ - if (compare_eth(router_orig->primary_addr, router_orig->orig)) { primary_orig_node = router_orig; } else { @@ -1266,6 +1265,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) + router = NULL; + rcu_read_unlock(); return router; } diff --git a/unicast.c b/unicast.c index b46cbf1..1be53d7 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;