All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/4] net/tls: small code cleanup
@ 2019-04-25 19:32 Jakub Kicinski
  2019-04-25 19:32 ` [PATCH net-next v2 1/4] net/tls: don't log errors every time offload can't proceed Jakub Kicinski
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jakub Kicinski @ 2019-04-25 19:32 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, borisp, aviadye, davejwatson,
	john.fastabend, daniel, alexei.starovoitov, saeedm,
	Jakub Kicinski

Hi!

This small patch set cleans up tls (mostly offload parts).
Other than avoiding unnecessary error messages - no functional
changes here.

v2 (Saeed):
 - fix up Review tags;
 - remove the warning on failure completely.

Jakub Kicinski (4):
  net/tls: don't log errors every time offload can't proceed
  net/tls: remove old exports of sk_destruct functions
  net/tls: move definition of tls ops into net/tls.h
  net/tls: byte swap device req TCP seq no upon setting

 include/linux/netdevice.h | 23 +-------------------
 include/net/tls.h         | 21 ++++++++++++++++---
 net/tls/tls_device.c      | 44 +++++++++++++++++----------------------
 3 files changed, 38 insertions(+), 50 deletions(-)

-- 
2.21.0


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

* [PATCH net-next v2 1/4] net/tls: don't log errors every time offload can't proceed
  2019-04-25 19:32 [PATCH net-next v2 0/4] net/tls: small code cleanup Jakub Kicinski
@ 2019-04-25 19:32 ` Jakub Kicinski
  2019-04-25 19:32 ` [PATCH net-next v2 2/4] net/tls: remove old exports of sk_destruct functions Jakub Kicinski
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2019-04-25 19:32 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, borisp, aviadye, davejwatson,
	john.fastabend, daniel, alexei.starovoitov, saeedm,
	Jakub Kicinski, Simon Horman

Currently when CONFIG_TLS_DEVICE is set each time kTLS
connection is opened and the offload is not successful
(either because the underlying device doesn't support
it or e.g. it's tables are full) a rate limited error
will be printed to the logs.

There is nothing wrong with failing TLS offload.  SW
path will process the packets just fine, drop the
noisy messages.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 net/tls/tls_device.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 9f3bdbc1e593..c22f50eae6d9 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -865,8 +865,6 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
 	}
 
 	if (!(netdev->features & NETIF_F_HW_TLS_RX)) {
-		pr_err_ratelimited("%s: netdev %s with no TLS offload\n",
-				   __func__, netdev->name);
 		rc = -ENOTSUPP;
 		goto release_netdev;
 	}
@@ -894,11 +892,8 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
 	rc = netdev->tlsdev_ops->tls_dev_add(netdev, sk, TLS_OFFLOAD_CTX_DIR_RX,
 					     &ctx->crypto_recv.info,
 					     tcp_sk(sk)->copied_seq);
-	if (rc) {
-		pr_err_ratelimited("%s: The netdev has refused to offload this socket\n",
-				   __func__);
+	if (rc)
 		goto free_sw_resources;
-	}
 
 	tls_device_attach(ctx, sk, netdev);
 	goto release_netdev;
-- 
2.21.0


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

* [PATCH net-next v2 2/4] net/tls: remove old exports of sk_destruct functions
  2019-04-25 19:32 [PATCH net-next v2 0/4] net/tls: small code cleanup Jakub Kicinski
  2019-04-25 19:32 ` [PATCH net-next v2 1/4] net/tls: don't log errors every time offload can't proceed Jakub Kicinski
@ 2019-04-25 19:32 ` Jakub Kicinski
  2019-04-25 19:32 ` [PATCH net-next v2 3/4] net/tls: move definition of tls ops into net/tls.h Jakub Kicinski
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2019-04-25 19:32 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, borisp, aviadye, davejwatson,
	john.fastabend, daniel, alexei.starovoitov, saeedm,
	Jakub Kicinski, Dirk van der Merwe, Simon Horman

tls_device_sk_destruct being set on a socket used to indicate
that socket is a kTLS device one.  That is no longer true -
now we use sk_validate_xmit_skb pointer for that purpose.
Remove the export.  tls_device_attach() needs to be moved.

While at it, remove the dead declaration of tls_sk_destruct().

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 include/net/tls.h    |  2 --
 net/tls/tls_device.c | 35 +++++++++++++++++------------------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/include/net/tls.h b/include/net/tls.h
