All of lore.kernel.org
 help / color / mirror / Atom feed
From: roopa <roopa@cumulusnetworks.com>
To: Robert Shearman <rshearma@brocade.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	Thomas Graf <tgraf@suug.ch>
Subject: Re: [PATCH net-next 0/2] lwtunnel: encap locally-generated ipv4 packets
Date: Mon, 03 Aug 2015 14:41:07 -0700	[thread overview]
Message-ID: <55BFDFF3.2030309@cumulusnetworks.com> (raw)
In-Reply-To: <1438619961-15919-1-git-send-email-rshearma@brocade.com>

On 8/3/15, 9:39 AM, Robert Shearman wrote:
> Locally-generated IPv4 packets, such as from applications running on
> the host or traceroute/ping currently don't have lwtunnel output
> redirected encap applied. However, they should do in the same way as
> for forwarded packets and this patch series addresses that.
>
> Robert Shearman (2):
>    lwtunnel: set skb protocol and dev
>    ipv4: apply lwtunnel encap for locally-generated packets
>
>   net/core/lwtunnel.c | 12 ++++++++++--
>   net/ipv4/route.c    |  2 ++
>   2 files changed, 12 insertions(+), 2 deletions(-)
>
Thanks for this patch Robert. Looks good.
I have been thinking of sending a similar patch out for this and
since i was also looking at ip fragmentation, I have a slightly 
different patch which I think should also take care of
encapsulating locally generated packets too. This patch moves the output 
redirection to after ip fragmentation.
What do you think about the below (I have briefly tested it. Was 
planning to test some more before sending it out as RFC) ?

[PATCH net-next] lwtunnel: move output redirection to after ip fragmentation

This patch adds tunnel headroom in lwtstate to make
sure we account for tunnel data in mtu calculations and
moves tunnel output redirection after ip fragmentation.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
  include/net/lwtunnel.h   |    1 +
  net/ipv4/ip_output.c     |    4 ++++
  net/ipv4/route.c         |    5 +++--
  net/mpls/mpls_iptunnel.c |    1 +
  4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/net/lwtunnel.h b/include/net/lwtunnel.h
index 918e03c..7816805 100644
--- a/include/net/lwtunnel.h
+++ b/include/net/lwtunnel.h
@@ -18,6 +18,7 @@ struct lwtunnel_state {
         __u16           flags;
         atomic_t        refcnt;
         int             len;
+       __u16           headroom;
         __u8            data[0];
  };

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 6bf89a6..ae3119f 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -73,6 +73,7 @@
  #include <net/icmp.h>
  #include <net/checksum.h>
  #include <net/inetpeer.h>
+#include <net/lwtunnel.h>
  #include <linux/igmp.h>
  #include <linux/netfilter_ipv4.h>
  #include <linux/netfilter_bridge.h>
@@ -201,6 +202,9 @@ static int ip_finish_output2(struct sock *sk, struct 
sk_buff *skb)
                 skb = skb2;
         }

+       if (lwtunnel_output_redirect(rt->rt_lwtstate))
+               return lwtunnel_output(sk, skb);
+
         rcu_read_lock_bh();
         nexthop = (__force u32) rt_nexthop(rt, ip_hdr(skb)->daddr);
         neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index d3964fa..4e07b9a 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1234,6 +1234,9 @@ static unsigned int ipv4_mtu(const struct 
dst_entry *dst)

         mtu = dst->dev->mtu;

+       if (lwtunnel_output_redirect(rt->rt_lwtstate))
+               mtu -= rt->rt_lwtstate->headroom;
+
         if (unlikely(dst_metric_locked(dst, RTAX_MTU))) {
                 if (rt->rt_uses_gateway && mtu > 576)
                         mtu = 576;
@@ -1634,8 +1637,6 @@ static int __mkroute_input(struct sk_buff *skb,
         rth->dst.output = ip_output;

         rt_set_nexthop(rth, daddr, res, fnhe, res->fi, res->type, itag);
-       if (lwtunnel_output_redirect(rth->rt_lwtstate))
-               rth->dst.output = lwtunnel_output;
         skb_dst_set(skb, &rth->dst);
  out:
         err = 0;

  parent reply	other threads:[~2015-08-03 21:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03 16:39 [PATCH net-next 0/2] lwtunnel: encap locally-generated ipv4 packets Robert Shearman
2015-08-03 16:39 ` [PATCH net-next 1/2] lwtunnel: set skb protocol and dev Robert Shearman
2015-08-03 16:39 ` [PATCH net-next 2/2] ipv4: apply lwtunnel encap for locally-generated packets Robert Shearman
2015-08-03 21:41 ` roopa [this message]
2015-08-04 13:55   ` [PATCH net-next 0/2] lwtunnel: encap locally-generated ipv4 packets Robert Shearman
2015-08-04  5:26 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55BFDFF3.2030309@cumulusnetworks.com \
    --to=roopa@cumulusnetworks.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=rshearma@brocade.com \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.