Skip to content

Commit 656bab0

Browse files
Vudentzjukkar
authored andcommitted
net: Introduce net_if_carrier_down
This introduces net_if_carrier_down so the L2 driver can inform when it has lost connectivity so all packets shall be flushed and the interface should be put down. Fixes #5317 Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 7e06be2 commit 656bab0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

subsys/net/ip/net_if.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,17 @@ int net_if_up(struct net_if *iface)
18761876
return 0;
18771877
}
18781878

1879+
void net_if_carrier_down(struct net_if *iface)
1880+
{
1881+
NET_DBG("iface %p", iface);
1882+
1883+
atomic_clear_bit(iface->flags, NET_IF_UP);
1884+
1885+
net_if_flush_tx(iface);
1886+
1887+
net_mgmt_event_notify(NET_EVENT_IF_DOWN, iface);
1888+
}
1889+
18791890
int net_if_down(struct net_if *iface)
18801891
{
18811892
int status;

subsys/net/ip/net_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
extern void net_pkt_init(void);
1919
extern void net_if_init(struct k_sem *startup_sync);
2020
extern void net_if_post_init(void);
21+
extern void net_if_carrier_down(struct net_if *iface);
2122
extern void net_context_init(void);
2223
enum net_verdict net_ipv4_process_pkt(struct net_pkt *pkt);
2324
enum net_verdict net_ipv6_process_pkt(struct net_pkt *pkt);

0 commit comments

Comments
 (0)