Re: [PATCH bpf 1/2] selftests/bpf: use thoff instead of nhoff in BPF flow dissector

2018-12-07 Thread Alexei Starovoitov
On Wed, Dec 05, 2018 at 08:40:47PM -0800, Stanislav Fomichev wrote: > We are returning thoff from the flow dissector, not the nhoff. Pass > thoff along with nhoff to the bpf program (initially thoff == nhoff) > and expect flow dissector amend/return thoff, not nhoff. > > This avoids confusion,

Re: [PATCH v2 bpf-next 0/7] bpf: support BPF_ALU | BPF_ARSH

2018-12-07 Thread Alexei Starovoitov
On Wed, Dec 05, 2018 at 01:52:29PM -0500, Jiong Wang wrote: > BPF_ALU | BPF_ARSH | BPF_* were rejected by commit: 7891a87efc71 > ("bpf: arsh is not supported in 32 bit alu thus reject it"). As explained > in the commit message, this is due to there is no complete support for them > on interpreter

Re: [PATCH bpf-next 0/7] Add XDP_ATTACH bind() flag to AF_XDP sockets

2018-12-07 Thread Alexei Starovoitov
On Fri, Dec 07, 2018 at 12:44:24PM +0100, Björn Töpel wrote: > From: Björn Töpel > > Hi! > > This patch set adds support for a new XDP socket bind option, > XDP_ATTACH. > > The rationale behind attach is performance and ease of use. Many XDP > socket users just need a simple way of

Re: [PATCH bpf-next] bpf: relax verifier restriction on BPF_MOV | BPF_ALU

2018-12-07 Thread Alexei Starovoitov
On Fri, Dec 07, 2018 at 05:19:21PM +, Jiong Wang wrote: > On 06/12/2018 03:13, Alexei Starovoitov wrote: > > On Wed, Dec 05, 2018 at 03:32:50PM +, Jiong Wang wrote: > > > On 05/12/2018 14:52, Edward Cree wrote: > > > > On 05/12/18 09:46, Jiong Wang wrote: &

Re: [PATCH bpf-next] tools: bpftool: add a command to dump the trace pipe

2018-12-06 Thread Alexei Starovoitov
On Thu, Dec 06, 2018 at 05:20:54PM +, Quentin Monnet wrote: > 2018-12-05 19:18 UTC-0800 ~ Alexei Starovoitov > > > On Wed, Dec 05, 2018 at 06:15:23PM +, Quentin Monnet wrote: > >>>> + > >>>> +/* Allow room for NULL terminating byte and

Re: [PATCH bpf-next] tools: bpftool: add a command to dump the trace pipe

2018-12-05 Thread Alexei Starovoitov
On Wed, Dec 05, 2018 at 06:15:23PM +, Quentin Monnet wrote: > > > + > > > + /* Allow room for NULL terminating byte and pipe file name */ > > > + snprintf(format, sizeof(format), "%%*s %%%zds %%99s %%*s %%*d %%*d\\n", > > > + PATH_MAX - strlen(pipe_name) - 1); > > > > before scanning

Re: [PATCH bpf-next] bpf: relax verifier restriction on BPF_MOV | BPF_ALU

2018-12-05 Thread Alexei Starovoitov
On Wed, Dec 05, 2018 at 03:32:50PM +, Jiong Wang wrote: > On 05/12/2018 14:52, Edward Cree wrote: > > On 05/12/18 09:46, Jiong Wang wrote: > > > There is NO processed instruction number regression, either with or > > > without > > > -mattr=+alu32. > > > > > Cilium bpf > > > === > > >

Re: [PATCH bpf-next 0/4] Misc improvements on bpf_func_info

2018-12-05 Thread Alexei Starovoitov
On Wed, Dec 05, 2018 at 05:35:43PM -0800, Martin KaFai Lau wrote: > The patchset has a few improvements on bpf_func_info: > 1. Improvements on the behaviors of info.func_info, info.func_info_cnt >and info.func_info_rec_size. > 2. Name change: s/insn_offset/insn_off/ > > Please see individual

Re: [PATCH bpf-next v2 3/5] selftests/bpf: use thoff instead of nhoff in BPF flow dissector

