From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Fastabend Subject: [PATCH bpf-next 2/3] bpf: add msg_pop_data helper to tools Date: Thu, 22 Nov 2018 17:38:49 -0800 Message-ID: <1542937130-4860-3-git-send-email-john.fastabend@gmail.com> References: <1542937130-4860-1-git-send-email-john.fastabend@gmail.com> Cc: john.fastabend@gmail.com, netdev@vger.kernel.org To: ast@kernel.org, daniel@iogearbox.net Return-path: Received: from mail-io1-f67.google.com ([209.85.166.67]:41715 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733028AbeKWMVY (ORCPT ); Fri, 23 Nov 2018 07:21:24 -0500 Received: by mail-io1-f67.google.com with SMTP id s22so7705014ioc.8 for ; Thu, 22 Nov 2018 17:39:16 -0800 (PST) In-Reply-To: <1542937130-4860-1-git-send-email-john.fastabend@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Add the necessary header definitions to tools for new msg_pop_data_helper. Signed-off-by: John Fastabend --- tools/include/uapi/linux/bpf.h | 13 ++++++++++++- tools/testing/selftests/bpf/bpf_helpers.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index c1554aa..95cf7a5 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -2268,6 +2268,16 @@ union bpf_attr { * * Return * 0 on success, or a negative error in case of failure. + * + * int bpf_msg_pop_data(struct sk_msg_buff *msg, u32 start, u32 pop, u64 flags) + * Description + * Will remove 'pop' bytes from a msg starting at byte 'start'. + * This result in ENOMEM errors under certain situations where + * a allocation and copy are required due to a full ring buffer. + * However, the helper will try to avoid doing the allocation + * if possible. Other errors can occur if input parameters are + * invalid either do to start byte not being valid part of msg + * payload and/or pop value being to large. */ #define __BPF_FUNC_MAPPER(FN) \ FN(unspec), \ @@ -2360,7 +2370,8 @@ union bpf_attr { FN(map_push_elem), \ FN(map_pop_elem), \ FN(map_peek_elem), \ - FN(msg_push_data), + FN(msg_push_data), \ + FN(msg_pop_data), /* integer value in 'imm' field of BPF_CALL instruction selects which helper * function eBPF program intends to call diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h index 686e57c..7b69519 100644 --- a/tools/testing/selftests/bpf/bpf_helpers.h +++ b/tools/testing/selftests/bpf/bpf_helpers.h @@ -113,6 +113,8 @@ static int (*bpf_msg_pull_data)(void *ctx, int start, int end, int flags) = (void *) BPF_FUNC_msg_pull_data; static int (*bpf_msg_push_data)(void *ctx, int start, int end, int flags) = (void *) BPF_FUNC_msg_push_data; +static int (*bpf_msg_pop_data)(void *ctx, int start, int cut, int flags) = + (void *) BPF_FUNC_msg_pop_data; static int (*bpf_bind)(void *ctx, void *addr, int addr_len) = (void *) BPF_FUNC_bind; static int (*bpf_xdp_adjust_tail)(void *ctx, int offset) = -- 2.7.4