return log->len_used >= log->len_total - 1;
}
+static inline bool bpf_verifier_log_needed(const struct bpf_verifier_log *log)
+{
+ return log->level && log->ubuf && !bpf_verifier_log_full(log);
+}
+
#define BPF_MAX_SUBPROGS 256
/* single container for all structs
u32 subprog_cnt;
};
+void bpf_verifier_vlog(struct bpf_verifier_log *log, const char *fmt,
+ va_list args);
__printf(2, 3) void bpf_verifier_log_write(struct bpf_verifier_env *env,
const char *fmt, ...);
static DEFINE_MUTEX(bpf_verifier_lock);
-static void log_write(struct bpf_verifier_env *env, const char *fmt,
- va_list args)
+void bpf_verifier_vlog(struct bpf_verifier_log *log, const char *fmt,
+ va_list args)
{
- struct bpf_verifier_log *log = &env->log;
unsigned int n;
- if (!log->level || !log->ubuf || bpf_verifier_log_full(log))
- return;
-
n = vscnprintf(log->kbuf, BPF_VERIFIER_TMP_LOG_SIZE, fmt, args);
WARN_ONCE(n >= BPF_VERIFIER_TMP_LOG_SIZE - 1,
{
va_list args;
+ if (!bpf_verifier_log_needed(&env->log))
+ return;
+
va_start(args, fmt);
- log_write(env, fmt, args);
+ bpf_verifier_vlog(&env->log, fmt, args);
va_end(args);
}
EXPORT_SYMBOL_GPL(bpf_verifier_log_write);
__printf(2, 3) static void verbose(void *private_data, const char *fmt, ...)
{
+ struct bpf_verifier_env *env = private_data;
va_list args;
+ if (!bpf_verifier_log_needed(&env->log))
+ return;
+
va_start(args, fmt);
- log_write(private_data, fmt, args);
+ bpf_verifier_vlog(&env->log, fmt, args);
va_end(args);
}