Skip to content

Commit e124557

Browse files
geliangtangdavem330
authored andcommitted
net_sched: sch_fq: use rb_entry()
To make the code clearer, use rb_entry() instead of container_of() to deal with rbtree. Signed-off-by: Geliang Tang <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f7fb138 commit e124557

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

net/sched/sch_fq.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f)
136136
struct fq_flow *aux;
137137

138138
parent = *p;
139-
aux = container_of(parent, struct fq_flow, rate_node);
139+
aux = rb_entry(parent, struct fq_flow, rate_node);
140140
if (f->time_next_packet >= aux->time_next_packet)
141141
p = &parent->rb_right;
142142
else
@@ -188,7 +188,7 @@ static void fq_gc(struct fq_sched_data *q,
188188
while (*p) {
189189
parent = *p;
190190

191-
f = container_of(parent, struct fq_flow, fq_node);
191+
f = rb_entry(parent, struct fq_flow, fq_node);
192192
if (f->sk == sk)
193193
break;
194194

@@ -256,7 +256,7 @@ static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q)
256256
while (*p) {
257257
parent = *p;
258258

259-
f = container_of(parent, struct fq_flow, fq_node);
259+
f = rb_entry(parent, struct fq_flow, fq_node);
260260
if (f->sk == sk) {
261261
/* socket might have been reallocated, so check
262262
* if its sk_hash is the same.
@@ -424,7 +424,7 @@ static void fq_check_throttled(struct fq_sched_data *q, u64 now)
424424

425425
q->time_next_delayed_flow = ~0ULL;
426426
while ((p = rb_first(&q->delayed)) != NULL) {
427-
struct fq_flow *f = container_of(p, struct fq_flow, rate_node);
427+
struct fq_flow *f = rb_entry(p, struct fq_flow, rate_node);
428428

429429
if (f->time_next_packet > now) {
430430
q->time_next_delayed_flow = f->time_next_packet;
@@ -563,7 +563,7 @@ static void fq_reset(struct Qdisc *sch)
563563
for (idx = 0; idx < (1U << q->fq_trees_log); idx++) {
564564
root = &q->fq_root[idx];
565565
while ((p = rb_first(root)) != NULL) {
566-
f = container_of(p, struct fq_flow, fq_node);
566+
f = rb_entry(p, struct fq_flow, fq_node);
567567
rb_erase(p, root);
568568

569569
fq_flow_purge(f);
@@ -593,7 +593,7 @@ static void fq_rehash(struct fq_sched_data *q,
593593
oroot = &old_array[idx];
594594
while ((op = rb_first(oroot)) != NULL) {
595595
rb_erase(op, oroot);
596-
of = container_of(op, struct fq_flow, fq_node);
596+
of = rb_entry(op, struct fq_flow, fq_node);
597597
if (fq_gc_candidate(of)) {
598598
fcnt++;
599599
kmem_cache_free(fq_flow_cachep, of);
@@ -606,7 +606,7 @@ static void fq_rehash(struct fq_sched_data *q,
606606
while (*np) {
607607
parent = *np;
608608

609-
nf = container_of(parent, struct fq_flow, fq_node);
609+
nf = rb_entry(parent, struct fq_flow, fq_node);
610610
BUG_ON(nf->sk == of->sk);
611611

612612
if (nf->sk > of->sk)

0 commit comments

Comments
 (0)