All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next v4 0/3] net/tls: Minor code cleanup patches
@ 2018-07-19 16:23 Vakul Garg
  2018-07-19 16:23 ` [net-next v5 1/3] net/tls: Use socket data_ready callback on record availability Vakul Garg
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vakul Garg @ 2018-07-19 16:23 UTC (permalink / raw)
  To: netdev; +Cc: borisp, aviadye, davejwatson, davem, Vakul Garg

This patch series improves tls_sw.c code by:

1) Using correct socket callback for flagging data availability.
2) Removing redundant variable assignments and wakeup callbacks.
3) Removing redundant dynamic array allocation.

The patches do not fix any functional bug. Hence "Fixes:" tag has not
been used. From patch series v3, this series v4 contains two patches
less. They will be submitted separately.

Vakul Garg (3):
  net/tls: Use socket data_ready callback on record availability
  net/tls: Remove redundant variable assignments and wakeup
  net/tls: Remove redundant array allocation.

 net/tls/tls_sw.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

-- 
2.13.6

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

* [net-next v5 1/3] net/tls: Use socket data_ready callback on record availability
  2018-07-19 16:23 [net-next v4 0/3] net/tls: Minor code cleanup patches Vakul Garg
@ 2018-07-19 16:23 ` Vakul Garg
  2018-07-19 16:23 ` [net-next v5 2/3] net/tls: Remove redundant variable assignments and wakeup Vakul Garg
  2018-07-19 16:23 ` [net-next v5 3/3] net/tls: Remove redundant array allocation Vakul Garg
  2 siblings, 0 replies; 5+ messages in thread
From: Vakul Garg @ 2018-07-19 16:23 UTC (permalink / raw)
  To: netdev; +Cc: borisp, aviadye, davejwatson, davem, Vakul Garg

On receipt of a complete tls record, use socket's saved data_ready
callback instead of state_change callback.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
---
 net/tls/tls_sw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 7d194c0cd6cf..a58661c624ec 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1023,7 +1023,7 @@ static void tls_queue(struct strparser *strp, struct sk_buff *skb)
 	ctx->recv_pkt = skb;
 	strp_pause(strp);
 
-	strp->sk->sk_state_change(strp->sk);
+	ctx->saved_data_ready(strp->sk);
 }
 
 static void tls_data_ready(struct sock *sk)
-- 
2.13.6

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

* [net-next v5 2/3] net/tls: Remove redundant variable assignments and wakeup
  2018-07-19 16:23 [net-next v4 0/3] net/tls: Minor code cleanup patches Vakul Garg
  2018-07-19 16:23 ` [net-next v5 1/3] net/tls: Use socket data_ready callback on record availability Vakul Garg
@ 2018-07-19 16:23 ` Vakul Garg
  2018-07-19 16:23 ` [net-next v5 3/3] net/tls: Remove redundant array allocation Vakul Garg
  2 siblings, 0 replies; 5+ messages in thread
From: Vakul Garg @ 2018-07-19 16:23 UTC (permalink / raw)
  To: netdev; +Cc: borisp, aviadye, davejwatson, davem, Vakul Garg

In function decrypt_skb_update(), the assignment to tls receive context
variable 'decrypted' is redundant as the same is being done in function
tls_sw_recvmsg() after calling decrypt_skb_update(). Also calling callback
function to wakeup processes sleeping on socket data availability is
useless as decrypt_skb_update() is invoked from user processes only. This
patch cleans these up.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
---

Changes from v4->v5: Fixed compilation issue.

 net/tls/tls_sw.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index a58661c624ec..e15ace0ebd79 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -679,8 +679,6 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb,
 	rxm->offset += tls_ctx->rx.prepend_size;
 	rxm->full_len -= tls_ctx->rx.overhead_size;
 	tls_advance_record_sn(sk, &tls_ctx->rx);
-	ctx->decrypted = true;
-	ctx->saved_data_ready(sk);
 
 	return err;
 }
-- 
2.13.6

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

* [net-next v5 3/3] net/tls: Remove redundant array allocation.
  2018-07-19 16:23 [net-next v4 0/3] net/tls: Minor code cleanup patches Vakul Garg
  2018-07-19 16:23 ` [net-next v5 1/3] net/tls: Use socket data_ready callback on record availability Vakul Garg
  2018-07-19 16:23 ` [net-next v5 2/3] net/tls: Remove redundant variable assignments and wakeup Vakul Garg
@ 2018-07-19 16:23 ` Vakul Garg
  2 siblings, 0 replies; 5+ messages in thread
