fq_flow_add_tail(q, f, OLD_FLOW);
}
-static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f)
+static void fq_flow_rb_insert(struct fq_sched_data *q, struct fq_flow *f)
{
struct rb_node **p = &q->delayed.rb_node, *parent = NULL;
}
rb_link_node(&f->rate_node, parent, p);
rb_insert_color(&f->rate_node, &q->delayed);
- q->throttled_flows++;
- q->stat_throttled++;
- f->next = &throttled;
if (q->time_next_delayed_flow > f->time_next_packet)
q->time_next_delayed_flow = f->time_next_packet;
}
+static void fq_flow_set_throttled(struct fq_sched_data *q, struct fq_flow *f)
+{
+ fq_flow_rb_insert(q, f);
+ q->throttled_flows++;
+ q->stat_throttled++;
+ f->next = &throttled;
+}
static struct kmem_cache *fq_flow_cachep __read_mostly;
return unlikely((s64)skb->tstamp > (s64)(now + q->horizon));
}
+static void fq_flow_adjust_timer(struct fq_sched_data *q, struct fq_flow *flow,
+ u64 time_to_send, u64 now)
+{
+ if (time_to_send <= now) {
+ fq_flow_unset_throttled(q, flow);
+ if (q->time_next_delayed_flow == flow->time_next_packet) {
+ struct rb_node *p = rb_first(&q->delayed);
+
+ q->time_next_delayed_flow = p ? rb_entry(p, struct fq_flow, rate_node)->time_next_packet : ~0ULL;
+ }
+ flow->time_next_packet = time_to_send;
+ } else {
+ rb_erase(&flow->rate_node, &q->delayed);
+ flow->time_next_packet = time_to_send;
+ fq_flow_rb_insert(q, flow);
+ }
+}
+
static int fq_enqueue(struct sk_buff *skb, struct Qdisc *sch,
struct sk_buff **to_free)
{
/* Note: this overwrites f->age */
flow_queue_add(f, skb);
+ if (fq_skb_cb(skb)->time_to_send < f->time_next_packet && skb->tstamp &&
+ fq_flow_is_throttled(f) && q->flow_max_rate == ~0UL)
+ fq_flow_adjust_timer(q, f, fq_skb_cb(skb)->time_to_send, now);
+
qdisc_qstats_backlog_inc(sch, skb);
qdisc_qlen_inc(sch);
["zero_delay", "a,0", "a,0"],
["one_pkt", "a,10", "a,10"],
["in_order", "a,10,b,20", "a,10,b,20"],
- ["reverse_order", "a,20,b,10", "b,20,a,20"],
+ ["reverse_order", "a,20,b,10", "b,10,a,20"],
]:
name = f"v{ipver}_{testcase[0]}"
yield KsftNamedVariant(name, ipver, testcase[1], testcase[2])