#include "xlat/bpf_commands.h"
#include "xlat/bpf_map_types.h"
#include "xlat/bpf_prog_types.h"
+#include "xlat/bpf_prog_flags.h"
#include "xlat/bpf_map_update_elem_flags.h"
#include "xlat/bpf_attach_type.h"
#include "xlat/bpf_attach_flags.h"
uint64_t ATTRIBUTE_ALIGNED(8) insns, license;
uint32_t log_level, log_size;
uint64_t ATTRIBUTE_ALIGNED(8) log_buf;
- uint32_t kern_version;
+ uint32_t kern_version, prog_flags;
} attr = {};
- const size_t attr_size =
- offsetofend(struct bpf_prog_load, kern_version);
- const unsigned int len = size < attr_size ? size : attr_size;
+ const unsigned int len = size < sizeof(attr) ? size : sizeof(attr);
memcpy(&attr, data, len);
PRINT_FIELD_U(", ", attr, log_size);
PRINT_FIELD_X(", ", attr, log_buf);
PRINT_FIELD_U(", ", attr, kern_version);
- decode_attr_extra_data(tcp, data, size, attr_size);
+ PRINT_FIELD_FLAGS(", ", attr, prog_flags, bpf_prog_flags, "BPF_F_???");
+ decode_attr_extra_data(tcp, data, size, sizeof(attr));
tprints("}");
return RVAL_DECODED | RVAL_FD;
&& (defined HAVE_UNION_BPF_ATTR_ATTACH_FLAGS \
|| defined HAVE_UNION_BPF_ATTR_BPF_FD \
|| defined HAVE_UNION_BPF_ATTR_FLAGS \
- || defined HAVE_UNION_BPF_ATTR_KERN_VERSION \
- || defined HAVE_UNION_BPF_ATTR_MAX_ENTRIES)
+ || defined HAVE_UNION_BPF_ATTR_MAX_ENTRIES \
+ || defined HAVE_UNION_BPF_ATTR_PROG_FLAGS)
# include <stddef.h>
# include <stdio.h>
# endif /* HAVE_UNION_BPF_ATTR_FLAGS */
-# ifdef HAVE_UNION_BPF_ATTR_KERN_VERSION
+# ifdef HAVE_UNION_BPF_ATTR_PROG_FLAGS
static unsigned int
init_BPF_PROG_LOAD_first(const unsigned long eop)
printf("prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=0, insns=0"
", license=NULL, log_level=0, log_size=0, log_buf=0"
- ", kern_version=0");
+ ", kern_version=0, prog_flags=0");
}
static const struct bpf_insn insns[] = {
.log_level = 42,
.log_size = sizeof(log_buf),
.log_buf = (uintptr_t) log_buf,
- .kern_version = 0xcafef00d
+ .kern_version = 0xcafef00d,
+ .prog_flags = 1
};
static const unsigned int offset =
- offsetofend(union bpf_attr, kern_version);
+ offsetofend(union bpf_attr, prog_flags);
const unsigned long addr = eop - offset;
memcpy((void *) addr, &attr, offset);
{
printf("prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=%u, insns=%p"
", license=\"GPL\", log_level=42, log_size=4096, log_buf=%p"
- ", kern_version=%u",
+ ", kern_version=%u, prog_flags=BPF_F_STRICT_ALIGNMENT",
(unsigned int) ARRAY_SIZE(insns), insns,
log_buf, 0xcafef00d);
}
-# endif /* HAVE_UNION_BPF_ATTR_KERN_VERSION */
+# endif /* HAVE_UNION_BPF_ATTR_PROG_FLAGS */
/*
* bpf() syscall and its first six commands were introduced in Linux kernel
TEST_BPF(BPF_MAP_GET_NEXT_KEY);
# endif
-# ifdef HAVE_UNION_BPF_ATTR_KERN_VERSION
+# ifdef HAVE_UNION_BPF_ATTR_PROG_FLAGS
TEST_BPF(BPF_PROG_LOAD);
# endif