diff --git a/include/zephyr/net/net_if.h b/include/zephyr/net/net_if.h index 754ea7342bf..3b38b785571 100644 --- a/include/zephyr/net/net_if.h +++ b/include/zephyr/net/net_if.h @@ -857,7 +857,7 @@ static inline int net_if_set_link_addr_unlocked(struct net_if *iface, uint8_t *addr, uint8_t len, enum net_link_type type) { - if (net_if_flag_is_set(iface, NET_IF_UP)) { + if (net_if_flag_is_set(iface, NET_IF_RUNNING)) { return -EPERM; } diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index f8a4d2ebc59..f72b319658c 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -4035,6 +4035,21 @@ static inline bool is_iface_offloaded(struct net_if *iface) static void notify_iface_up(struct net_if *iface) { + /* In many places it's assumed that link address was set with + * net_if_set_link_addr(). Better check that now. + */ +#if defined(CONFIG_NET_L2_CANBUS_RAW) + if (IS_ENABLED(CONFIG_NET_SOCKETS_CAN) && + (net_if_l2(iface) == &NET_L2_GET_NAME(CANBUS_RAW))) { + /* CAN does not require link address. */ + } else +#endif /* CONFIG_NET_L2_CANBUS_RAW */ + { + if (!is_iface_offloaded(iface)) { + NET_ASSERT(net_if_get_link_addr(iface)->addr != NULL); + } + } + net_if_flag_set(iface, NET_IF_RUNNING); net_mgmt_event_notify(NET_EVENT_IF_UP, iface); net_virtual_enable(iface); @@ -4172,19 +4187,6 @@ int net_if_up(struct net_if *iface) goto out; } - /* In many places it's assumed that link address was set with - * net_if_set_link_addr(). Better check that now. - */ -#if defined(CONFIG_NET_L2_CANBUS_RAW) - if (IS_ENABLED(CONFIG_NET_SOCKETS_CAN) && - (net_if_l2(iface) == &NET_L2_GET_NAME(CANBUS_RAW))) { - /* CAN does not require link address. */ - } else -#endif /* CONFIG_NET_L2_CANBUS_RAW */ - { - NET_ASSERT(net_if_get_link_addr(iface)->addr != NULL); - } - done: net_if_flag_set(iface, NET_IF_UP); net_mgmt_event_notify(NET_EVENT_IF_ADMIN_UP, iface);