Network stack not recovering form Filled Buffers.

The network stack from Zephyr is not working correctly on my nrf5340. I want to receive data from a custom driver through the network stack to my application. For this, I request network packets to be allocated and fill them with data.

Using the packet manager from: docs.nordicsemi.com/.../net_pkt.html, I was able to do this successfully. This is the code of the driver adding messages to the network stack:

	pkt = net_pkt_rx_alloc_with_buffer(ctx->iface, rx_len, AF_UNSPEC, 0, K_MSEC(100));
	if (!pkt)
	{
		LOG_ERR("Message NMR: %lld, ERROR: Failed to allocate RX buffer. Wanted to allocate: %d Bytes", MessageCouter, rx_len);
		eth_stats_update_errors_rx(ctx->iface);
		w6100_command(dev, W6100_RV_SR_CR_RECV);
		return;
	}

	read_len = rx_len;
	reader = off + 2;

	do
	{
		size_t frag_len;
		uint8_t *data_ptr;
		size_t frame_len;

		data_ptr = pkt_buf->data;

		frag_len = net_buf_tailroom(pkt_buf);

		if (read_len > frag_len)
		{
			frame_len = frag_len;
		}
		else
		{
			frame_len = read_len;
		}

		w6100_readbuf(dev, reader, data_ptr, frame_len);
		net_buf_add(pkt_buf, frame_len);
		reader += frame_len;

		read_len -= frame_len;

		if (pkt_buf->frags == NULL && read_len > 0 && read_len >= frame_len)
		{
			LOG_ERR("Message NMR: %lld, ERROR: Buffer Filled Dropping remaining message", MessageCouter);
			read_len = 0;
		}
		else
		{
			pkt_buf = pkt_buf->frags;
		}

	} while (read_len > 0);

	if (net_pkt_is_empty(pkt))
	{
		LOG_ERR("Message NMR: %lld, ERROR: Packet is empty", MessageCouter);
		// net_pkt_unref(pkt);
		// w6100_command(dev, W6100_RV_SR_CR_RECV);
		// return;
	}
	

	int ret = net_recv_data(ctx->iface, pkt);

	if (ret < 0)
	{
		LOG_ERR("Message NMR: %lld, Failed to notify uperstack of nieuw network message, Err: %d", MessageCouter, ret);
		net_pkt_unref(pkt);
	}


The problem occurs when the buffer fills up and there is no more room to allocate. It declines allocation and continues to handle the error.

The network stack, however, seems to never regain space to allocate new buffers. And the network stack function zsock_recvfrom does not output any messages. I have tried lowering and raising the priority of the driver thread, but it did not seem to change anything. This occurs at high traffic but is not solved by lowering or temporarily stopping traffic.

Why could this be occurring?
Especially why does the network stack stop freeing my packets?

Some Screen shots after buffer filled:


Screen shots before buffer filled:

Related