Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5189140imm; Wed, 12 Sep 2018 02:23:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYsOigWDDte7PStfjn5GdGeKFr0c0Uysr6NRWGOYfJ7Za642s1D3qIz+7r/yyon81Ud1Vhb X-Received: by 2002:a17:902:b40e:: with SMTP id x14-v6mr1112495plr.314.1536744198643; Wed, 12 Sep 2018 02:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536744198; cv=none; d=google.com; s=arc-20160816; b=uiHxwSIghO92jE6RzPqsAfD+3Bjg+LbhsC3PIe8UIRaXemxCPynFhp5bvC6eQd6uBK zwMKXP5PIeoTgxMQ0eepxwU3IHkALYmb/J0OWQRIuURRp95ZiZgJa5rJK+fUJxCZxYJU BYlqlNIbaBi/mx5/R6FS3adrTLTmDxizgI9nNM9owmFgd+NKNfCmmo/2EAmXLa23q70C b9RV1AyilpLSG35I/ewuPn9oifPVaAHa5xWCBE/wzY03VfxKtJCWWbCABIPR300yryBy Uu4i7bL2rsTLs3n5AyMIA3J6i9lVby5ZaVl4K0Y9PT8ReVDbF4nq3GfOui8Xl5OKzOQl 0DMQ== 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=w46ejKVRIBj1/46/HOqyI+VllyBVofpOCkOYgQD4fUb5PP9k1ylvjcSZX89P1WIt6S /IOh37gCDI53Pv9sv9oZ0Jt/Ttkmt3Abkst23n4uVprK5IHpCgTEgncB4slb6G9Xg001 d7JMZ+j972Vg9/dR+Qnuf6ar4sqCKnAqo/WBYvGLF5TZ/7A7r+kJDliwshv+5lxjSRH2 H9oWL24tB2EjYsK3idEVYovIqKMX7lEityBjNP4q62gAOZN+3dUMKoXJx1DfcPcz8ZB3 Vrxa7KmGzXp5VgHPcuCwr5SUbc55kjE1zIhsVG8lRCx0rVoPCKDumFjMfNWxVIcvkJ2m kEbQ== 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 k195-v6si525446pgc.53.2018.09.12.02.23.03; Wed, 12 Sep 2018 02:23:18 -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 S1728010AbeILO0d (ORCPT + 99 others); Wed, 12 Sep 2018 10:26:33 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:48971 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbeILO0c (ORCPT ); Wed, 12 Sep 2018 10:26:32 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.7]) by rmmx-syy-dmz-app06-12006 (RichMail) with SMTP id 2ee65b98daeb3b1-90b99; Wed, 12 Sep 2018 17:22:51 +0800 (CST) X-RM-TRANSID: 2ee65b98daeb3b1-90b99 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost (unknown[223.105.0.240]) by rmsmtp-syy-appsvr04-12004 (RichMail) with SMTP id 2ee45b98dae946f-6408d; Wed, 12 Sep 2018 17:22:51 +0800 (CST) X-RM-TRANSID: 2ee45b98dae946f-6408d 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 v2,net-next 2/2] ip6_gre: simplify gre header parsing in ip6gre_err Date: Wed, 12 Sep 2018 17:21:22 +0800 Message-Id: <1536744082-3568-2-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536744082-3568-1-git-send-email-yanhaishuang@cmss.chinamobile.com> References: <1536744082-3568-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