UA2F icon indicating copy to clipboard operation
UA2F copied to clipboard

NETLINK_NO_ENOBUFS: Potential packet drop in the large uplink bandwidth

Open SunBK201 opened this issue 3 months ago • 3 comments

I noticed that nfqueue-mnl.c sets the NETLINK_NO_ENOBUFS option:

https://github.com/Zxilly/UA2F/blob/2a64891c762f439aca0d12a26a7eb5a02f44831b/src/third/nfqueue-mnl/nfqueue-mnl.c#L608

This option suppresses errors resulting from an insufficient receive buffer.

According to the netlink(7) man page, netlink messages will be dropped if the receive buffer is insufficient:

However, reliable transmissions from kernel to user are impossible in any case. The kernel can't send a netlink message if the socket buffer is full: the message will be dropped and the kernel and the user-space process will no longer have the same view of kernel state. It is up to the application to detect when this happens (via the ENOBUFS error returned by recvmsg(2)) and resynchronize.

I also noticed that the receive buffer size used in mnl_socket_recvfrom is defined as RECV_BUF_LEN (8K + 0xffff):

https://github.com/Zxilly/UA2F/blob/2a64891c762f439aca0d12a26a7eb5a02f44831b/src/third/nfqueue-mnl/nfqueue-mnl.h#L202

I believe that a buffer size of 8K + 0xffff might be insufficient under heavy upstream traffic, possibly causing ENOBUFS error and resulting in netlink message drops.

A potential solution is to increase the receive buffer size using the SO_RCVBUFFORCE option.

SunBK201 avatar Nov 13 '25 11:11 SunBK201