index d9d0ac66f040..20196cb31ecc 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -317,7 +317,6 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx);
 int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
 int tls_device_sendpage(struct sock *sk, struct page *page,
 			int offset, size_t size, int flags);
-void tls_device_sk_destruct(struct sock *sk);
 void tls_device_free_resources_tx(struct sock *sk);
 void tls_device_init(void);
 void tls_device_cleanup(void);
@@ -336,7 +335,6 @@ static inline u32 tls_record_start_seq(struct tls_record_info *rec)
 	return rec->end_seq - rec->len;
 }
 
-void tls_sk_destruct(struct sock *sk, struct tls_context *ctx);
 int tls_push_sg(struct sock *sk, struct tls_context *ctx,
 		struct scatterlist *sg, u16 first_offset,
 		int flags);
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index c22f50eae6d9..c93643589c4b 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -89,22 +89,6 @@ static void tls_device_gc_task(struct work_struct *work)
 	}
 }
 
-static void tls_device_attach(struct tls_context *ctx, struct sock *sk,
-			      struct net_device *netdev)
-{
-	if (sk->sk_destruct != tls_device_sk_destruct) {
-		refcount_set(&ctx->refcount, 1);
-		dev_hold(netdev);
-		ctx->netdev = netdev;
-		spin_lock_irq(&tls_device_lock);
-		list_add_tail(&ctx->list, &tls_device_list);
-		spin_unlock_irq(&tls_device_lock);
-
-		ctx->sk_destruct = sk->sk_destruct;
-		sk->sk_destruct = tls_device_sk_destruct;
-	}
-}
-
 static void tls_device_queue_ctx_destruction(struct tls_context *ctx)
 {
 	unsigned long flags;
@@ -199,7 +183,7 @@ static void tls_icsk_clean_acked(struct sock *sk, u32 acked_seq)
  * socket and no in-flight SKBs associated with this
  * socket, so it is safe to free all the resources.
  */
-void tls_device_sk_destruct(struct sock *sk)
+static void tls_device_sk_destruct(struct sock *sk)
 {
 	struct tls_context *tls_ctx = tls_get_ctx(sk);
 	struct tls_offload_context_tx *ctx = tls_offload_ctx_tx(tls_ctx);
@@ -217,7 +201,6 @@ void tls_device_sk_destruct(struct sock *sk)
 	if (refcount_dec_and_test(&tls_ctx->refcount))
 		tls_device_queue_ctx_destruction(tls_ctx);
 }
-EXPORT_SYMBOL(tls_device_sk_destruct);
 
 void tls_device_free_resources_tx(struct sock *sk)
 {
@@ -682,6 +665,22 @@ int tls_device_decrypted(struct sock *sk, struct sk_buff *skb)
 		tls_device_reencrypt(sk, skb);
 }
 
+static void tls_device_attach(struct tls_context *ctx, struct sock *sk,
+			      struct net_device *netdev)
+{
+	if (sk->sk_destruct != tls_device_sk_destruct) {
+		refcount_set(&ctx->refcount, 1);
+		dev_hold(netdev);
+		ctx->netdev = netdev;
+		spin_lock_irq(&tls_device_lock);
+		list_add_tail(&ctx->list, &tls_device_list);
+		spin_unlock_irq(&tls_device_lock);
+
+		ctx->sk_destruct = sk->sk_destruct;
+		sk->sk_destruct = tls_device_sk_destruct;
+	}
+}
+
 int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
 {
 	u16 nonce_size, tag_size, iv_size, rec_seq_size;
-- 
2.21.0


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

* [PATCH net-next v2 3/4] net/tls: move definition of tls ops into net/tls.h
  2019-04-25 19:32 [PATCH net-next v2 0/4] net/tls: small code cleanup Jakub Kicinski
  2019-04-25 19:32 ` [PATCH net-next v2 1/4] net/tls: don't log errors every time offload can't proceed Jakub Kicinski
  2019-04-25 19:32 ` [PATCH net-next v2 2/4] net/tls: remove old exports of sk_destruct functions Jakub Kicinski
@ 2019-04-25 19:32 ` Jakub Kicinski
  2019-04-25 19:32 ` [PATCH net-next v2 4/4] net/tls: byte swap device req TCP seq no upon setting Jakub Kicinski
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2019-04-25 19:32 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, borisp, aviadye, davejwatson,
	john.fastabend, daniel, alexei.starovoitov, saeedm,
	Jakub Kicinski, Simon Horman

There seems to be no reason for tls_ops to be defined in netdevice.h
which is included in a lot of places.  Don't wrap the struct/enum
declaration in ifdefs, it trickles down unnecessary ifdefs into
driver code.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 include/linux/netdevice.h | 23 +----------------------
 include/net/tls.h         | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c46d218a0456..44b47e9df94a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -914,34 +914,13 @@ struct xfrmdev_ops {
 };
 #endif
 
-#if IS_ENABLED(CONFIG_TLS_DEVICE)
-enum tls_offload_ctx_dir {
-	TLS_OFFLOAD_CTX_DIR_RX,
-	TLS_OFFLOAD_CTX_DIR_TX,
-};
-
-struct tls_crypto_info;
-struct tls_context;
-
-struct tlsdev_ops {
-	int (*tls_dev_add)(struct net_device *netdev, struct sock *sk,
-			   enum tls_offload_ctx_dir direction,
-			   struct tls_crypto_info *crypto_info,
-			   u32 start_offload_tcp_sn);
-	void (*tls_dev_del)(struct net_device *netdev,
-			    struct tls_context *ctx,
-			    enum tls_offload_ctx_dir direction);
-	void (*tls_dev_resync_rx)(struct net_device *netdev,
-				  struct sock *sk, u32 seq, u64 rcd_sn);
-};
-#endif
-
 struct dev_ifalias {
 	struct rcu_head rcuhead;
 	char ifalias[];
 };
 
 struct devlink;
+struct tlsdev_ops;
 
 /*
  * This structure defines the management hooks for network devices.
diff --git a/include/net/tls.h b/include/net/tls.h
index 20196cb31ecc..41a2ee643fc5 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -277,6 +277,23 @@ struct tls_context {
 	void (*unhash)(struct sock *sk);
 };
 
+enum tls_offload_ctx_dir {
+	TLS_OFFLOAD_CTX_DIR_RX,
+	TLS_OFFLOAD_CTX_DIR_TX,
+};
+
+struct tlsdev_ops {
+	int (*tls_dev_add)(struct net_device *netdev, struct sock *sk,
+			   enum tls_offload_ctx_dir direction,
+			   struct tls_crypto_info *crypto_info,
+			   u32 start_offload_tcp_sn);
+	void (*tls_dev_del)(struct net_device *netdev,
+			    struct tls_context *ctx,
+			    enum tls_offload_ctx_dir direction);
+	void (*tls_dev_resync_rx)(struct net_device *netdev,
+				  struct sock *sk, u32 seq, u64 rcd_sn);
+};
+
 struct tls_offload_context_rx {
 	/* sw must be the first member of tls_offload_context_rx */
 	struct tls_sw_context_rx sw;
-- 
2.21.0


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

* [PATCH net-next v2 4/4] net/tls: byte swap device req TCP seq no upon setting
  2019-04-25 19:32 [PATCH net-next v2 0/4] net/tls: small code cleanup Jakub Kicinski
                   ` (2 preceding siblings ...)
  2019-04-25 19:32 ` [PATCH net-next v2 3/4] net/tls: move definition of tls ops into net/tls.h Jakub Kicinski
@ 2019-04-25 19:32 ` Jakub Kicinski
  2019-04-25 20:17 ` [PATCH net-next v2 0/4] net/tls: small code cleanup Saeed Mahameed
  2019-04-27 20:52 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2019-04-25 19:32 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, borisp, aviadye, davejwatson,
	john.fastabend, daniel, alexei.starovoitov, saeedm,
	Jakub Kicinski, Simon Horman

To avoid a sparse warning byteswap the be32 sequence number
before it's stored in the atomic value.  While at it drop
unnecessary brackets and use kernel's u64 type.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 include/net/tls.h    | 2 +-
 net/tls/tls_device.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/net/tls.h b/include/net/tls.h
index 41a2ee643fc5..39ea62f0c1f6 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -562,7 +562,7 @@ static inline void tls_offload_rx_resync_request(struct sock *sk, __be32 seq)
 	struct tls_context *tls_ctx = tls_get_ctx(sk);
 	struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx);
 
-	atomic64_set(&rx_ctx->resync_req, ((((uint64_t)seq) << 32) | 1));
+	atomic64_set(&rx_ctx->resync_req, ((u64)ntohl(seq) << 32) | 1);
 }
 
 
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index c93643589c4b..ae73024bf665 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -567,7 +567,7 @@ void handle_device_resync(struct sock *sk, u32 seq, u64 rcd_sn)
 
 	rx_ctx = tls_offload_ctx_rx(tls_ctx);
 	resync_req = atomic64_read(&rx_ctx->resync_req);
