From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yafang Shao Subject: [PATCH] tcp: do not update snd_una if it is same with ack_seq Date: Sun, 4 Nov 2018 00:54:31 +0800 Message-ID: <1541264071-9905-1-git-send-email-laoar.shao@gmail.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao To: davem@davemloft.net, edumazet@google.com Return-path: Received: from mail-pg1-f196.google.com ([209.85.215.196]:39357 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbeKDCGo (ORCPT ); Sat, 3 Nov 2018 22:06:44 -0400 Sender: netdev-owner@vger.kernel.org List-ID: In the slow path, TCP_SKB_SB(skb)->ack_seq may be same with tp->snd_una, and under this condition we don't need to update the snd_una. Furthermore, tcp_ack_update_window() is only called in slow path, so introducing this check won't affect the fast path processing. By the way, '&' is a little faster than '-', so I replaced after() with "flag & FLAG_SND_UNA_ADVANCED". Signed-off-by: Yafang Shao --- net/ipv4/tcp_input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 2868ef2..db5a6b7 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3376,7 +3376,8 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32 } } - tcp_snd_una_update(tp, ack); + if (after(ack, tp->snd_una)) + tcp_snd_una_update(tp, ack); return flag; } @@ -3610,7 +3611,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) if (flag & FLAG_UPDATE_TS_RECENT) tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq); - if (!(flag & FLAG_SLOWPATH) && after(ack, prior_snd_una)) { + if (!(flag & FLAG_SLOWPATH) && flag & FLAG_SND_UNA_ADVANCED) { /* Window is constant, pure forward advance. * No more checks are required. * Note, we use the fact that SND.UNA>=SND.WL2. -- 1.8.3.1