diff --git a/include/zephyr/net/net_pkt.h b/include/zephyr/net/net_pkt.h index 98646b25b26..591002a9d66 100644 --- a/include/zephyr/net/net_pkt.h +++ b/include/zephyr/net/net_pkt.h @@ -836,6 +836,20 @@ static inline void net_pkt_set_ipv6_fragment_id(struct net_pkt *pkt, } #endif /* CONFIG_NET_IPV6_FRAGMENT */ +static inline bool net_pkt_is_ip_reassembled(struct net_pkt *pkt) +{ + if ((IS_ENABLED(CONFIG_NET_IPV4_FRAGMENT) && + net_pkt_family(pkt) == AF_INET && + net_pkt_ipv4_fragment_more(pkt)) || + (IS_ENABLED(CONFIG_NET_IPV6_FRAGMENT) && + net_pkt_family(pkt) == AF_INET6 && + net_pkt_ipv6_fragment_start(pkt))) { + return true; + } + + return false; +} + static inline uint8_t net_pkt_priority(struct net_pkt *pkt) { return pkt->priority; diff --git a/subsys/net/ip/net_core.c b/subsys/net/ip/net_core.c index 3d37743a39d..baa8cd695c5 100644 --- a/subsys/net/ip/net_core.c +++ b/subsys/net/ip/net_core.c @@ -76,8 +76,7 @@ static inline enum net_verdict process_data(struct net_pkt *pkt, /* If the packet is routed back to us when we have reassembled an IPv4 or IPv6 packet, * then do not pass it to L2 as the packet does not have link layer headers in it. */ - if ((IS_ENABLED(CONFIG_NET_IPV4_FRAGMENT) && net_pkt_ipv4_fragment_more(pkt)) || - (IS_ENABLED(CONFIG_NET_IPV6_FRAGMENT) && net_pkt_ipv6_fragment_start(pkt))) { + if (net_pkt_is_ip_reassembled(pkt)) { locally_routed = true; }