diff --git a/include/zephyr/net/net_pkt.h b/include/zephyr/net/net_pkt.h index 6f67ad0dcdc..858a57382de 100644 --- a/include/zephyr/net/net_pkt.h +++ b/include/zephyr/net/net_pkt.h @@ -124,6 +124,7 @@ struct net_pkt { /* Filled by layer 2 when network packet is received. */ struct net_linkaddr lladdr_src; struct net_linkaddr lladdr_dst; + uint16_t ll_proto_type; #if defined(CONFIG_NET_TCP) /** Allow placing the packet into sys_slist_t */ @@ -1018,6 +1019,16 @@ static inline void net_pkt_lladdr_clear(struct net_pkt *pkt) net_pkt_lladdr_src(pkt)->len = 0U; } +static inline uint16_t net_pkt_ll_proto_type(struct net_pkt *pkt) +{ + return pkt->ll_proto_type; +} + +static inline void net_pkt_set_ll_proto_type(struct net_pkt *pkt, uint16_t type) +{ + pkt->ll_proto_type = type; +} + #if defined(CONFIG_IEEE802154) || defined(CONFIG_IEEE802154_RAW_MODE) static inline uint8_t net_pkt_ieee802154_rssi(struct net_pkt *pkt) { diff --git a/subsys/net/ip/net_pkt.c b/subsys/net/ip/net_pkt.c index b9d36c1c314..8976170a398 100644 --- a/subsys/net/ip/net_pkt.c +++ b/subsys/net/ip/net_pkt.c @@ -1775,6 +1775,7 @@ static void clone_pkt_attributes(struct net_pkt *pkt, struct net_pkt *clone_pkt) net_pkt_set_captured(clone_pkt, net_pkt_is_captured(pkt)); net_pkt_set_l2_bridged(clone_pkt, net_pkt_is_l2_bridged(pkt)); net_pkt_set_l2_processed(clone_pkt, net_pkt_is_l2_processed(pkt)); + net_pkt_set_ll_proto_type(clone_pkt, net_pkt_ll_proto_type(pkt)); if (IS_ENABLED(CONFIG_NET_IPV4) && net_pkt_family(pkt) == AF_INET) { net_pkt_set_ipv4_ttl(clone_pkt, net_pkt_ipv4_ttl(pkt)); diff --git a/subsys/net/l2/ethernet/ethernet.c b/subsys/net/l2/ethernet/ethernet.c index 3e7e158a959..13124effff6 100644 --- a/subsys/net/l2/ethernet/ethernet.c +++ b/subsys/net/l2/ethernet/ethernet.c @@ -274,6 +274,8 @@ static enum net_verdict ethernet_recv(struct net_if *iface, lladdr->len = sizeof(struct net_eth_addr); lladdr->type = NET_LINK_ETHERNET; + net_pkt_set_ll_proto_type(pkt, type); + if (net_eth_is_vlan_enabled(ctx, iface)) { if (type == NET_ETH_PTYPE_VLAN || (eth_is_vlan_tag_stripped(iface) &&