netlink

How to send and receive messages from function other than registered callback function in Netlink socket?

左心房为你撑大大i 提交于 2021-02-18 19:10:14
问题 In following kernel module, I hooked syscall sys_open, and now trying to send filename to process in userspace using Netlink socket, in response process will return a msg, and then according to msg, the kernel module will proceed further. source code: foo.c #include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <asm/uaccess.h> #include <asm/cacheflush.h> #include <linux/syscalls.h> #include <linux/delay.h> // loops_per_jiffy //===============netlink===============

How to send and receive messages from function other than registered callback function in Netlink socket?

别等时光非礼了梦想. 提交于 2021-02-18 19:10:12
问题 In following kernel module, I hooked syscall sys_open, and now trying to send filename to process in userspace using Netlink socket, in response process will return a msg, and then according to msg, the kernel module will proceed further. source code: foo.c #include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <asm/uaccess.h> #include <asm/cacheflush.h> #include <linux/syscalls.h> #include <linux/delay.h> // loops_per_jiffy //===============netlink===============

How to send and receive messages from function other than registered callback function in Netlink socket?

混江龙づ霸主 提交于 2021-02-18 19:07:13
问题 In following kernel module, I hooked syscall sys_open, and now trying to send filename to process in userspace using Netlink socket, in response process will return a msg, and then according to msg, the kernel module will proceed further. source code: foo.c #include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <asm/uaccess.h> #include <asm/cacheflush.h> #include <linux/syscalls.h> #include <linux/delay.h> // loops_per_jiffy //===============netlink===============

cannot understand this “message sequence mismatch error”

本小妞迷上赌 提交于 2021-01-27 11:50:38
问题 I've used the program answered in this link with some modifications. Below is my modified code: #include <linux/netlink.h> #include <netlink/netlink.h> #include <netlink/route/qdisc.h> #include <netlink/route/qdisc/plug.h> #include <netlink/socket.h> #include <atomic> #include <csignal> #include <iostream> #include <stdexcept> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <thread> #include <queue> #include <chrono> /** * Netlink route socket. */ struct Socket {

Different package present in /usr/lib/x86_64-linux-gnu/

℡╲_俬逩灬. 提交于 2020-12-31 06:48:11
问题 I'm running this command nl-qdisc-add --dev=veth-host --parent=root plug --limit=32768 It throws an error of Error: Unable to load module "/usr/lib/x86_64-linux-gnu/libnl/cli/qdisc/plug.so": /usr/lib/x86_64-linux-gnu/libnl/cli/qdisc/plug.so: cannot open shared object file: No such file or directory I looked into the folder and found that there was another folder present named libnl-3 with same files. I can't even rename it to run the command. How can i resolve this? Even if i successfully

Different package present in /usr/lib/x86_64-linux-gnu/

时光总嘲笑我的痴心妄想 提交于 2020-12-31 06:47:08
问题 I'm running this command nl-qdisc-add --dev=veth-host --parent=root plug --limit=32768 It throws an error of Error: Unable to load module "/usr/lib/x86_64-linux-gnu/libnl/cli/qdisc/plug.so": /usr/lib/x86_64-linux-gnu/libnl/cli/qdisc/plug.so: cannot open shared object file: No such file or directory I looked into the folder and found that there was another folder present named libnl-3 with same files. I can't even rename it to run the command. How can i resolve this? Even if i successfully

Netlink: sending from kernel to user - EAGAIN and ENOBUFS

我的未来我决定 提交于 2020-07-21 10:26:48
问题 I'm having a lot of trouble sending netlink messages from kernel module to userspace-daemon. They randomly fail. On the kernel side, the genlmsg_unicast fails with EAGAIN while on the user-side, nl_recvmsgs_default (function from libnl ) fails with NLE_NOMEM which is caused by recvmsg syscall failing with ENOBUFS . Netlink messages are small, maximum payload size is ~300B. Here is the code for sending message from kernel: int send_to_daemon(void* msg, int len, int command, int seq, u32 pid) {

Netlink: sending from kernel to user - EAGAIN and ENOBUFS

﹥>﹥吖頭↗ 提交于 2020-07-21 10:22:46
问题 I'm having a lot of trouble sending netlink messages from kernel module to userspace-daemon. They randomly fail. On the kernel side, the genlmsg_unicast fails with EAGAIN while on the user-side, nl_recvmsgs_default (function from libnl ) fails with NLE_NOMEM which is caused by recvmsg syscall failing with ENOBUFS . Netlink messages are small, maximum payload size is ~300B. Here is the code for sending message from kernel: int send_to_daemon(void* msg, int len, int command, int seq, u32 pid) {

wpa_supplicant与kernel的接口

我怕爱的太早我们不能终老 提交于 2020-03-01 10:22:08
1. 接口定义实现wpa_drivers wpa_drivers的定义如下: [cpp] view plain copy struct wpa_driver_ops *wpa_drivers[] = { #ifdef CONFIG_DRIVER_WEXT &wpa_driver_wext_ops, // 我的系统使用的这个老的接口 #endif #ifdef CONFIG_DRIVER_NL80211 // 现在流行的NL80211接口 &wpa_driver_nl80211_ops, #endif #ifdef CONFIG_DRIVER_HOSTAP &wpa_driver_hostap_ops, #endif #ifdef CONFIG_DRIVER_MADWIFI &wpa_driver_madwifi_ops, #endif #ifdef CONFIG_DRIVER_BROADCOM &wpa_driver_broadcom_ops, #endif #ifdef CONFIG_DRIVER_BSD &wpa_driver_bsd_ops, #endif #ifdef CONFIG_DRIVER_NDIS &wpa_driver_ndis_ops, #endif #ifdef CONFIG_DRIVER_WIRED &wpa_driver_wired_ops, #endif