From patchwork Thu Oct 26 19:09:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 830890 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="EKE+tdlL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yNGmR34Q5z9t66 for ; Fri, 27 Oct 2017 06:10:15 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751949AbdJZTKO (ORCPT ); Thu, 26 Oct 2017 15:10:14 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:57133 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751821AbdJZTKE (ORCPT ); Thu, 26 Oct 2017 15:10:04 -0400 Received: by mail-pg0-f66.google.com with SMTP id m18so3420755pgd.13 for ; Thu, 26 Oct 2017 12:10:04 -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=EKE+tdlLMGAi7ly33rRoA/lLHLu9MvJXUbWODsT1sbI0nu9XvShhM5Xxzfgc6hwQwQ GYrQ7lYw9YMDTZfT43T5eN28gZseiuOzsQg+LZm1/7XPsVuFu21DYE6gXIpfstSqmI9A 7tYCvp9lMh36iyoYKfiCmaDEVeT7ikykgoGZx8irg/Ere4fJpLF/U4ouA0u8p9PYBItF YFB/lR8cLKS+haoIgK5SwlCZaV/UovE1RGS2ZNSwM0m4erDE3Pf9Q+oSjb0tysU1JFYD clxth9oYvVWQNGx25hxhNgT73hkHqChn34tImOiMi8Q5q9daTi9tYC/QSEBi7Bf1T1K/ 7dWw== 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=tojuyaDJvjxOhIzNlMdyRoCGMQeL1AZyE6z64ZLq5nAzCngYLOsy7yydCb/CbBr0q9 m14AyTp9KmDRe+gNmocBCA1YkQulhzouFRD8KWjHX2pO6jPRfI2Q51A8FOD/QcpFjPjI m7roBfwnFswjBfC/2BClFRWhlVz/xldP2pThxb4jkHhfUjTtb/4wUyH/rTU/qSxNXyGB /lWx8Eo3MX+W03wZb4h6fvzS+y8xtEyC4sHop8Tcx7NFhMof2IQ6tZ9r7afuKI6BB3Xs cc7C64CdOtBEv1cnWs1XzTvtv+SfQrwmSmRydqWrgt5L4qeuZSb10np70KGRbGqvoibl lMEg== X-Gm-Message-State: AMCzsaVy/5kxohV8KZL4PA3TScpVeQa+TxKM7WWOdjXG0LzDsXkzITal 3PQ386zIo8VHZpftpSSTnn7nAw== X-Google-Smtp-Source: ABhQp+S0LwO+hfF4Bp2GQvuU0sih0yIQ3znBVaq9OMkuLQWTpFEjqS2eA+2uVA8t8/Qnc0UHtMzVBQ== X-Received: by 10.98.32.206 with SMTP id m75mr6455940pfj.231.1509045004212; Thu, 26 Oct 2017 12:10:04 -0700 (PDT) Received: from localhost.localdomain (67-207-98-108.static.wiline.com. [67.207.98.108]) by smtp.gmail.com with ESMTPSA id j1sm11071502pfc.169.2017.10.26.12.10.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2017 12:10:03 -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 v6 net-next 04/12] iptunnel: Generalize tunnel update pmtu Date: Thu, 26 Oct 2017 12:09:21 -0700 Message-Id: <20171026190929.11619-5-tom@quantonium.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171026190929.11619-1-tom@quantonium.net> References: <20171026190929.11619-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; }