Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1618005

Re: [PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging format

From Juergen Borleis <jbe@pengutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging format
Date 2017-04-06 15:40 +0200
Message-ID <ttfNL-DZ-3@gated-at.bofh.it> (permalink)
References <tsPqh-Mk-1@gated-at.bofh.it> <tsPqi-Mk-17@gated-at.bofh.it> <tsWLa-5w8-65@gated-at.bofh.it>
Organization Pengutronix e.K.

Show all headers | View raw


Hi Andrew,

On Wednesday 05 April 2017 19:10:01 Andrew Lunn wrote:
> [...]
> > +static int lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
> > +		       struct packet_type *pt, struct net_device *orig_dev)
> > +{
> > +	u16 *lan9303_tag;
> > +	struct dsa_switch_tree *dst = dev->dsa_ptr;
> > +	struct dsa_switch *ds = dst->ds[0];
> > +	unsigned int source_port;
> > +
> > +	if (unlikely(!dst)) {
> > +		dev_warn_ratelimited(&dev->dev, "Dropping packet, due to missing switch tree device\n");
> > +		goto out_drop; 
> > +	}
>
> By the time you get here, you have already dereferenced dst, in order
> to get ds. So this is pointless.

Ups! Thanks! Fixed in v2.

> > +	lan9303_tag = (u16 *)(skb->data - 2);
> > +
> > +	if (lan9303_tag[0] != htons(0x8100)) {
> > +		dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid VLAN marker\n");
> > +		goto out_drop; 
> > +	}
>
> In the transmit function, you use ETH_P_8021Q, please do so here as
> well.

Done in v2.

> > +	source_port = ntohs(lan9303_tag[1]) & 0x3;
> > +
> > +	if (source_port >= DSA_MAX_PORTS) {
> > +		dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid source port\n");
> > +		goto out_drop; 
> > +	}
>
> You can be more specific here. For this hardware, > 3 is invalid and
> should be dropped. If we later add other chips which have more ports,
> we can relax this check then.

Done in v2.

> > +	/* remove the special VLAN tag between the MAC addresses
> > +	 * and the current ethertype field.
> > +	 */
> > +	skb_pull_rcsum(skb, 2 + 2);
> > +	memmove(skb->data - ETH_HLEN, skb->data - (ETH_HLEN + LAN9303_TAG_LEN),
> > +		2 * ETH_ALEN); 
> > +	skb_push(skb, ETH_HLEN);
>
> Do you need to do anything with the checksum here? Other tagging
> protocols do.

Don't know exactly what you are meaning here. For me it does the same like
the qca_tag_rcv() function in tag_qca.c does.

Juergen

-- 
Pengutronix e.K.                             | Juergen Borleis             |
Industrial Linux Solutions                   | http://www.pengutronix.de/  |

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

net: dsa: add SMSC/Microchip LAN9303 three port ethernet switch driver Juergen Borleis <jbe@pengutronix.de> - 2017-04-05 11:30 +0200
  [PATCH 2/4] net: dsa: add new DSA switch driver for the SMSC-LAN9303 Juergen Borleis <jbe@pengutronix.de> - 2017-04-05 11:30 +0200
    Re: [PATCH 2/4] net: dsa: add new DSA switch driver for the  SMSC-LAN9303 Andrew Lunn <andrew@lunn.ch> - 2017-04-05 20:20 +0200
      Re: [PATCH 2/4] net: dsa: add new DSA switch driver for the SMSC-LAN9303 Juergen Borleis <jbe@pengutronix.de> - 2017-04-06 12:30 +0200
        Re: [PATCH 2/4] net: dsa: add new DSA switch driver for the  SMSC-LAN9303 Andrew Lunn <andrew@lunn.ch> - 2017-04-06 14:00 +0200
          Re: [PATCH 2/4] net: dsa: add new DSA switch driver for the SMSC-LAN9303 Juergen Borleis <jbe@pengutronix.de> - 2017-04-06 15:50 +0200
      Re: [PATCH 2/4] net: dsa: add new DSA switch driver for the SMSC-LAN9303 Juergen Borleis <jbe@pengutronix.de> - 2017-04-06 12:50 +0200
  [PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging format Juergen Borleis <jbe@pengutronix.de> - 2017-04-05 11:30 +0200
    Re: [PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging  format Andrew Lunn <andrew@lunn.ch> - 2017-04-05 19:20 +0200
      Re: [PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging format Juergen Borleis <jbe@pengutronix.de> - 2017-04-06 15:40 +0200
  [PATCH 3/4] net: dsa: LAN9303: add I2C managed mode support Juergen Borleis <jbe@pengutronix.de> - 2017-04-05 11:30 +0200
    Re: [PATCH 3/4] net: dsa: LAN9303: add I2C managed mode support Andrew Lunn <andrew@lunn.ch> - 2017-04-05 20:30 +0200
      Re: [PATCH 3/4] net: dsa: LAN9303: add I2C managed mode support Juergen Borleis <jbe@pengutronix.de> - 2017-04-06 15:50 +0200
        Re: [PATCH 3/4] net: dsa: LAN9303: add I2C managed mode support Florian Fainelli <f.fainelli@gmail.com> - 2017-04-06 16:00 +0200
  [PATCH 4/4] net: dsa: LAN9303: add MDIO managed mode support Juergen Borleis <jbe@pengutronix.de> - 2017-04-05 11:30 +0200
    Re: [PATCH 4/4] net: dsa: LAN9303: add MDIO managed mode support Andrew Lunn <andrew@lunn.ch> - 2017-04-05 21:40 +0200
      Re: [PATCH 4/4] net: dsa: LAN9303: add MDIO managed mode support Florian Fainelli <f.fainelli@gmail.com> - 2017-04-06 16:00 +0200
        Re: [PATCH 4/4] net: dsa: LAN9303: add MDIO managed mode support Andrew Lunn <andrew@lunn.ch> - 2017-04-06 16:30 +0200

csiph-web