Commit b9968e9d authored by Cla Mattia Galliard's avatar Cla Mattia Galliard Committed by Benjamin Cabé
Browse files

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: default avatarCla Mattia Galliard <clamattia@gmail.com>
parent 0327bb1a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -211,9 +211,9 @@ static void reassemble_packet(struct net_ipv4_reassembly *reass)
	/* We need to use the queue when feeding the packet back into the
	 * IP stack as we might run out of stack if we call processing_data()
	 * directly. As the packet does not contain link layer header, we
	 * MUST NOT pass it to L2 so there will be a special check for that
	 * in process_data() when handling the packet.
	 * MUST NOT pass it to L2 so mark it as l2_processed.
	 */
	net_pkt_set_l2_processed(pkt, true);
	if (net_recv_data(net_pkt_iface(pkt), pkt) >= 0) {
		return;
	}
+2 −2
Original line number Diff line number Diff line
@@ -346,9 +346,9 @@ static void reassemble_packet(struct net_ipv6_reassembly *reass)
	/* We need to use the queue when feeding the packet back into the
	 * IP stack as we might run out of stack if we call processing_data()
	 * directly. As the packet does not contain link layer header, we
	 * MUST NOT pass it to L2 so there will be a special check for that
	 * in process_data() when handling the packet.
	 * MUST NOT pass it to L2 so mark it as l2_processed.
	 */
	net_pkt_set_l2_processed(pkt, true);
	if (net_recv_data(net_pkt_iface(pkt), pkt) >= 0) {
		return;
	}
+2 −13
Original line number Diff line number Diff line
@@ -67,9 +67,6 @@ LOG_MODULE_REGISTER(net_core, CONFIG_NET_CORE_LOG_LEVEL);
static inline enum net_verdict process_data(struct net_pkt *pkt)
{
	int ret;
	bool locally_routed = false;

	net_pkt_set_l2_processed(pkt, false);

	/* Initial call will forward packets to SOCK_RAW packet sockets. */
	ret = net_packet_socket_input(pkt, ETH_P_ALL);
@@ -77,13 +74,6 @@ static inline enum net_verdict process_data(struct net_pkt *pkt)
		return ret;
	}

	/* If the packet is routed back to us when we have reassembled an IPv4 or IPv6 packet,
	 * then do not pass it to L2 as the packet does not have link layer headers in it.
	 */
	if (net_pkt_is_ip_reassembled(pkt)) {
		locally_routed = true;
	}

	/* If there is no data, then drop the packet. */
	if (!pkt->frags) {
		NET_DBG("Corrupted packet (frags %p)", pkt->frags);
@@ -92,8 +82,9 @@ static inline enum net_verdict process_data(struct net_pkt *pkt)
		return NET_DROP;
	}

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

	net_pkt_set_l2_processed(pkt, true);

	/* L2 has modified the buffer starting point, it is easier
	 * to re-initialize the cursor rather than updating it.
	 */