Re: [PATCH net-next 2/2] net sched act_vlan: VLAN action rewrite to use RCU lock/unlock and update

From: Jiri Pirko
Date: Wed Oct 11 2017 - 16:41:09 EST


Wed, Oct 11, 2017 at 06:27:07PM CEST, xiyou.wangcong@xxxxxxxxx wrote:
>On Tue, Oct 10, 2017 at 7:33 PM, Manish Kurup <kurup.manish@xxxxxxxxx> wrote:

[...]


>> @@ -187,16 +196,33 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
>>
>> v = to_vlan(*a);
>>
>> - spin_lock_bh(&v->tcf_lock);
>> -
>> - v->tcfv_action = action;
>> - v->tcfv_push_vid = push_vid;
>> - v->tcfv_push_prio = push_prio;
>> - v->tcfv_push_proto = push_proto;
>> + ASSERT_RTNL();
>> + p = kzalloc(sizeof(*p), GFP_KERNEL);
>> + if (unlikely(!p)) {
>> + if (ovr)
>> + tcf_idr_release(*a, bind);
>> + return -ENOMEM;
>> + }
>>
>> v->tcf_action = parm->action;
>>
>> - spin_unlock_bh(&v->tcf_lock);
>> + p_old = rtnl_dereference(v->vlan_p);
>> +
>> + if (ovr)
>> + spin_lock_bh(&v->tcf_lock);
>
>Why still take spinlock when you already have RTNL lock?
>What's the point?

Yeah, I believe this is copy&paste bug from act_skbmod