diff mbox series

xfrm: Allow ESP over UDP in packet offload mode

Message ID 20230718092405.4124345-1-quic_ilial@quicinc.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series xfrm: Allow ESP over UDP in packet offload mode | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1344 this patch: 1344
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1365 this patch: 1365
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1367 this patch: 1367
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Ilia Lin <quic_ilial@quicinc.com>' != 'Signed-off-by: Ilia Lin <ilia.lin@kernel.org>' WARNING: line length of 86 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ilia Lin July 18, 2023, 9:24 a.m. UTC
The ESP encapsulation is not supported only in crypto mode.
In packet offload mode, the RX is bypassing the XFRM,
so we can enable the encapsulation.

Signed-off-by: Ilia Lin <ilia.lin@kernel.org>
---
 net/xfrm/xfrm_device.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--

Comments

Leon Romanovsky July 18, 2023, 9:52 a.m. UTC | #1
On Tue, Jul 18, 2023 at 12:24:05PM +0300, Ilia Lin wrote:
> The ESP encapsulation is not supported only in crypto mode.
> In packet offload mode, the RX is bypassing the XFRM,
> so we can enable the encapsulation.

It is not accurate. RX is bypassed after XFRM validated packet to ensure
that it was really handled by HW.

However, this patch should come with relevant driver code which should
support ESP over UDP. You can see it here:

https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=xfrm-next
 xfrm: Support UDP encapsulation in packet offload mode
 net/mlx5e: Support IPsec NAT-T functionality
 net/mlx5e: Check for IPsec NAT-T support
 net/mlx5: Add relevant capabilities bits to support NAT-T

Thanks

