From patchwork Mon Dec 16 09:02:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Timo Teras X-Patchwork-Id: 301546 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 A34972C007B for ; Mon, 16 Dec 2013 20:02:39 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752861Ab3LPJCf (ORCPT ); Mon, 16 Dec 2013 04:02:35 -0500 Received: from mail-la0-f46.google.com ([209.85.215.46]:50732 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751870Ab3LPJCc (ORCPT ); Mon, 16 Dec 2013 04:02:32 -0500 Received: by mail-la0-f46.google.com with SMTP id eh20so2550513lab.33 for ; Mon, 16 Dec 2013 01:02:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Ks816XVxC2X7nbziAPvFja5CsyLy3X+C1UHjbnfJNVw=; b=I+yebVR+gky0dV7wmuZMCRVI6NOdYjl8U+vDyjI+ASOWPUHA38FujsMoSKRBfiSUe4 Ei24zeF8biIjF2K3OFI+1YCz0bERXrc/TV6RL37NOYxkWc/vB0z8mWC9xccNMJBDt3ip jY+7zqu4iqm7p/ztHeAZCjd5RNLWCVOYAM3/8K6mP4vq1wkYtpWAdk8N/1gCINbHCMUC STsV7zC2xyHuQd13xw5FIpxco9hfcWv1PfD3e92wGxG1XTEQPupme+VJmxc/qljJS/3I t9Cg1ZvBGJ7jlhd2BcNsQWFIRAgq/r7L7BDOUM6Gi678zuuuBhC4goKOSpxmT8eeov4c 30/Q== X-Received: by 10.152.45.8 with SMTP id i8mr6257084lam.12.1387184550989; Mon, 16 Dec 2013 01:02:30 -0800 (PST) Received: from vostro.util.wtbts.net ([83.145.235.199]) by mx.google.com with ESMTPSA id m5sm19965134laj.4.2013.12.16.01.02.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2013 01:02:30 -0800 (PST) From: =?UTF-8?q?Timo=20Ter=C3=A4s?= To: David Miller , netdev@vger.kernel.org Cc: =?UTF-8?q?Timo=20Ter=C3=A4s?= , Pravin B Shelar Subject: [PATCH net,v2] ip_gre: fix msg_name parsing for recvfrom/recvmsg Date: Mon, 16 Dec 2013 11:02:09 +0200 Message-Id: <1387184529-6911-1-git-send-email-timo.teras@iki.fi> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <20131214.005232.1773340007123224291.davem@davemloft.net> References: <20131214.005232.1773340007123224291.davem@davemloft.net> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ipgre_header_parse() needs to parse the tunnel's ip header and it uses mac_header to locate the iphdr. This got broken when gre tunneling was refactored as mac_header is no longer updated to point to iphdr. Introduce skb_pop_mac_header() helper to do the mac_header assignment and use it in ipgre_rcv() to fix msg_name parsing. Bug introduced in commit c54419321455 (GRE: Refactor GRE tunneling code.) Cc: Pravin B Shelar Signed-off-by: Timo Teräs --- Updated as suggested. Please queue for -stable too. include/linux/skbuff.h | 5 +++++ net/ipv4/ip_gre.c | 1 + 2 files changed, 6 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 77c7aae..8b38a2f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1638,6 +1638,11 @@ static inline void skb_set_mac_header(struct sk_buff *skb, const int offset) skb->mac_header += offset; } +static inline void skb_pop_mac_header(struct sk_buff *skb) +{ + skb->mac_header = skb->network_header; +} + static inline void skb_probe_transport_header(struct sk_buff *skb, const int offset_hint) { diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index d7aea4c..e560ef3 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -217,6 +217,7 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi) iph->saddr, iph->daddr, tpi->key); if (tunnel) { + skb_pop_mac_header(skb); ip_tunnel_rcv(tunnel, skb, tpi, log_ecn_error); return PACKET_RCVD; }