Index | Thread | Search

From:
David Gwynne <david@gwynne.id.au>
Subject:
Re: ether_input(): remove redundant etype assignment
To:
Ido <ido@wireplug.org>
Cc:
tech@openbsd.org
Date:
Tue, 17 Mar 2026 10:19:12 +1000

Download raw body.

Thread
hey Ido,

On Mon, Mar 16, 2026 at 01:04:07PM -0400, Ido wrote:
> etype is already assigned the same value early in the function and remains unchanged.

except that vlan_input() between the first assignment and this one can
change the packet to make a different ethertype available.

if the packet has a vlan tag, but the hardware that received it does not
do vlan tag offloads, then the first etype will be ETHERTYPE_VLAN. if
the vlan id in that packet is 0, the tag exists to encode priority for
the packet, but it should be delivered as if it did not have a vlan tag
on it. in this situation vlan_input removes the vlan tag and returns the
packet to ether_input for processing.

the second etype assignment you're trying to remove here will then be
able to read the actual type of the packet rather than the vlan type.

cheers,
dlg

> ---
> Ido
> 
> diff --git sys/net/if_ethersubr.c sys/net/if_ethersubr.c
> index d67e791e7fa..63c4a80d811 100644
> --- sys/net/if_ethersubr.c
> +++ sys/net/if_ethersubr.c
> @@ -525,7 +525,6 @@ ether_input(struct ifnet *ifp, struct mbuf *m, struct netstack *ns)
>  	 * At this point it is known that the packet is destined
>  	 * for layer 3 protocol handling on the local port.
>  	 */
> -	etype = ntohs(eh->ether_type);
>  
>  	switch (etype) {
>  	case ETHERTYPE_IP:
>