2018-12-05 Thread Alexei Starovoitov
On Tue, Dec 04, 2018 at 03:26:15PM -0800, Stanislav Fomichev wrote: > On 12/04, Song Liu wrote: > > On Mon, Dec 3, 2018 at 8:01 PM Stanislav Fomichev wrote: > > > > > > We are returning thoff from the flow dissector, not the nhoff. Pass > > > thoff along with nhoff to the bpf program (initially

pull-request: bpf 2018-12-05

2018-12-05 Thread Alexei Starovoitov
to a92a72a24d48080f6c49bb514c082fbb1e5bf8fc: Merge branch 'bpf-verifier-resilience' (2018-12-04 17:22:03 +0100) Alexei Starovoitov (4): Merge branch 'btf-check-name' bpf: check pending signals while verifying programs bpf: improve verifier

Re: [PATCH bpf-next] tools: bpftool: add a command to dump the trace pipe

2018-12-05 Thread Alexei Starovoitov
On Wed, Dec 05, 2018 at 10:28:24AM +, Quentin Monnet wrote: > BPF programs can use the bpf_trace_printk() helper to print debug > information into the trace pipe. Add a subcommand > "bpftool prog tracelog" to simply dump this pipe to the console. > > This is for a good part copied from

Re: [RFC bpf-next 1/7] bpf: interpreter support BPF_ALU | BPF_ARSH

2018-12-04 Thread Alexei Starovoitov
On Tue, Dec 04, 2018 at 12:10:05PM -0800, David Miller wrote: > From: Alexei Starovoitov > Date: Tue, 4 Dec 2018 11:29:55 -0800 > > > I guess sparc doesn't really have 32 subregisters. All registers > > are considered 64-bit. It has 32-bit alu ops on 64-bit registers &g

Re: [oss-drivers] Re: [RFC bpf-next 1/7] bpf: interpreter support BPF_ALU | BPF_ARSH

2018-12-04 Thread Alexei Starovoitov
On Tue, Dec 04, 2018 at 11:42:54AM -0800, Jakub Kicinski wrote: > On Tue, 4 Dec 2018 11:29:55 -0800, Alexei Starovoitov wrote: > > Regarding the set... It looks good to me. Pls resubmit without RFC tag > > and probably include mips patch as patch 1, so we can apply the whole > &

Re: [RFC bpf-next 1/7] bpf: interpreter support BPF_ALU | BPF_ARSH

2018-12-04 Thread Alexei Starovoitov
On Tue, Dec 04, 2018 at 08:43:11AM -0800, David Miller wrote: > From: Jiong Wang > Date: Tue, 4 Dec 2018 04:56:29 -0500 > > > This patch implements interpreting BPF_ALU | BPF_ARSH. Do arithmetic right > > shift on low 32-bit sub-register, and zero the high 32 bits. > > > > Reviewed-by: Jakub

Re: [PATCH v5 0/4] Fix unsafe BPF_PROG_TEST_RUN interface

2018-12-04 Thread Alexei Starovoitov
On Mon, Dec 03, 2018 at 11:31:22AM +, Lorenz Bauer wrote: > Right now, there is no safe way to use BPF_PROG_TEST_RUN with data_out. > This is because bpf_test_finish copies the output buffer to user space > without checking its size. This can lead to the kernel overwriting > data in user space

[PATCH bpf 2/3] bpf: improve verifier branch analysis

2018-12-03 Thread Alexei Starovoitov
_L4.o 31733089 bpf_lb-DUNKNOWN.o 10801065 bpf_lxc-DDROP_ALL.o 29584 28052 bpf_lxc-DUNKNOWN.o 36916 35487 bpf_netdev.o11188 10864 bpf_overlay.o 66796643 bpf_lcx_jit.o 39555 38437 Reported-by: Anatoly Trosinenko Signed-

[PATCH bpf 0/3] bpf: improve verifier resilience

2018-12-03 Thread Alexei Starovoitov
Three patches to improve verifier ability to handle pathological bpf programs with a lot of branches: - make sure prog_load syscall can be aborted - improve branch taken analysis - introduce per-insn complexity limit for unprivileged programs Alexei Starovoitov (3): bpf: check pending signals

[PATCH bpf 3/3] bpf: add per-insn complexity limit

2018-12-03 Thread Alexei Starovoitov
6643 bpf_lcx_jit.o 38437 38437 But it also makes malicious program to be rejected in 0.4 seconds vs 6.5 Hence apply this limit to unprivileged programs only. Signed-off-by: Alexei Starovoitov Acked-by: Daniel Borkmann Acked-by: Edward Cree --- kernel/bpf/verifier.c | 7 ++- 1 fi

[PATCH bpf 1/3] bpf: check pending signals while verifying programs

2018-12-03 Thread Alexei Starovoitov
verification. Reported-by: Anatoly Trosinenko Signed-off-by: Alexei Starovoitov Acked-by: Daniel Borkmann Acked-by: Edward Cree --- kernel/bpf/verifier.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 6dd419550aba..751bb30b7c5c 100644

Re: [PATCH bpf-next] bpf: Fix memleak in aux->func_info and aux->btf

2018-12-02 Thread Alexei Starovoitov
On Sat, Dec 01, 2018 at 05:08:44PM -0800, Martin KaFai Lau wrote: > The aux->func_info and aux->btf are leaked in the error out cases > during bpf_prog_load(). This patch fixes it. > > Fixes: ba64e7d85252 ("bpf: btf: support proper non-jit func info") > Cc: Yonghong Song > Signed-off-by: Martin

Re: [PATCH net] bpf: uninitialized variables in test code

2018-12-01 Thread Alexei Starovoitov
with the return value of the testing > program. Let's add an additional argument with a pointer where to > store the testing program's result; and make bpf_test_run() > return either 0 or -ENOMEM. > > Fixes: f42ee093be29 ("bpf/test_run: support cgroup local storage") > Re

Re: [PATCH net] bpf: uninitialized variables in test code

2018-12-01 Thread Alexei Starovoitov
On Sat, Dec 01, 2018 at 07:13:50PM +, Roman Gushchin wrote: > On Fri, Nov 30, 2018 at 02:58:03PM -0800, Alexei Starovoitov wrote: > > On Thu, Nov 29, 2018 at 01:27:03PM +0300, Dan Carpenter wrote: > > > Smatch complains that if bpf_test_run() fails with -ENOMEM at

Re: [PATCH bpf-next v2 0/2] sample: xdp1 improvements

2018-11-30 Thread Alexei Starovoitov
On Sat, Dec 01, 2018 at 01:23:04AM +0100, Matteo Croce wrote: > Small improvements to improve the readability and easiness > to use of the xdp1 sample. Applied to bpf-next. I think that sample code could be more useful if it's wrapped with bash script like selftests/test_xdp* tests do. At that

Re: [PATCH v2 bpf-next 0/4] bpf: Improve verifier test coverage on sparc64 et al.

2018-11-30 Thread Alexei Starovoitov
On Fri, Nov 30, 2018 at 09:07:54PM -0800, David Miller wrote: > > On sparc64 a ton of test cases in test_verifier.c fail because > the memory accesses in the test case are unaligned (or cannot > be proven to be aligned by the verifier). > > Perhaps we can eventually try to (carefully) modify

Re: [PATCH bpf-next 1/4] bpf: Add BPF_F_ANY_ALIGNMENT.

2018-11-30 Thread Alexei Starovoitov
On Fri, Nov 30, 2018 at 08:44:20PM -0800, David Miller wrote: > From: Alexei Starovoitov > Date: Fri, 30 Nov 2018 13:58:20 -0800 > > > On Thu, Nov 29, 2018 at 07:32:41PM -0800, David Miller wrote: > >> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h >

Re: [PATCHv3 bpf 1/2] bpf: Support sk lookup in netns with id 0

2018-11-30 Thread Alexei Starovoitov
On Fri, Nov 30, 2018 at 03:32:20PM -0800, Joe Stringer wrote: > David Ahern and Nicolas Dichtel report that the handling of the netns id > 0 is incorrect for the BPF socket lookup helpers: rather than finding > the netns with id 0, it is resolving to the current netns. This renders > the netns_id

Re: [PATCH bpf] bpf: fix pointer offsets in context for 32 bit

2018-11-30 Thread Alexei Starovoitov
On Sat, Dec 01, 2018 at 01:18:53AM +0100, Daniel Borkmann wrote: > Currently, pointer offsets in three BPF context structures are > broken in two scenarios: i) 32 bit compiled applications running > on 64 bit kernels, and ii) LLVM compiled BPF programs running > on 32 bit kernels. The latter is