-	req_seq = ntohl(resync_req >> 32) - ((u32)TLS_HEADER_SIZE - 1);
+	req_seq = (resync_req >> 32) - ((u32)TLS_HEADER_SIZE - 1);
 	is_req_pending = resync_req;
 
 	if (unlikely(is_req_pending) && req_seq == seq &&
-- 
2.21.0


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

* Re: [PATCH net-next v2 0/4] net/tls: small code cleanup
  2019-04-25 19:32 [PATCH net-next v2 0/4] net/tls: small code cleanup Jakub Kicinski
                   ` (3 preceding siblings ...)
  2019-04-25 19:32 ` [PATCH net-next v2 4/4] net/tls: byte swap device req TCP seq no upon setting Jakub Kicinski
@ 2019-04-25 20:17 ` Saeed Mahameed
  2019-04-27 20:52 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Saeed Mahameed @ 2019-04-25 20:17 UTC (permalink / raw)
  To: davem, jakub.kicinski
  Cc: daniel, davejwatson, oss-drivers, Boris Pismenny, john.fastabend,
	Aviad Yehezkel, alexei.starovoitov, netdev

On Thu, 2019-04-25 at 12:32 -0700, Jakub Kicinski wrote:
> Hi!
> 
> This small patch set cleans up tls (mostly offload parts).
> Other than avoiding unnecessary error messages - no functional
> changes here.
> 
> v2 (Saeed):
>  - fix up Review tags;
>  - remove the warning on failure completely.
> 
> Jakub Kicinski (4):
>   net/tls: don't log errors every time offload can't proceed
>   net/tls: remove old exports of sk_destruct functions
>   net/tls: move definition of tls ops into net/tls.h
>   net/tls: byte swap device req TCP seq no upon setting
> 
>  include/linux/netdevice.h | 23 +-------------------
>  include/net/tls.h         | 21 ++++++++++++++++---
>  net/tls/tls_device.c      | 44 +++++++++++++++++------------------
> ----
>  3 files changed, 38 insertions(+), 50 deletions(-)
> 

Reviewed-by: Saeed Mahameed <saeedm@mellanox.com>



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

* Re: [PATCH net-next v2 0/4] net/tls: small code cleanup
  2019-04-25 19:32 [PATCH net-next v2 0/4] net/tls: small code cleanup Jakub Kicinski
                   ` (4 preceding siblings ...)
  2019-04-25 20:17 ` [PATCH net-next v2 0/4] net/tls: small code cleanup Saeed Mahameed
@ 2019-04-27 20:52 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2019-04-27 20:52 UTC (permalink / raw)
  To: jakub.kicinski
  Cc: netdev, oss-drivers, borisp, aviadye, davejwatson,
	john.fastabend, daniel, alexei.starovoitov, saeedm

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Thu, 25 Apr 2019 12:32:00 -0700

> Other than avoiding unnecessary error messages - no functional
> changes here.
> 
> v2 (Saeed):
>  - fix up Review tags;
>  - remove the warning on failure completely.

Series applied, thanks Jakub.

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

end of thread, other threads:[~2019-04-27 20:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25 19:32 [PATCH net-next v2 0/4] net/tls: small code cleanup Jakub Kicinski
2019-04-25 19:32 ` [PATCH net-next v2 1/4] net/tls: don't log errors every time offload can't proceed Jakub Kicinski
2019-04-25 19:32 ` [PATCH net-next v2 2/4] net/tls: remove old exports of sk_destruct functions Jakub Kicinski
2019-04-25 19:32 ` [PATCH net-next v2 3/4] net/tls: move definition of tls ops into net/tls.h Jakub Kicinski
2019-04-25 19:32 ` [PATCH net-next v2 4/4] net/tls: byte swap device req TCP seq no upon setting Jakub Kicinski
2019-04-25 20:17 ` [PATCH net-next v2 0/4] net/tls: small code cleanup Saeed Mahameed
2019-04-27 20:52 ` 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.