All of lore.kernel.org
 help / color / mirror / Atom feed
* pull request (net-next): ipsec-next 2018-10-01
@ 2018-10-01  9:16 Steffen Klassert
  2018-10-01  9:16 ` [PATCH 1/3] xfrm: Make function xfrmi_get_link_net() static Steffen Klassert
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Steffen Klassert @ 2018-10-01  9:16 UTC (permalink / raw)
  To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev

1) Make xfrmi_get_link_net() static to silence a sparse warning.
   From Wei Yongjun.

2) Remove a unused esph pointer definition in esp_input().
   From Haishuang Yan.

3) Allow the NIC driver to quietly refuse xfrm offload
   in case it does not support it, the SA is created
   without offload in this case.
   From Shannon Nelson.

Please pull or let me know if there are problems.

Thanks!

The following changes since commit 817e60a7a2bb1f22052f18562990d675cb3a3762:

  Merge branch 'nfp-add-NFP5000-support' (2018-08-28 16:01:48 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git master

for you to fetch changes up to 4a132095dd64fefabdc5dad1cd9e9809b126e582:

  xfrm: allow driver to quietly refuse offload (2018-08-29 08:04:44 +0200)

----------------------------------------------------------------
Haishuang Yan (1):
      esp: remove redundant define esph

Shannon Nelson (1):
      xfrm: allow driver to quietly refuse offload

Wei Yongjun (1):
      xfrm: Make function xfrmi_get_link_net() static

 Documentation/networking/xfrm_device.txt | 4 ++++
 net/ipv4/esp4.c                          | 7 +++----
 net/ipv6/esp6.c                          | 7 +++----
 net/xfrm/xfrm_device.c                   | 6 +++++-
 net/xfrm/xfrm_interface.c                | 2 +-
 5 files changed, 16 insertions(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] xfrm: Make function xfrmi_get_link_net() static
  2018-10-01  9:16 pull request (net-next): ipsec-next 2018-10-01 Steffen Klassert
@ 2018-10-01  9:16 ` Steffen Klassert
  2018-10-01  9:16 ` [PATCH 2/3] esp: remove redundant define esph Steffen Klassert
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Steffen Klassert @ 2018-10-01  9:16 UTC (permalink / raw)
  To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev

From: Wei Yongjun <weiyongjun1@huawei.com>

Fixes the following sparse warning:

net/xfrm/xfrm_interface.c:745:12: warning:
 symbol 'xfrmi_get_link_net' was not declared. Should it be static?

Fixes: f203b76d7809 ("xfrm: Add virtual xfrm interfaces")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 31acc6f33d98..2c0a5c59dcd0 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -742,7 +742,7 @@ static int xfrmi_fill_info(struct sk_buff *skb, const struct net_device *dev)
 	return -EMSGSIZE;
 }
 
-struct net *xfrmi_get_link_net(const struct net_device *dev)
+static struct net *xfrmi_get_link_net(const struct net_device *dev)
 {
 	struct xfrm_if *xi = netdev_priv(dev);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] esp: remove redundant define esph
  2018-10-01  9:16 pull request (net-next): ipsec-next 2018-10-01 Steffen Klassert
  2018-10-01  9:16 ` [PATCH 1/3] xfrm: Make function xfrmi_get_link_net() static Steffen Klassert