Re: BPF uapi structures and 32-bit

2018-11-30 Thread Alexei Starovoitov
On Wed, Nov 28, 2018 at 11:02:00AM -0800, David Miller wrote: > From: Daniel Borkmann > Date: Wed, 28 Nov 2018 11:34:55 +0100 > > > Yeah fully agree. Thinking diff below should address it, do you > > have a chance to give this a spin for sparc / 32 bit to check if > > test_verifier still

Re: [PATCHv2 bpf 1/2] bpf: Support sk lookup in netns with id 0

2018-11-30 Thread Alexei Starovoitov
On Fri, Nov 30, 2018 at 03:18:25PM -0800, Joe Stringer wrote: > On Fri, 30 Nov 2018 at 14:42, Alexei Starovoitov > wrote: > > > > On Thu, Nov 29, 2018 at 04:29:33PM -0800, Joe Stringer wrote: > > > David Ahern and Nicolas Dichtel report that the handling of the ne

Re: [PATCH net] bpf: uninitialized variables in test code

2018-11-30 Thread Alexei Starovoitov
On Thu, Nov 29, 2018 at 01:27:03PM +0300, Dan Carpenter wrote: > Smatch complains that if bpf_test_run() fails with -ENOMEM at the > begining then the "duration" is uninitialized. We then copy the > unintialized variables to the user inside the bpf_test_finish() > function. The functions require

Re: [PATCH bpf] bpf: Fix verifier log string check for bad alignment.

2018-11-30 Thread Alexei Starovoitov
On Wed, Nov 28, 2018 at 10:33:53PM -0800, David Miller wrote: > > The message got changed a lot time ago. > > This was responsible for 36 test case failures on sparc64. > > Fixes: f1174f77b50c ("bpf/verifier: rework value tracking") > Signed-off-by: David S. Miller Applied to bpf tree.

Re: [PATCHv2 bpf 1/2] bpf: Support sk lookup in netns with id 0

2018-11-30 Thread Alexei Starovoitov
On Thu, Nov 29, 2018 at 04:29:33PM -0800, Joe Stringer wrote: > David Ahern and Nicolas Dichtel report that the handling of the netns id > 0 is incorrect for the BPF socket lookup helpers: rather than finding > the netns with id 0, it is resolving to the current netns. This renders > the netns_id

Re: [PATCH bpf-next 0/5] tools: bpftool: fixes and small improvements

2018-11-30 Thread Alexei Starovoitov
On Fri, Nov 30, 2018 at 04:25:43PM +, Quentin Monnet wrote: > Hi, > Several items for bpftool are included in this set: the first three patches > are fixes for bpftool itself and bash completion, while the last two > slightly improve the information obtained when dumping programs or maps, on >

Re: [PATCH bpf-next 1/4] bpf: Add BPF_F_ANY_ALIGNMENT.

2018-11-30 Thread Alexei Starovoitov
On Thu, Nov 29, 2018 at 07:32:41PM -0800, David Miller wrote: > > Often we want to write tests cases that check things like bad context > offset accesses. And one way to do this is to use an odd offset on, > for example, a 32-bit load. > > This unfortunately triggers the alignment checks first

Re: [PATCH v4 3/4] libbpf: add bpf_prog_test_run_xattr

2018-11-30 Thread Alexei Starovoitov
On Wed, Nov 28, 2018 at 04:53:11PM +, Lorenz Bauer wrote: > Add a new function, which encourages safe usage of the test interface. > bpf_prog_test_run continues to work as before, but should be considered > unsafe. > > Signed-off-by: Lorenz Bauer .. > + > +LIBBPF_API int

Re: [PATCH bpf] tools: bpftool: fix a bitfield pretty print issue

2018-11-28 Thread Alexei Starovoitov
On Wed, Nov 28, 2018 at 09:38:23AM -0800, Yonghong Song wrote: > Commit b12d6ec09730 ("bpf: btf: add btf print functionality") > added btf pretty print functionality to bpftool. > There is a problem though in printing a bitfield whose type > has modifiers. > > For example, for a type like >

