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:
parent
f38d5f440f
commit
129f34fd0b
2 changed files with 16 additions and 14 deletions
|
@ -857,7 +857,7 @@ static inline int net_if_set_link_addr_unlocked(struct net_if *iface,
|
||||||
uint8_t *addr, uint8_t len,
|
uint8_t *addr, uint8_t len,
|
||||||
enum net_link_type type)
|
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;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4035,6 +4035,21 @@ static inline bool is_iface_offloaded(struct net_if *iface)
|
||||||
|
|
||||||
static void notify_iface_up(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_if_flag_set(iface, NET_IF_RUNNING);
|
||||||
net_mgmt_event_notify(NET_EVENT_IF_UP, iface);
|
net_mgmt_event_notify(NET_EVENT_IF_UP, iface);
|
||||||
net_virtual_enable(iface);
|
net_virtual_enable(iface);
|
||||||
|
@ -4172,19 +4187,6 @@ int net_if_up(struct net_if *iface)
|
||||||
goto out;
|
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:
|
done:
|
||||||
net_if_flag_set(iface, NET_IF_UP);
|
net_if_flag_set(iface, NET_IF_UP);
|
||||||
net_mgmt_event_notify(NET_EVENT_IF_ADMIN_UP, iface);
|
net_mgmt_event_notify(NET_EVENT_IF_ADMIN_UP, iface);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue