Skip to content

Commit 2c21048

Browse files
rlubosnashif
authored andcommitted
net: core: Verify interface state in net_try_send_data()
Verify that the interface is in operational UP state before attempting to send the packet with net_send_data() / net_try_send_data(). So far there's only been an NET_IF_LOWER_UP check in a lower level function, net_if_try_send_data(), however that didn't work well with interface like Wi-Fi, whouch could have carrier state set to ON, but was still not associated with the network (so the interface was no operational UP). Protocols like ICMP or DHCP, which use net_send_data() directly, should not be able to send packets in such case. Signed-off-by: Robert Lubos <[email protected]>
1 parent 75dfc05 commit 2c21048

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

subsys/net/ip/net_core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,11 @@ int net_try_send_data(struct net_pkt *pkt, k_timeout_t timeout)
384384
goto err;
385385
}
386386

387+
if (!net_if_is_up(net_pkt_iface(pkt))) {
388+
ret = -ENETDOWN;
389+
goto err;
390+
}
391+
387392
net_pkt_trim_buffer(pkt);
388393
net_pkt_cursor_init(pkt);
389394

0 commit comments

Comments
 (0)