From: Juergen Borleis <jbe@pengutronix.de>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
f.fainelli@gmail.com, kernel@pengutronix.de,
vivien.didelot@savoirfairelinux.com, davem@davemloft.net
Subject: Re: [PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging format
Date: Thu, 6 Apr 2017 15:36:26 +0200 [thread overview]
Message-ID: <201704061536.27164.jbe@pengutronix.de> (raw)
In-Reply-To: <20170405171001.GD21965@lunn.ch>
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/ |
next prev parent reply other threads:[~2017-04-06 13:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-05 9:20 net: dsa: add SMSC/Microchip LAN9303 three port ethernet switch driver Juergen Borleis
2017-04-05 9:20 ` [PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging format Juergen Borleis
2017-04-05 17:10 ` Andrew Lunn
2017-04-06 13:36 ` Juergen Borleis [this message]
2017-04-05 9:20 ` [PATCH 2/4] net: dsa: add new DSA switch driver for the SMSC-LAN9303 Juergen Borleis
2017-04-05 18:12 ` Andrew Lunn
2017-04-06 10:18 ` Juergen Borleis
2017-04-06 11:59 ` Andrew Lunn
2017-04-06 13:42 ` Juergen Borleis
2017-04-06 10:39 ` Juergen Borleis
2017-04-05 9:20 ` [PATCH 3/4] net: dsa: LAN9303: add I2C managed mode support Juergen Borleis
2017-04-05 18:21 ` Andrew Lunn
2017-04-06 13:46 ` Juergen Borleis
2017-04-06 13:52 ` Florian Fainelli
2017-04-05 9:20 ` [PATCH 4/4] net: dsa: LAN9303: add MDIO " Juergen Borleis
2017-04-05 19:32 ` Andrew Lunn
2017-04-06 13:53 ` Florian Fainelli
2017-04-06 14:25 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201704061536.27164.jbe@pengutronix.de \
--to=jbe@pengutronix.de \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.