@ 2018-10-01  9:16 ` Steffen Klassert
  2018-10-01  9:16 ` [PATCH 3/3] xfrm: allow driver to quietly refuse offload Steffen Klassert
  2018-10-02  5:32 ` pull request (net-next): ipsec-next 2018-10-01 David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Steffen Klassert @ 2018-10-01  9:16 UTC (permalink / raw)
  To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev

From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

The pointer 'esph' is defined but is never used hence it is redundant
and canbe removed.

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv4/esp4.c | 7 +++----
 net/ipv6/esp6.c | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 97689012b357..211caaf27f6e 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -683,12 +683,11 @@ static void esp_input_done_esn(struct crypto_async_request *base, int err)
  */
 static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 {
-	struct ip_esp_hdr *esph;
 	struct crypto_aead *aead = x->data;
 	struct aead_request *req;
 	struct sk_buff *trailer;
 	int ivlen = crypto_aead_ivsize(aead);
-	int elen = skb->len - sizeof(*esph) - ivlen;
+	int elen = skb->len - sizeof(struct ip_esp_hdr) - ivlen;
 	int nfrags;
 	int assoclen;
 	int seqhilen;
@@ -698,13 +697,13 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 	struct scatterlist *sg;
 	int err = -EINVAL;
 
-	if (!pskb_may_pull(skb, sizeof(*esph) + ivlen))
+	if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + ivlen))
 		goto out;
 
 	if (elen <= 0)
 		goto out;
 
-	assoclen = sizeof(*esph);
+	assoclen = sizeof(struct ip_esp_hdr);
 	seqhilen = 0;
 
 	if (x->props.flags & XFRM_STATE_ESN) {
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 88a7579c23bd..63b2b66f9dfa 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -601,12 +601,11 @@ static void esp_input_done_esn(struct crypto_async_request *base, int err)
 
 static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 {
-	struct ip_esp_hdr *esph;
 	struct crypto_aead *aead = x->data;
 	struct aead_request *req;
 	struct sk_buff *trailer;
 	int ivlen = crypto_aead_ivsize(aead);
-	int elen = skb->len - sizeof(*esph) - ivlen;
+	int elen = skb->len - sizeof(struct ip_esp_hdr) - ivlen;
 	int nfrags;
 	int assoclen;
 	int seqhilen;
@@ -616,7 +615,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 	u8 *iv;
 	struct scatterlist *sg;
 
-	if (!pskb_may_pull(skb, sizeof(*esph) + ivlen)) {
+	if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr) + ivlen)) {
 		ret = -EINVAL;
 		goto out;
 	}
@@ -626,7 +625,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 		goto out;
 	}
 
-	assoclen = sizeof(*esph);
+	assoclen = sizeof(struct ip_esp_hdr);
 	seqhilen = 0;
 
 	if (x->props.flags & XFRM_STATE_ESN) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] xfrm: allow driver to quietly refuse offload
  2018-10-01  9:16 pull request (net-next): ipsec-next 2018-10-01 Steffen Klassert
  2018-10-01  9:16 ` [PATCH 1/3] xfrm: Make function xfrmi_get_link_net() static Steffen Klassert
  2018-10-01  9:16 ` [PATCH 2/3] esp: remove redundant define esph Steffen Klassert
@ 2018-10-01  9:16 ` Steffen Klassert
  2018-10-02  5:32 ` pull request (net-next): ipsec-next 2018-10-01 David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Steffen Klassert @ 2018-10-01  9:16 UTC (permalink / raw)
  To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev

From: Shannon Nelson <shannon.nelson@oracle.com>

If the "offload" attribute is used to create an IPsec SA
and the .xdo_dev_state_add() fails, the SA creation fails.
However, if the "offload" attribute is used on a device that
doesn't offer it, the attribute is quietly ignored and the SA
is created without an offload.

Along the same line of that second case, it would be good to
have a way for the device to refuse to offload an SA without
failing the whole SA creation.  This patch adds that feature
by allowing the driver to return -EOPNOTSUPP as a signal that
the SA may be fine, it just can't be offloaded.

This allows the user a little more flexibility in requesting
offloads and not needing to know every detail at all times about
each specific NIC when trying to create SAs.

Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 Documentation/networking/xfrm_device.txt | 4 ++++
 net/xfrm/xfrm_device.c                   | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/networking/xfrm_device.txt b/Documentation/networking/xfrm_device.txt
index 50c34ca65efe..267f55b5f54a 100644
--- a/Documentation/networking/xfrm_device.txt
+++ b/Documentation/networking/xfrm_device.txt
@@ -68,6 +68,10 @@ and an indication of whether it is for Rx or Tx.  The driver should
 	- verify the algorithm is supported for offloads
 	- store the SA information (key, salt, target-ip, protocol, etc)
 	- enable the HW offload of the SA
+	- return status value:
+		0             success
+		-EOPNETSUPP   offload not supported, try SW IPsec
+		other         fail the request
 
 The driver can also set an offload_handle in the SA, an opaque void pointer
 that can be used to convey context into the fast-path offload requests.
diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index 5611b7521020..3a1d9d6aefb4 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -192,9 +192,13 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
 
 	err = dev->xfrmdev_ops->xdo_dev_state_add(x);
 	if (err) {
+		xso->num_exthdrs = 0;
+		xso->flags = 0;
 		xso->dev = NULL;
 		dev_put(dev);
-		return err;
+
+		if (err != -EOPNOTSUPP)
+			return err;
 	}
 
 	return 0;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: pull request (net-next): ipsec-next 2018-10-01
  2018-10-01  9:16 pull request (net-next): ipsec-next 2018-10-01 Steffen Klassert
                   ` (2 preceding siblings ...)
  2018-10-01  9:16 ` [PATCH 3/3] xfrm: allow driver to quietly refuse offload Steffen Klassert
@ 2018-10-02  5:32 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-10-02  5:32 UTC (permalink / raw)
  To: steffen.klassert; +Cc: herbert, netdev

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Mon, 1 Oct 2018 11:16:06 +0200

> 1) Make xfrmi_get_link_net() static to silence a sparse warning.
>    From Wei Yongjun.
> 
> 2) Remove a unused esph pointer definition in esp_input().
>    From Haishuang Yan.
> 
> 3) Allow the NIC driver to quietly refuse xfrm offload
>    in case it does not support it, the SA is created
>    without offload in this case.
>    From Shannon Nelson.
> 
> Please pull or let me know if there are problems.

Also pulled, thank you!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-10-02 12:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01  9:16 pull request (net-next): ipsec-next 2018-10-01 Steffen Klassert
2018-10-01  9:16 ` [PATCH 1/3] xfrm: Make function xfrmi_get_link_net() static Steffen Klassert
2018-10-01  9:16 ` [PATCH 2/3] esp: remove redundant define esph Steffen Klassert
2018-10-01  9:16 ` [PATCH 3/3] xfrm: allow driver to quietly refuse offload Steffen Klassert
2018-10-02  5:32 ` pull request (net-next): ipsec-next 2018-10-01 David Miller

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.