Questions tagged [netlink]

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.

337 questions
0
votes
0 answers

How can I handle a netlink event without a waiting cycle?

I'm writing a PCI linux driver that handles an interrupt and sends a notification to the user-space program with netlink socket. It works, but user-space program is blocked while waiting for an event( nl_recvmsgs_default() function ). Is it possible…
0
votes
1 answer

Exceptions are seeing while Monitoring Ethernet interface kernel events using pyroute2 IPDB functionality

I am trying to monitor the kernel network interface(link) up or down events using pyroute2 IPDB functionality. Exceptions are seen while fetching the interface index information from the callback function. But here in the "msg" there is an index…
rishi narian
  • 373
  • 1
  • 12
0
votes
0 answers

An EAGAIN error when writing from kernel to user space app

I have this issue, that happens once in a while for no clear reason: I have kernel module, that sends messages to user space deamon application using genlmsg_unicast(). After some time, all messages start to fail and the error code is -11…
0
votes
0 answers

debug netlink messages using nlmon devices

How do you create a nlmon device? Is it supported? $ uname -r 4.10.0-42-generic $ cat /boot/config-4.10.0-42-generic | grep NLMON CONFIG_NLMON=m $ modprobe nlmon modprobe: FATAL: Module nlmon not found in directory /lib/modules/4.10.0-42-generic
0
votes
0 answers

debug bpf code on netlink messages

I am writing a bpf filter to prevent certain netlink messages. I am trying to debug the bpf code. Is there any debug tool that could help me? I was initially thinking of using nlmon to capture netlink messages: From…
0
votes
1 answer

Retrieve unaligned netlink message size in kernel space

I am working on a Linux kernel module which has a bi-directional communication link with a userspace module provided by netlink. I have an issue with an incorrect message length calculation on messages sent from userspace to kernel space. The…
trigger
  • 108
  • 7
0
votes
1 answer

Casting between sequential unsafe structs

I'm trying to port some netlink socket code from C to C#. The code is the same as in the link: First, we port sockaddr_nl structure (c source): [StructLayout(LayoutKind.Sequential)] public struct sockaddr_nl { public ushort nl_family; public…
turbo
  • 1,233
  • 14
  • 36
0
votes
2 answers

Netlink sockets

I am trying send a list/array of struct to kernel space from userspace. Similar to Link As recommended there, I am thinking of using sockets for which i found link. Message is set hello in this line strcpy(NLMSG_DATA(nlh), "Hello"); I…
Alkesh
  • 61
  • 1
  • 3
  • 9
0
votes
2 answers

NetLink Message Memory Issue

I am trying to send messages from user space to kernel. I am able to send it succesfully via netlink sockets. But I would like to know whether I should free the messages in kernel function which I have written or netlink socket API's are…
0
votes
0 answers

Permanently save Netlink Sockets changes

In order to set Network Interfaces on Ubuntu 16.04 LTS I've recently developed a C program which takes advantage of Netlink Sockets for interprocess communication between User-Space and Kernel-Space. After having successfully changed the…
SimoBrazz
  • 81
  • 7
0
votes
0 answers

mnl_socket_bind with setsockopt(..., SO_REUSEADDR | SO_REUSEPORT ...) address already in use?

I am trying to get multiple sockets to bind to the same address/port on the same machine, listening for multicasts. Here is a bit of the code: struct mnl_socket *nl; nl = mnl_socket_open(NETLINK_USERSOCK); if (NULL == nl) { …
Fuad
  • 1,419
  • 1
  • 16
  • 31
0
votes
1 answer

netlink and big endian format

I have not found any document/note in the kernel that would mandate to pass 16/32-bit values in netlink messages towards the kernel in network byte order. So my question is if I have to use htonl/htons functions when filling up netlink message. Is…
Mark
  • 6,052
  • 8
  • 61
  • 129
0
votes
1 answer

How to trigger first recv message on a socket to get NETLINK status

I am getting the current status of my link whenever it changes (based on this answer) however I need to get the initial status when my daemon starts up. This is what I have. void read_msg(int fd) { // loop through the struct nlmsghdr and pull…
jiveturkey
  • 2,484
  • 1
  • 23
  • 41
0
votes
1 answer

Does libevent support netlink socket

I use netlink to receive an interrupt number from kernel. The application in user space uses libevent to handle TCP/IP request and netlink message. Does libevent support Linux netlink socket? I will appreciate for a simple example.
sfzhang
  • 669
  • 9
  • 18
0
votes
1 answer

Fetch neighbor table from linux

Does libnl allows to fetch the neighbor table from linux kernel? I tried using the API rtnl_neightbl_get but I fail to fetch the entries in the cache. Only the entries with "lo" as their interface are fetched. How can I dump the entire table? I am…