Looking at the Linux Git kernel repository, it looks like neither PF_INET sockets nor PF_INET6 sockets support memory access, so if
My application only needs the standard linux interface of a UDP socket. I want to use package_mmap solely for efficiency - now syscalls consumes more than 50% of my processor cycles.
you mean that you want to use memory access for a regular UDP or TCP socket, unfortunately you cannot. The same goes for raw IP sockets.
Sockets
PF_PACKET support memory-compatible access, but they require elevated privileges, whether you use memory access or not. They do not replace the PF_INET or PF_INET6 ; they are a mechanism for reading and writing data link packets, so if you want to run regular Internet applications on them, good luck:
- You will have to reuse the IP address and any transport protocol you use (UDP, TCP, etc.);
- somehow you have to keep the IP kernel and transport protocol stack from processing these packets;
and you really don't want to do this.
(Note that with “elevated privileges” I do not necessarily mean “root privileges”; it is enough to have CAP_NET_RAW privileges. However, as I already noted, if you are trying to replace normal socket access, you want to use PF_PACKET sockets.)
user862787
source share