Skip to content

Commit 7eec417

Browse files
edumazetdavem330
authored andcommitted
pkt_sched: fq: fix non TCP flows pacing
Steinar reported FQ pacing was not working for UDP flows. It looks like the initial sk->sk_pacing_rate value of 0 was a wrong choice. We should init it to ~0U (unlimited) Then, TCA_FQ_FLOW_DEFAULT_RATE should be removed because it makes no real sense. The default rate is really unlimited, and we need to avoid a zero divide. Reported-by: Steinar H. Gunderson <sesse@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2b1f18a commit 7eec417

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

net/core/sock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,6 +2319,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
23192319
sk->sk_ll_usec = sysctl_net_busy_read;
23202320
#endif
23212321

2322+
sk->sk_pacing_rate = ~0U;
23222323
/*
23232324
* Before updating sk_refcnt, we must commit prior changes to memory
23242325
* (Documentation/RCU/rculist_nulls.txt for details)

net/sched/sch_fq.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -472,20 +472,16 @@ static struct sk_buff *fq_dequeue(struct Qdisc *sch)
472472
if (f->credit > 0 || !q->rate_enable)
473473
goto out;
474474

475-
if (skb->sk && skb->sk->sk_state != TCP_TIME_WAIT) {
476-
rate = skb->sk->sk_pacing_rate ?: q->flow_default_rate;
475+
rate = q->flow_max_rate;
476+
if (skb->sk && skb->sk->sk_state != TCP_TIME_WAIT)
477+
rate = min(skb->sk->sk_pacing_rate, rate);
477478

478-
rate = min(rate, q->flow_max_rate);
479-
} else {
480-
rate = q->flow_max_rate;
481-
if (rate == ~0U)
482-
goto out;
483-
}
484-
if (rate) {
479+
if (rate != ~0U) {
485480
u32 plen = max(qdisc_pkt_len(skb), q->quantum);
486481
u64 len = (u64)plen * NSEC_PER_SEC;
487482

488-
do_div(len, rate);
483+
if (likely(rate))
484+
do_div(len, rate);
489485
/* Since socket rate can change later,
490486
* clamp the delay to 125 ms.
491487
* TODO: maybe segment the too big skb, as in commit
@@ -735,12 +731,14 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb)
735731
if (opts == NULL)
736732
goto nla_put_failure;
737733

734+
/* TCA_FQ_FLOW_DEFAULT_RATE is not used anymore,
735+
* do not bother giving its value
736+
*/
738737
if (nla_put_u32(skb, TCA_FQ_PLIMIT, sch->limit) ||
739738
nla_put_u32(skb, TCA_FQ_FLOW_PLIMIT, q->flow_plimit) ||
740739
nla_put_u32(skb, TCA_FQ_QUANTUM, q->quantum) ||
741740
nla_put_u32(skb, TCA_FQ_INITIAL_QUANTUM, q->initial_quantum) ||
742741
nla_put_u32(skb, TCA_FQ_RATE_ENABLE, q->rate_enable) ||
743-
nla_put_u32(skb, TCA_FQ_FLOW_DEFAULT_RATE, q->flow_default_rate) ||
744742
nla_put_u32(skb, TCA_FQ_FLOW_MAX_RATE, q->flow_max_rate) ||
745743
nla_put_u32(skb, TCA_FQ_BUCKETS_LOG, q->fq_trees_log))
746744
goto nla_put_failure;

0 commit comments

Comments
 (0)