Skip to content

Commit

Permalink
bpf: Export bpf_dynptr_set_size
Browse files Browse the repository at this point in the history
It will be used by the following patch to shrink the size of dynptr when
the actual data length is smaller than the size of dynptr during
map_get_next_key operation.

Signed-off-by: Hou Tao <[email protected]>
  • Loading branch information
Hou Tao authored and Kernel Patches Daemon committed Jan 25, 2025
1 parent 1aad10d commit 19f1cf9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,7 @@ enum bpf_dynptr_type {
};

int bpf_dynptr_check_size(u32 size);
void bpf_dynptr_set_size(struct bpf_dynptr_kern *ptr, u32 new_size);
u32 __bpf_dynptr_size(const struct bpf_dynptr_kern *ptr);
const void *__bpf_dynptr_data(const struct bpf_dynptr_kern *ptr, u32 len);
void *__bpf_dynptr_data_rw(const struct bpf_dynptr_kern *ptr, u32 len);
Expand Down
2 changes: 1 addition & 1 deletion kernel/bpf/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ u32 __bpf_dynptr_size(const struct bpf_dynptr_kern *ptr)
return ptr->size & DYNPTR_SIZE_MASK;
}

static void bpf_dynptr_set_size(struct bpf_dynptr_kern *ptr, u32 new_size)
void bpf_dynptr_set_size(struct bpf_dynptr_kern *ptr, u32 new_size)
{
u32 metadata = ptr->size & ~DYNPTR_SIZE_MASK;

Expand Down

0 comments on commit 19f1cf9

Please sign in to comment.