netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	netdev@vger.kernel.org, Raed Salem <raeds@nvidia.com>,
	ipsec-devel <devel@linux-ipsec.org>
Subject: Re: [PATCH ipsec-next 4/6] xfrm: add TX datapath support for IPsec full offload mode
Date: Tue, 24 May 2022 21:30:28 +0300	[thread overview]
Message-ID: <Yo0kRO8xPR7iET20@unreal> (raw)
In-Reply-To: <20220518074914.GP680067@gauss3.secunet.de>

On Wed, May 18, 2022 at 09:49:14AM +0200, Steffen Klassert wrote:
> On Mon, May 16, 2022 at 08:44:58AM +0300, Leon Romanovsky wrote:
> > On Fri, May 13, 2022 at 04:56:58PM +0200, Steffen Klassert wrote:
> > > On Tue, May 10, 2022 at 01:36:55PM +0300, Leon Romanovsky wrote:
> > > > From: Leon Romanovsky <leonro@nvidia.com>
> > > > 
> > > > In IPsec full mode, the device is going to encrypt and encapsulate
> > > > packets that are associated with offloaded policy. After successful
> > > > policy lookup to indicate if packets should be offloaded or not,
> > > > the stack forwards packets to the device to do the magic.
> > > > 
> > > > Signed-off-by: Raed Salem <raeds@nvidia.com>
> > > > Signed-off-by: Huy Nguyen <huyn@nvidia.com>
> > > > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > > > ---
> > > >  net/xfrm/xfrm_output.c | 19 +++++++++++++++++++
> > > >  1 file changed, 19 insertions(+)
> > > > 
> > > > diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
> > > > index d4935b3b9983..2599f3dbac08 100644
> > > > --- a/net/xfrm/xfrm_output.c
> > > > +++ b/net/xfrm/xfrm_output.c
> > > > @@ -718,6 +718,25 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
> > > >  		break;
> > > >  	}
> > > >  
> > > > +	if (x->xso.type == XFRM_DEV_OFFLOAD_FULL) {
> > > > +		struct dst_entry *dst = skb_dst_pop(skb);
> > > > +
> > > > +		if (!dst) {
> > > > +			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
> > > > +			return -EHOSTUNREACH;
> > > > +		}
> > > > +
> > > > +		skb_dst_set(skb, dst);
> > > > +		err = skb_dst(skb)->ops->local_out(net, skb->sk, skb);
> > > > +		if (unlikely(err != 1))
> > > > +			return err;
> > > > +
> > > > +		if (!skb_dst(skb)->xfrm)
> > > > +			return dst_output(net, skb->sk, skb);
> > > > +
> > > > +		return 0;
> > > > +	}
> > > > +
> > > 
> > > How do we know that we send the packet really to a device that
> > > supports this type of offload? For crypto offload, we check that
> > > in xfrm_dev_offload_ok() and I think something similar is required
> > > here too.
> > 
> > I think that function is needed to make sure that we will have SW
> > fallback. It is not needed in full offload, anything that is not
> > supported/wrong should be dropped by HW.
> 
> Yes, but only if the final output device really supports this kind
> of offload. How can we be sure that this is the case? Packets can be
> rerouted etc. We need to make sure that the outgoing device supports
> full offload, and I think this check is missing somewhere.

I think that something like this is missing (on top of the original patch):

diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index 2599f3dbac08..a41aef3e8903 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -726,6 +726,9 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
                        return -EHOSTUNREACH;
                }

+               if (!xfrm_dev_offload_ok(skb, x))
+                       return -EOPNOTSUPP;
+
                skb_dst_set(skb, dst);
                err = skb_dst(skb)->ops->local_out(net, skb->sk, skb);
                if (unlikely(err != 1))
(END)


  reply	other threads:[~2022-05-24 18:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 10:36 [PATCH ipsec-next 0/6] Extend XFRM core to allow full offload configuration Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 1/6] xfrm: add new full offload flag Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 2/6] xfrm: allow state full offload mode Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 3/6] xfrm: add an interface to offload policy Leon Romanovsky
2022-05-13 14:44   ` Steffen Klassert
2022-05-16  5:18     ` Leon Romanovsky
2022-05-10 10:36 ` [PATCH ipsec-next 4/6] xfrm: add TX datapath support for IPsec full offload mode Leon Romanovsky
2022-05-13 14:56   ` Steffen Klassert
2022-05-16  5:44     ` Leon Romanovsky
2022-05-18  7:49       ` Steffen Klassert
2022-05-24 18:30         ` Leon Romanovsky [this message]
2022-05-10 10:36 ` [PATCH ipsec-next 5/6] xfrm: add RX datapath protection " Leon Romanovsky
2022-05-13 15:02   ` Steffen Klassert
2022-05-16  5:29     ` Leon Romanovsky
2022-05-18  8:02       ` Steffen Klassert
2022-05-10 10:36 ` [PATCH ipsec-next 6/6] xfrm: enforce separation between priorities of HW/SW policies Leon Romanovsky
2022-05-13 15:07   ` Steffen Klassert
2022-05-16  5:17     ` Leon Romanovsky

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=Yo0kRO8xPR7iET20@unreal \
    --to=leon@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devel@linux-ipsec.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    --cc=raeds@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).