kprobe consume_skb faile
- Dominant language
- C
- Stars
- 22.7k
- Forks
- 4.1k
- Avg merge
- 10d 4h
- Merged PRs (30d)
- 3
Description
i run kprobe consume_skb programe sucees,but to read skb->data parsing HTTP Frame is empty or other character。and parsing http is not exsit. but i can get ssh session body infomation,i don't understand
I thought about it for days and didn't figure it out,please help me see question ,thanks
i try read `《understanding linux network internals》` and linux source,i did not debug succeed
code example :
```c
SEC("kprobe/consume_skb")
int BPF_KPROBE(consume_skb, struct sk_buff *skb, void *location) {
int data_len;
if (NULL != skb) {
// 读取字符串
unsigned char *data = BPF_CORE_READ(skb,head);
int header_len =
sizeof(struct ethhdr) + sizeof(struct iphdr) + sizeof(struct tcphdr);
char G, E, T;
bpf_probe_read(&G, sizeof(G), (data));
bpf_probe_read(&E, sizeof(E), (data + 1));
bpf_probe_read(&T, sizeof(T), (data + 2));
if (G != 0) {
// ((G > 47 && G < 58) || (G > 64 && G < 91) || (G > 96 && G < 123)) &&
if (((G != 'R' && E != 'T'))) {
if (G != 'l') {
// bpf_printk("BPF header_len %d -- %d -- %d \n", G, E, T);
//
bpf_printk("BPF data %s \n", data);
struct net_device *dev = BPF_CORE_READ(skb, dev);
char name[16];
bpf_core_read_str(&name, sizeof(name), dev->name);
// this is empty
bpf_printk("BPF dev name %c %c %c \n", name[0], name[1], name[2]);
}
}
}
}
return 0;
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the posted C example at the kprobe/consume_skb entry point, then compare its skb access with the Linux source and the networking internals reference mentioned in the issue. Reproduce or trace why skb data and the device name are empty, and document a verified explanation or correction for the reported HTTP and SSH observations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux
- Domain
- networking, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100