Commit e124557d authored by Geliang Tang's avatar Geliang Tang Committed by David S. Miller

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: default avatarGeliang Tang <geliangtang@gmail.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f7fb1383
...@@ -136,7 +136,7 @@ static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f) ...@@ -136,7 +136,7 @@ static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f)
struct fq_flow *aux; struct fq_flow *aux;
parent = *p; parent = *p;
aux = container_of(parent, struct fq_flow, rate_node); aux = rb_entry(parent, struct fq_flow, rate_node);
if (f->time_next_packet >= aux->time_next_packet) if (f->time_next_packet >= aux->time_next_packet)
p = &parent->rb_right; p = &parent->rb_right;
else else
...@@ -188,7 +188,7 @@ static void fq_gc(struct fq_sched_data *q, ...@@ -188,7 +188,7 @@ static void fq_gc(struct fq_sched_data *q,
while (*p) { while (*p) {
parent = *p; parent = *p;
f = container_of(parent, struct fq_flow, fq_node); f = rb_entry(parent, struct fq_flow, fq_node);
if (f->sk == sk) if (f->sk == sk)
break; break;
...@@ -256,7 +256,7 @@ static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q) ...@@ -256,7 +256,7 @@ static struct fq_flow *fq_classify(struct sk_buff *skb, struct fq_sched_data *q)
while (*p) { while (*p) {
parent = *p; parent = *p;
f = container_of(parent, struct fq_flow, fq_node); f = rb_entry(parent, struct fq_flow, fq_node);
if (f->sk == sk) { if (f->sk == sk) {
/* socket might have been reallocated, so check /* socket might have been reallocated, so check
* if its sk_hash is the same. * if its sk_hash is the same.
...@@ -424,7 +424,7 @@ static void fq_check_throttled(struct fq_sched_data *q, u64 now) ...@@ -424,7 +424,7 @@ static void fq_check_throttled(struct fq_sched_data *q, u64 now)
q->time_next_delayed_flow = ~0ULL; q->time_next_delayed_flow = ~0ULL;
while ((p = rb_first(&q->delayed)) != NULL) { while ((p = rb_first(&q->delayed)) != NULL) {
struct fq_flow *f = container_of(p, struct fq_flow, rate_node); struct fq_flow *f = rb_entry(p, struct fq_flow, rate_node);
if (f->time_next_packet > now) { if (f->time_next_packet > now) {
q->time_next_delayed_flow = f->time_next_packet; q->time_next_delayed_flow = f->time_next_packet;
...@@ -563,7 +563,7 @@ static void fq_reset(struct Qdisc *sch) ...@@ -563,7 +563,7 @@ static void fq_reset(struct Qdisc *sch)
for (idx = 0; idx < (1U << q->fq_trees_log); idx++) { for (idx = 0; idx < (1U << q->fq_trees_log); idx++) {
root = &q->fq_root[idx]; root = &q->fq_root[idx];
while ((p = rb_first(root)) != NULL) { while ((p = rb_first(root)) != NULL) {
f = container_of(p, struct fq_flow, fq_node); f = rb_entry(p, struct fq_flow, fq_node);
rb_erase(p, root); rb_erase(p, root);
fq_flow_purge(f); fq_flow_purge(f);
...@@ -593,7 +593,7 @@ static void fq_rehash(struct fq_sched_data *q, ...@@ -593,7 +593,7 @@ static void fq_rehash(struct fq_sched_data *q,
oroot = &old_array[idx]; oroot = &old_array[idx];
while ((op = rb_first(oroot)) != NULL) { while ((op = rb_first(oroot)) != NULL) {
rb_erase(op, oroot); rb_erase(op, oroot);
of = container_of(op, struct fq_flow, fq_node); of = rb_entry(op, struct fq_flow, fq_node);
if (fq_gc_candidate(of)) { if (fq_gc_candidate(of)) {
fcnt++; fcnt++;
kmem_cache_free(fq_flow_cachep, of); kmem_cache_free(fq_flow_cachep, of);
...@@ -606,7 +606,7 @@ static void fq_rehash(struct fq_sched_data *q, ...@@ -606,7 +606,7 @@ static void fq_rehash(struct fq_sched_data *q,
while (*np) { while (*np) {
parent = *np; parent = *np;
nf = container_of(parent, struct fq_flow, fq_node); nf = rb_entry(parent, struct fq_flow, fq_node);
BUG_ON(nf->sk == of->sk); BUG_ON(nf->sk == of->sk);
if (nf->sk > of->sk) if (nf->sk > of->sk)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment