From patchwork Thu Aug 23 13:10:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 179640 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 D92152C00B3 for ; Thu, 23 Aug 2012 23:11:29 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933868Ab2HWNLZ (ORCPT ); Thu, 23 Aug 2012 09:11:25 -0400 Received: from contumacia.investici.org ([178.255.144.35]:28883 "EHLO contumacia.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933657Ab2HWNLA (ORCPT ); Thu, 23 Aug 2012 09:11:00 -0400 Received: from [178.255.144.35] (contumacia [178.255.144.35]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id C1E50E86FB; Thu, 23 Aug 2012 13:10:57 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 contumacia.investici.org C1E50E86FB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1345727458; bh=B+BfrhnadZwAe7EYW3sNo6Rb6j+Guv5tPucD52Dya+w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; b=ESxmm91JE5uRWTpZydrJ6p+UyVYtoj/gu3kpCIThnROvcqY3u4l0j/RjJ+F6UAZSD lRQzXxaU1FmRHouyq2rdlK43bjU4Thfoddd3Fo+JmYKd+r7HpLD+h9gzGJhJjY82fF x4n+nkKDkxZu2vmcGcv318eZQC4Pn+gSD3EpO86Y= From: Antonio Quartulli To: davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= , Antonio Quartulli Subject: [PATCH 11/18] batman-adv: Move batadv_check_unicast_packet() Date: Thu, 23 Aug 2012 15:10:20 +0200 Message-Id: <1345727427-20805-12-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.9.4 In-Reply-To: <1345727427-20805-1-git-send-email-ordex@autistici.org> References: <1345727427-20805-1-git-send-email-ordex@autistici.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Martin Hundebøll batadv_check_unicast_packet() is needed in batadv_recv_tt_query(), so move the former to before the latter. Signed-off-by: Martin Hundebøll Signed-off-by: Antonio Quartulli --- net/batman-adv/routing.c | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index d5edee7..a79ded5 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -579,6 +579,31 @@ batadv_find_ifalter_router(struct batadv_orig_node *primary_orig, return router; } +static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size) +{ + struct ethhdr *ethhdr; + + /* drop packet if it has not necessary minimum size */ + if (unlikely(!pskb_may_pull(skb, hdr_size))) + return -1; + + ethhdr = (struct ethhdr *)skb_mac_header(skb); + + /* packet with unicast indication but broadcast recipient */ + if (is_broadcast_ether_addr(ethhdr->h_dest)) + return -1; + + /* packet with broadcast sender address */ + if (is_broadcast_ether_addr(ethhdr->h_source)) + return -1; + + /* not for me */ + if (!batadv_is_my_mac(ethhdr->h_dest)) + return -1; + + return 0; +} + int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if) { struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); @@ -819,31 +844,6 @@ err: return NULL; } -static int batadv_check_unicast_packet(struct sk_buff *skb, int hdr_size) -{ - struct ethhdr *ethhdr; - - /* drop packet if it has not necessary minimum size */ - if (unlikely(!pskb_may_pull(skb, hdr_size))) - return -1; - - ethhdr = (struct ethhdr *)skb_mac_header(skb); - - /* packet with unicast indication but broadcast recipient */ - if (is_broadcast_ether_addr(ethhdr->h_dest)) - return -1; - - /* packet with broadcast sender address */ - if (is_broadcast_ether_addr(ethhdr->h_source)) - return -1; - - /* not for me */ - if (!batadv_is_my_mac(ethhdr->h_dest)) - return -1; - - return 0; -} - static int batadv_route_unicast_packet(struct sk_buff *skb, struct batadv_hard_iface *recv_if) {