Re: [PATCH net-next v2 07/10] net: fec: fec_enet_rx_queue(): replace manual VLAN header calculation with skb_vlan_eth_hdr()

From: Andrew Lunn
Date: Fri Jun 13 2025 - 14:37:59 EST


On Thu, Jun 12, 2025 at 04:16:00PM +0200, Marc Kleine-Budde wrote:
> Use the provided helper function skb_vlan_eth_hdr() to replace manual VLAN
> header calculation for better readability and maintainability.
>
> Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> Reviewed-by: Wei Fang <wei.fang@xxxxxxx>
> Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
> ---
> drivers/net/ethernet/freescale/fec_main.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 6b456372de9a..f238cb60aa65 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1860,8 +1860,7 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
> fep->bufdesc_ex &&
> (ebdp->cbd_esc & cpu_to_fec32(BD_ENET_RX_VLAN))) {
> /* Push and remove the vlan tag */
> - struct vlan_hdr *vlan_header =
> - (struct vlan_hdr *) (data + ETH_HLEN);
> + struct vlan_ethhdr *vlan_header = skb_vlan_eth_hdr(skb);

This is not 'obviously correct', so probably the commit message needs
expanding.

static inline struct vlan_ethhdr *skb_vlan_eth_hdr(const struct sk_buff *skb)
{
return (struct vlan_ethhdr *)skb->data;
}

I can see a few lines early:

data = skb->data;

but what about the + ETH_HLEN?

Andrew