Skip to content

Commit 5076f5e

Browse files
jukkarkartben
authored andcommitted
net: l2: virtual: Handle the packet if no attached interfaces
If there are no virtual interfaces attached to this virtual interface, check if there is a RX handler for this virtual interface and pass data to it. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent 799742a commit 5076f5e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

subsys/net/l2/virtual/virtual.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,32 @@ static enum net_verdict virtual_recv(struct net_if *iface,
6969
return verdict;
7070
}
7171

72+
if (IS_ENABLED(CONFIG_NET_STATISTICS)) {
73+
size_t pkt_len;
74+
75+
pkt_len = net_pkt_get_len(pkt);
76+
77+
NET_DBG("Received pkt %p len %zu", pkt, pkt_len);
78+
79+
net_stats_update_bytes_recv(iface, pkt_len);
80+
}
81+
82+
/* If there are no virtual interfaces attached, then pass the packet
83+
* to the actual virtual network interface.
84+
*/
85+
api = net_if_get_device(iface)->api;
86+
if (!api || api->recv == NULL) {
87+
goto drop;
88+
}
89+
90+
if (!net_if_is_up(iface)) {
91+
NET_DBG("Interface %d is down.", net_if_get_by_iface(iface));
92+
goto drop;
93+
}
94+
95+
return api->recv(iface, pkt);
96+
97+
drop:
7298
NET_DBG("No handler, dropping pkt %p len %zu", pkt, net_pkt_get_len(pkt));
7399

74100
return NET_DROP;

0 commit comments

Comments
 (0)