Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2286436ybl; Thu, 29 Aug 2019 06:18:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXFibLKBW7FlczQIabW4RivQZ1prQaCE08pd1XZJIAHQdDjISE2OA6VA6zntN3dX+fvOOO X-Received: by 2002:a05:6a00:8e:: with SMTP id c14mr11009398pfj.241.1567084700323; Thu, 29 Aug 2019 06:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567084700; cv=none; d=google.com; s=arc-20160816; b=CWmIoAyZ6JXWBH7+NmrwnPPe0IpaUG2IduOs/pNfMifu6M2+PkYLyNIDkQeD0rELEP I/zq7mAuGJQXdlHuL17BqLfTi6ZxcFqSmoDSugBa3voDB+Vgz1Ps5IvQZ3wfe4qT3XIn m+OQsVgiSDw1KrSSazkScsR9CohTrxalPgBvR5EgTG/I0+QRaSfq5yND3ih3J61gO2FO sd8UraPnki+jRIMKARu8fwp7+YSnEPMcfLXQ8QUCitH+fwf+LudfGZMldbrKN1GF6ddj 6OEdRIv8axTNXqbHD4xnM5x8ZsYnzJ35isy4dC2+Yi739BTix/ui1/3Eg+RADZ/ttJFi ++9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=jFMdGRkchqnYEBrx24o+aDmbK62nouD4dZcC7gAUcKw=; b=zKIh8uK8hBZGziMoMyoaEFxfp1fkpb2doMMlp8YRbywm2NinrKP2Gnj0V4QCfpk/6K vGf7PvLa75XhAm+hAKEHRltg1bFzYxuQsNop+db6KRi9vvpCECmrFSF0PNZ2alkvKQZA KkOBRkYTSOI15cyUL5R2O74K6qJ4KvW8jPA0gQuLYDjUgbtMBrRSfqM4hJ7bi+LaypDG /4SlOBrUIFF6GXf/dzeDhVh+desYeMNjOJS05Nx6Y22jP8gETAN/iw6W+sGKwcJW9HJ9 nK6AGZtuwfS++9YZ+394Va2+/oTqFAfgwu7PKP1donj94gknYGT2MP/mMYD9JNhAUCwt sjug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=WbNRVsGD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si2167451pjw.43.2019.08.29.06.18.04; Thu, 29 Aug 2019 06:18:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=WbNRVsGD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727810AbfH2NPz (ORCPT + 99 others); Thu, 29 Aug 2019 09:15:55 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:40692 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727109AbfH2NPx (ORCPT ); Thu, 29 Aug 2019 09:15:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jFMdGRkchqnYEBrx24o+aDmbK62nouD4dZcC7gAUcKw=; b=WbNRVsGDr16eD5VFXzibrYWSTw ZUvdxn6w6eSnOtiO9raQPa7u48PVNYr6HKxUr1eMHyoeH+UtrualQdcUrg9o1h04pYW95Ua9WozwZ 0Nns1CYUZhYi+isiGmWoY5LTaDwxJJSVBq3xJfImOiEff9sr/XRFpVp3i4WFewiD2CMk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.89) (envelope-from ) id 1i3KH9-0002EA-FC; Thu, 29 Aug 2019 15:15:43 +0200 Date: Thu, 29 Aug 2019 15:15:43 +0200 From: Andrew Lunn To: Ivan Vecera Cc: Horatiu Vultur , Jiri Pirko , alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, davem@davemloft.net, allan.nielsen@microchip.com, f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] net: core: Notify on changes to dev->promiscuity. Message-ID: <20190829131543.GB6998@lunn.ch> References: <1567070549-29255-1-git-send-email-horatiu.vultur@microchip.com> <1567070549-29255-2-git-send-email-horatiu.vultur@microchip.com> <20190829095100.GH2312@nanopsycho> <20190829105650.btgvytgja63sx6wx@soft-dev3.microsemi.net> <20190829121811.GI2312@nanopsycho> <20190829124412.nrlpz5tzx3fkdoiw@soft-dev3.microsemi.net> <20190829145518.393fb99d@ceranb> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190829145518.393fb99d@ceranb> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 29, 2019 at 02:55:18PM +0200, Ivan Vecera wrote: > On Thu, 29 Aug 2019 14:44:14 +0200 > Horatiu Vultur wrote: > > > When a port is added to a bridge, then the port gets in promisc mode. > > But in our case the HW has bridge capabilities so it is not required > > to set the port in promisc mode. > > But if someone else requires the port to be in promisc mode (tcpdump > > or any other application) then I would like to set the port in promisc > > mode. > > In previous emails Andrew came with the suggestion to look at > > dev->promiscuity and check if the port is a bridge port. Using this > > information I could see when to add the port in promisc mode. He also > > suggested to add a new switchdev call(maybe I missunderstood him, or I > > have done it at the wrong place) in case there are no callbacks in the > > driver to get this information. > > I would use the 1st suggestion. > > for/in your driver: > if (dev->promiscuity > 0) { > if (dev->promiscuity == 1 && netif_is_bridge_port(dev)) { > /* no need to set promisc mode because promiscuity > * was requested by bridge > */ > ... > } else { > /* need to set promisc mode as someone else requested > * promiscuity > */ > } > } Hi Ivan The problem with this is, the driver only gets called when promisc goes from 0 to !0. So, the port is added to the bridge. Promisc goes 0->1, and the driver gets called. We can evaluate as you said above, and leave the port filtering frames, not forwarding everything. When tcpdump is started, the core does promisc 1->2, but does not call into the driver. Also, currently sending a notification is not unconditional. What this patch adds is an unconditional call into the switchdev driver so it can evaluate the condition above, with every change to the promisc counter. Andrew