From patchwork Wed Jan 15 22:54:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 3744 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=212.227.15.3; helo=mout.web.de; envelope-from=linus.luessing@web.de; receiver=b.a.t.m.a.n@lists.open-mesh.org X-Greylist: delayed 752 seconds by postgrey-1.34 at open-mesh.org; Thu, 16 Jan 2014 00:06:53 CET Received: from mout.web.de (mout.web.de [212.227.15.3]) by open-mesh.org (Postfix) with ESMTPS id 1A5DE6022B2 for ; Thu, 16 Jan 2014 00:06:52 +0100 (CET) Received: from localhost ([95.211.148.154]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MWB4X-1VsO9q3BxR-00XIlG for ; Wed, 15 Jan 2014 23:54:21 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 15 Jan 2014 23:54:44 +0100 Message-Id: <1389826484-7075-1-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.8.5.2 MIME-Version: 1.0 X-Provags-ID: V03:K0:5zSbyKzWd0CbdfmgMS27gE7uDe+g1KL25lK3uutgBFRad083LGd n+o0ylGIhg5x4zKopm5AGIkC/wVGHEA9yTe2VtfRRU2dcDO75TrV61u0iYWAsXSfFbjGicL euL1HWagAX27NppBWMDVt73NQjhPADZXaOsyasfebgfppDb6jufQCXeXxqP1bsRKGGD0+Ji jYfrk6uqMWPTNfKvDmXzg== Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: use eth_hdr() instead of skb->data in interface_tx path 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: Wed, 15 Jan 2014 23:06:53 -0000 Using eth_hdr() instead of skb->data avoids some ugly type casts. I wasn't able to reproduce the skb ether header pointer mismatch mentioned in batadv_bla_tx() on a 3.11 kernel with a vlan on top of bat0 and therefore removed the according skb_reset_mac_header() call, too. Nevertheless I've added a check to the beginning of batadv_interface_tx() as I guess there might potentially be some device drivers not being that nice. Signed-off-by: Linus Lüssing --- bridge_loop_avoidance.c | 3 --- soft-interface.c | 12 +++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 5c0eda4..26ec489 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -1535,9 +1535,6 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, if (!atomic_read(&bat_priv->bridge_loop_avoidance)) goto allow; - /* in VLAN case, the mac header might not be set. */ - skb_reset_mac_header(skb); - if (batadv_bla_process_claim(bat_priv, primary_if, skb)) goto handled; diff --git a/soft-interface.c b/soft-interface.c index f82c267..8af69b9 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -176,7 +176,13 @@ static int batadv_interface_tx(struct sk_buff *skb, soft_iface->trans_start = jiffies; vid = batadv_get_vid(skb, 0); - ethhdr = (struct ethhdr *)skb->data; + + if (skb->data != eth_hdr(skb)) { + pr_warn("Upper device did not set the ethernet header pointer correctly - adjusting\n"); + skb_reset_mac_header(skb); + } + + ethhdr = eth_hdr(skb); switch (ntohs(ethhdr->h_proto)) { case ETH_P_8021Q: @@ -194,7 +200,7 @@ static int batadv_interface_tx(struct sk_buff *skb, goto dropped; /* skb->data might have been reallocated by batadv_bla_tx() */ - ethhdr = (struct ethhdr *)skb->data; + ethhdr = eth_hdr(skb); /* Register the client MAC in the transtable */ if (!is_multicast_ether_addr(ethhdr->h_source)) { @@ -230,7 +236,7 @@ static int batadv_interface_tx(struct sk_buff *skb, /* skb->data may have been modified by * batadv_gw_dhcp_recipient_get() */ - ethhdr = (struct ethhdr *)skb->data; + ethhdr = eth_hdr(skb); /* if gw_mode is on, broadcast any non-DHCP message. * All the DHCP packets are going to be sent as unicast */