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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241017-fox-of-awesome-blizzard-544df5-mkl@pengutronix.de>
Date: Thu, 17 Oct 2024 09:09:15 +0200
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Wei Fang <wei.fang@....com>
Cc: Shenwei Wang <shenwei.wang@....com>, 
	Clark Wang <xiaoning.wang@....com>, "David S. Miller" <davem@...emloft.net>, 
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, 
	Paolo Abeni <pabeni@...hat.com>, Richard Cochran <richardcochran@...il.com>, 
	"imx@...ts.linux.dev" <imx@...ts.linux.dev>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>, 
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "kernel@...gutronix.de" <kernel@...gutronix.de>
Subject: Re: RE: [PATCH net-next 13/13] net: fec: fec_enet_rx_queue(): factor
 out VLAN handling into separate function fec_enet_rx_vlan()

On 17.10.2024 03:33:09, Wei Fang wrote:
> > -----Original Message-----
> > From: Marc Kleine-Budde <mkl@...gutronix.de>
> > Sent: 2024年10月17日 5:52
> > To: Wei Fang <wei.fang@....com>; Shenwei Wang <shenwei.wang@....com>;
> > Clark Wang <xiaoning.wang@....com>; David S. Miller
> > <davem@...emloft.net>; Eric Dumazet <edumazet@...gle.com>; Jakub
> > Kicinski <kuba@...nel.org>; Paolo Abeni <pabeni@...hat.com>; Richard
> > Cochran <richardcochran@...il.com>
> > Cc: imx@...ts.linux.dev; netdev@...r.kernel.org; linux-kernel@...r.kernel.org;
> > kernel@...gutronix.de; Marc Kleine-Budde <mkl@...gutronix.de>
> > Subject: [PATCH net-next 13/13] net: fec: fec_enet_rx_queue(): factor out
> > VLAN handling into separate function fec_enet_rx_vlan()
> > 
> > In order to clean up of the VLAN handling, factor out the VLAN
> > handling into separate function fec_enet_rx_vlan().
> > 
> > Signed-off-by: Marc Kleine-Budde <mkl@...gutronix.de>
> > ---
> >  drivers/net/ethernet/freescale/fec_main.c | 32
> > ++++++++++++++++++-------------
> >  1 file changed, 19 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/freescale/fec_main.c
> > b/drivers/net/ethernet/freescale/fec_main.c
> > index
> > d9415c7c16cea3fc3d91e198c21af9fe9e21747e..e14000ba85586b9cd73151e
> > 62924c3b4597bb580 100644
> > --- a/drivers/net/ethernet/freescale/fec_main.c
> > +++ b/drivers/net/ethernet/freescale/fec_main.c
> > @@ -1672,6 +1672,22 @@ fec_enet_run_xdp(struct fec_enet_private *fep,
> > struct bpf_prog *prog,
> >  	return ret;
> >  }
> > 
> > +static void fec_enet_rx_vlan(struct net_device *ndev, struct sk_buff *skb)
> > +{
> > +	struct vlan_ethhdr *vlan_header = skb_vlan_eth_hdr(skb);
> 
> Why not move vlan_header into the if statement?

I've an upcoming patch that adds NETIF_F_HW_VLAN_STAG_RX (a.k.a.
801.2ad, S-VLAN) handling that changes this function.

One hunk looks like this, it uses the vlan_header outside of the if:

@@ -1675,15 +1678,19 @@ fec_enet_run_xdp(struct fec_enet_private *fep, struct bpf_prog *prog,
 static void fec_enet_rx_vlan(struct net_device *ndev, struct sk_buff *skb)
 {
         struct vlan_ethhdr *vlan_header = skb_vlan_eth_hdr(skb);
+        __be16 vlan_proto = vlan_header->h_vlan_proto;
 
-        if (ndev->features & NETIF_F_HW_VLAN_CTAG_RX) {
+        if ((vlan_proto == htons(ETH_P_8021Q) &&
+             ndev->features & NETIF_F_HW_VLAN_CTAG_RX) ||
+            (vlan_proto == htons(ETH_P_8021AD) &&
+             ndev->features & NETIF_F_HW_VLAN_STAG_RX)) {
                 /* Push and remove the vlan tag */
                 u16 vlan_tag = ntohs(vlan_header->h_vlan_TCI);

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