Subject: Re: [PATCH net-next] net: sched: remove redundant 'rtnl_held' argument

From: Vlad Buslov <[email-masked]>
Date: Tue, 1 Dec 2020 09:55:37 +0200

On Tue 01 Dec 2020 at 04:52, Jakub Kicinski <[email-masked]> wrote:
> On Fri, 27 Nov 2020 17:12:05 +0200 Vlad Buslov wrote:
>> @@ -2262,7 +2260,7 @@ static int tc_del_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
>>  
>>  	if (prio == 0) {
>>  		tfilter_notify_chain(net, skb, block, q, parent, n,
>> -				     chain, RTM_DELTFILTER, rtnl_held);
>> +				     chain, RTM_DELTFILTER);
>>  		tcf_chain_flush(chain, rtnl_held);
>>  		err = 0;
>>  		goto errout;
>
> Hum. This looks off.

Hi Jakub,

Prio==0 means user requests to flush whole chain. In such case rtnl lock
is obtained earlier in tc_del_tfilter():

	/* Take rtnl mutex if flushing whole chain, block is shared (no qdisc
	 * found), qdisc is not unlocked, classifier type is not specified,
	 * classifier is not unlocked.
	 */
	if (!prio ||
	    (q && !(q->ops->cl_ops->flags & QDISC_CLASS_OPS_DOIT_UNLOCKED)) ||
	    !tcf_proto_is_unlocked(name)) {
		rtnl_held = true;
		rtnl_lock();
	}