From: Vakul Garg @ 2018-07-19 16:23 UTC (permalink / raw)
  To: netdev; +Cc: borisp, aviadye, davejwatson, davem, Vakul Garg

In function decrypt_skb(), array allocation in case when sgout is NULL
is unnecessary. Instead, local variable sgin_arr[] can be used.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
---
 net/tls/tls_sw.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index e15ace0ebd79..1aa2d46713d7 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -704,7 +704,6 @@ int decrypt_skb(struct sock *sk, struct sk_buff *skb,
 	memcpy(iv, tls_ctx->rx.iv, TLS_CIPHER_AES_GCM_128_SALT_SIZE);
 	if (!sgout) {
 		nsg = skb_cow_data(skb, 0, &unused) + 1;
-		sgin = kmalloc_array(nsg, sizeof(*sgin), sk->sk_allocation);
 		sgout = sgin;
 	}
 
@@ -725,9 +724,6 @@ int decrypt_skb(struct sock *sk, struct sk_buff *skb,
 				rxm->full_len - tls_ctx->rx.overhead_size,
 				skb, sk->sk_allocation);
 
-	if (sgin != &sgin_arr[0])
-		kfree(sgin);
-
 	return ret;
 }
 
-- 
2.13.6

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

* [net-next v5 2/3] net/tls: Remove redundant variable assignments and wakeup
  2018-07-19 16:26 [net-next v5 0/3] net/tls: Minor code cleanup patches Vakul Garg
@ 2018-07-19 16:26 ` Vakul Garg
  0 siblings, 0 replies; 5+ messages in thread
From: Vakul Garg @ 2018-07-19 16:26 UTC (permalink / raw)
  To: netdev; +Cc: borisp, aviadye, davejwatson, davem, Vakul Garg

In function decrypt_skb_update(), the assignment to tls receive context
variable 'decrypted' is redundant as the same is being done in function
tls_sw_recvmsg() after calling decrypt_skb_update(). Also calling callback
function to wakeup processes sleeping on socket data availability is
useless as decrypt_skb_update() is invoked from user processes only. This
patch cleans these up.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
---

Changes from v4->v5: Fixed compilation issue.

 net/tls/tls_sw.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index a58661c624ec..e15ace0ebd79 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -679,8 +679,6 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb,
 	rxm->offset += tls_ctx->rx.prepend_size;
 	rxm->full_len -= tls_ctx->rx.overhead_size;
 	tls_advance_record_sn(sk, &tls_ctx->rx);
-	ctx->decrypted = true;
-	ctx->saved_data_ready(sk);
 
 	return err;
 }
-- 
2.13.6

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

end of thread, other threads:[~2018-07-19 11:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19 16:23 [net-next v4 0/3] net/tls: Minor code cleanup patches Vakul Garg
2018-07-19 16:23 ` [net-next v5 1/3] net/tls: Use socket data_ready callback on record availability Vakul Garg
2018-07-19 16:23 ` [net-next v5 2/3] net/tls: Remove redundant variable assignments and wakeup Vakul Garg
2018-07-19 16:23 ` [net-next v5 3/3] net/tls: Remove redundant array allocation Vakul Garg
2018-07-19 16:26 [net-next v5 0/3] net/tls: Minor code cleanup patches Vakul Garg
2018-07-19 16:26 ` [net-next v5 2/3] net/tls: Remove redundant variable assignments and wakeup Vakul Garg

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.