From patchwork Sun Oct 28 11:17: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: 194674 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E00D82C008D for ; Sun, 28 Oct 2012 22:18:16 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752054Ab2J1LSN (ORCPT ); Sun, 28 Oct 2012 07:18:13 -0400 Received: from latitanza.investici.org ([82.94.249.234]:55341 "EHLO latitanza.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751975Ab2J1LSK (ORCPT ); Sun, 28 Oct 2012 07:18:10 -0400 Received: from [82.94.249.234] (latitanza [82.94.249.234]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 26CEA98116; Sun, 28 Oct 2012 11:18:06 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 latitanza.investici.org 26CEA98116 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1351423089; bh=CXKtZmwTe/280U/dJ08OCTaLbMVoXLImEoPtVm/yxDo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=EbKx83CraFI5FGTYH7mL47ziGf5k6YYtsCybBGwJZtoieNnsDunh2D8rO0k4Oy8/A 8vRuZ/I+bQVpgyKMs9HQ6xrobp/Nc15vM0kpGOLaX3+83gm2CEWTsSi6eapbxNQtxY nXhkw2xvZkZW1K+HHvBbRbgRVcGk6ErWuimLPi6o= From: Antonio Quartulli To: davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Antonio Quartulli Subject: [PATCH 01/16] batman-adv: use check_unicast_packet() in recv_roam_adv() Date: Sun, 28 Oct 2012 12:17:02 +0100 Message-Id: <1351423037-5292-2-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1351423037-5292-1-git-send-email-ordex@autistici.org> References: <1351423037-5292-1-git-send-email-ordex@autistici.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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);