Skip to contentSkip to conversation

tcp: remove an unnecessary check in tcp_tx_timestamp

PATCH Superseded Soheil Hassas Yeganeh 3 participants 4 messages Apr 25, 2016 – Apr 27, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tcp: remove an unnecessary check in tcp_tx_timestamp

From: Soheil Hassas Yeganeh <[email protected]>

tcp_tx_timestamp() receives tsflags as a parameter. tsflags is initialized to sk->sk_tsflags and is overridden by control messages. As a result the "sk->sk_tsflags || tsflags" is the same expression as "tsflags"

Remove the redundant check for sk->sk_tsflags in tcp_tx_timestamp.

---
 net/ipv4/tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp.c +1 -1
index 4d73858..3c542dc 100644
@@ -430,7 +430,7 @@ EXPORT_SYMBOL(tcp_init_sock);
 
 static void tcp_tx_timestamp(struct sock *sk, u16 tsflags, struct sk_buff *skb)
 {
-	if (sk->sk_tsflags || tsflags) {
+	if (tsflags) {
 		struct skb_shared_info *shinfo = skb_shinfo(skb);
 		struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH 2/2 tcp: remove a redundant check for SKBTX_ACK_TSTAMP

From: Soheil Hassas Yeganeh <[email protected]>

txstamp_ack in tcp_skb_cb is set iff the SKBTX_ACK_TSTAMP flag is set for an skb. Thus, it is not required to check shinfo->tx_flags if the txstamp_ack bit is checked.

Remove the check on shinfo->tx_flags & SKBTX_ACK_TSTAMP, since it has already been checked using the txstamp_ack bit.

---
 net/ipv4/tcp_input.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/ipv4/tcp_input.c +1 -2
index 967520d..2f3fd92 100644
@@ -3087,8 +3087,7 @@ static void tcp_ack_tstamp(struct sock *sk, struct sk_buff *skb,
 		return;
 
 	shinfo = skb_shinfo(skb);
-	if ((shinfo->tx_flags & SKBTX_ACK_TSTAMP) &&
-	    !before(shinfo->tskey, prior_snd_una) &&
+	if (!before(shinfo->tskey, prior_snd_una) &&
 	    before(shinfo->tskey, tcp_sk(sk)->snd_una))
 		__skb_tstamp_tx(skb, NULL, sk, SCM_TSTAMP_ACK);
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH net-next 2/2] tcp: remove a redundant check for SKBTX_ACK_TSTAMP

Quoted 29 lines · Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <[email protected]>

txstamp_ack in tcp_skb_cb is set iff the SKBTX_ACK_TSTAMP flag is set for an skb. Thus, it is not required to check shinfo->tx_flags if the txstamp_ack bit is checked.

Remove the check on shinfo->tx_flags & SKBTX_ACK_TSTAMP, since it has already been checked using the txstamp_ack bit.

---
 net/ipv4/tcp_input.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/ipv4/tcp_input.c +1 -3
index 967520d..2f3fd92 100644
@@ -3087,8 +3087,7 @@ static void tcp_ack_tstamp(struct sock *sk, struct sk_buff *skb,
 		return;
 
 	shinfo = skb_shinfo(skb);
-	if ((shinfo->tx_flags & SKBTX_ACK_TSTAMP) &&
-	    !before(shinfo->tskey, prior_snd_una) &&
+	if (!before(shinfo->tskey, prior_snd_una) &&
 	    before(shinfo->tskey, tcp_sk(sk)->snd_una))
 		__skb_tstamp_tx(skb, NULL, sk, SCM_TSTAMP_ACK);
 }
--
Quoted 2 lines

2.8.0.rc3.226.g39d4020

Can it be one step further and completely remove SKBTX_ACK_TSTAMP? like what Willem has also suggested here:
http://www.spinics.net/lists/netdev/msg374231.html

It seems no one else is using the SKBTX_ACK_TSTAMP except TCP.

#3 lore raw

Re: [PATCH net-next 2/2] tcp: remove a redundant check for SKBTX_ACK_TSTAMP

Quoted 34 lines · Martin KaFai Lau
Quoted 29 lines · Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <[email protected]>

txstamp_ack in tcp_skb_cb is set iff the SKBTX_ACK_TSTAMP flag is set for an skb. Thus, it is not required to check shinfo->tx_flags if the txstamp_ack bit is checked.

Remove the check on shinfo->tx_flags & SKBTX_ACK_TSTAMP, since it has already been checked using the txstamp_ack bit.

---
 net/ipv4/tcp_input.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/ipv4/tcp_input.c +1 -3
index 967520d..2f3fd92 100644
@@ -3087,8 +3087,7 @@ static void tcp_ack_tstamp(struct sock *sk, struct sk_buff *skb,
              return;
 
      shinfo = skb_shinfo(skb);
-     if ((shinfo->tx_flags & SKBTX_ACK_TSTAMP) &&
-         !before(shinfo->tskey, prior_snd_una) &&
+     if (!before(shinfo->tskey, prior_snd_una) &&
          before(shinfo->tskey, tcp_sk(sk)->snd_una))
              __skb_tstamp_tx(skb, NULL, sk, SCM_TSTAMP_ACK);
 }
--
Quoted 2 lines

2.8.0.rc3.226.g39d4020

Quoted 5 lines

Can it be one step further and completely remove SKBTX_ACK_TSTAMP? like what Willem has also suggested here:
http://www.spinics.net/lists/netdev/msg374231.html

It seems no one else is using the SKBTX_ACK_TSTAMP except TCP.

Ah, good point. Will update the patch then. Thanks!