linux-kernel

How to extract entire packet from skb including ethernet header, ip, and tcp plus pay load in poll method of device driver

耗尽温柔 提交于 2021-02-11 12:05:58
问题 in r8169 driver from realtek it does rx_buf = page_address(tp->Rx_databuff[entry]); dma_sync_single_for_cpu(d, addr, pkt_size, DMA_FROM_DEVICE); prefetch(rx_buf); skb_copy_to_linear_data(skb, rx_buf, pkt_size);<----//Do I get packet at this???? skb->tail += pkt_size; skb->len = pkt_size; dma_sync_single_for_device(d, addr, pkt_size, DMA_FROM_DEVICE); //csum... skb->protocol = eth_type_trans(skb, dev); napi_gro_receive(&tp->napi, skb); this is inside rtl_rx function called from poll of driver.

Reference to “current” task in Linux Interrupt Context

流过昼夜 提交于 2021-02-11 08:15:51
问题 As I was going through the Interrupt Handling in Linux, I had this question if we can make reference to the current macro pointing to the interrupted task, while the core is in hard-irq mode? Also, if this referencing is possible whatwill happen if we make a call to semaphore "down", though this is highly discouraged.? 回答1: I believe it's possible to do, at least on x86, in the sense that it won't cause an immediate panic. It is however ALWAYS wrong to do this. An interrupt is not associated

Reference to “current” task in Linux Interrupt Context

人盡茶涼 提交于 2021-02-11 08:15:43
问题 As I was going through the Interrupt Handling in Linux, I had this question if we can make reference to the current macro pointing to the interrupted task, while the core is in hard-irq mode? Also, if this referencing is possible whatwill happen if we make a call to semaphore "down", though this is highly discouraged.? 回答1: I believe it's possible to do, at least on x86, in the sense that it won't cause an immediate panic. It is however ALWAYS wrong to do this. An interrupt is not associated

Cannot use set_memory_rw in Linux kernel on ARM64

元气小坏坏 提交于 2021-02-11 07:04:41
问题 I am trying to develop a kernel module that hooks the read() system call. for some reason the set_memory_rw() function does not seem to work. I saw another question of this sort but I didn't really understand what to do. I am working on Kali 4.19.93 with Raspberry-pi 4 My code: #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/moduleparam.h> #include <linux/syscalls.h> #include <linux/kallsyms.h> #include <linux/slab.h> #include <linux/kern_levels.h>

Cannot use set_memory_rw in Linux kernel on ARM64

老子叫甜甜 提交于 2021-02-11 07:03:17
问题 I am trying to develop a kernel module that hooks the read() system call. for some reason the set_memory_rw() function does not seem to work. I saw another question of this sort but I didn't really understand what to do. I am working on Kali 4.19.93 with Raspberry-pi 4 My code: #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/moduleparam.h> #include <linux/syscalls.h> #include <linux/kallsyms.h> #include <linux/slab.h> #include <linux/kern_levels.h>

pci_rescan_bus() doesn't rescan PCI bus in Linux

岁酱吖の 提交于 2021-02-11 05:59:32
问题 I am trying to rescan PCI bus in my own kernel driver with the help of pci_rescan_bus() kernel function but I do not see it is functioning same. If I try to do same from user space by running following command, I see that rescanning happens: echo 1 > /sys/devices/pci0000:00/0000:00:14.1/rescan I am trying to re-initialize my ethernet ports which sit on PCI bus. Below is the code I am using for now: struct pci_dev *pci_eth_dev01, *pci_eth_dev02 = NULL; pci_eth_dev01 = pci_get_device(0x10ec,

What is the predictable behavior of changing SOL_SOCKET, SO_RCVBUF on the fly on a UDP socket?

爱⌒轻易说出口 提交于 2021-02-10 15:35:42
问题 What should be expected to happen if we resize the input buffer of a UDP server socket on the fly on a Linux system? setsockopt(sock, SOL_SOCKET, SO_RCVBUF, ...) I am particularly interested in these questions: If I shrink below what is currently in the buffer, would this simply drop the oldest/newest? datagrams properly, or could it flush everything that's there, or worse could it corrupt data such as truncating a datagram? Would shrinking the buffer even save memory or something prevents

Unable to run bpf program as non root

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 14:35:44
问题 I am trying to run a simple bpf program that I wrote. But I am not able to run it as non root user. Below is the program I am trying to load, It basically gets the pointer to my map whose fd is map_fd (I am not showing the code where I create the map). It works as root but for some reason fails with non root user. Output of uname -a Linux 5.8.0-38-generic #43~20.04.1-Ubuntu SMP Tue Jan 12 16:39:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux BPF program BPF_MOV64_IMM(BPF_REG_0, 0), BPF_STX_MEM(BPF

is tcpdump affected by iptables filtering?

倖福魔咒の 提交于 2021-02-10 14:35:26
问题 If my development machine has an iptables rule to FORWARD some packets, are those packets being captured by tcpdump? I have this question because I know there exist other chain called INPUT which filters packets to apps, if a packet is routed to FORWARD chain, will it reach tcpdump app? May you make some reliable reference to official documentation or express well explained ideas to solve this question? 回答1: TCPDump captures traffic from the hardware device. Iptables handles network frames at

Device Tree dependency between two nodes

随声附和 提交于 2021-02-10 14:35:04
问题 I have two device tree nodes, one sets a gpio pin and the other one configures one i2c bus, ex: &gpio2 { en-gpio { gpio-hog; gpios = <5 0>; output-high; }; }; &i2c1 { gpiom1: gpio@27 { compatible = "microchip,mcp23008"; gpio-controller; #gpio-cells = <2>; reg = <0x27>; }; }; How can i add a dependency between the i2c node and gpio one? What i want to achieve is that the gpio pin should be set before the devices on i2c are initialized. 回答1: Short answer You can't provide dependency between