Re: [PATCH] bpf: Fix various lib and testsuite build failures on 32-bit.

2018-11-28 Thread Alexei Starovoitov
On Wed, Nov 28, 2018 at 12:56:10PM -0800, David Miller wrote: > > Cannot cast a u64 to a pointer on 32-bit without an intervening (long) > cast otherwise GCC warns. > > Signed-off-by: David S. Miller I was contemplating to apply that to bpf tree, but the first hunk is bpf-next only and later

Re: [PATCH bpf v2 0/4] bpf: btf: check name validity for various types

2018-11-28 Thread Alexei Starovoitov
On Tue, Nov 27, 2018 at 01:23:26PM -0800, Yonghong Song wrote: > This patch set added name checking for PTR, ARRAY, VOLATILE, TYPEDEF, > CONST, RESTRICT, STRUCT, UNION, ENUM and FWD types. Such a strict > name checking makes BTF more sound in the kernel and future > BTF-to-header-file converesion

Re: [PATCH v3 3/4] libbpf: add bpf_prog_test_run_xattr

2018-11-27 Thread Alexei Starovoitov
On Mon, Nov 26, 2018 at 4:45 AM Lorenz Bauer wrote: > > That's what I had initially, but that makes re-using test_attr really > awkward. Either > you need to reset data_out_size before every call because it is used > to return the > buffer size, I think that is exactly what the user of the

Re: [PATCH bpf] bpf: Support sk lookup in netns with id 0

