tcp: remove an unnecessary check in tcp_tx_timestamp
Subsystems (3)
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
@@ -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
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
@@ -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
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_ackintcp_skb_cbis set iff theSKBTX_ACK_TSTAMPflag is set for an skb. Thus, it is not required to checkshinfo->tx_flagsif thetxstamp_ackbit is checked.Remove the check on
shinfo->tx_flags&SKBTX_ACK_TSTAMP, since it has already been checked using thetxstamp_ackbit.Signed-off-by Soheil Hassas Yeganeh <[email protected]>--- net/ipv4/tcp_input.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/ipv4/tcp_input.c +1
-3@@ -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.
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_ackintcp_skb_cbis set iff theSKBTX_ACK_TSTAMPflag is set for an skb. Thus, it is not required to checkshinfo->tx_flagsif thetxstamp_ackbit is checked.Remove the check on
shinfo->tx_flags&SKBTX_ACK_TSTAMP, since it has already been checked using thetxstamp_ackbit.Signed-off-by Soheil Hassas Yeganeh <[email protected]>--- net/ipv4/tcp_input.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/ipv4/tcp_input.c +1
-3@@ -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
Acked-by Martin KaFai Lau <[email protected]>
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.htmlIt seems no one else is using the
SKBTX_ACK_TSTAMPexcept TCP.
Ah, good point. Will update the patch then. Thanks!