kernel-module

Getting list of network devices inside the Linux kernel

不打扰是莪最后的温柔 提交于 2019-12-03 05:57:10
问题 I've been looking through net/core/dev.c and other files to try to find out how to get the list of network devices that are currently configured and it's proving to be a little difficult to find. The end goal is to be able to get network device statistics using dev_get_stats in dev.c, but I need to know the current interfaces so I can grab the net_device struct to pass in. I'm having to do this inside the kernel as I'm writing a module which adds in a new /proc/ entry which relates to some

Communication between Linux kernel and user space program

拜拜、爱过 提交于 2019-12-03 05:23:46
问题 I'm currently writing a Linux kernel module, and have problems implementing its communication with user space programs. This kernel module needs to receive tasks issued by a user space program, and send results back to user space program after completion. The user space program should be blocked while the kernel module is doing its job. I think a kernel-user space IPC or an Unix socket would be sweet, but I had no luck finding an example by Google. Currently my ugly solution is to export a

Yocto: Adding kernel module recipe to image, but it doesn't load on boot

一个人想着一个人 提交于 2019-12-03 04:49:36
For testing purposes, I am using the example recipe provided by yocto to demonstrate how to build kernel modules. SUMMARY = "Example of how to build an external Linux kernel module" LICENSE = "GPLv2" LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e" inherit module PR = "r0" PV = "0.1" SRC_URI = "file://Makefile \ file://hello.c \ file://COPYING \ " S = "${WORKDIR}" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. The hello.c file is very simple. #include <linux/module.h>

Using sk_buff to add an Ethernet frame header

懵懂的女人 提交于 2019-12-03 03:48:07
I have a kernel module that captures outgoing Internet traffic(Netfilter hook: LOCAL_OUT) At this hook, there's still no Ethernet header. I built the Ethernet header and it's ready to use, but how can I attach it to the skb so that I can send the whole skb struct to dev_queue_xmit() ? Is there any guide on how to manipulate sk_buff data that you can provide me for further information? As a sample, I try to do what I want to do on all ECHO ICMP traffic; this is the code I have. But when checking with Wireshark on the other machine, I get a working Ethernet header but an EMPTY IP packet...how

How do you create a loadable kernel module for Android?

你离开我真会死。 提交于 2019-12-03 02:27:36
问题 I know there a number of walkthroughs and tutorials floating around out there which describe this activity, but after having read many of them I still can't get this working. If anyone has the patience to wade through the steps I've taken (posted below) and suggest where I may have gone off track I'd be very appreciative. I've spent about a day and a half staring at make files and reading walkthroughs so literally any suggestions would be helpful. Environment: I'm using an Ubuntu 10.04 32 bit

How to stop Linux kernel threads on rmmod?

℡╲_俬逩灬. 提交于 2019-12-03 02:22:28
问题 I wrote the following code to create a kernel thread: #include<linux/init.h> #include<linux/module.h> #include<linux/kernel.h> #include<linux/kthread.h> #include<linux/sched.h> struct task_struct *task; int data; int ret; int thread_function(void *data) { int var; var = 10; return var; } static int kernel_init(void) { data = 20; printk(KERN_INFO"--------------------------------------------"); task = kthread_create(&thread_function,(void *)data,"pradeep"); task = kthread_run(&thread_function,

mapping memory reserved by mmap kernel boot param into user space

假装没事ソ 提交于 2019-12-03 00:33:37
As discussed in this question, i am reserving a memory chunk at the boot time using a kernel boot parameter memmap=8G$64G I have written a character driver kernel module which , during initialization does a ioremap of this reserved memory chunk. As explained here , in my driver mmap all i need to do is remap_pfn_range for this memory chunk pointer returned by the ioremap . I am running this on 3.0 linux kernel . My user space application opens this memory chunk as a device mounted by the driver. When i do mmap from the use space application i see a system hang. my dmesg don't provide me much

How does the Linux kernel determine the order of __init calls?

北城以北 提交于 2019-12-02 19:44:48
There are many instances of __init calls in kernel both in drivers module_init and other functions of kernel. My doubt is how exactly kernel determines the sequence of the __init call. More importantly, How it also determine the sequence of driver module_init call? Ilya Matveychikov All the init magic are implemented in files: include/asm-generic/vmlinux.lds.h include/linux/init.h init/main.c Firstly, look at include/asm-generic/vmlinux.lds.h that contains the following : 13 * . = START; 14 * __init_begin = .; 15 * HEAD_TEXT_SECTION 16 * INIT_TEXT_SECTION(PAGE_SIZE) 17 * INIT_DATA_SECTION(...)

Communication between Linux kernel and user space program

霸气de小男生 提交于 2019-12-02 18:55:52
I'm currently writing a Linux kernel module, and have problems implementing its communication with user space programs. This kernel module needs to receive tasks issued by a user space program, and send results back to user space program after completion. The user space program should be blocked while the kernel module is doing its job. I think a kernel-user space IPC or an Unix socket would be sweet, but I had no luck finding an example by Google. Currently my ugly solution is to export a chardev and let user space program write requests to the device file, and read results from it. But I can

How do you create a loadable kernel module for Android?

ε祈祈猫儿з 提交于 2019-12-02 15:58:42
I know there a number of walkthroughs and tutorials floating around out there which describe this activity, but after having read many of them I still can't get this working. If anyone has the patience to wade through the steps I've taken (posted below) and suggest where I may have gone off track I'd be very appreciative. I've spent about a day and a half staring at make files and reading walkthroughs so literally any suggestions would be helpful. Environment: I'm using an Ubuntu 10.04 32 bit vm. I'm hosting from a 64 bit windows 7 My Core 2 Duo does not have the hardware support for 64 bit