diff --git a/include/zephyr/net/net_core.h b/include/zephyr/net/net_core.h index 1b4bf0479bda..5c017a9780e2 100644 --- a/include/zephyr/net/net_core.h +++ b/include/zephyr/net/net_core.h @@ -186,8 +186,7 @@ struct net_l3_register { .handler = _handler, \ .name = STRINGIFY(_name), \ .l2 = _l2_type, \ - }; \ - BUILD_ASSERT((_handler) != NULL, "Handler is not defined") + }; /* @endcond */ diff --git a/subsys/net/l2/ethernet/ethernet.c b/subsys/net/l2/ethernet/ethernet.c index ab7add695b13..c93705bc11a9 100644 --- a/subsys/net/l2/ethernet/ethernet.c +++ b/subsys/net/l2/ethernet/ethernet.c @@ -353,7 +353,8 @@ static enum net_verdict ethernet_recv(struct net_if *iface, net_buf_pull(pkt->frags, hdr_len); STRUCT_SECTION_FOREACH(net_l3_register, l3) { - if (l3->ptype != type || l3->l2 != &NET_L2_GET_NAME(ETHERNET)) { + if (l3->ptype != type || l3->l2 != &NET_L2_GET_NAME(ETHERNET) || + l3->handler == NULL) { continue; }