From patchwork Mon Oct 29 08:58:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2418 Return-Path: Received: from contumacia.investici.org (contumacia.investici.org [178.255.144.35]) by open-mesh.org (Postfix) with ESMTPS id 69CBF601474 for ; Mon, 29 Oct 2012 09:58:58 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass reason="1024-bit key; insecure key" header.i=@autistici.org header.b=dyg8JF7v; dkim-adsp=pass; dkim-atps=neutral Received: from [178.255.144.35] (contumacia [178.255.144.35]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 506DCE87DE; Mon, 29 Oct 2012 08:58:57 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 contumacia.investici.org 506DCE87DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1351501137; bh=CXKtZmwTe/280U/dJ08OCTaLbMVoXLImEoPtVm/yxDo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=dyg8JF7vPnypuvVS34llp9pt94imlTPLwEoLt05WJokzJp62nkX/yf/rGOlxsu7Ig 4nYgn0rGCFU61zxOFwdkmjA9b1jMFFKO8pkCzVECjCy08QnlzNwaUyVzHw7cynU2nx mrR4XdpAa1URrrinUEat2hyyviScNlhJwEhvCcwY= From: Antonio Quartulli To: davem@davemloft.net Date: Mon, 29 Oct 2012 09:58:02 +0100 Message-Id: <1351501097-1289-2-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1351501097-1289-1-git-send-email-ordex@autistici.org> References: <1351501097-1289-1-git-send-email-ordex@autistici.org> Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org Subject: [B.A.T.M.A.N.] [PATCH 01/16] batman-adv: use check_unicast_packet() in recv_roam_adv() 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: Mon, 29 Oct 2012 08:58:58 -0000 To avoid code duplication and to simplify further changes, check_unicast_packet() is now used in recv_roam_adv() to check for not well formed packets and so discard them. Signed-off-by: Antonio Quartulli --- net/batman-adv/routing.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 376b4cc..8bdafc8 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -687,21 +687,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if) struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); struct batadv_roam_adv_packet *roam_adv_packet; struct batadv_orig_node *orig_node; - struct ethhdr *ethhdr; - /* drop packet if it has not necessary minimum size */ - if (unlikely(!pskb_may_pull(skb, - sizeof(struct batadv_roam_adv_packet)))) - goto out; - - ethhdr = (struct ethhdr *)skb_mac_header(skb); - - /* packet with unicast indication but broadcast recipient */ - if (is_broadcast_ether_addr(ethhdr->h_dest)) - goto out; - - /* packet with broadcast sender address */ - if (is_broadcast_ether_addr(ethhdr->h_source)) + if (batadv_check_unicast_packet(skb, sizeof(*roam_adv_packet)) < 0) goto out; batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX);