Skip to content

Commit

Permalink
pkt_sched: fq: use proper locking in fq_dump_stats()
Browse files Browse the repository at this point in the history
When fq is used on 32bit kernels, we need to lock the qdisc before
copying 64bit fields.

Otherwise "tc -s qdisc ..." might report bogus values.

Fixes: afe4fd0 ("pkt_sched: fq: Fair Queue packet scheduler")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 19, 2016
1 parent db74a33 commit 695b4ec
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions net/sched/sch_fq.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,20 +823,24 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb)
static int fq_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
{
struct fq_sched_data *q = qdisc_priv(sch);
u64 now = ktime_get_ns();
struct tc_fq_qd_stats st = {
.gc_flows = q->stat_gc_flows,
.highprio_packets = q->stat_internal_packets,
.tcp_retrans = q->stat_tcp_retrans,
.throttled = q->stat_throttled,
.flows_plimit = q->stat_flows_plimit,
.pkts_too_long = q->stat_pkts_too_long,
.allocation_errors = q->stat_allocation_errors,
.flows = q->flows,
.inactive_flows = q->inactive_flows,
.throttled_flows = q->throttled_flows,
.time_next_delayed_flow = q->time_next_delayed_flow - now,
};
struct tc_fq_qd_stats st;

sch_tree_lock(sch);

st.gc_flows = q->stat_gc_flows;
st.highprio_packets = q->stat_internal_packets;
st.tcp_retrans = q->stat_tcp_retrans;
st.throttled = q->stat_throttled;
st.flows_plimit = q->stat_flows_plimit;
st.pkts_too_long = q->stat_pkts_too_long;
st.allocation_errors = q->stat_allocation_errors;
st.time_next_delayed_flow = q->time_next_delayed_flow - ktime_get_ns();
st.flows = q->flows;
st.inactive_flows = q->inactive_flows;
st.throttled_flows = q->throttled_flows;
st.pad = 0;

sch_tree_unlock(sch);

return gnet_stats_copy_app(d, &st, sizeof(st));
}
Expand Down

0 comments on commit 695b4ec

Please sign in to comment.