Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2851198ybk; Tue, 12 May 2020 09:36:26 -0700 (PDT) X-Google-Smtp-Source: APiQypJ2iNIU8ydVk5G28p8DDpAzaO5ROJOHf9GonRo9Pu3na3qYERJqE+BmMaLSfgYkkdS7Ku43 X-Received: by 2002:a05:6402:1296:: with SMTP id w22mr17610980edv.364.1589301386021; Tue, 12 May 2020 09:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589301386; cv=none; d=google.com; s=arc-20160816; b=t9tKyfxYcQUxloJ41233slyhIMJp1Q2IsF1MlzDeFeNa3ZdNf9X7MrRXKEYxka1LK2 1taqbaJ08FNxpl3X7erMswvm1vuRxpL0Fnt7wyuxtBFtUA126d4QkK8cMYwxJMm69803 yt2hAyUInvhnCiqTkrcmoSqGidGY7NGe0hghIIxBY5XZimXS7TezJg4Md7Lf45E7Baf6 ZgJtzyamwPSOBIfb0tF4gVjSe8MajxIPT9Te+s9DxB36YJP3rpDyaEHFjBQxxkovNIJ1 CM0BEhKENyDH3PRq/WArkXgFraKsAz1qsUVJESKCzJZUh7wDYRLDbWjPfoWAPQeoGq8D lnew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=s2SrDvwPQ6UZ9GvGAv7piKx1gwXE3b8Elq3inN+lZ8U=; b=aMoxU3njpAG7LEnJBKHaCFf4tUF7swPROUNpHsYzhhKkGGbrOtI+U8SCAVMqwMR8b6 0nfCKGW7hg9YK0HQpuGHgk/Cn+0eZUhpID5k+2xq0b04RZdfxV+0hlS7yleeL/VGbUxn uf5tAel/YN5Zw1WHHTW7OrXIsThA7cuACKculSdFQXR21OF5VpGoT7/NER1CJ65wP3tr SMr91iN56+0j8yLEhW/LRgoluGoGnMS64xoU943Itu59/FVxe5gB5iD0QcazkeBF48Jk Hm7Hw666vlbqgjCmucEhhxvNZ7l0yls+DWKI+BJfrPC9QRZIUS5dOsnp6QMdSoLfyjtP 68lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gyfUMILZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u13si5031072ejg.291.2020.05.12.09.36.02; Tue, 12 May 2020 09:36:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gyfUMILZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728485AbgELQce (ORCPT + 99 others); Tue, 12 May 2020 12:32:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:33634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbgELQce (ORCPT ); Tue, 12 May 2020 12:32:34 -0400 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 12432206CC; Tue, 12 May 2020 16:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589301153; bh=iai6OsTrstOImYGBblatIa+HRYGTeEYXR6O6Jhuge0Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gyfUMILZKf/6nFVyJhQlgWnDBIITwatliCL6ozMK0oYYDh9/NAxgxc1CXknpwXadj yyTgtV1zyYYhV6oo9ENRsJf+k/FGgpJvBVXQRyW1r8HEY4I+/AKreK2X+lh3ZWz0M1 LJzi7cV8FRpSdqnDdByESWwxf/OWll2UtOoH1i2U= Date: Tue, 12 May 2020 09:32:31 -0700 From: Jakub Kicinski To: Madhuparna Bhowmik Cc: sfr@canb.auug.org.au, Amol Grover , "David S . Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , "Paul E . McKenney" Subject: Re: [PATCH net 2/2 RESEND] ipmr: Add lockdep expression to ipmr_for_each_table macro Message-ID: <20200512093231.7ce29f30@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20200512051705.GB9585@madhuparna-HP-Notebook> References: <20200509072243.3141-1-frextrite@gmail.com> <20200509072243.3141-2-frextrite@gmail.com> <20200509141938.028fa959@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20200512051705.GB9585@madhuparna-HP-Notebook> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 May 2020 10:47:05 +0530 Madhuparna Bhowmik wrote: > > > #ifdef CONFIG_IP_MROUTE_MULTIPLE_TABLES > > > -#define ipmr_for_each_table(mrt, net) \ > > > - list_for_each_entry_rcu(mrt, &net->ipv4.mr_tables, list, \ > > > - lockdep_rtnl_is_held()) > > > +#define ipmr_for_each_table(mrt, net) \ > > > + list_for_each_entry_rcu(mrt, &net->ipv4.mr_tables, list, \ > > > + lockdep_rtnl_is_held() || \ > > > + lockdep_is_held(&pernet_ops_rwsem)) > > > > This is a strange condition, IMHO. How can we be fine with either > > lock.. This is supposed to be the writer side lock, one can't have > > two writer side locks.. > > > > I think what is happening is this: > > > > ipmr_net_init() -> ipmr_rules_init() -> ipmr_new_table() > > > > ipmr_new_table() returns an existing table if there is one, but > > obviously none can exist at init. So a better fix would be: > > > > #define ipmr_for_each_table(mrt, net) \ > > list_for_each_entry_rcu(mrt, &net->ipv4.mr_tables, list, \ > > lockdep_rtnl_is_held() || \ > > list_empty(&net->ipv4.mr_tables)) > > > (adding Stephen) > > Hi Jakub, > > Thank you for your suggestion about this patch. > Here is a stack trace for ipmr.c: > > [...] Thanks! > > Thoughts? > > Do you think a similar fix (the one you suggested) is also applicable > in the ip6mr case. Yes, looking at the code it seems ip6mr has the exact same flow for netns init.