2018-11-27 Thread Alexei Starovoitov
On Tue, Nov 27, 2018 at 10:01:40AM -0800, Joe Stringer wrote: > On Tue, 27 Nov 2018 at 06:49, Nicolas Dichtel > wrote: > > > > Le 26/11/2018 à 23:08, David Ahern a écrit : > > > On 11/26/18 2:27 PM, Joe Stringer wrote: > > >> @@ -2405,6 +2407,9 @@ enum bpf_func_id { > > >> /*

Re: [PATCH bpf-next 1/3] bpf: btf: check name validity for various types

2018-11-27 Thread Alexei Starovoitov
On Mon, Nov 26, 2018 at 09:17:13PM -0800, Yonghong Song wrote: > Commit 2667a2626f4d ("bpf: btf: Add BTF_KIND_FUNC > and BTF_KIND_FUNC_PROTO") checked the name validity > for BTF_KIND_FUNC/BTF_KIND_FUNC_PROTO types such that: > . BTF_KIND_FUNC must have a valid identifier name > . BTF_KIND_PROTO

Re: [PATCH bpf-next v2 0/3] bpf: add sk_msg helper sk_msg_pop_data

2018-11-27 Thread Alexei Starovoitov
bly confusing user space applications, so fix it. lgtm for the set: Acked-by: Alexei Starovoitov

Re: [PATCH bpf-next v2 0/4] libbpf: ABI versioning and documentation

2018-11-26 Thread Alexei Starovoitov
On Fri, Nov 23, 2018 at 04:44:31PM -0800, Andrey Ignatov wrote: > This patch set adds ABI versioning and documentation to libbpf. > > Patch 1 renames btf_get_from_id to btf__get_from_id to follow naming > convention. > Patch 2 adds version script and has more details on ABI versioning. > Patch 3

Re: [PATCH bpf] bpf, doc: add entries of who looks over which jits

2018-11-26 Thread Alexei Starovoitov
and therefore BPF > core under a given architecture. Every new JIT in future /must/ > have an entry here as well. > > Signed-off-by: Daniel Borkmann > Acked-by: Alexei Starovoitov > Acked-by: Naveen N. Rao > Acked-by: Sandipan Das > Acked-by: Martin Schwidefsky > Ac

Re: [PATCH bpf-next 0/2] bpf: support proper non-jit func info

2018-11-26 Thread Alexei Starovoitov
On Sat, Nov 24, 2018 at 11:20:43PM -0800, Yonghong Song wrote: > Commit 838e96904ff3 ("bpf: Introduce bpf_func_info") > added bpf func info support. The userspace is able > to get better ksym's for bpf programs with jit, and > is able to print out func prototypes. > > For a program containing

Re: [PATCH bpf] sparc: Correct ctx->saw_frame_pointer logic.

2018-11-26 Thread Alexei Starovoitov
On Mon, Nov 26, 2018 at 02:52:18PM -0800, David Miller wrote: > > We need to initialize the frame pointer register not just if it is > seen as a source operand, but also if it is seen as the destination > operand of a store or an atomic instruction (which effectively is a > source operand). > >

Re: [PATCH bpf] sparc: Fix JIT fused branch convergance.

2018-11-26 Thread Alexei Starovoitov
On Mon, Nov 26, 2018 at 01:03:46PM -0800, David Miller wrote: > > On T4 and later sparc64 cpus we can use the fused compare and branch > instruction. > > However, it can only be used if the branch destination is in the range > of a signed 10-bit immediate offset. This amounts to 1024 >

Re: [PATCH bpf 0/2] Fix for arm64 jit

2018-11-26 Thread Alexei Starovoitov
On Mon, Nov 26, 2018 at 02:05:37PM +0100, Daniel Borkmann wrote: > This set contains a fix for arm64 BPF JIT. First patch generalizes > ppc64 way of retrieving subprog into bpf_jit_get_func_addr() as core > code and uses the same on arm64 in second patch. Tested on both arm64 > and ppc64. > >

Re: [PATCH v3 3/4] libbpf: add bpf_prog_test_run_xattr

2018-11-24 Thread Alexei Starovoitov
On Fri, Nov 23, 2018 at 11:25:11PM +0100, Daniel Borkmann wrote: > On 11/22/2018 03:09 PM, Lorenz Bauer wrote: > > Add a new function, which encourages safe usage of the test interface. > > bpf_prog_test_run continues to work as before, but should be considered > > unsafe. > > > > Signed-off-by:

Re: [PATCH v2 bpf-next] bpf: add skb->tstamp r/w access from tc clsact and cg skb progs

2018-11-22 Thread Alexei Starovoitov
On Thu, Nov 22, 2018 at 02:39:16PM -0500, Vlad Dumitrescu wrote: > This could be used to rate limit egress traffic in concert with a qdisc > which supports Earliest Departure Time, such as FQ. > > Write access from cg skb progs only with CAP_SYS_ADMIN, since the value > will be used by downstream

[PATCH bpf] bpf: fix integer overflow in queue_stack_map

2018-11-22 Thread Alexei Starovoitov
fix the following issues: - allow queue_stack_map for root only - fix u32 max_entries overflow - disallow value_size == 0 Reported-by: Wei Wu Fixes: f1a2e44a3aec ("bpf: add queue and stack maps") Signed-off-by: Alexei Starovoitov --- kernel/bpf/queue_stack_maps.c | 16 --

Re: [PATCH bpf-next] bpf: add read/write access to skb->tstamp from tc clsact progs

2018-11-21 Thread Alexei Starovoitov
On Wed, Nov 21, 2018 at 10:48:21AM -0800, Vlad Dumitrescu wrote: > On Wed, Nov 21, 2018 at 5:08 AM Eric Dumazet wrote: > > > > > > > > On 11/20/2018 06:40 PM, Alexei Starovoitov wrote: > > > > > > > > looks good to me. > > > >

Re: [PATCH bpf-next 1/2] libbpf: Add version script for DSO

2018-11-21 Thread Alexei Starovoitov
On 11/21/18 12:18 PM, Yonghong Song wrote: > > > On 11/21/18 9:40 AM, Andrey Ignatov wrote: >> More and more projects use libbpf and one day it'll likely be packaged >> and distributed as DSO and that requires ABI versioning so that both >> compatible and incompatible changes to ABI can be

Re: [PATCH bpf-next v2] libbpf: make sure bpf headers are c++ include-able

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 05:59:52PM -0800, Stanislav Fomichev wrote: > On 11/20, Alexei Starovoitov wrote: > > On Tue, Nov 20, 2018 at 04:05:55PM -0800, Stanislav Fomichev wrote: > > > On 11/20, Alexei Starovoitov wrote: > > > > On Tue, Nov 20, 2018 at 01:37:23PM -

Re: [PATCH bpf-next] bpf: add read/write access to skb->tstamp from tc clsact progs

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 07:18:48PM -0500, Vlad Dumitrescu wrote: > This could be used to rate limit egress traffic in concert with a qdisc > which supports Earliest Departure Time, such as FQ. > > Signed-off-by: Vlad Dumitrescu > --- > include/uapi/linux/bpf.h| 1 + >

Re: [PATCH v4 bpf-next 1/2] bpf: adding support for map in map in libbpf

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 05:33:43PM -0800, Nikita V. Shirokov wrote: > idea is pretty simple. for specified map (pointed by struct bpf_map) > we would provide descriptor of already loaded map, which is going to be > used as a prototype for inner map. proposed workflow: > 1) open bpf's object

Re: [PATCH bpf-next v2] libbpf: make sure bpf headers are c++ include-able

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 04:05:55PM -0800, Stanislav Fomichev wrote: > On 11/20, Alexei Starovoitov wrote: > > On Tue, Nov 20, 2018 at 01:37:23PM -0800, Stanislav Fomichev wrote: > > > Wrap headers in extern "C", to turn off C++ mangling. > > > This simplifie

Re: BPF probe namespacing

2018-11-20 Thread Alexei Starovoitov
On Mon, Nov 19, 2018 at 03:29:07PM +, Peter Parkanyi wrote: > Hi, > > At LPC I raised the observation that currently it doesn't seem > feasible to insert a BPF probe from within a container that sees > events happening outside of the container, while it is possible to > insert a kernel

Re: [PATCH bpf-next v2] libbpf: make sure bpf headers are c++ include-able

2018-11-20 Thread Alexei Starovoitov
> --- a/tools/lib/bpf/bpf.h > +++ b/tools/lib/bpf/bpf.h > @@ -27,6 +27,10 @@ > #include > #include > > +#ifdef __cplusplus > +extern "C" { > +#endif Acked-by: Alexei Starovoitov was wondering whether it's possible to make it testable. HOSTCXX is available, but I don't see much of the kernel tree using it...

Re: [PATCH bpf-next v2] bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 02:08:20PM -0800, Yonghong Song wrote: > Kernel test robot (l...@intel.com) reports a compilation error at > https://www.spinics.net/lists/netdev/msg534913.html > introduced by commit 838e96904ff3 ("bpf: Introduce bpf_func_info"). > > If CONFIG_BPF is defined and

Re: [PATCH bpf-next] bpf: libbpf: retry program creation without the name

2018-11-20 Thread Alexei Starovoitov
On Wed, Nov 21, 2018 at 12:18:57AM +0100, Daniel Borkmann wrote: > On 11/21/2018 12:04 AM, Alexei Starovoitov wrote: > > On Tue, Nov 20, 2018 at 01:19:05PM -0800, Stanislav Fomichev wrote: > >> On 11/20, Alexei Starovoitov wrote: > >>> On Mon, Nov 19, 2018 at 04:46:

Re: [PATCH v3 bpf-next 1/2] bpf: adding support for map in map in libbpf

2018-11-20 Thread Alexei Starovoitov
On Mon, Nov 19, 2018 at 10:42:21PM -0800, Nikita V. Shirokov wrote: > idea is pretty simple. for specified map (pointed by struct bpf_map) > we would provide descriptor of already loaded map, which is going to be > used as a prototype for inner map. proposed workflow: > 1) open bpf's object

Re: [PATCH bpf-next] bpf: libbpf: retry program creation without the name

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 01:19:05PM -0800, Stanislav Fomichev wrote: > On 11/20, Alexei Starovoitov wrote: > > On Mon, Nov 19, 2018 at 04:46:25PM -0800, Stanislav Fomichev wrote: > > > [Recent commit 23499442c319 ("bpf: libbpf: retry map creation without > > > the

Re: [PATCH v2 3/4] libbpf: require size hint in bpf_prog_test_run

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 07:43:57PM +, Lorenz Bauer wrote: > On Tue, 20 Nov 2018 at 19:18, Alexei Starovoitov > wrote: > > > > On Tue, Nov 20, 2018 at 03:43:05PM +, Lorenz Bauer wrote: > > > Require size_out to be non-NULL if data_out is given. This prevents &

Re: [PATCH bpf-next] bpf: libbpf: retry program creation without the name

2018-11-20 Thread Alexei Starovoitov
On Mon, Nov 19, 2018 at 04:46:25PM -0800, Stanislav Fomichev wrote: > [Recent commit 23499442c319 ("bpf: libbpf: retry map creation without > the name") fixed this issue for maps, let's do the same for programs.] > > Since commit 88cda1c9da02 ("bpf: libbpf: Provide basic API support > to specify

Re: [PATCH v2 3/4] libbpf: require size hint in bpf_prog_test_run

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 03:43:05PM +, Lorenz Bauer wrote: > Require size_out to be non-NULL if data_out is given. This prevents > accidental overwriting of process memory after the output buffer. > > Adjust callers of bpf_prog_test_run to this behaviour. > > Signed-off-by: Lorenz Bauer >

Re: [PATCH v5 bpf-next 00/13] bpf: Add btf func info support

2018-11-20 Thread Alexei Starovoitov
On Tue, Nov 20, 2018 at 11:26:37AM +, Edward Cree wrote: > On 19/11/18 23:29, Martin KaFai Lau wrote: > > The BTF support was added to kernel by Commit 69b693f0aefa > > ("bpf: btf: Introduce BPF Type Format (BTF)"), which introduced > > .BTF section into ELF file and is primarily > > used for

Re: [PATCH bpf-next v2] bpftool: make libbfd optional

2018-11-16 Thread Alexei Starovoitov
nother patch on top of that to fix > libbfd feature detection (it's semi broken on ubuntu/fedora now). I think you'd need to wait until all trees merge. pls don't top post. > On Fri, Nov 16, 2018 at 8:47 PM Alexei Starovoitov < > alexei.starovoi...@gmail.com> wrote: > >

Re: [PATCH bpf-next v2] filter: add BPF_ADJ_ROOM_DATA mode to bpf_skb_adjust_room()

2018-11-16 Thread Alexei Starovoitov
On Tue, Nov 13, 2018 at 05:35:17PM +0100, Nicolas Dichtel wrote: > This new mode enables to add or remove an l2 header in a programmatic way > with cls_bpf. > For example, it enables to play with mpls headers. > > Signed-off-by: Nicolas Dichtel > Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v2] bpftool: make libbfd optional

2018-11-16 Thread Alexei Starovoitov
On Mon, Nov 12, 2018 at 1:44 PM Stanislav Fomichev wrote: > > Make it possible to build bpftool without libbfd. libbfd and libopcodes are > typically provided in dev/dbg packages (binutils-dev in debian) which we > usually don't have installed on the fleet machines and we'd like a way to have >

Re: [PATCH bpf-next v2 0/3] bpf: Support socket lookup in CGROUP_SOCK_ADDR progs

2018-11-16 Thread Alexei Starovoitov
On Fri, Nov 9, 2018 at 6:54 PM Andrey Ignatov wrote: > > This patch set makes bpf_sk_lookup_tcp, bpf_sk_lookup_udp and > bpf_sk_release helpers available in programs of type > BPF_PROG_TYPE_CGROUP_SOCK_ADDR. > > Patch 1 is a fix for bpf_sk_lookup_udp that was already merged to bpf > (stable)

Re: [PATCH bpf-next] bpf: libbpf: Fix bpf_program__next() API

2018-11-16 Thread Alexei Starovoitov
On Mon, Nov 12, 2018 at 03:44:53PM -0800, Martin KaFai Lau wrote: > This patch restores the behavior in > commit eac7d84519a3 ("tools: libbpf: don't return '.text' as a program for > multi-function programs") > such that bpf_program__next() does not return pseudo programs in ".text". > > Fixes:

Re: [PATCH bpf-next] selftests/bpf: Fix uninitialized duration warning

2018-11-16 Thread Alexei Starovoitov
On Fri, Nov 9, 2018 at 6:20 PM Joe Stringer wrote: > > Daniel Borkmann reports: > > test_progs.c: In function ‘main’: > test_progs.c:81:3: warning: ‘duration’ may be used uninitialized in this > function [-Wmaybe-uninitialized] >printf("%s:PASS:%s %d nsec\n", __func__, tag, duration);\ >

Re: [PATCH bpf-next v2 0/3] bpf: Allow narrow loads with offset > 0

2018-11-10 Thread Alexei Starovoitov
On Sat, Nov 10, 2018 at 10:15:12PM -0800, Andrey Ignatov wrote: > This patch set adds support for narrow loads with offset > 0 to BPF > verifier. > > Patch 1 provides more details and is the main patch in the set. > Patches 2 and 3 add new test cases to test_verifier and test_sock_addr >

Re: [PATCH v5 bpf-next 0/7] bpftool: support loading flow dissector

2018-11-10 Thread Alexei Starovoitov
On Fri, Nov 09, 2018 at 12:15:11PM -0800, Jakub Kicinski wrote: > On Fri, 9 Nov 2018 08:21:39 -0800, Stanislav Fomichev wrote: > > v5 changes: > > * FILE -> PATH for load/loadall (can be either file or directory now) > > * simpler implementation for __bpf_program__pin_name > > * removed p_err for

Re: [PATCH bpf-next 0/3] bpf: Allow narrow loads with offset > 0

2018-11-10 Thread Alexei Starovoitov
On Sat, Nov 10, 2018 at 11:13 AM Alexei Starovoitov wrote: > > On Tue, Nov 06, 2018 at 05:23:25PM -0800, Andrey Ignatov wrote: > > This patch set adds support for narrow loads with offset > 0 to BPF > > verifier. > > > > Patch 1 provides more details and is the m

Re: [PATCH bpf-next 0/3] bpf: Allow narrow loads with offset > 0

2018-11-10 Thread Alexei Starovoitov
On Tue, Nov 06, 2018 at 05:23:25PM -0800, Andrey Ignatov wrote: > This patch set adds support for narrow loads with offset > 0 to BPF > verifier. > > Patch 1 provides more details and is the main patch in the set. > Patches 2 and 3 add new test cases to test_verifier and test_sock_addr >

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-09 Thread Alexei Starovoitov
On 11/9/18 1:28 PM, Edward Cree wrote: > On 09/11/18 21:14, Alexei Starovoitov wrote: >> same link, but i cannot make it right now. >> have to extinguish few fires. >> may be at 2pm (unlikely) or 3pm (more likely) PST? > > Yep I can do either of those, just let me know

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-09 Thread Alexei Starovoitov
On 11/9/18 12:00 PM, Edward Cree wrote: > On 09/11/18 04:35, Alexei Starovoitov wrote: >> On Thu, Nov 08, 2018 at 10:56:55PM +, Edward Cree wrote: >>>  think this question of maps should be discussed in tomorrow's >>>  call, since it is when we start having other k

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-08 Thread Alexei Starovoitov
On Thu, Nov 08, 2018 at 10:56:55PM +, Edward Cree wrote: > On 08/11/18 19:42, Alexei Starovoitov wrote: > > same link let's continue at 1pm PST. > So, one thing we didn't really get onto was maps, and you mentioned that it >  wasn't really clear what I was proposing there.

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-08 Thread Alexei Starovoitov
On Thu, Nov 8, 2018 at 10:21 AM Alexei Starovoitov wrote: > > On Thu, Nov 08, 2018 at 05:58:56PM +, Edward Cree wrote: > > > > > Happy to jump on the call to explain it again. > > > 10:30am pacific time works for me tomorrow. > > That works for me (th

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-08 Thread Alexei Starovoitov
On Thu, Nov 08, 2018 at 05:58:56PM +, Edward Cree wrote: > > > Happy to jump on the call to explain it again. > > 10:30am pacific time works for me tomorrow. > That works for me (that's in ~30 minutes from now if I've converted >  correctly.)  Please email me offlist with the phone number to

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-07 Thread Alexei Starovoitov
On Wed, Nov 07, 2018 at 07:29:31PM +, Edward Cree wrote: > Whereas I don't, and I don't feel like my core criticisms have >  been addressed _at all_.  The only answer I get to "BTF should >  store type and instance information in separate records" is >  "it's a debuginfo", ... >  I am just

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-06 Thread Alexei Starovoitov
On Tue, Nov 06, 2018 at 10:58:42PM +, Edward Cree wrote: >  share its type record with 'foo'.  And partly just because the >  name of the function itself is no more part of its type than the >  name of an integer variable is part of the integer's type. correct. function name is not part of

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-06 Thread Alexei Starovoitov
On Tue, Nov 06, 2018 at 06:52:11PM +, Edward Cree wrote: > On 06/11/18 06:29, Alexei Starovoitov wrote: > > BTF is not pure type information. BTF is everything that verifier needs > > to know to make safety decisions that bpf instruction set doesn't have. > Yes,

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-05 Thread Alexei Starovoitov
On Thu, Nov 01, 2018 at 09:08:37PM +, Edward Cree wrote: > I've spent a bit more time thinking about / sleeping on this, and I >  still think there's a major disagreement here.  Basically it seems >  like I'm saying "the design of BTF is wrong" and you're saying "but >  it's the design" (with

Re: [PATCH bpf] bpf: fix bpf_prog_get_info_by_fd to return 0 func_lens for unpriv

2018-11-02 Thread Alexei Starovoitov
On Fri, Nov 02, 2018 at 11:35:46AM +0100, Daniel Borkmann wrote: > While dbecd7388476 ("bpf: get kernel symbol addresses via syscall") > zeroed info.nr_jited_ksyms in bpf_prog_get_info_by_fd() for queries > from unprivileged users, commit 815581c11cc2 ("bpf: get JITed image > lengths of functions

Re: [PATCH bpf 0/3] show more accurrate bpf program address

2018-11-01 Thread Alexei Starovoitov
eturns the main prog address. For the set: Acked-by: Alexei Starovoitov I think we have to make the whole thing consistent like this set does and send it to stable. The only other alternative is to invent new cmd and prog_info fields to return proper jited_ksyms and keep this one buggy forever

Re: [PATCH bpf 0/4] BPF fixes and tests

2018-10-31 Thread Alexei Starovoitov
On Thu, Nov 01, 2018 at 12:05:51AM +0100, Daniel Borkmann wrote: > The series contains two fixes in BPF core and test cases. For details > please see individual patches. Thanks! > > Daniel Borkmann (4): > bpf: fix partial copy of map_ptr when dst is scalar > bpf: don't set id on after map

Re: [PATCH bpf] bpf: fix wrong helper enablement in cgroup local storage

2018-10-26 Thread Alexei Starovoitov
On Fri, Oct 26, 2018 at 10:57:18PM +, Roman Gushchin wrote: > On Sat, Oct 27, 2018 at 12:49:02AM +0200, Daniel Borkmann wrote: > > Commit cd3394317653 ("bpf: introduce the bpf_get_local_storage() > > helper function") enabled the bpf_get_local_storage() helper also > > for BPF program types

Re: [PATCH bpf 0/7] Batch of direct packet access fixes for BPF

2018-10-25 Thread Alexei Starovoitov
On Wed, Oct 24, 2018 at 10:05:42PM +0200, Daniel Borkmann wrote: > Several fixes to get direct packet access in order from verifier > side. Also test suite fix to run cg_skb as unpriv and an improvement > to make direct packet write less error prone in future. Applied, Thanks

Re: [PATCH net-next 1/3] net/sock: factor out dequeue/peek with offset code

2018-10-24 Thread Alexei Starovoitov
On Tue, Oct 23, 2018 at 09:28:03AM +0200, Paolo Abeni wrote: > Hi, > > On Mon, 2018-10-22 at 21:49 -0700, Alexei Starovoitov wrote: > > On Mon, May 15, 2017 at 11:01:42AM +0200, Paolo Abeni wrote: > > > And update __sk_queue_drop_skb() to work on the specified queue. >

Re: [PATCH net-next 1/3] net/sock: factor out dequeue/peek with offset code

2018-10-22 Thread Alexei Starovoitov
On Mon, May 15, 2017 at 11:01:42AM +0200, Paolo Abeni wrote: > And update __sk_queue_drop_skb() to work on the specified queue. > This will help the udp protocol to use an additional private > rx queue in a later patch. > > Signed-off-by: Paolo Abeni > --- > include/linux/skbuff.h | 7 >

Re: [PATCH bpf-next 0/3] tools: bpftool: bring minor fixes to bpftool

2018-10-21 Thread Alexei Starovoitov
On Sat, Oct 20, 2018 at 11:01:47PM +0100, Quentin Monnet wrote: > Hi, > These are three minor fixes for bpftool, its documentation and its bash > completion function. Please refer to individual patches for details. Applied, Thanks

Re: [PATCH bpf-next] selftests/bpf: fix return value comparison for tests in test_libbpf.sh

2018-10-21 Thread Alexei Starovoitov
On Sat, Oct 20, 2018 at 10:58:44PM +0100, Quentin Monnet wrote: > The return value for each test in test_libbpf.sh is compared with > > if (( $? == 0 )) ; then ... > > This works well with bash, but not with dash, that /bin/sh is aliased to > on some systems (such as Ubuntu). > > Let's

Re: [PATCH bpf-next 0/6] Misc improvements and few minor fixes

2018-10-21 Thread Alexei Starovoitov
On Sun, Oct 21, 2018 at 02:09:22AM +0200, Daniel Borkmann wrote: > Last batch of misc patches I had in queue: first one removes some left-over > bits from ULP, second is a fix in the verifier where we wrongly use register > number as type to fetch the string for the dump, third disables xadd on

Re: [PATCH v8 bpf-next 0/2] bpf: add cg_skb_is_valid_access

2018-10-19 Thread Alexei Starovoitov
On Fri, Oct 19, 2018 at 09:57:56AM -0700, Song Liu wrote: > Changes v7 -> v8: > 1. Dynamically allocate the dummy sk to avoid race conditions. > > Changes v6 -> v7: > 1. Make dummy sk a global variable (test_run_sk). > > Changes v5 -> v6: > 1. Fixed dummy sk in bpf_prog_test_run_skb() as

Re: [PATCH bpf-next v2 0/2] improve and fix barriers for walking perf ring buffer

2018-10-19 Thread Alexei Starovoitov
On Fri, Oct 19, 2018 at 03:51:01PM +0200, Daniel Borkmann wrote: > This set first adds smp_* barrier variants to tools infrastructure > and updates perf and libbpf to make use of them. For details, please > see individual patches, thanks! > > Arnaldo, if there are no objections, could this be

Re: [PATCH bpf-next v3 0/7] Implement queue/stack maps

2018-10-19 Thread Alexei Starovoitov
On Fri, Oct 19, 2018 at 10:08:08PM +0200, Daniel Borkmann wrote: > On 10/18/2018 03:16 PM, Mauricio Vasquez B wrote: > > In some applications this is needed have a pool of free elements, for > > example the list of free L4 ports in a SNAT. None of the current maps allow > > to do it as it is not

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-18 Thread Alexei Starovoitov
On Thu, Oct 18, 2018 at 09:00:46PM +0200, Daniel Borkmann wrote: > On 10/18/2018 05:33 PM, Alexei Starovoitov wrote: > > On Thu, Oct 18, 2018 at 05:04:34PM +0200, Daniel Borkmann wrote: > >> #endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */ > >> diff --git a/tools/arch/po

  1   2   3   4   5   6   7   8   9   10   >