Skip to content

Commit

Permalink
Avoid depending on prog_bind_map being present in bpf_attr
Browse files Browse the repository at this point in the history
Resolves #3884
  • Loading branch information
rocallahan committed Nov 26, 2024
1 parent f7067f1 commit 3121089
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/test/bpf_prog_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ int main(void) {
VERIFY_GUARD(map_attr);

memset(map_attr, 0, sizeof(*map_attr));
map_attr->prog_bind_map.map_fd = map_fd;
map_attr->prog_bind_map.prog_fd = prog;
struct {
uint32_t prog_fd;
uint32_t map_fd;
uint32_t flags;
} prog_bind_map;
prog_bind_map.map_fd = map_fd;
prog_bind_map.prog_fd = prog;
memcpy(map_attr, &prog_bind_map, sizeof(prog_bind_map));
int ret = bpf(RR_BPF_PROG_BIND_MAP, map_attr, sizeof(*map_attr));
test_assert(ret == 0 || errno == EINVAL);
VERIFY_GUARD(map_attr);
Expand Down

0 comments on commit 3121089

Please sign in to comment.