From patchwork Sat Oct 28 00:09:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 831552 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quantonium-net.20150623.gappssmtp.com header.i=@quantonium-net.20150623.gappssmtp.com header.b="mZr9mMfS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yP1NF2zRQz9t4X for ; Sat, 28 Oct 2017 11:10:21 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751560AbdJ1AKR (ORCPT ); Fri, 27 Oct 2017 20:10:17 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:46006 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751326AbdJ1AKN (ORCPT ); Fri, 27 Oct 2017 20:10:13 -0400 Received: by mail-pg0-f67.google.com with SMTP id b192so6419232pga.2 for ; Fri, 27 Oct 2017 17:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantonium-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l7zd9/QVFOoCtjMrUcz5qK+0Oh109N5V5VJJNrKIpaQ=; b=mZr9mMfSCn7sNzQlzsDH6qwqL/vPfACxDW7mBrK+/wgrQGBloJbT1DR7Q6RE6M9F6O pkd35C9KSVJ/kRd7nmIIt8+glLCFRfbn/Ac9BtepHTMjKH0rDdnUkdnuhqzvCmTh1fi/ uqhQM1SWOfXQuh/0k22lNBXkhLQcCo2vBY2D66UoSJYW6IWXCZi6JCXd0gkOr7PwthID j/G3gJoFaRjgvuBLwFqP8bwDaCu8g6vgmPKZCarDlZOYEG/xLLhl5TKF1FwqlyFRnwVJ ReLiVHJyB+sABiCnwEVMkoPTFawMrwf3E4+Pg+fEuNxLxYCadGVVXfokVGldZ/euhzyP 3UkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l7zd9/QVFOoCtjMrUcz5qK+0Oh109N5V5VJJNrKIpaQ=; b=deCMIQEExjrC9keC1eC1X3MRlNQnNeyzqABbv83T6KEkGoG6l+71CC7ADhAPKtWuyE NoH2TPTI37iYPDCJTNSL5mUMBYcLYgPCdDR+ctX+aiUe567WskqdkhHHLAUvHlvIohLB xX8fqXqMB1r+8gfXGEYTpQBcbJTWKamCJFQvVV4m4wFOyCS2GdTSradJN0RDlqBmTqF1 NsTl3Y6VPmX3chshDJgkk5h+i42UNFHanPdkK9mOArb9wWTWZdorUS7338AfkkJ2vnwv U8tW9wP/4dTWmxomIaDh4RAiOIVCiC1HxRanROzc0o3iD/wGyV365X2N3AUXE7pvXGSU PeOA== X-Gm-Message-State: AMCzsaVT6l98LytK30QL1AcTryqC6rZ1lXVFoAx/e04IfiISTZmQA4s2 NLPUP3pKwBzL9ePGPh+1CEtRag== X-Google-Smtp-Source: ABhQp+SEOCVPxkwRJGqpLb07i69FX2erM9zO0Sn/HL2VuLRVGYKCOyYvflWyxun0shvSwWXFlkFxAg== X-Received: by 10.101.67.200 with SMTP id n8mr1633651pgp.228.1509149412527; Fri, 27 Oct 2017 17:10:12 -0700 (PDT) Received: from localhost.localdomain (c-73-162-13-107.hsd1.ca.comcast.net. [73.162.13.107]) by smtp.gmail.com with ESMTPSA id 2sm9068398pgb.30.2017.10.27.17.10.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Oct 2017 17:10:11 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net Cc: pablo@netfilter.org, laforge@gnumonks.org, aschultz@tpip.net, netdev@vger.kernel.org, rohit@quantonium.net, Tom Herbert Subject: [PATCH v7 net-next 05/13] iptunnel: Generalize tunnel update pmtu Date: Fri, 27 Oct 2017 17:09:29 -0700 Message-Id: <20171028000937.2631-6-tom@quantonium.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171028000937.2631-1-tom@quantonium.net> References: <20171028000937.2631-1-tom@quantonium.net> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add __iptunnel_update_pmtu exported function which does not take an iptunnel argument but instead includes the fields from the iptunnel structure as arguments which are needed in the function. iptunnel_update_pmtu was modified to call __iptunnel_update_pmtu. Signed-off-by: Tom Herbert --- include/net/ip_tunnels.h | 4 ++++ net/ipv4/ip_tunnel.c | 30 ++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 2b05ae24f4f6..be675836d35a 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -317,6 +317,10 @@ static inline struct rtable *ip_tunnel_get_route(struct net_device *dev, dst_cache, use_cache); } +int __iptunnel_update_pmtu(struct net_device *dev, struct sk_buff *skb, + struct dst_entry *dst, __be16 df, + const struct iphdr *inner_iph, int hlen, u32 daddr); + struct ip_tunnel_encap_ops { size_t (*encap_hlen)(struct ip_tunnel_encap *e); int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e, diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index c97525d8dff9..0ee84ca76e0f 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -506,17 +506,16 @@ int ip_tunnel_encap_setup(struct ip_tunnel *t, } EXPORT_SYMBOL_GPL(ip_tunnel_encap_setup); -static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb, - struct rtable *rt, __be16 df, - const struct iphdr *inner_iph) +int __iptunnel_update_pmtu(struct net_device *dev, struct sk_buff *skb, + struct dst_entry *dst, __be16 df, + const struct iphdr *inner_iph, int hlen, u32 daddr) { - struct ip_tunnel *tunnel = netdev_priv(dev); - int pkt_size = skb->len - tunnel->hlen - dev->hard_header_len; + int pkt_size = skb->len - hlen - dev->hard_header_len; int mtu; if (df) - mtu = dst_mtu(&rt->dst) - dev->hard_header_len - - sizeof(struct iphdr) - tunnel->hlen; + mtu = dst_mtu(dst) - dev->hard_header_len + - sizeof(struct iphdr) - hlen; else mtu = skb_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu; @@ -538,8 +537,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb, if (rt6 && mtu < dst_mtu(skb_dst(skb)) && mtu >= IPV6_MIN_MTU) { - if ((tunnel->parms.iph.daddr && - !ipv4_is_multicast(tunnel->parms.iph.daddr)) || + if ((daddr && !ipv4_is_multicast(daddr)) || rt6->rt6i_dst.plen == 128) { rt6->rt6i_flags |= RTF_MODIFIED; dst_metric_set(skb_dst(skb), RTAX_MTU, mtu); @@ -555,6 +553,17 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb, #endif return 0; } +EXPORT_SYMBOL(__iptunnel_update_pmtu); + +static int iptunnel_update_pmtu(struct net_device *dev, struct sk_buff *skb, + struct rtable *rt, __be16 df, + const struct iphdr *inner_iph) +{ + struct ip_tunnel *tunnel = netdev_priv(dev); + + return __iptunnel_update_pmtu(dev, skb, &rt->dst, df, inner_iph, + tunnel->hlen, tunnel->parms.iph.daddr); +} void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, u8 proto) { @@ -739,7 +748,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, goto tx_error; } - if (tnl_update_pmtu(dev, skb, rt, tnl_params->frag_off, inner_iph)) { + if (iptunnel_update_pmtu(dev, skb, rt, tnl_params->frag_off, + inner_iph)) { ip_rt_put(rt); goto tx_error; }