Netlink is a socket based inter process communication protocol for Linux systems. It is currently the preferred way, as of 2.6, of communicating with user space from the kernel.
Questions tagged [netlink]
337 questions
2
votes
1 answer
Manage Linux routing rules using RTNETLINK
I'm trying to write a small C based user space app that provides feature of managing routing rules using RTNETLINK. Below is an example accepting 3 arguments: add/del (rule), IP address and iface.
The problem with code below that it adds routing…

Ogy89
- 21
- 2
2
votes
1 answer
Linux carrier detection notification
Is there an interface in Linux to get notification of a network interface carrier change? I know its possible to poll an interface with SIOCETHTOOL, but was wondering if there was any way to get notified or any blocking calls that would return on…

tMC
- 18,105
- 14
- 62
- 98
2
votes
0 answers
linux c rtnetlink RTM_GETADDR ignores ifa_index in struct ifaddrmsg and instead outputs for all interfaces
When sending a "packet" to a rtnetlink socket to get the IP addresses of a specific interface then it answers with what appears to be data for all interfaces.
This is a small example program that illustrates my problem:
#include
#include…

Alexander Schütz
- 21
- 1
2
votes
0 answers
how to get qdisc plug state (buffered or released)?
I have two network namespaces (red at 192.168.15.1 and blue at 192.168.15.2) connected by a virtual ethernet cable. Red side, the device is named veth-red, blue side, it is named veth-blue.
Now i want to add a "plug" qdisc to veth-blue, I'm doing it…

MatMo
- 51
- 1
- 3
2
votes
1 answer
Audit netlink response don't have the right packet length
I have been trying to read the linux audit logs from go using mdlayher/netlink. I am able to make a connection and set the PID as well to be able to receive logs from the netlink socket over unicast and multicast.
The problem is, when the library…

prateeknischal
- 752
- 4
- 12
2
votes
1 answer
How to get WiFi security key(WPA, WPA2, ESS) of scanned networks using NL80211_BSS_CAPABILITY?
I'm using netlink library nl80211.h to scan wifi networks and successfully getting ssid, mac address, status, frequency and signal. I want to add security type of every network using same library.
I'm using NL80211_BSS_CAPABILITY as one of the enums…

iambhaskaranand
- 23
- 1
- 5
2
votes
0 answers
is netlink synchronous or asynchronous protocol?
I was reading various resources about netlink, and they all say that the netlink communication protocol is asynchronous (example: https://www.opensourceforu.com/2015/08/netlink-a-communication-mechanism-in-linux/), however this confuses me: I think…

Mark
- 6,052
- 8
- 61
- 129
2
votes
1 answer
Request list of attached devices from netlink socket
I am working on a C++ application for embedded devices that listens to USB hotplug events via a netlink socket. Detecting events works flawlessly but additionally I would like to query already attached devices in the beginning of the program. I was…

teawolf
- 31
- 4
2
votes
2 answers
How to reliably detect dropped netlink requests or responses
I'm interested in using netlink for a straightforward application (reading cgroup stats at high frequency).
The man page cautions that the protocol is not reliable, hinting that the application needs to be prepared to handle dropped…

jacobsa
- 5,719
- 1
- 28
- 60
2
votes
1 answer
Fetch dropped packet count of an interface with netlink sockets
I am familiar with different tools (like netstat, tcpdump, etc.) and files (like /sys/class/net//statistics) with which we can get the count.
But can anyone tell me if there is a way of getting that information directly from the kernel, using…

Dusan
- 95
- 5
2
votes
1 answer
Why the route items in the route table(fetched via netlink socket) doesn't have netmask info?
I'm writing a program to find out which network interface is the best to connect to a specified target address.
Right now, I can get the route table via netlink socket APIs, but seems there is no netmask infos in it. I read the manual of…

Chao Zhang
- 21
- 3
2
votes
1 answer
Why does Linux NETLINK man page provide C++ examples but not C?
I dealt with netlink API and examine its man pages netlink(3) and netlink(7).
Suddenly I faced with such construction:
struct msghdr msg;
msg = { &sa, sizeof(sa), &iov, 1, NULL, 0, 0 };
I tried it in C, but it gives the error:
error: expected…

z0lupka
- 236
- 4
- 19
2
votes
1 answer
get process inode using netlink
I want to try and correlate an IP packet (using libpcap) to a process. I have had some limited success using the relevant /proc/net/ files but found that on some of the machines i'm using, this file can be many thousands of lines and parsing it is…

incubus
- 681
- 1
- 5
- 21
2
votes
1 answer
Kernel to userspace application communication
I am trying to make Kernel (Android, kernel 4.9.59) communicate with userspace applications. I found a solution using Netlink sockets: https://stackoverflow.com/a/25071310/4190159
The first issue with the solution is that struct netlink_skb_parms…

Somdip Dey
- 3,346
- 6
- 28
- 60
2
votes
1 answer
Obtaining real device of VLAN-interface through the netlink
I need to obtain the real_dev (f.e. ID) of the given VLAN-inteface.
I wrote some test snippet using libnl:
int main(void) {
struct nl_sock *sock;
struct nl_cache *cache;
char iface[] = "eno1.10";
//char iface[] = "eno1";
if…

red0ct
- 4,840
- 3
- 17
- 44