> 
> Signed-off-by: Ilia Lin <ilia.lin@kernel.org>
> ---
>  net/xfrm/xfrm_device.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
> index 4aff76c6f12e0..3018468d97662 100644
> --- a/net/xfrm/xfrm_device.c
> +++ b/net/xfrm/xfrm_device.c
> @@ -246,8 +246,10 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
>  		return -EINVAL;
>  	}
>  
> -	/* We don't yet support UDP encapsulation and TFC padding. */
> -	if (x->encap || x->tfcpad) {
> +	is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
> +
> +	/* We don't yet support UDP encapsulation except full mode and TFC padding. */
> +	if ((!is_packet_offload && x->encap) || x->tfcpad) {
>  		NL_SET_ERR_MSG(extack, "Encapsulation and TFC padding can't be offloaded");
>  		return -EINVAL;
>  	}
> @@ -258,7 +260,6 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
>  		return -EINVAL;
>  	}
>  
> -	is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
>  	dev = dev_get_by_index(net, xuo->ifindex);
>  	if (!dev) {
>  		if (!(xuo->flags & XFRM_OFFLOAD_INBOUND)) {
> -- 
> 
>
Ilia Lin July 18, 2023, 10:15 a.m. UTC | #2
Hi Leon,

Indeed the policy check is checking the sec_path lags set after
decapsulation, but this has nothing to do with UDP encapsulation, the
driver will set them anyway.
Regarding the driver support, each driver may restrict NAT-T support
in their state_add callback, so in common code it may stay allowed.

Thanks,
Ilia

BR,
Ilia Lin



On Tue, Jul 18, 2023 at 12:53 PM Leon Romanovsky <leonro@nvidia.com> wrote:
>
> On Tue, Jul 18, 2023 at 12:24:05PM +0300, Ilia Lin wrote:
> > The ESP encapsulation is not supported only in crypto mode.
> > In packet offload mode, the RX is bypassing the XFRM,
> > so we can enable the encapsulation.
>
> It is not accurate. RX is bypassed after XFRM validated packet to ensure
> that it was really handled by HW.
>
> However, this patch should come with relevant driver code which should
> support ESP over UDP. You can see it here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=xfrm-next
>  xfrm: Support UDP encapsulation in packet offload mode
>  net/mlx5e: Support IPsec NAT-T functionality
>  net/mlx5e: Check for IPsec NAT-T support
>  net/mlx5: Add relevant capabilities bits to support NAT-T
>
> Thanks
>
> >
> > Signed-off-by: Ilia Lin <ilia.lin@kernel.org>
> > ---
> >  net/xfrm/xfrm_device.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
> > index 4aff76c6f12e0..3018468d97662 100644
> > --- a/net/xfrm/xfrm_device.c
> > +++ b/net/xfrm/xfrm_device.c
> > @@ -246,8 +246,10 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
> >               return -EINVAL;
> >       }
> >
> > -     /* We don't yet support UDP encapsulation and TFC padding. */
> > -     if (x->encap || x->tfcpad) {
> > +     is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
> > +
> > +     /* We don't yet support UDP encapsulation except full mode and TFC padding. */
> > +     if ((!is_packet_offload && x->encap) || x->tfcpad) {
> >               NL_SET_ERR_MSG(extack, "Encapsulation and TFC padding can't be offloaded");
> >               return -EINVAL;
> >       }
> > @@ -258,7 +260,6 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
> >               return -EINVAL;
> >       }
> >
> > -     is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
> >       dev = dev_get_by_index(net, xuo->ifindex);
> >       if (!dev) {
> >               if (!(xuo->flags & XFRM_OFFLOAD_INBOUND)) {
> > --
> >
> >
Leon Romanovsky July 18, 2023, 10:54 a.m. UTC | #3
On Tue, Jul 18, 2023 at 01:15:12PM +0300, Ilia Lin wrote:
> Hi Leon,

Please don't top-post your replies.

> 
> Indeed the policy check is checking the sec_path lags set after
> decapsulation, but this has nothing to do with UDP encapsulation, the
> driver will set them anyway.

It doesn't make commit message correct.
"In packet offload mode, the RX is bypassing the XFRM, so we can enable the encapsulation."

> Regarding the driver support, each driver may restrict NAT-T support
> in their state_add callback, so in common code it may stay allowed.

We don't support out-of-tree drivers. Please submit it together with
relevant driver changes which exercise your newly opened path.

If you want, you can even take my series and submit it.

Thanks

> 
> Thanks,
> Ilia
> 
> BR,
> Ilia Lin
> 
> 
> 
> On Tue, Jul 18, 2023 at 12:53 PM Leon Romanovsky <leonro@nvidia.com> wrote:
> >
> > On Tue, Jul 18, 2023 at 12:24:05PM +0300, Ilia Lin wrote:
> > > The ESP encapsulation is not supported only in crypto mode.
> > > In packet offload mode, the RX is bypassing the XFRM,
> > > so we can enable the encapsulation.
> >
> > It is not accurate. RX is bypassed after XFRM validated packet to ensure
> > that it was really handled by HW.
> >
> > However, this patch should come with relevant driver code which should
> > support ESP over UDP. You can see it here:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=xfrm-next
> >  xfrm: Support UDP encapsulation in packet offload mode
> >  net/mlx5e: Support IPsec NAT-T functionality
> >  net/mlx5e: Check for IPsec NAT-T support
> >  net/mlx5: Add relevant capabilities bits to support NAT-T
> >
> > Thanks
> >
> > >
> > > Signed-off-by: Ilia Lin <ilia.lin@kernel.org>
> > > ---
> > >  net/xfrm/xfrm_device.c | 7 ++++---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
> > > index 4aff76c6f12e0..3018468d97662 100644
> > > --- a/net/xfrm/xfrm_device.c
> > > +++ b/net/xfrm/xfrm_device.c
> > > @@ -246,8 +246,10 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
> > >               return -EINVAL;
> > >       }
> > >
> > > -     /* We don't yet support UDP encapsulation and TFC padding. */
> > > -     if (x->encap || x->tfcpad) {
> > > +     is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
> > > +
> > > +     /* We don't yet support UDP encapsulation except full mode and TFC padding. */
> > > +     if ((!is_packet_offload && x->encap) || x->tfcpad) {
> > >               NL_SET_ERR_MSG(extack, "Encapsulation and TFC padding can't be offloaded");
> > >               return -EINVAL;
> > >       }
> > > @@ -258,7 +260,6 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
> > >               return -EINVAL;
> > >       }
> > >
> > > -     is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
> > >       dev = dev_get_by_index(net, xuo->ifindex);
> > >       if (!dev) {
> > >               if (!(xuo->flags & XFRM_OFFLOAD_INBOUND)) {
> > > --
> > >
> > >
>
diff mbox series

Patch

diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index 4aff76c6f12e0..3018468d97662 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -246,8 +246,10 @@  int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
 		return -EINVAL;
 	}
 
-	/* We don't yet support UDP encapsulation and TFC padding. */
-	if (x->encap || x->tfcpad) {
+	is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
+
+	/* We don't yet support UDP encapsulation except full mode and TFC padding. */
+	if ((!is_packet_offload && x->encap) || x->tfcpad) {
 		NL_SET_ERR_MSG(extack, "Encapsulation and TFC padding can't be offloaded");
 		return -EINVAL;
 	}
@@ -258,7 +260,6 @@  int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
 		return -EINVAL;
 	}
 
-	is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
 	dev = dev_get_by_index(net, xuo->ifindex);
 	if (!dev) {
 		if (!(xuo->flags & XFRM_OFFLOAD_INBOUND)) {