Commit 137733d0 authored by Yaqi Chen's avatar Yaqi Chen Committed by Alexei Starovoitov

samples/bpf: Fix broken tracex1 due to kprobe argument change

>From commit c0bbbdc3 ("__netif_receive_skb_core: pass skb by
reference"), the first argument passed into __netif_receive_skb_core
has changed to reference of a skb pointer.

This commit fixes by using bpf_probe_read_kernel.
Signed-off-by: default avatarYaqi Chen <chendotjs@gmail.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarYonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210416154803.37157-1-chendotjs@gmail.com
parent 900367b2
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
SEC("kprobe/__netif_receive_skb_core") SEC("kprobe/__netif_receive_skb_core")
int bpf_prog1(struct pt_regs *ctx) int bpf_prog1(struct pt_regs *ctx)
{ {
/* attaches to kprobe netif_receive_skb, /* attaches to kprobe __netif_receive_skb_core,
* looks for packets on loobpack device and prints them * looks for packets on loobpack device and prints them
*/ */
char devname[IFNAMSIZ]; char devname[IFNAMSIZ];
...@@ -35,7 +35,7 @@ int bpf_prog1(struct pt_regs *ctx) ...@@ -35,7 +35,7 @@ int bpf_prog1(struct pt_regs *ctx)
int len; int len;
/* non-portable! works for the given kernel only */ /* non-portable! works for the given kernel only */
skb = (struct sk_buff *) PT_REGS_PARM1(ctx); bpf_probe_read_kernel(&skb, sizeof(skb), (void *)PT_REGS_PARM1(ctx));
dev = _(skb->dev); dev = _(skb->dev);
len = _(skb->len); len = _(skb->len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment