From: Leon Romanovsky <leonro@nvidia.com>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: Ilia Lin <ilia.lin@kernel.org>, <herbert@gondor.apana.org.au>,
<davem@davemloft.net>, <dsahern@kernel.org>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<horms@kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] xfrm: Add pre-encap fragmentation for packet offload
Date: Tue, 26 Nov 2024 15:22:20 +0200 [thread overview]
Message-ID: <20241126132220.GB1245331@unreal> (raw)
In-Reply-To: <Z0XEXqe38O5lcsq5@gauss3.secunet.de>
On Tue, Nov 26, 2024 at 01:51:42PM +0100, Steffen Klassert wrote:
> On Sun, Nov 24, 2024 at 11:35:31AM +0200, Ilia Lin wrote:
> > In packet offload mode the raw packets will be sent to the NiC,
> > and will not return to the Network Stack. In event of crossing
> > the MTU size after the encapsulation, the NiC HW may not be
> > able to fragment the final packet.
> > Adding mandatory pre-encapsulation fragmentation for both
> > IPv4 and IPv6, if tunnel mode with packet offload is configured
> > on the state.
> >
> > Signed-off-by: Ilia Lin <ilia.lin@kernel.org>
> > ---
> > net/ipv4/xfrm4_output.c | 31 +++++++++++++++++++++++++++++--
> > net/ipv6/xfrm6_output.c | 8 ++++++--
> > 2 files changed, 35 insertions(+), 4 deletions(-)
> >
> > diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
> > index 3cff51ba72bb0..a4271e0dd51bb 100644
> > --- a/net/ipv4/xfrm4_output.c
> > +++ b/net/ipv4/xfrm4_output.c
> > @@ -14,17 +14,44 @@
> > #include <net/xfrm.h>
> > #include <net/icmp.h>
> >
> > +static int __xfrm4_output_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
> > +{
> > + return xfrm_output(sk, skb);
> > +}
> > +
> > static int __xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
> > {
> > -#ifdef CONFIG_NETFILTER
> > - struct xfrm_state *x = skb_dst(skb)->xfrm;
> > + struct dst_entry *dst = skb_dst(skb);
> > + struct xfrm_state *x = dst->xfrm;
> > + unsigned int mtu;
> > + bool toobig;
> >
> > +#ifdef CONFIG_NETFILTER
> > if (!x) {
> > IPCB(skb)->flags |= IPSKB_REROUTED;
> > return dst_output(net, sk, skb);
> > }
> > #endif
> >
> > + if (x->props.mode != XFRM_MODE_TUNNEL || x->xso.type != XFRM_DEV_OFFLOAD_PACKET)
> > + goto skip_frag;
> > +
> > + mtu = xfrm_state_mtu(x, dst_mtu(skb_dst(skb)));
> > +
> > + toobig = skb->len > mtu && !skb_is_gso(skb);
> > +
> > + if (!skb->ignore_df && toobig && skb->sk) {
> > + xfrm_local_error(skb, mtu);
> > + kfree_skb(skb);
> > + return -EMSGSIZE;
> > + }
> > +
> > + if (toobig) {
> > + IPCB(skb)->frag_max_size = mtu;
> > + return ip_do_fragment(net, sk, skb, __xfrm4_output_finish);
> > + }
>
> This would fragment the packet even if the DF bit is set.
>
> Please no further packet offload stuff in generic code.
+ 100000
Thanks
>
prev parent reply other threads:[~2024-11-26 13:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-24 9:35 [PATCH] xfrm: Add pre-encap fragmentation for packet offload Ilia Lin
2024-11-24 12:04 ` Leon Romanovsky
2024-11-25 9:26 ` Ilia Lin
2024-11-25 19:43 ` Leon Romanovsky
2024-11-26 7:48 ` Ilia Lin
[not found] ` <CA+5LGR0e677wm5zEx9yYZDtsCUL6etMoRB2yF9o5msqdVOWU8w@mail.gmail.com>
2024-11-26 8:35 ` Leon Romanovsky
2024-11-26 12:59 ` Steffen Klassert
2024-11-26 13:21 ` Leon Romanovsky
2024-11-28 9:25 ` Steffen Klassert
2024-11-28 12:14 ` Leon Romanovsky
2024-11-26 12:51 ` Steffen Klassert
2024-11-26 13:22 ` Leon Romanovsky [this message]
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=20241126132220.GB1245331@unreal \
--to=leonro@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=ilia.lin@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.com \
/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.