Commit 01daf66b authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net_sched: sch_fifo: implement lockless __fifo_dump()

Instead of relying on RTNL, __fifo_dump() can use READ_ONCE()
annotations, paired with WRITE_ONCE() ones in __fifo_init().

Also add missing READ_ONCE(sh->limit) in bfifo_enqueue(),
pfifo_enqueue() and pfifo_tail_enqueue().
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5f1dde7
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
static int bfifo_enqueue(struct sk_buff *skb, struct Qdisc *sch, static int bfifo_enqueue(struct sk_buff *skb, struct Qdisc *sch,
struct sk_buff **to_free) struct sk_buff **to_free)
{ {
if (likely(sch->qstats.backlog + qdisc_pkt_len(skb) <= sch->limit)) if (likely(sch->qstats.backlog + qdisc_pkt_len(skb) <=
READ_ONCE(sch->limit)))
return qdisc_enqueue_tail(skb, sch); return qdisc_enqueue_tail(skb, sch);
return qdisc_drop(skb, sch, to_free); return qdisc_drop(skb, sch, to_free);
...@@ -28,7 +29,7 @@ static int bfifo_enqueue(struct sk_buff *skb, struct Qdisc *sch, ...@@ -28,7 +29,7 @@ static int bfifo_enqueue(struct sk_buff *skb, struct Qdisc *sch,
static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc *sch, static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc *sch,
struct sk_buff **to_free) struct sk_buff **to_free)
{ {
if (likely(sch->q.qlen < sch->limit)) if (likely(sch->q.qlen < READ_ONCE(sch->limit)))
return qdisc_enqueue_tail(skb, sch); return qdisc_enqueue_tail(skb, sch);
return qdisc_drop(skb, sch, to_free); return qdisc_drop(skb, sch, to_free);
...@@ -39,7 +40,7 @@ static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc *sch, ...@@ -39,7 +40,7 @@ static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc *sch,
{ {
unsigned int prev_backlog; unsigned int prev_backlog;
if (likely(sch->q.qlen < sch->limit)) if (likely(sch->q.qlen < READ_ONCE(sch->limit)))
return qdisc_enqueue_tail(skb, sch); return qdisc_enqueue_tail(skb, sch);
prev_backlog = sch->qstats.backlog; prev_backlog = sch->qstats.backlog;
...@@ -105,14 +106,14 @@ static int __fifo_init(struct Qdisc *sch, struct nlattr *opt, ...@@ -105,14 +106,14 @@ static int __fifo_init(struct Qdisc *sch, struct nlattr *opt,
if (is_bfifo) if (is_bfifo)
limit *= psched_mtu(qdisc_dev(sch)); limit *= psched_mtu(qdisc_dev(sch));
sch->limit = limit; WRITE_ONCE(sch->limit, limit);
} else { } else {
struct tc_fifo_qopt *ctl = nla_data(opt); struct tc_fifo_qopt *ctl = nla_data(opt);
if (nla_len(opt) < sizeof(*ctl)) if (nla_len(opt) < sizeof(*ctl))
return -EINVAL; return -EINVAL;
sch->limit = ctl->limit; WRITE_ONCE(sch->limit, ctl->limit);
} }
if (is_bfifo) if (is_bfifo)
...@@ -154,7 +155,7 @@ static void fifo_destroy(struct Qdisc *sch) ...@@ -154,7 +155,7 @@ static void fifo_destroy(struct Qdisc *sch)
static int __fifo_dump(struct Qdisc *sch, struct sk_buff *skb) static int __fifo_dump(struct Qdisc *sch, struct sk_buff *skb)
{ {
struct tc_fifo_qopt opt = { .limit = sch->limit }; struct tc_fifo_qopt opt = { .limit = READ_ONCE(sch->limit) };
if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt)) if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
goto nla_put_failure; goto nla_put_failure;
......
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