Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp301603imm; Thu, 13 Sep 2018 21:28:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbxNOxZw8x+s2MQkCV3h6etu6scc2NpVf/vsPtH2odVLs4NkEf5EA5UOXpkdqobze93NgeR X-Received: by 2002:a17:902:c6b:: with SMTP id 98-v6mr10118020pls.233.1536899328940; Thu, 13 Sep 2018 21:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536899328; cv=none; d=google.com; s=arc-20160816; b=BNiLtset6EzjGNFugI3ttuViGglTonzTanFIHDGFF3VWEpmE0V1ovcosMaEaT0NW8z MNy428BAxJRiuMeookPRvo2n0BVAbhDy7xtBUjWLaFm+LQWwvXd1eWUZETkonq+EOZjr 4X9smNvUOylXjSuLlWWx196FtBHrojZXTjGaXW75+Xwd8AxJUisqRw/9mInDHaZJg4Y8 xF2sebjZhSL4u6gGaAbEA5J2CEArLgEN6fR27yZhpuoC5XFzSj4Z0C1UbU2CvJCyAIXr bSP4Is+a+4x/N0+dJAViAWNYEj1P1o9bWS0yJxWg6khLzcMDKcGBfNwhSDpJRvv6WzBc X+cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=6NRWbJ8YPfKAW0nCtCl9rIJNrsk7ySG/oDmPkIA5tf8=; b=z43SS58xDQsNKj3bC+RnzXqhTyghwo1Rvl9y78Mo0hK6kmaplGhfi1pPiNKD2jbbel PkZz8KMdDBqzjZ+s105vmx7geyJMMWOCS+eJtzRU7FFytyo2ONC87YNkja7NM+6DeDlI 3BY/xSQPCRnxUDxatl4rPIbnWHSJ1wzIW3AWoUwuaO+eooDQmzB1+QRlogzBnVE5Pu6j Zzl1eMRWIxBShRM95oHlJS0OdGC88u60wx1hjgy5fpSPtYUtapQDa3Zi6Uv8Mm659sDT 25n7uch0OEorlg0+07S4dCL7lrZpYPuQg3AUBRIS+DT1+k1SxNHqPsI2ElK8Sy6pdU9q gngw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3-v6si6090432pla.37.2018.09.13.21.28.33; Thu, 13 Sep 2018 21:28:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726891AbeINJjw (ORCPT + 99 others); Fri, 14 Sep 2018 05:39:52 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:22700 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbeINJjw (ORCPT ); Fri, 14 Sep 2018 05:39:52 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.3]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee75b9b389a7f5-be8e2; Fri, 14 Sep 2018 12:27:07 +0800 (CST) X-RM-TRANSID: 2ee75b9b389a7f5-be8e2 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.105.0.240]) by rmsmtp-syy-appsvr02-12002 (RichMail) with SMTP id 2ee25b9b38995c9-e03d9; Fri, 14 Sep 2018 12:27:07 +0800 (CST) X-RM-TRANSID: 2ee25b9b38995c9-e03d9 From: Haishuang Yan To: "David S. Miller" , Alexey Kuznetsov Cc: Jiri Benc , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Haishuang Yan Subject: [PATCH v3,net-next 2/2] ip6_gre: simplify gre header parsing in ip6gre_err Date: Fri, 14 Sep 2018 12:26:48 +0800 Message-Id: <1536899208-2958-2-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536899208-2958-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1536899208-2958-1-git-send-email-yanhaishuang@cmss.chinamobile.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Same as ip_gre, use gre_parse_header to parse gre header in gre error handler code. Signed-off-by: Haishuang Yan --- net/ipv6/ip6_gre.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index e493b04..515adbd 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -427,35 +427,17 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, u8 type, u8 code, int offset, __be32 info) { struct net *net = dev_net(skb->dev); - const struct gre_base_hdr *greh; const struct ipv6hdr *ipv6h; - int grehlen = sizeof(*greh); + struct tnl_ptk_info tpi; struct ip6_tnl *t; - int key_off = 0; - __be16 flags; - __be32 key; - if (!pskb_may_pull(skb, offset + grehlen)) - return; - greh = (const struct gre_base_hdr *)(skb->data + offset); - flags = greh->flags; - if (flags & (GRE_VERSION | GRE_ROUTING)) + if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IPV6), + offset) < 0) return; - if (flags & GRE_CSUM) - grehlen += 4; - if (flags & GRE_KEY) { - key_off = grehlen + offset; - grehlen += 4; - } - if (!pskb_may_pull(skb, offset + grehlen)) - return; ipv6h = (const struct ipv6hdr *)skb->data; - greh = (const struct gre_base_hdr *)(skb->data + offset); - key = key_off ? *(__be32 *)(skb->data + key_off) : 0; - t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr, - key, greh->protocol); + tpi.key, tpi.proto); if (!t) return; -- 1.8.3.1