History

bpf: Add flags arg to bpf_dynptr_read and bpf_dynptr_write APIs

Commit 13bbbfbea759 ("bpf: Add bpf_dynptr_read and bpf_dynptr_write") added the bpf_dynptr_write() and bpf_dynptr_read() APIs. However, it will be needed for some dynptr types to pass in flags as well (e.g. when writing to a skb, the user may like to invalidate the hash or recompute the checksum). This patch adds a "u64 flags" arg to the bpf_dynptr_read() and bpf_dynptr_write() APIs before their UAPI signature freezes where we then cannot change them anymore with a 5.19.x released kernel.

Joanne Koong committed 4 years ago

Commit f8d3da41 parent 03261955 files · +29 −19Browse files

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

Unified · Split

include/uapi/linux/bpf.h+7−4
@@ -5222,22 +5222,25 @@ union bpf_attr { · 5221 unmodified lines
52225222 * Return
52235223 * Nothing. Always succeeds.
52245224 *
5225− * long bpf_dynptr_read(void *dst, u32 len, struct bpf_dynptr *src, u32 offset)
5225+ * long bpf_dynptr_read(void *dst, u32 len, struct bpf_dynptr *src, u32 offset, u64 flags)
52265226 * Description
52275227 * Read *len* bytes from *src* into *dst*, starting from *offset*
52285228 * into *src*.
5229+ * *flags* is currently unused.
52295230 * Return
52305231 * 0 on success, -E2BIG if *offset* + *len* exceeds the length
5231− * of *src*'s data, -EINVAL if *src* is an invalid dynptr.
5232+ * of *src*'s data, -EINVAL if *src* is an invalid dynptr or if
5233+ * *flags* is not 0.
52325234 *
5233− * long bpf_dynptr_write(struct bpf_dynptr *dst, u32 offset, void *src, u32 len)
5235+ * long bpf_dynptr_write(struct bpf_dynptr *dst, u32 offset, void *src, u32 len, u64 flags)
52345236 * Description
52355237 * Write *len* bytes from *src* into *dst*, starting from *offset*
52365238 * into *dst*.
5239+ * *flags* is currently unused.
52375240 * Return
52385241 * 0 on success, -E2BIG if *offset* + *len* exceeds the length
52395242 * of *dst*'s data, -EINVAL if *dst* is an invalid dynptr or if *dst*
5240− * is a read-only dynptr.
5243+ * is a read-only dynptr or if *flags* is not 0.
52415244 *
52425245 * void *bpf_dynptr_data(struct bpf_dynptr *ptr, u32 offset, u32 len)
52435246 * Description