History

bpf: introduce bpf_skb_vlan_push/pop() helpers

Allow eBPF programs attached to TC qdiscs call skb_vlan_push/pop via helper functions. These functions may change skb->data/hlen which are cached by some JITs to improve performance of ld_abs/ld_ind instructions. Therefore JITs need to recognize bpf_skb_vlan_push/pop() calls, re-compute header len and re-cache skb->data/hlen back into cpu registers. Note, skb->data/hlen are not directly accessible from the programs, so any changes to skb->data done either by these helpers or by other TC actions are safe. eBPF JIT supported by three architectures: - arm64 JIT is using bpf_load_pointer() without caching, so it's ok as-is. - x64 JIT re-caches skb->data/hlen unconditionally after vlan_push/pop calls (experiments showed that conditional re-caching is slower). - s390 JIT falls back to interpreter for now when bpf_skb_vlan_push() is present in the program (re-caching is tbd). These helpers allow more scalable handling of vlan from the programs. Instead of creating thousands of vlan netdevs on top of eth0 and attaching TC+ingress+bpf to all of them, the program can be attached to eth0 directly and manipulate vlans as necessary.

Alexei Starovoitov committed 11 years ago

Commit 4e10df91 parent f3120ac6 files · +99 −38Browse files

Showing the changes to include/uapi (1 of 6 files). Show all

Unified · Split

include/uapi/linux/bpf.h+2−0
@@ -256,6 +256,8 @@ enum bpf_func_id { · 255 unmodified lines
256 * Return: classid if != 0256 * Return: classid if != 0
257 */257 */
258 BPF_FUNC_get_cgroup_classid,258 BPF_FUNC_get_cgroup_classid,
259 BPF_FUNC_skb_vlan_push, /* bpf_skb_vlan_push(skb, vlan_proto, vlan_tci) */
260 BPF_FUNC_skb_vlan_pop, /* bpf_skb_vlan_pop(skb) */
259 __BPF_FUNC_MAX_ID,261 __BPF_FUNC_MAX_ID,
260};262};
261 263