From: David Ahern Subject: Re: [RFC v4 4/5] netdev: add netdev_is_upper_master Date: Thu, 22 Nov 2018 10:14:46 -0700 Message-ID: References: <20181122010713.3995-1-abauvin@scaleway.com> <20181122010713.3995-5-abauvin@scaleway.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, akherbouche@scaleway.com To: Alexis Bauvin , roopa@cumulusnetworks.com Return-path: Received: from mail-it1-f196.google.com ([209.85.166.196]:51924 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404641AbeKWDzG (ORCPT ); Thu, 22 Nov 2018 22:55:06 -0500 Received: by mail-it1-f196.google.com with SMTP id x19so15038517itl.1 for ; Thu, 22 Nov 2018 09:14:49 -0800 (PST) In-Reply-To: <20181122010713.3995-5-abauvin@scaleway.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 11/21/18 6:07 PM, Alexis Bauvin wrote: > diff --git a/net/core/dev.c b/net/core/dev.c > index 93243479085f..12459036d0da 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -7225,6 +7225,23 @@ void netdev_lower_state_changed(struct net_device *lower_dev, > } > EXPORT_SYMBOL(netdev_lower_state_changed); > > +/** > + * netdev_is_upper_master - Test if a device is a master, direct or indirect, > + * of another one. > + * @dev: device to start looking from > + * @master: device to test if master of dev > + */ > +bool netdev_is_upper_master(struct net_device *dev, struct net_device *master) > +{ > + if (!dev) > + return false; > + > + if (dev->ifindex == master->ifindex) dev == master should work as well without the dereference. > + return true; > + return netdev_is_upper_master(netdev_master_upper_dev_get(dev), master); > +} > +EXPORT_SYMBOL(netdev_is_upper_master); > + > static void dev_change_rx_flags(struct net_device *dev, int flags) > { > const struct net_device_ops *ops = dev->netdev_ops; >