From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Fastabend Subject: [net-next PATCH v5 2/6] net: xdp: add invalid buffer warning Date: Wed, 07 Dec 2016 12:11:34 -0800 Message-ID: <20161207201134.28121.52362.stgit@john-Precision-Tower-5810> References: <20161207200139.28121.4811.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: john.r.fastabend@intel.com, netdev@vger.kernel.org, john.fastabend@gmail.com, brouer@redhat.com To: daniel@iogearbox.net, mst@redhat.com, shm@cumulusnetworks.com, davem@davemloft.net, tgraf@suug.ch, alexei.starovoitov@gmail.com Return-path: Received: from mail-pg0-f67.google.com ([74.125.83.67]:33054 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932424AbcLGULw (ORCPT ); Wed, 7 Dec 2016 15:11:52 -0500 Received: by mail-pg0-f67.google.com with SMTP id 3so24451539pgd.0 for ; Wed, 07 Dec 2016 12:11:52 -0800 (PST) In-Reply-To: <20161207200139.28121.4811.stgit@john-Precision-Tower-5810> Sender: netdev-owner@vger.kernel.org List-ID: 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 --- include/linux/filter.h | 1 + net/core/filter.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/filter.h b/include/linux/filter.h index f078d2b..860f953 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -600,6 +600,7 @@ int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, 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; diff --git a/net/core/filter.c b/net/core/filter.c index b751202..849f23d 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2948,6 +2948,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,