Netdev List
 help / color / mirror / Atom feed
From: Shannon Nelson <shannon.nelson@oracle.com>
To: yossefe@mellanox.com, "David S. Miller" <davem@davemloft.net>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: borisp@mellanox.com, kliteyn@mellanox.com, yossiku@mellanox.com
Subject: Re: [PATCH net-next 3/3] xfrm: Add ESN support for IPSec HW offload
Date: Fri, 1 Dec 2017 11:23:50 -0800	[thread overview]
Message-ID: <6bfd5012-a22b-a70e-c052-21f2d47d364f@oracle.com> (raw)
In-Reply-To: <1511862571-3494-3-git-send-email-yossefe@mellanox.com>

On 11/28/2017 1:49 AM, yossefe@mellanox.com wrote:
> From: Yossef Efraim <yossefe@mellanox.com>
> 
> This patch adds ESN support to IPsec device offload.
> Adding new xfrm device operation to synchronize device ESN.
> 
> Signed-off-by: Yossef Efraim <yossefe@mellanox.com>
> ---
>   include/linux/netdevice.h |  1 +
>   include/net/xfrm.h        | 12 ++++++++++++
>   net/xfrm/xfrm_device.c    |  4 ++--
>   net/xfrm/xfrm_replay.c    |  2 ++
>   4 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 7de7656..d4e9198 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -825,6 +825,7 @@ struct xfrmdev_ops {
>   	void	(*xdo_dev_state_free) (struct xfrm_state *x);
>   	bool	(*xdo_dev_offload_ok) (struct sk_buff *skb,
>   				       struct xfrm_state *x);
> +	void	(*xdo_dev_state_advance_esn) (struct xfrm_state *x);
>   };
>   #endif
>   
> diff --git a/include/net/xfrm.h b/include/net/xfrm.h
> index dc28a98..372bfcb 100644
> --- a/include/net/xfrm.h
> +++ b/include/net/xfrm.h
> @@ -1863,6 +1863,14 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
>   		       struct xfrm_user_offload *xuo);
>   bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x);
>   
> +static inline void xfrm_dev_state_advance_esn(struct xfrm_state *x)
> +{
> +	struct xfrm_state_offload *xso = &x->xso;
> +
> +	if (xso->dev && xso->dev->xfrmdev_ops->xdo_dev_state_advance_esn)
> +		xso->dev->xfrmdev_ops->xdo_dev_state_advance_esn(x);

If there isn't an implementation for xdo_dev_state_advance_esn, should 
this even have been called?  See my comment below about checking the 
XFRM_STATE_ESN.

What is the driver expected to do with this?  I would guess that maybe 
the hardware doing the offload needs to know when the ESN is advanced so 
that it can change the ICV calculation accordingly, but that only is 
useful for hardware that knows about ESN.

> +}
> +
>   static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
>   {
>   	struct xfrm_state *x = dst->xfrm;
> @@ -1920,6 +1928,10 @@ static inline bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x
>   	return false;
>   }
>   
> +static inline void xfrm_dev_state_advance_esn(struct xfrm_state *x)
> +{
> +}
> +
>   static inline bool xfrm_dst_offload_ok(struct dst_entry *dst)
>   {
>   	return false;
> diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
> index dc68d9c..fc7e1e44 100644
> --- a/net/xfrm/xfrm_device.c
> +++ b/net/xfrm/xfrm_device.c
> @@ -65,8 +65,8 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
>   	if (!x->type_offload)
>   		return -EINVAL;
>   
> -	/* We don't yet support UDP encapsulation, TFC padding and ESN. */
> -	if (x->encap || x->tfcpad || (x->props.flags & XFRM_STATE_ESN))
> +	/* We don't yet support UDP encapsulation and TFC padding. */
> +	if (x->encap || x->tfcpad)
>   		return -EINVAL;

Maybe we should check to see that xdo_dev_state_advance_esn is 
implemented before allowing XFRM_STATE_ESN?

sln

>   
>   	dev = dev_get_by_index(net, xuo->ifindex);
> diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
> index 0250181..1d38c6a 100644
> --- a/net/xfrm/xfrm_replay.c
> +++ b/net/xfrm/xfrm_replay.c
> @@ -551,6 +551,8 @@ static void xfrm_replay_advance_esn(struct xfrm_state *x, __be32 net_seq)
>   			bitnr = replay_esn->replay_window - (diff - pos);
>   	}
>   
> +	xfrm_dev_state_advance_esn(x);
> +
>   	nr = bitnr >> 5;
>   	bitnr = bitnr & 0x1F;
>   	replay_esn->bmp[nr] |= (1U << bitnr);
> 

  parent reply	other threads:[~2017-12-01 19:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28  9:49 [PATCH net-next 1/3] xfrm: Fix xfrm_replay_overflow_offload_esn yossefe
2017-11-28  9:49 ` [PATCH net-next 2/3] xfrm: Fix xfrm_dev_state_add to fail for unsupported HW SA option yossefe
2017-12-01  6:21   ` Steffen Klassert
2017-11-28  9:49 ` [PATCH net-next 3/3] xfrm: Add ESN support for IPSec HW offload yossefe
2017-12-01  6:23   ` Steffen Klassert
2017-12-01 19:23     ` Shannon Nelson
2018-01-10 10:35     ` Yossef Efraim
2017-12-01 19:23   ` Shannon Nelson [this message]
2018-01-10 11:37     ` Yossef Efraim
2017-12-01  6:20 ` [PATCH net-next 1/3] xfrm: Fix xfrm_replay_overflow_offload_esn Steffen Klassert

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=6bfd5012-a22b-a70e-c052-21f2d47d364f@oracle.com \
    --to=shannon.nelson@oracle.com \
    --cc=borisp@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kliteyn@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=yossefe@mellanox.com \
    --cc=yossiku@mellanox.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