Skip to content

Commit 9658506

Browse files
congwangdavem330
authored andcommitted
cls_rsvp: use tcf_exts_get_net() before call_rcu()
Hold netns refcnt before call_rcu() and release it after the tcf_exts_destroy() is done. Note, on ->destroy() path we have to respect the return value of tcf_exts_get_net(), on other paths it should always return true, so we don't need to care. Cc: Lucas Bates <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3fd51de commit 9658506

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

net/sched/cls_rsvp.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,19 @@ static int rsvp_init(struct tcf_proto *tp)
285285
return -ENOBUFS;
286286
}
287287

288+
static void __rsvp_delete_filter(struct rsvp_filter *f)
289+
{
290+
tcf_exts_destroy(&f->exts);
291+
tcf_exts_put_net(&f->exts);
292+
kfree(f);
293+
}
294+
288295
static void rsvp_delete_filter_work(struct work_struct *work)
289296
{
290297
struct rsvp_filter *f = container_of(work, struct rsvp_filter, work);
291298

292299
rtnl_lock();
293-
tcf_exts_destroy(&f->exts);
294-
kfree(f);
300+
__rsvp_delete_filter(f);
295301
rtnl_unlock();
296302
}
297303

@@ -310,7 +316,10 @@ static void rsvp_delete_filter(struct tcf_proto *tp, struct rsvp_filter *f)
310316
* grace period, since converted-to-rcu actions are relying on that
311317
* in cleanup() callback
312318
*/
313-
call_rcu(&f->rcu, rsvp_delete_filter_rcu);
319+
if (tcf_exts_get_net(&f->exts))
320+
call_rcu(&f->rcu, rsvp_delete_filter_rcu);
321+
else
322+
__rsvp_delete_filter(f);
314323
}
315324

316325
static void rsvp_destroy(struct tcf_proto *tp)

0 commit comments

Comments
 (0)