From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6448DC10F0E for ; Fri, 12 Apr 2019 13:58:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 323ED206BA for ; Fri, 12 Apr 2019 13:58:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="exzOb1oz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726847AbfDLN56 (ORCPT ); Fri, 12 Apr 2019 09:57:58 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:50509 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbfDLN56 (ORCPT ); Fri, 12 Apr 2019 09:57:58 -0400 Received: by mail-wm1-f67.google.com with SMTP id z11so11437568wmi.0 for ; Fri, 12 Apr 2019 06:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Do7rQA5LpwEFIurbt0f+eo6jS9eVmvBqPiD7sLf6yHk=; b=exzOb1oz1qp6LYqhFWWfD0VBrqhon0nqXGcJaBL9JAwpLvySwy/GATHubGKYBZPf7P it7DMAQZFBCDqOouO3quqtgb5yoYif4vHofLqN87sIyhAtmy1tgLjoj7ExwDeXohMz/m VLVNc1eyy/QAC8QSHFPG4eG009+2VXPg9JiEkXz3Cc+OGqJJSPLG6lKobyiSv88TMN4g 96PSrJ89g8u/w8xkmwIeXTweGPwjtyaQAKTBfYFGmSA824LOEKJmvHVL+YgVJYnJyjvo HbXlvcW8xnM0AlZsSm4SO4EoY48JB/p9HzXqheHKhhNnF2AKFyj4PIihItbbOjXyuXQN TqOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Do7rQA5LpwEFIurbt0f+eo6jS9eVmvBqPiD7sLf6yHk=; b=J8NAIK0f8ZZy2ljZVvFmqkr5EzxmKfQwWU3BhFaL8Fh2etEMY3hSq3RXZTVxlJHPpz xA4ITUpdDk2fXY1rT2l6H4lQBBjtAAgfHeUMtrQtu7vM+dmSGvfMNyXuOTenDQNEj1+N 4gy+MRO9zFHShKk06niRq6jWbN5w0r2Dw3SRmR+PUqhOqLcjUIJIWk4cGCadnO6kezNM 50Ljm6G5XMlb7rc0NvSHc+DL4vbTRfnE+VEn12FNl5Zf52I6fKRw6Qd1Mb/idlpBnZT/ 4aptynvVnsut9JnF+U6Ow6YgFyfOXpva4drNSaZRDAaGBo4XS/QGOx0sXDxk+iePol9m qmAg== X-Gm-Message-State: APjAAAXzihcH/EAuAWm66a80xw9j4Iu7HcHr6fyy6n1Bmvnt4RH6U+y+ Wn3uQZK3bG7/RfP+3r+NAK/siw== X-Google-Smtp-Source: APXvYqw2P2wie9WGByjnyfBhGuCw5QM//ntiIvjkwvpyeBN3BZMNlJjUsI3HdsNWeo0z7At7Q0M2kg== X-Received: by 2002:a1c:1d81:: with SMTP id d123mr11715878wmd.59.1555077476796; Fri, 12 Apr 2019 06:57:56 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id a4sm16188754wmf.45.2019.04.12.06.57.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2019 06:57:56 -0700 (PDT) Date: Fri, 12 Apr 2019 15:57:55 +0200 From: Jiri Pirko To: Sabrina Dubroca Cc: netdev@vger.kernel.org, Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Jarod Wilson Subject: Re: [PATCH net] bonding: fix event handling for stacked bonds Message-ID: <20190412135755.GA2268@nanopsycho.orion> References: <9e7fda25884e8e68b1932a48de58189a08ef906f.1555073754.git.sd@queasysnail.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9e7fda25884e8e68b1932a48de58189a08ef906f.1555073754.git.sd@queasysnail.net> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fri, Apr 12, 2019 at 03:04:10PM CEST, sd@queasysnail.net wrote: >When a bond is enslaved to another bond, bond_netdev_event() only >handles the event as if the bond is a master, and skips treating the >bond as a slave. > >This leads to a refcount leak on the slave, since we don't remove the >adjacency to its master and the master holds a reference on the slave. > >Reproducer: > ip link add bondL type bond > ip link add bondU type bond > ip link set bondL master bondU > ip link del bondL Out of curiosity, what is a usecase of stacked bonds? I don't see any. > >No "Fixes:" tag, this code is older than git history. > >Signed-off-by: Sabrina Dubroca >--- >I also spotted some lockdep warnings when I started stacking random >devices on top of random devices, I'm trying to clean that up too, but >this fix is independent of that. > > drivers/net/bonding/bond_main.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > >diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c >index b59708c35faf..ee610721098e 100644 >--- a/drivers/net/bonding/bond_main.c >+++ b/drivers/net/bonding/bond_main.c >@@ -3213,8 +3213,12 @@ static int bond_netdev_event(struct notifier_block *this, > return NOTIFY_DONE; > > if (event_dev->flags & IFF_MASTER) { >+ int ret; >+ > netdev_dbg(event_dev, "IFF_MASTER\n"); >- return bond_master_netdev_event(event, event_dev); >+ ret = bond_master_netdev_event(event, event_dev); >+ if (ret != NOTIFY_DONE) >+ return ret; > } > > if (event_dev->flags & IFF_SLAVE) { >-- >2.21.0 >