lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210803095419.y6hly7euht7gsktu@pengutronix.de>
Date:   Tue, 3 Aug 2021 11:54:19 +0200
From:   Oleksij Rempel <o.rempel@...gutronix.de>
To:     Vladimir Oltean <olteanv@...il.com>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Russell King <linux@...linux.org.uk>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-mips@...r.kernel.org
Subject: Re: [PATCH net v2 1/1] net: dsa: qca: ar9331: make proper initial
 port defaults

On Tue, Aug 03, 2021 at 12:06:05PM +0300, Vladimir Oltean wrote:
> On Tue, Aug 03, 2021 at 10:53:20AM +0200, Oleksij Rempel wrote:
> > Make sure that all external port are actually isolated from each other,
> > so no packets are leaked.
> > 
> > Fixes: ec6698c272de ("net: dsa: add support for Atheros AR9331 built-in switch")
> > Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
> > ---
> > changes v2:
> > - do not enable address learning by default
> > 
> >  drivers/net/dsa/qca/ar9331.c | 98 +++++++++++++++++++++++++++++++++++-
> >  1 file changed, 97 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c
> > index 6686192e1883..de7c06b6c85f 100644
> > --- a/drivers/net/dsa/qca/ar9331.c
> > +++ b/drivers/net/dsa/qca/ar9331.c
> > @@ -101,6 +101,46 @@
> >  	 AR9331_SW_PORT_STATUS_RX_FLOW_EN | AR9331_SW_PORT_STATUS_TX_FLOW_EN | \
> >  	 AR9331_SW_PORT_STATUS_SPEED_M)
> >  
> > +#define AR9331_SW_REG_PORT_CTRL(_port)			(0x104 + (_port) * 0x100)
> > +#define AR9331_SW_PORT_CTRL_ING_MIRROR_EN		BIT(17)
> > +#define AR9331_SW_PORT_CTRL_LOCK_DROP_EN		BIT(5)
> 
> not used

ack, will remove

> 
> > +#define AR9331_SW_PORT_CTRL_PORT_STATE			GENMASK(2, 0)
> > +#define AR9331_SW_PORT_CTRL_PORT_STATE_DISABLED		0
> > +#define AR9331_SW_PORT_CTRL_PORT_STATE_BLOCKING		1
> > +#define AR9331_SW_PORT_CTRL_PORT_STATE_LISTENING	2
> > +#define AR9331_SW_PORT_CTRL_PORT_STATE_LEARNING		3
> > +#define AR9331_SW_PORT_CTRL_PORT_STATE_FORWARD		4

....
> >  
> > -static int ar9331_sw_setup(struct dsa_switch *ds)
> > +static int ar9331_sw_setup_port(struct dsa_switch *ds, int port)
> >  {
> >  	struct ar9331_sw_priv *priv = (struct ar9331_sw_priv *)ds->priv;
> >  	struct regmap *regmap = priv->regmap;
> > +	u32 port_mask, port_ctrl, val;
> >  	int ret;
> >  
> > +	/* Generate default port settings */
> > +	port_ctrl = FIELD_PREP(AR9331_SW_PORT_CTRL_PORT_STATE,
> > +			       AR9331_SW_PORT_CTRL_PORT_STATE_DISABLED);
> 
> PORT_STATE_DISABLED? why? Can you ping over any interface after applying
> this patch?

grr... good point. My fault, sorry.

> > +
> > +	if (dsa_is_cpu_port(ds, port)) {
> > +		/* CPU port should be allowed to communicate with all user
> > +		 * ports.
> > +		 */
> > +		port_mask = dsa_user_ports(ds);
> > +		/* Enable Atheros header on CPU port. This will allow us
> > +		 * communicate with each port separately
> > +		 */
> > +		port_ctrl |= AR9331_SW_PORT_CTRL_HEAD_EN;
> > +	} else if (dsa_is_user_port(ds, port)) {
> > +		/* User ports should communicate only with the CPU port.
> > +		 */
> > +		port_mask = BIT(dsa_to_port(ds, port)->cpu_dp->index);
> 
> You can use "port_mask = BIT(dsa_upstream_port(ds, port));", looks nicer
> at least to me.

ok. 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