Subject: Re: [PATCH net-next v5 1/8] hsr: Add header_ops::parse_protocol

From: Willem de Bruijn <[email-masked]>
Date: Fri, 29 May 2026 15:53:06 -0400

Sebastian Andrzej Siewior wrote:
> af_packet uses dev_parse_header_protocol() to assign skb::protocol.
> The hsr stack does not assign a callback so the field is assigned to 0.

It does this as a last resort. It is preferable for set protocol.

Either by binding the packet socket to a protocol at socket() or
bind() time (but that affects which packets will get delivered to it),
or by passing msg_name (of type sockaddr_ll).

That said, good to have this backup for senders that fail to do so.

> The header used by the hsr stack corresponds to the ethernet header for
> the "first" part so the protocol member is at the same position.
> 
> Use eth_header_parse_protocol() for the hsr_header_ops's parse_protocol
> callback.
> 
> Signed-off-by: Sebastian Andrzej Siewior <[email-masked]>
> ---
>  net/hsr/hsr_device.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
> index 5555b71ab19b5..a999ddccc46c5 100644
> --- a/net/hsr/hsr_device.c
> +++ b/net/hsr/hsr_device.c
> @@ -247,6 +247,7 @@ static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, struct net_device *dev)
>  static const struct header_ops hsr_header_ops = {
>  	.create	 = eth_header,
>  	.parse	 = eth_header_parse,
> +	.parse_protocol = eth_header_parse_protocol,
>  };
>  
>  static struct sk_buff *hsr_init_skb(struct hsr_port *master, int extra)
> 
> -- 
> 2.53.0
>