Skip to content

Commit 542688a

Browse files
committed
net_core: Decide about l2-processing based on l2_processed-flag
Use the l2_processed-flag to decide whether a network packet needs to be processed by an L2-handler. This could be used in the future to requeue packets for later processing by a different traffic class queue. Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
1 parent dadb7bf commit 542688a

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

subsys/net/ip/ipv4_fragment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ static void reassemble_packet(struct net_ipv4_reassembly *reass)
211211
/* We need to use the queue when feeding the packet back into the
212212
* IP stack as we might run out of stack if we call processing_data()
213213
* directly. As the packet does not contain link layer header, we
214-
* MUST NOT pass it to L2 so there will be a special check for that
215-
* in process_data() when handling the packet.
214+
* MUST NOT pass it to L2 so mark it as l2_processed.
216215
*/
216+
net_pkt_set_l2_processed(pkt, true);
217217
if (net_recv_data(net_pkt_iface(pkt), pkt) >= 0) {
218218
return;
219219
}

subsys/net/ip/ipv6_fragment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ static void reassemble_packet(struct net_ipv6_reassembly *reass)
346346
/* We need to use the queue when feeding the packet back into the
347347
* IP stack as we might run out of stack if we call processing_data()
348348
* directly. As the packet does not contain link layer header, we
349-
* MUST NOT pass it to L2 so there will be a special check for that
350-
* in process_data() when handling the packet.
349+
* MUST NOT pass it to L2 so mark it as l2_processed.
351350
*/
351+
net_pkt_set_l2_processed(pkt, true);
352352
if (net_recv_data(net_pkt_iface(pkt), pkt) >= 0) {
353353
return;
354354
}

subsys/net/ip/net_core.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,13 @@ LOG_MODULE_REGISTER(net_core, CONFIG_NET_CORE_LOG_LEVEL);
6767
static inline enum net_verdict process_data(struct net_pkt *pkt)
6868
{
6969
int ret;
70-
bool locally_routed = false;
71-
72-
net_pkt_set_l2_processed(pkt, false);
7370

7471
/* Initial call will forward packets to SOCK_RAW packet sockets. */
7572
ret = net_packet_socket_input(pkt, ETH_P_ALL);
7673
if (ret != NET_CONTINUE) {
7774
return ret;
7875
}
7976

80-
/* If the packet is routed back to us when we have reassembled an IPv4 or IPv6 packet,
81-
* then do not pass it to L2 as the packet does not have link layer headers in it.
82-
*/
83-
if (net_pkt_is_ip_reassembled(pkt)) {
84-
locally_routed = true;
85-
}
86-
8777
/* If there is no data, then drop the packet. */
8878
if (!pkt->frags) {
8979
NET_DBG("Corrupted packet (frags %p)", pkt->frags);
@@ -92,8 +82,9 @@ static inline enum net_verdict process_data(struct net_pkt *pkt)
9282
return NET_DROP;
9383
}
9484

95-
if (!net_pkt_is_loopback(pkt) && !locally_routed) {
85+
if (!net_pkt_is_loopback(pkt) && !net_pkt_is_l2_processed(pkt)) {
9686
ret = net_if_recv_data(net_pkt_iface(pkt), pkt);
87+
net_pkt_set_l2_processed(pkt, true);
9788
if (ret != NET_CONTINUE) {
9889
if (ret == NET_DROP) {
9990
NET_DBG("Packet %p discarded by L2", pkt);
@@ -105,8 +96,6 @@ static inline enum net_verdict process_data(struct net_pkt *pkt)
10596
}
10697
}
10798

108-
net_pkt_set_l2_processed(pkt, true);
109-
11099
/* L2 has modified the buffer starting point, it is easier
111100
* to re-initialize the cursor rather than updating it.
112101
*/

0 commit comments

Comments
 (0)