net: if: Allow to set LL address after interface was brough admin UP

Bluetooth IPSP L2 sets the LL address only after establishing Bluetooth
connection. As this can take place after the interface was brough UP by
the application, the network interface API should not block such
attempt. Instead, verify the NET_IF_RUNNING flag.

For the same reason, move the assert verifying that LL address is set
from net_if_up() (which only puts the interface in the admin UP state)
into the function that transitions the interface into operational UP
state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2022-12-09 13:54:19 +01:00 committed by Carles Cufí
commit 129f34fd0b
2 changed files with 16 additions and 14 deletions

View file

@ -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);