Usually as a part of network software development you do socket programming. But this is typically done in user-space, where the user-space socket APIs takes the instructions (via socket API arguments) and passes down to kernel to establish and maintain the socket connections. Although internally its actually kernel does via IPv4 stack or IPv6 stack or raw-sockets, it is provided as an abstract service to the user-space applications.
But there are cases actually being inside kernel-space we can do socket-programming. This is highly uncommon and niche. But this happens here and there. For example in the case of Wireguard VPN, it generates UDP sockets to carry its VPN encapsulated traffic all within the kernel-space via Wireguard network driver.
I had also stumbled across an interesting open-source Github sample source-code where the author provides a framework to do kernel-space socket-programming.
So here is my detailed YouTube video and overall introduction of Linux Kernel-space socket programming.
Refer;
VPN and Tunnel Network Overheads – MTU – Tunnel Headers – VPN Packet Encapsulations #vpn #networking #sdwan ↗
VPN Stack Architecture – Linux Kernel Virtual Network Interfaces – OpenVPN – Wireguard – VTun – IPsec ↗
Linux TUN/TAP virtual network interfaces ↗
Linux (user-space) RAW Socket Programming ↗
ksocket API – BSD-style socket API in kernel space for TCP/IP networking ↗
VTun ↗
WireGuard ↗
OpenVPN ↗
Linux Kernel Wireguard source
https://elixir.bootlin.com/linux/latest/source/drivers/net/wireguard
https://elixir.bootlin.com/linux/latest/source/drivers/net/wireguard/socket.c
https://elixir.bootlin.com/linux/latest/source/drivers/net/wireguard/socket.h
I also conduct sessions/classes on Systems and Network Software Programming, Linux Kernel Programming and Architecture. If you are interested, click HERE for more details.
If you have any queries or anything to discuss further on Linux Kernel Programming and writing Kernel modules kindly feel free to contact me.