History

bpf: add bpf_set_hash helper for tc progs

Allow for tc BPF programs to set a skb->hash, apart from clearing and triggering a recalc that we have right now. It allows for BPF to implement a custom hashing routine for skb_get_hash().

Daniel Borkmann committed 9 years ago

Commit ded092c1 parent 966789f3 files · +34 −2Browse files

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

Unified · Split

include/uapi/linux/bpf.h+7−1
@@ -513,6 +513,11 @@ union bpf_attr { · 512 unmodified lines
513513 * Get the owner uid of the socket stored inside sk_buff.
514514 * @skb: pointer to skb
515515 * Return: uid of the socket owner on success or overflowuid if failed.
516+ *
517+ * u32 bpf_set_hash(skb, hash)
518+ * Set full skb->hash.
519+ * @skb: pointer to skb
520+ * @hash: hash to set
516521 */
517522 #define __BPF_FUNC_MAPPER(FN) \
518523 FN(unspec), \
@@ -562,7 +567,8 @@ union bpf_attr { · 43 unmodified lines
562567 FN(xdp_adjust_head), \
563568 FN(probe_read_str), \
564569 FN(get_socket_cookie), \
565− FN(get_socket_uid),
570+ FN(get_socket_uid), \
571+ FN(set_hash),
566572
567573 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
568574 * function eBPF program intends to call