fprintf(stderr, " bytecode-file FILE\n");
fprintf(stderr, "\n");
fprintf(stderr, "eBPF use case:\n");
- fprintf(stderr, " object-file FILE [ section CLS_NAME ] [ export UDS_FILE ]\n");
+ fprintf(stderr, " object-file FILE [ section CLS_NAME ] [ export UDS_FILE ]");
+ fprintf(stderr, " [ verbose ]\n");
fprintf(stderr, "\n");
fprintf(stderr, "Common remaining options:\n");
fprintf(stderr, " [ action ACTION_SPEC ]\n");
while (argc > 0) {
if (matches(*argv, "run") == 0) {
struct sock_filter bpf_ops[BPF_MAXINSNS];
- bool from_file, ebpf;
+ bool from_file, ebpf, bpf_verbose;
int ret;
NEXT_ARG();
opt_bpf:
bpf_sec_name = bpf_default_section(bpf_type);
+ bpf_verbose = false;
ebpf = false;
seen_run = true;
bpf_uds_name = *argv;
NEXT_ARG();
}
+ if (strcmp(*argv, "verbose") == 0 ||
+ strcmp(*argv, "verb") == 0) {
+ bpf_verbose = true;
+ NEXT_ARG();
+ }
PREV_ARG();
}
- ret = ebpf ? bpf_open_object(bpf_obj, bpf_type, bpf_sec_name) :
+ ret = ebpf ? bpf_open_object(bpf_obj, bpf_type, bpf_sec_name,
+ bpf_verbose) :
bpf_parse_ops(argc, argv, bpf_ops, from_file);
if (ret < 0) {
fprintf(stderr, "%s\n", ebpf ?
/*
- * m_bpf.c BFP based action module
+ * m_bpf.c BPF based action module
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
fprintf(stderr, " bytecode-file FILE\n");
fprintf(stderr, "\n");
fprintf(stderr, "eBPF use case:\n");
- fprintf(stderr, " object-file FILE [ section ACT_NAME ] [ export UDS_FILE ]\n");
+ fprintf(stderr, " object-file FILE [ section ACT_NAME ] [ export UDS_FILE ]");
+ fprintf(stderr, " [ verbose ]\n");
fprintf(stderr, "\n");
fprintf(stderr, "Where BPF_BYTECODE := \'s,c t f k,c t f k,c t f k,...\'\n");
fprintf(stderr, "c,t,f,k and s are decimals; s denotes number of 4-tuples\n");
while (argc > 0) {
if (matches(*argv, "run") == 0) {
- bool from_file;
+ bool from_file, bpf_verbose;
int ret;
NEXT_ARG();
opt_bpf:
bpf_sec_name = bpf_default_section(bpf_type);
+ bpf_verbose = false;
seen_run = true;
if (strcmp(*argv, "bytecode-file") == 0 ||
bpf_uds_name = *argv;
NEXT_ARG();
}
+ if (strcmp(*argv, "verbose") == 0 ||
+ strcmp(*argv, "verb") == 0) {
+ bpf_verbose = true;
+ NEXT_ARG();
+ }
PREV_ARG();
}
- ret = ebpf ? bpf_open_object(bpf_obj, bpf_type, bpf_sec_name) :
+ ret = ebpf ? bpf_open_object(bpf_obj, bpf_type, bpf_sec_name,
+ bpf_verbose) :
bpf_parse_ops(argc, argv, bpf_ops, from_file);
if (ret < 0) {
fprintf(stderr, "%s\n", ebpf ?
* verifier we still want to hand something descriptive to the user.
*/
static char bpf_log_buf[65536];
+static bool bpf_verbose;
static struct bpf_elf_st bpf_st;
vfprintf(stderr, format, vl);
va_end(vl);
- fprintf(stderr, "%s\n", bpf_log_buf);
- memset(bpf_log_buf, 0, sizeof(bpf_log_buf));
+ if (bpf_log_buf[0]) {
+ fprintf(stderr, "%s\n", bpf_log_buf);
+ memset(bpf_log_buf, 0, sizeof(bpf_log_buf));
+ }
}
static void bpf_save_finfo(int file_fd)
{
int prog_fd = bpf_prog_load(type, insns, size, license);
- if (prog_fd < 0)
- bpf_dump_error("BPF program rejected: %s\n", strerror(errno));
+ if (prog_fd < 0 || bpf_verbose) {
+ bpf_dump_error("%s: %s\n", prog_fd < 0 ?
+ "BPF program rejected" :
+ "BPF program verification", strerror(errno));
+ }
return prog_fd;
}
return prog_fd;
}
-int bpf_open_object(const char *path, enum bpf_prog_type type, const char *sec)
+int bpf_open_object(const char *path, enum bpf_prog_type type,
+ const char *sec, bool verbose)
{
char license[ELF_MAX_LICENSE_LEN];
int file_fd, prog_fd = -1, ret;
}
memset(license, 0, sizeof(license));
+ bpf_verbose = verbose;
+
if (!bpf_may_skip_map_creation(file_fd))
bpf_maps_init();
#ifdef HAVE_ELF
int bpf_open_object(const char *path, enum bpf_prog_type type,
- const char *sec);
+ const char *sec, bool verbose);
int bpf_send_map_fds(const char *path, const char *obj);
int bpf_recv_map_fds(const char *path, int *fds, struct bpf_map_aux *aux,
}
#else
static inline int bpf_open_object(const char *path, enum bpf_prog_type type,
- const char *sec)
+ const char *sec, bool verbose)
{
fprintf(stderr, "No ELF library support compiled in.\n");
errno = ENOSYS;