From: Yafang Shao <laoar.shao@gmail.com>
To: davem@davemloft.net, edumazet@google.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH net-next] tcp: introduce skb_rbtree_walk_safe() and use it in tcp_clean_rtx_queue()
Date: Wed, 28 Nov 2018 20:16:19 +0800 [thread overview]
Message-ID: <1543407379-3144-1-git-send-email-laoar.shao@gmail.com> (raw)
When walk RB tree, we'd better use skb_rbtree_walk* helpers, that can make
the code more clear.
As skb_rbtree_walk() can't be used in tcp_clean_rtx_queue(), so the new
helper skb_rbtree_walk_safe() is introduced.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/linux/skbuff.h | 5 +++++
net/ipv4/tcp_input.c | 5 ++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 73902ac..37ff792 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3256,6 +3256,11 @@ static inline int __skb_grow_rcsum(struct sk_buff *skb, unsigned int len)
for (skb = skb_rb_first(root); skb != NULL; \
skb = skb_rb_next(skb))
+#define skb_rbtree_walk_safe(skb, root, tmp) \
+ for (skb = skb_rb_first(root); \
+ tmp = skb ? skb_rb_next(skb) : NULL, skb != NULL; \
+ skb = tmp)
+
#define skb_rbtree_walk_from(skb) \
for (; skb != NULL; \
skb = skb_rb_next(skb))
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index f323978..ab6add2 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3043,7 +3043,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack,
struct tcp_sock *tp = tcp_sk(sk);
u32 prior_sacked = tp->sacked_out;
u32 reord = tp->snd_nxt; /* lowest acked un-retx un-sacked seq */
- struct sk_buff *skb, *next;
+ struct sk_buff *skb, *tmp;
bool fully_acked = true;
long sack_rtt_us = -1L;
long seq_rtt_us = -1L;
@@ -3055,7 +3055,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack,
first_ackt = 0;
- for (skb = skb_rb_first(&sk->tcp_rtx_queue); skb; skb = next) {
+ skb_rbtree_walk_safe(skb, &sk->tcp_rtx_queue, tmp) {
struct tcp_skb_cb *scb = TCP_SKB_CB(skb);
const u32 start_seq = scb->seq;
u8 sacked = scb->sacked;
@@ -3126,7 +3126,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack,
if (!fully_acked)
break;
- next = skb_rb_next(skb);
if (unlikely(skb == tp->retransmit_skb_hint))
tp->retransmit_skb_hint = NULL;
if (unlikely(skb == tp->lost_skb_hint))
--
1.8.3.1
next reply other threads:[~2018-11-28 12:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-28 12:16 Yafang Shao [this message]
2018-11-28 14:44 ` [PATCH net-next] tcp: introduce skb_rbtree_walk_safe() and use it in tcp_clean_rtx_queue() Eric Dumazet
2018-11-28 16:53 ` Eric Dumazet
2018-11-28 17:26 ` Eric Dumazet
2018-11-29 2:32 ` Yafang Shao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1543407379-3144-1-git-send-email-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).