On Thu, 2017-04-20 at 16:28 +0200, Daniel Borkmann wrote: > > I see what you mean now. Yes, that's fine. We already do something > similar essentially with skb->ifindex access already (skb->dev + > dev->ifindex), f.e.: > > [...] > case offsetof(struct __sk_buff, ifindex): > BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, ifindex) > != 4); > > *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, > dev), > si->dst_reg, si->src_reg, > offsetof(struct sk_buff, dev)); > *insn++ = BPF_JMP_IMM(BPF_JEQ, si->dst_reg, 0, 1); > *insn++ = BPF_LDX_MEM(BPF_W, si->dst_reg, si->dst_reg, > offsetof(struct net_device, > ifindex)); > break; > [...]
Oh, right, good point. > Which is not too different from the above. You'd probably need to > populate the struct wifi_data each time if you place it onto the > stack, but perhaps could be optimized by storing that somewhere > else (e.g. somewhere via netdev, etc) and walking the pointer from > there, which would also spare you the cb[] save/restore. Hmm. I don't see what "somewhere else" I could possibly have though, given that I want the (kernel-side) context to be "struct sk_buff *" to allow the skb helpers? johannes