net_sched: switch to rcu_work
Commit 05f0fe6b74
("RCU, workqueue: Implement rcu_work") introduces
new API's for dispatching work in a RCU callback. Now we can just
switch to the new API's for tc filters. This could get rid of a lot
of code.
Cc: Tejun Heo <tj@kernel.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
1bb58d2d3c
commit
aaa908ffbe
@@ -49,10 +49,7 @@ struct cls_bpf_prog {
|
||||
struct sock_filter *bpf_ops;
|
||||
const char *bpf_name;
|
||||
struct tcf_proto *tp;
|
||||
union {
|
||||
struct work_struct work;
|
||||
struct rcu_head rcu;
|
||||
};
|
||||
struct rcu_work rwork;
|
||||
};
|
||||
|
||||
static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = {
|
||||
@@ -275,21 +272,14 @@ static void __cls_bpf_delete_prog(struct cls_bpf_prog *prog)
|
||||
|
||||
static void cls_bpf_delete_prog_work(struct work_struct *work)
|
||||
{
|
||||
struct cls_bpf_prog *prog = container_of(work, struct cls_bpf_prog, work);
|
||||
|
||||
struct cls_bpf_prog *prog = container_of(to_rcu_work(work),
|
||||
struct cls_bpf_prog,
|
||||
rwork);
|
||||
rtnl_lock();
|
||||
__cls_bpf_delete_prog(prog);
|
||||
rtnl_unlock();
|
||||
}
|
||||
|
||||
static void cls_bpf_delete_prog_rcu(struct rcu_head *rcu)
|
||||
{
|
||||
struct cls_bpf_prog *prog = container_of(rcu, struct cls_bpf_prog, rcu);
|
||||
|
||||
INIT_WORK(&prog->work, cls_bpf_delete_prog_work);
|
||||
tcf_queue_work(&prog->work);
|
||||
}
|
||||
|
||||
static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
@@ -300,7 +290,7 @@ static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog,
|
||||
list_del_rcu(&prog->link);
|
||||
tcf_unbind_filter(tp, &prog->res);
|
||||
if (tcf_exts_get_net(&prog->exts))
|
||||
call_rcu(&prog->rcu, cls_bpf_delete_prog_rcu);
|
||||
tcf_queue_work(&prog->rwork, cls_bpf_delete_prog_work);
|
||||
else
|
||||
__cls_bpf_delete_prog(prog);
|
||||
}
|
||||
@@ -526,7 +516,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
|
||||
list_replace_rcu(&oldprog->link, &prog->link);
|
||||
tcf_unbind_filter(tp, &oldprog->res);
|
||||
tcf_exts_get_net(&oldprog->exts);
|
||||
call_rcu(&oldprog->rcu, cls_bpf_delete_prog_rcu);
|
||||
tcf_queue_work(&oldprog->rwork, cls_bpf_delete_prog_work);
|
||||
} else {
|
||||
list_add_rcu(&prog->link, &head->plist);
|
||||
}
|
||||
|
Reference in New Issue
Block a user