From: Vijay Subramanian <subramanian.vijay@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, shemminger@vyatta.com,
eric.dumazet@gmail.com,
Vijay Subramanian <subramanian.vijay@gmail.com>
Subject: [PATCH net] net: sch_red: Fix race between timer and red_destroy()
Date: Mon, 4 Nov 2013 18:08:16 -0800 [thread overview]
Message-ID: <1383617296-20273-1-git-send-email-subramanian.vijay@gmail.com> (raw)
Make sure timer does not fire once qdisc is destroyed.
Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
---
net/sched/sch_red.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index 633e32d..380507e 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -39,6 +39,7 @@
struct red_sched_data {
u32 limit; /* HARD maximal queue length */
unsigned char flags;
+ bool timeron; /* to prevent race on destroy*/
struct timer_list adapt_timer;
struct red_parms parms;
struct red_vars vars;
@@ -166,6 +167,7 @@ static void red_destroy(struct Qdisc *sch)
{
struct red_sched_data *q = qdisc_priv(sch);
+ q->timeron = false;
del_timer_sync(&q->adapt_timer);
qdisc_destroy(q->qdisc);
}
@@ -241,7 +243,8 @@ static inline void red_adaptative_timer(unsigned long arg)
spin_lock(root_lock);
red_adaptative_algo(&q->parms, &q->vars);
- mod_timer(&q->adapt_timer, jiffies + HZ/2);
+ if (q->timeron)
+ mod_timer(&q->adapt_timer, jiffies + HZ/2);
spin_unlock(root_lock);
}
@@ -250,6 +253,7 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt)
struct red_sched_data *q = qdisc_priv(sch);
q->qdisc = &noop_qdisc;
+ q->timeron = true;
setup_timer(&q->adapt_timer, red_adaptative_timer, (unsigned long)sch);
return red_change(sch, opt);
}
--
1.7.9.5
next reply other threads:[~2013-11-05 2:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 2:08 Vijay Subramanian [this message]
2013-11-06 3:16 ` [PATCH net] net: sch_red: Fix race between timer and red_destroy() David Miller
2013-11-08 21:59 ` Vijay Subramanian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1383617296-20273-1-git-send-email-subramanian.vijay@gmail.com \
--to=subramanian.vijay@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).