net: xdp: add invalid buffer warning
authorJohn Fastabend <john.fastabend@gmail.com>
Thu, 15 Dec 2016 20:12:54 +0000 (12:12 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 17 Dec 2016 16:48:55 +0000 (11:48 -0500)
This adds a warning for drivers to use when encountering an invalid
buffer for XDP. For normal cases this should not happen but to catch
this in virtual/qemu setups that I may not have expected from the
emulation layer having a standard warning is useful.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/filter.h
net/core/filter.c

index 6a1658308612622b3d5e3eff2bfcd8cf5c1ff386..af8a1804cac65258b376a8ec4d7fdd16ba72c5c1 100644 (file)
@@ -602,6 +602,7 @@ bool bpf_helper_changes_pkt_data(void *func);
 struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
                                       const struct bpf_insn *patch, u32 len);
 void bpf_warn_invalid_xdp_action(u32 act);
+void bpf_warn_invalid_xdp_buffer(void);
 
 #ifdef CONFIG_BPF_JIT
 extern int bpf_jit_enable;
index b1461708a9774b03376d78a8761677feb031bfe6..7190bd648154e61d19f652dba5fbd861a72f6c36 100644 (file)
@@ -2972,6 +2972,12 @@ void bpf_warn_invalid_xdp_action(u32 act)
 }
 EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action);
 
+void bpf_warn_invalid_xdp_buffer(void)
+{
+       WARN_ONCE(1, "Illegal XDP buffer encountered, expect throughput degradation\n");
+}
+EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_buffer);
+
 static u32 sk_filter_convert_ctx_access(enum bpf_access_type type, int dst_reg,
                                        int src_reg, int ctx_off,
                                        struct bpf_insn *insn_buf,