Re: [PATCH bpf-next V11 4/7] bpf: add BPF-helper for MTU checking

2021-01-13 Thread Daniel Borkmann
On 1/12/21 6:45 PM, Jesper Dangaard Brouer wrote: This BPF-helper bpf_check_mtu() works for both XDP and TC-BPF programs. [...] + * int bpf_check_mtu(void *ctx, u32 ifindex, u32 *mtu_len, s32 len_diff, u64 flags) + * Description + * Check ctx packet size against MTU of net devi

Re: [PATCH bpf-next V11 4/7] bpf: add BPF-helper for MTU checking

2021-01-14 Thread Daniel Borkmann
On 1/14/21 3:36 PM, Jesper Dangaard Brouer wrote: [...] +BPF_CALL_5(bpf_skb_check_mtu, struct sk_buff *, skb, + u32, ifindex, u32 *, mtu_len, s32, len_diff, u64, flags) +{ + int ret = BPF_MTU_CHK_RET_FRAG_NEEDED; + struct net_device *dev = skb->dev; + int skb_len, dev_l

pull-request: bpf 2021-01-16

2021-01-15 Thread Daniel Borkmann
Hi David, hi Jakub, The following pull-request contains BPF updates for your *net* tree. We've added 11 non-merge commits during the last 6 day(s) which contain a total of 14 files changed, 128 insertions(+), 115 deletions(-). The main changes are: 1) Fix a double bpf_prog_put() for BPF_PROG_{T

pull-request: bpf-next 2021-01-16

2021-01-15 Thread Daniel Borkmann
ieve SOL_SOCKET opts from sock_addr progs, from Daniel Borkmann. 6) Clean up driver's XDP buffer init and split into two helpers to init per- descriptor and non-changing fields during processing, from Lorenzo Bianconi. 7) Minor misc improvements to libbpf & bpftool, from Ian Rogers.

Re: [PATCH v12 bpf-next] bpf/selftests: fold test_current_pid_tgid_new_ns into test_progs.

2021-01-18 Thread Daniel Borkmann
On 1/14/21 3:10 PM, Carlos Neira wrote: Currently tests for bpf_get_ns_current_pid_tgid() are outside test_progs. This change folds test cases into test_progs. Changes from v11: - Fixed test failure is not detected. - Removed EXIT(3) call as it will stop test_progs execution. Signed-off-by

Re: [PATCHv7 bpf-next] samples/bpf: add xdp program on egress for xdp_redirect_map

2021-01-18 Thread Daniel Borkmann
On 1/15/21 7:24 AM, Hangbin Liu wrote: This patch add a xdp program on egress to show that we can modify the packet on egress. In this sample we will set the pkt's src mac to egress's mac address. The xdp_prog will be attached when -X option supplied. Signed-off-by: Hangbin Liu This has a bun

pull-request: bpf 2021-01-20

2021-01-20 Thread Daniel Borkmann
elper callback, from Mircea Cirjaliu. 2) Fix signed_{sub,add32}_overflows type truncation, from Daniel Borkmann. 3) Fix AF_XDP to also clear pools for inactive queues, from Maxim Mikityanskiy. Please consider pulling these changes from: git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git Tha

Re: [PATCH bpf-next] samples/bpf: fix possible hang in xdpsock with multiple threads

2020-12-10 Thread Daniel Borkmann
On 12/10/20 4:36 PM, Magnus Karlsson wrote: From: Magnus Karlsson Fix a possible hang in xdpsock that can occur when using multiple threads. In this case, one or more of the threads might get stuck in the while-loop in tx_only after the user has signaled the main thread to stop execution. In th

Re: [PATCH bpf-next] selftests/bpf: Fix selftest compilation on clang 11

2020-12-10 Thread Daniel Borkmann
On 12/10/20 5:28 PM, KP Singh wrote: On Thu, Dec 10, 2020 at 5:18 PM Jiri Olsa wrote: [...] It's hard and time-consuming enough to develop these features, I'd rather keep selftests simpler, more manageable, and less brittle by not having excessive amount of feature detection and skipped selfte

Re: [PATCH v3 1/1] xdp: avoid calling kfree twice

2020-12-10 Thread Daniel Borkmann
On 12/11/20 5:26 AM, Zhu Yanjun wrote: In the function xdp_umem_pin_pages, if npgs != umem->npgs and npgs >= 0, the function xdp_umem_unpin_pages is called. In this function, kfree is called to handle umem->pgs, and then in the function xdp_umem_pin_pages, kfree is called again to handle umem->pg

Re: [PATCH bpf-next v2] samples/bpf: fix possible hang in xdpsock with multiple threads

2020-12-10 Thread Daniel Borkmann
On 12/10/20 5:34 PM, Magnus Karlsson wrote: From: Magnus Karlsson Fix a possible hang in xdpsock that can occur when using multiple threads. In this case, one or more of the threads might get stuck in the while-loop in tx_only after the user has signaled the main thread to stop execution. In th

Re: [PATCHv4 bpf-next] samples/bpf: add xdp program on egress for xdp_redirect_map

2020-12-10 Thread Daniel Borkmann
On 12/8/20 1:01 PM, Hangbin Liu wrote: [...] +static int get_mac_addr(unsigned int ifindex_out, void *mac_addr) +{ + struct ifreq ifr; + char ifname[IF_NAMESIZE]; + int fd = socket(AF_INET, SOCK_DGRAM, 0); + + if (fd < 0) + return -1; + + if (!if_ind

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-11 Thread Daniel Borkmann
On 12/11/20 9:19 AM, Gary Lin wrote: The x64 bpf jit expects bpf images converge within the given passes, but it could fail to do so with some corner cases. For example: l0: ldh [4] l1: jeq #0x537d, l2, l40 l2: ld [0] l3: jeq #0xfa163e0d, l4, l40

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-11 Thread Daniel Borkmann
On 12/11/20 9:58 PM, Andrii Nakryiko wrote: On Fri, Dec 11, 2020 at 8:51 AM Gary Lin wrote: [...] +static int emit_nops(u8 **pprog, int len) +{ + u8 *prog = *pprog; + int i, noplen, cnt = 0; + + while (len > 0) { + noplen = len; + + if (noplen >

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-14 Thread Daniel Borkmann
On 12/14/20 9:15 AM, Gary Lin wrote: On Mon, Dec 14, 2020 at 11:56:22AM +0800, Gary Lin wrote: On Fri, Dec 11, 2020 at 09:05:05PM +0100, Daniel Borkmann wrote: On 12/11/20 9:19 AM, Gary Lin wrote: The x64 bpf jit expects bpf images converge within the given passes, but it could fail to do so

pull-request: bpf-next 2020-12-14

2020-12-14 Thread Daniel Borkmann
socket members Brendan Jackman (1): libbpf: Expose libbpf ring_buffer epoll_fd Daniel Borkmann (1): Merge branch 'bpf-xsk-selftests' Eric Dumazet (1): bpf: Avoid overflows involving hash elem_size Florent Revest (7): net: Remove the err argument from sock_from_fi

Re: [PATCH v3 bpf-next 2/2] net: xdp: introduce xdp_prepare_buff utility routine

2020-12-15 Thread Daniel Borkmann
On 12/15/20 2:47 PM, Lorenzo Bianconi wrote: [...] diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 329397c60d84..61d3f5f8b7f3 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -866,10 +866,8 @@ static u32 xennet_run_xdp(struct netfront_queue *q

Re: [Patch bpf-next v2 2/5] bpf: introduce timeout map

2020-12-15 Thread Daniel Borkmann
On 12/15/20 11:03 PM, Andrii Nakryiko wrote: On Tue, Dec 15, 2020 at 12:06 PM Cong Wang wrote: On Tue, Dec 15, 2020 at 11:27 AM Andrii Nakryiko wrote: On Mon, Dec 14, 2020 at 12:17 PM Cong Wang wrote: From: Cong Wang This borrows the idea from conntrack and will be used for conntrack i

Re: [Patch bpf-next v2 2/5] bpf: introduce timeout map

2020-12-17 Thread Daniel Borkmann
On 12/16/20 1:22 AM, Cong Wang wrote: On Tue, Dec 15, 2020 at 3:23 PM Daniel Borkmann wrote: On 12/15/20 11:03 PM, Andrii Nakryiko wrote: On Tue, Dec 15, 2020 at 12:06 PM Cong Wang wrote: On Tue, Dec 15, 2020 at 11:27 AM Andrii Nakryiko wrote: On Mon, Dec 14, 2020 at 12:17 PM Cong Wang

Re: linux-next: build failure after merge of the bpf-next tree

2020-12-01 Thread Daniel Borkmann
On 12/1/20 9:07 AM, Stephen Rothwell wrote: Hi all, After merging the bpf-next tree, today's linux-next build (x86_64 allnoconfig) failed like this: In file included from fs/select.c:32: include/net/busy_poll.h: In function 'sk_mark_napi_id_once': include/net/busy_poll.h:150:36: error: 'const s

Re: [PATCH bpf-next V7 2/8] bpf: fix bpf_fib_lookup helper MTU check for SKB ctx

2020-12-02 Thread Daniel Borkmann
On 11/20/20 5:18 PM, Jesper Dangaard Brouer wrote: BPF end-user on Cilium slack-channel (Carlo Carraro) wants to use bpf_fib_lookup for doing MTU-check, but *prior* to extending packet size, by adjusting fib_params 'tot_len' with the packet length plus the expected encap size. (Just like the bpf_

Re: [PATCH bpf-next V7 2/8] bpf: fix bpf_fib_lookup helper MTU check for SKB ctx

2020-12-02 Thread Daniel Borkmann
On 12/2/20 10:44 PM, Daniel Borkmann wrote: On 11/20/20 5:18 PM, Jesper Dangaard Brouer wrote: BPF end-user on Cilium slack-channel (Carlo Carraro) wants to use bpf_fib_lookup for doing MTU-check, but *prior* to extending packet size, by adjusting fib_params 'tot_len' with the pac

Re: [PATCH bpf-next V8 3/8] bpf: bpf_fib_lookup return MTU value as output when looked up

2020-12-02 Thread Daniel Borkmann
On 11/27/20 7:06 PM, Jesper Dangaard Brouer wrote: The BPF-helpers for FIB lookup (bpf_xdp_fib_lookup and bpf_skb_fib_lookup) can perform MTU check and return BPF_FIB_LKUP_RET_FRAG_NEEDED. The BPF-prog don't know the MTU value that caused this rejection. If the BPF-prog wants to implement PMTU

Re: [PATCH bpf-next V8 4/8] bpf: add BPF-helper for MTU checking

2020-12-02 Thread Daniel Borkmann
On 11/27/20 7:06 PM, Jesper Dangaard Brouer wrote: [...] +static struct net_device *__dev_via_ifindex(struct net_device *dev_curr, + u32 ifindex) +{ + struct net *netns = dev_net(dev_curr); + + /* Non-redirect use-cases can use ifindex=0 and s

Re: [PATCH bpf-next V8 5/8] bpf: drop MTU check when doing TC-BPF redirect to ingress

2020-12-02 Thread Daniel Borkmann
On 11/27/20 7:06 PM, Jesper Dangaard Brouer wrote: The use-case for dropping the MTU check when TC-BPF does redirect to ingress, is described by Eyal Birger in email[0]. The summary is the ability to increase packet size (e.g. with IPv6 headers for NAT64) and ingress redirect packet and let norma

Re: [PATCH bpf-next V8 6/8] bpf: make it possible to identify BPF redirected SKBs

2020-12-02 Thread Daniel Borkmann
On 11/27/20 7:06 PM, Jesper Dangaard Brouer wrote: This change makes it possible to identify SKBs that have been redirected by TC-BPF (cls_act). This is needed for a number of cases. (1) For collaborating with driver ifb net_devices. (2) For avoiding starting generic-XDP prog on TC ingress redir

Re: [PATCH v2 bpf 1/5] net: ethtool: add xdp properties flag set

2020-12-04 Thread Daniel Borkmann
On 12/4/20 1:46 PM, Maciej Fijalkowski wrote: On Fri, Dec 04, 2020 at 01:18:31PM +0100, Toke Høiland-Jørgensen wrote: alar...@gmail.com writes: From: Marek Majtyka Implement support for checking what kind of xdp functionality a netdev supports. Previously, there was no way to do this other th

Re: [PATCH v2 bpf 1/5] net: ethtool: add xdp properties flag set

2020-12-04 Thread Daniel Borkmann
On 12/4/20 6:20 PM, Toke Høiland-Jørgensen wrote: Daniel Borkmann writes: [...] We tried to standardize on a minimum guaranteed amount, but unfortunately not everyone seems to implement it, but I think it would be very useful to query this from application side, for example, consider that an

Re: [PATCH bpf-next v9 00/34] bpf: switch to memcg-based memory accounting

2020-12-04 Thread Daniel Borkmann
On 12/3/20 4:26 AM, Roman Gushchin wrote: On Wed, Dec 02, 2020 at 06:54:46PM -0800, Alexei Starovoitov wrote: On Tue, Dec 1, 2020 at 1:59 PM Roman Gushchin wrote: 5) Cryptic -EPERM is returned on exceeding the limit. Libbpf even had a function to "explain" this case for users. ... v9:

Re: [PATCH v2 bpf 1/5] net: ethtool: add xdp properties flag set

2020-12-08 Thread Daniel Borkmann
On 12/8/20 10:00 AM, Jesper Dangaard Brouer wrote: On Mon, 07 Dec 2020 12:52:22 -0800 John Fastabend wrote: Use-case(1): Cloud-provider want to give customers (running VMs) ability to load XDP program for DDoS protection (only), but don't want to allow customer to use XDP_TX (that can implemen

Re: [PATCH v2 1/1] xdp: avoid calling kfree twice

2020-12-08 Thread Daniel Borkmann
On 12/9/20 6:03 AM, Zhu Yanjun wrote: In the function xdp_umem_pin_pages, if npgs != umem->npgs and npgs >= 0, the function xdp_umem_unpin_pages is called. In this function, kfree is called to handle umem->pgs, and then in the function xdp_umem_pin_pages, kfree is called again to handle umem->pgs

Re: [PATCH bpf v4 0/7] selftests/bpf: Restore test_offload.py to working order

2020-12-09 Thread Daniel Borkmann
On 12/9/20 2:57 PM, Toke Høiland-Jørgensen wrote: This series restores the test_offload.py selftest to working order. It seems a number of subtle behavioural changes have crept into various subsystems which broke test_offload.py in a number of ways. Most of these are fairly benign changes where s

Re: [PATCH bpf-next v6 06/34] bpf: prepare for memcg-based memory accounting for bpf maps

2020-11-18 Thread Daniel Borkmann
On 11/18/20 2:28 AM, Roman Gushchin wrote: On Tue, Nov 17, 2020 at 05:11:00PM -0800, Alexei Starovoitov wrote: On Tue, Nov 17, 2020 at 5:07 PM Roman Gushchin wrote: On Tue, Nov 17, 2020 at 04:46:34PM -0800, Roman Gushchin wrote: On Wed, Nov 18, 2020 at 01:06:17AM +0100, Daniel Borkmann wrote

Re: [PATCH] bpf: Check the return value of dev_get_by_index_rcu()

2020-11-20 Thread Daniel Borkmann
ady earlier in bpf_ipv{4,6}_fib_lookup() and now need to redo it again ... so yeah there could be a tiny race in here. We wanted do bring this logic closer to what XDP does anyway, something like below, for example. David, thoughts? Thx Subject: [PATCH] diff mtu check Signed-off-by: Daniel Borkm

Re: [PATCH] bpf: Check the return value of dev_get_by_index_rcu()

2020-11-20 Thread Daniel Borkmann
On 11/20/20 4:19 PM, David Ahern wrote: On 11/20/20 8:13 AM, Daniel Borkmann wrote: [ +David ] On 11/19/20 8:04 AM, xiakaixu1...@gmail.com wrote: From: Kaixu Xia The return value of dev_get_by_index_rcu() can be NULL, so here it is need to check the return value and return error code if it

Re: [k...@kernel.org: Re: [PATCH net-next v2 0/3] net: introduce rps_default_mask]

2020-11-20 Thread Daniel Borkmann
@vger.kernel.org, Jonathan Corbet , "David S. Miller" , Shuah Khan , linux-...@vger.kernel.org, linux-kselft...@vger.kernel.org, Marcelo Tosatti , Daniel Borkmann Bcc: Date: Wed, 4 Nov 2020 11:42:26 -0800 Subject: Re: [PATCH net-next v2 0/3] net: introduce rps_default_mask On Wed, 04 Nov 202

Re: [PATCH bpf-next] bpf: simplify task_file_seq_get_next()

2020-11-20 Thread Daniel Borkmann
On 11/20/20 1:28 AM, Song Liu wrote: Simplify task_file_seq_get_next() by removing two in/out arguments: task and fstruct. Use info->task and info->files instead. Cc: Yonghong Song Signed-off-by: Song Liu Applied, thanks!

Re: [PATCH bpf-next v7 00/34] bpf: switch to memcg-based memory accounting

2020-11-23 Thread Daniel Borkmann
On 11/19/20 6:37 PM, Roman Gushchin wrote: Currently bpf is using the memlock rlimit for the memory accounting. This approach has its downsides and over time has created a significant amount of problems: 1) The limit is per-user, but because most bpf operations are performed as root, the lim

Re: [PATCH bpf] net, xsk: Avoid taking multiple skbuff references

2020-11-23 Thread Daniel Borkmann
On 11/23/20 2:12 PM, Björn Töpel wrote: From: Björn Töpel Commit 642e450b6b59 ("xsk: Do not discard packet when NETDEV_TX_BUSY") addressed the problem that packets were discarded from the Tx AF_XDP ring, when the driver returned NETDEV_TX_BUSY. Part of the fix was bumping the skbuff reference c

Re: [PATCH bpf v2] net, xsk: Avoid taking multiple skbuff references

2020-11-24 Thread Daniel Borkmann
On 11/23/20 6:56 PM, Björn Töpel wrote: From: Björn Töpel Commit 642e450b6b59 ("xsk: Do not discard packet when NETDEV_TX_BUSY") addressed the problem that packets were discarded from the Tx AF_XDP ring, when the driver returned NETDEV_TX_BUSY. Part of the fix was bumping the skbuff reference c

Re: [PATCH][V2] libbpf: add support for canceling cached_cons advance

2020-11-24 Thread Daniel Borkmann
On 11/24/20 9:12 AM, Magnus Karlsson wrote: On Tue, Nov 24, 2020 at 8:33 AM Li RongQing wrote: Add a new function for returning descriptors the user received after an xsk_ring_cons__peek call. After the application has gotten a number of descriptors from a ring, it might not be able to or want

Re: [PATCH v3 1/1] xdp: remove the function xsk_map_inc

2020-11-24 Thread Daniel Borkmann
On 11/23/20 4:05 PM, Zhu Yanjun wrote: From: Zhu Yanjun The function xsk_map_inc is a simple wrapper of bpf_map_inc and always returns zero. As such, replacing this function with bpf_map_inc and removing the test code. Signed-off-by: Zhu Yanjun --- net/xdp/xsk.c| 2 +- net/xdp/xsk.h

Re: [PATCH net-next 0/3] mvneta: access skb_shared_info only on last frag

2020-11-24 Thread Daniel Borkmann
On 11/24/20 11:18 PM, Lorenzo Bianconi wrote: On Fri, 20 Nov 2020 18:05:41 +0100 Lorenzo Bianconi wrote: Build skb_shared_info on mvneta_rx_swbm stack and sync it to xdp_buff skb_shared_info area only on the last fragment. Avoid avoid unnecessary xdp_buff initialization in mvneta_rx_swbm routine

Re: [PATCH net-next 0/3] mvneta: access skb_shared_info only on last frag

2020-11-24 Thread Daniel Borkmann
On 11/24/20 11:30 PM, Jakub Kicinski wrote: On Tue, 24 Nov 2020 23:25:11 +0100 Daniel Borkmann wrote: On 11/24/20 11:18 PM, Lorenzo Bianconi wrote: On Fri, 20 Nov 2020 18:05:41 +0100 Lorenzo Bianconi wrote: Build skb_shared_info on mvneta_rx_swbm stack and sync it to xdp_buff skb_shared_info

Re: [PATCH][V2] libbpf: add support for canceling cached_cons advance

2020-11-25 Thread Daniel Borkmann
On 11/25/20 9:30 AM, Magnus Karlsson wrote: On Tue, Nov 24, 2020 at 10:58 PM Daniel Borkmann wrote: On 11/24/20 9:12 AM, Magnus Karlsson wrote: On Tue, Nov 24, 2020 at 8:33 AM Li RongQing wrote: Add a new function for returning descriptors the user received after an xsk_ring_cons__peek

Re: [PATCH][V2] libbpf: add support for canceling cached_cons advance

2020-11-25 Thread Daniel Borkmann
On 11/25/20 10:13 AM, Magnus Karlsson wrote: On Wed, Nov 25, 2020 at 10:02 AM Daniel Borkmann wrote: On 11/25/20 9:30 AM, Magnus Karlsson wrote: On Tue, Nov 24, 2020 at 10:58 PM Daniel Borkmann wrote: On 11/24/20 9:12 AM, Magnus Karlsson wrote: On Tue, Nov 24, 2020 at 8:33 AM Li RongQing

Re: [PATCH][V2] libbpf: add support for canceling cached_cons advance

2020-11-25 Thread Daniel Borkmann
On 11/25/20 11:09 AM, Magnus Karlsson wrote: On Wed, Nov 25, 2020 at 11:07 AM Daniel Borkmann wrote: On 11/25/20 10:13 AM, Magnus Karlsson wrote: On Wed, Nov 25, 2020 at 10:02 AM Daniel Borkmann wrote: On 11/25/20 9:30 AM, Magnus Karlsson wrote: On Tue, Nov 24, 2020 at 10:58 PM Daniel

Re: [PATCH bpf-next v8 06/34] bpf: prepare for memcg-based memory accounting for bpf maps

2020-11-25 Thread Daniel Borkmann
On 11/25/20 4:00 AM, Roman Gushchin wrote: In the absolute majority of cases if a process is making a kernel allocation, it's memory cgroup is getting charged. Bpf maps can be updated from an interrupt context and in such case there is no process which can be charged. It makes the memory account

Re: [PATCH bpf v2 2/2] xsk: change the tx writeable condition

2020-11-27 Thread Daniel Borkmann
On 11/25/20 7:48 AM, Xuan Zhuo wrote: Modify the tx writeable condition from the queue is not full to the number of present tx queues is less than the half of the total number of queues. Because the tx queue not full is a very short time, this will cause a large number of EPOLLOUT events, and cau

Re: [PATCH] bpf, x64: add extra passes without size optimizations

2020-11-27 Thread Daniel Borkmann
On 11/27/20 8:22 AM, Gary Lin wrote: The x64 bpf jit expects bpf images converge within the given passes, but it could fail to do so with some corner cases. For example: l0: ldh [4] l1: jeq #0x537d, l2, l40 l2: ld [0] l3: jeq #0xfa163e0d, l4, l40

Re: [PATCH] bpf: remove trailing semicolon in macro definition

2020-11-27 Thread Daniel Borkmann
On 11/27/20 8:27 PM, t...@redhat.com wrote: From: Tom Rix The macro use will already have a semicolon. Signed-off-by: Tom Rix --- include/trace/events/xdp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/trace/events/xdp.h b/include/trace/events/xdp.h index

pull-request: bpf 2020-11-28

2020-11-27 Thread Daniel Borkmann
Hi David, hi Jakub, The following pull-request contains BPF updates for your *net* tree. We've added 6 non-merge commits during the last 6 day(s) which contain a total of 9 files changed, 61 insertions(+), 23 deletions(-). The main changes are: 1) Do not reference the skb for xsk's generic TX s

Re: [PATCHv5 bpf] bpf: Move iterator functions into special init section

2020-11-09 Thread Daniel Borkmann
On 11/9/20 7:57 PM, Jiri Olsa wrote: With upcoming changes to pahole, that change the way how and which kernel functions are stored in BTF data, we need a way to recognize iterator functions. Iterator functions need to be in BTF data, but have no real body and are currently placed in .init.text

Re: [PATCHv5 bpf] bpf: Move iterator functions into special init section

2020-11-10 Thread Daniel Borkmann
On 11/10/20 11:35 AM, Jiri Olsa wrote: On Mon, Nov 09, 2020 at 11:04:34PM +0100, Daniel Borkmann wrote: SNIP index 7b53cb3092ee..a7c71e3b5f9a 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -52,6 +52,7 @@ #define __initconst __section(".init.rodata") #define

Re: [PATCH v3] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id

2020-11-11 Thread Daniel Borkmann
On 11/11/20 6:03 AM, xiakaixu1...@gmail.com wrote: From: Kaixu Xia The unsigned variable datasec_id is assigned a return value from the call to check_pseudo_btf_id(), which may return negative error code. Fixes coccicheck warning: ./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expressio

Re: [PATCHv6 bpf] bpf: Move iterator functions into special init section

2020-11-11 Thread Daniel Borkmann
On 11/10/20 4:40 PM, Jiri Olsa wrote: With upcoming changes to pahole, that change the way how and which kernel functions are stored in BTF data, we need a way to recognize iterator functions. Iterator functions need to be in BTF data, but have no real body and are currently placed in .init.text

Re: [PATCHv3 iproute2-next 0/5] iproute2: add libbpf support

2020-11-11 Thread Daniel Borkmann
On 11/11/20 12:02 PM, Toke Høiland-Jørgensen wrote: Alexei Starovoitov writes: On Mon, Nov 09, 2020 at 09:09:44PM -0700, David Ahern wrote: On 11/8/20 6:45 PM, Alexei Starovoitov wrote: I don't understand why on one side you're pointing out existing quirkiness with bpf usability while at the

Re: [PATCH v3 bpf] tools: bpftool: Add missing close before bpftool net attach exit

2020-11-11 Thread Daniel Borkmann
On 11/11/20 2:54 PM, Wang Hai wrote: progfd is created by prog_parse_fd(), before 'bpftool net attach' exit, it should be closed. Fixes: 04949ccc273e ("tools: bpftool: add net attach command to attach XDP on interface") Signed-off-by: Wang Hai --- v2->v3: add 'err = 0' before successful return

Re: [bpf PATCH 3/5] bpf, sockmap: Avoid returning unneeded EAGAIN when redirecting to self

2020-11-11 Thread Daniel Borkmann
On 11/7/20 8:38 PM, John Fastabend wrote: If a socket redirects to itself and it is under memory pressure it is possible to get a socket stuck so that recv() returns EAGAIN and the socket can not advance for some time. This happens because when redirecting a skb to the same socket we received the

Re: [bpf PATCH 1/5] bpf, sockmap: fix partial copy_page_to_iter so progress can still be made

2020-11-11 Thread Daniel Borkmann
On 11/7/20 8:37 PM, John Fastabend wrote: If copy_page_to_iter() fails or even partially completes, but with fewer bytes copied than expected we currently reset sg.start and return EFAULT. This proves problematic if we already copied data into the user buffer before we return an error. Because we

Re: [PATCH] selftest/bpf: fix IPV6FR handling in flow dissector

2020-11-11 Thread Daniel Borkmann
On 11/11/20 3:12 PM, Santucci Pierpaolo wrote: Hi Jakub, thanks for your reply. (Santucci, please do not top-post but always reply inline which makes it easier for discussions to follow.) Let me explain the problem with an example. Please consider the PCAP file: https://github.com/named-da

Re: [PATCH bpf] MAINTAINERS/bpf: Update Andrii's entry.

2020-11-12 Thread Daniel Borkmann
On 11/12/20 7:03 PM, Alexei Starovoitov wrote: From: Alexei Starovoitov Andrii has been a de-facto maintainer for libbpf and other components. Update maintainers entry to acknowledge his work de-jure. The folks with git write permissions will continue to follow the rule of not applying their o

Re: [PATCHv3 iproute2-next 0/5] iproute2: add libbpf support

2020-11-12 Thread Daniel Borkmann
On 11/12/20 11:36 PM, Toke Høiland-Jørgensen wrote: Daniel Borkmann writes: Besides, for the entire history of BPF support in iproute2 so far, the benefit has come from all the features that libbpf has just started automatically supporting on load (BTF, etc), so users would have benefited

Re: [PATCH v2 bpf-next 1/3] bpf: Support for pointers beyond pkt_end.

2020-11-12 Thread Daniel Borkmann
On 11/12/20 8:16 PM, John Fastabend wrote: Alexei Starovoitov wrote: From: Alexei Starovoitov This patch adds the verifier support to recognize inlined branch conditions. The LLVM knows that the branch evaluates to the same value, but the verifier couldn't track it. Hence causing valid program

Re: [PATCH v2 bpf-next 1/3] bpf: Support for pointers beyond pkt_end.

2020-11-12 Thread Daniel Borkmann
On 11/13/20 1:09 AM, Alexei Starovoitov wrote: On Fri, Nov 13, 2020 at 12:56:52AM +0100, Daniel Borkmann wrote: On 11/12/20 8:16 PM, John Fastabend wrote: Alexei Starovoitov wrote: From: Alexei Starovoitov This patch adds the verifier support to recognize inlined branch conditions. The LLVM

Re: csum_partial() on different archs (selftest/bpf)

2020-11-13 Thread Daniel Borkmann
On 11/13/20 3:15 PM, Al Viro wrote: On Fri, Nov 13, 2020 at 02:22:16PM +0100, Björn Töpel wrote: Folding Al's input to this reply. I think the bpf_csum_diff() is supposed to be used in combination with another helper(s) (e.g. bpf_l4_csum_replace) so I'd guess the returned __wsum should be seen

Re: [PATCH v4 bpf] tools: bpftool: Add missing close before bpftool net attach exit

2020-11-13 Thread Daniel Borkmann
On 11/13/20 12:51 PM, Wang Hai wrote: progfd is created by prog_parse_fd(), before 'bpftool net attach' exit, it should be closed. Fixes: 04949ccc273e ("tools: bpftool: add net attach command to attach XDP on interface") Signed-off-by: Wang Hai Applied & improved commit msg a bit, thanks!

Re: [PATCH] ip_tunnels: Set tunnel option flag when tunnel metadata is present

2020-11-13 Thread Daniel Borkmann
On 11/14/20 1:13 AM, Jakub Kicinski wrote: On Tue, 10 Nov 2020 16:16:40 -0800 Yi-Hung Wei wrote: Currently, we may set the tunnel option flag when the size of metadata is zero. For example, we set TUNNEL_GENEVE_OPT in the receive function no matter the geneve option is present or not. As this

pull-request: bpf-next 2020-11-14

2020-11-13 Thread Daniel Borkmann
BTF and return extra info for BTF in GET_OBJ_INFO kbuild: Build kernel module BTFs if BTF is enabled and pahole supports it bpf: Load and verify kernel module BTFs tools/bpftool: Add support for in-kernel and named BTF in `btf show` bpf: Compile out btf_parse_module() if m

Re: [PATCH bpf-next v6 06/34] bpf: prepare for memcg-based memory accounting for bpf maps

2020-11-17 Thread Daniel Borkmann
On 11/17/20 4:40 AM, Roman Gushchin wrote: In the absolute majority of cases if a process is making a kernel allocation, it's memory cgroup is getting charged. Bpf maps can be updated from an interrupt context and in such case there is no process which can be charged. It makes the memory account

Re: [PATCH 1/3 v4 bpf-next] bpf: save correct stopping point in file seq iteration.

2020-12-23 Thread Daniel Borkmann
On 12/18/20 10:01 PM, Andrii Nakryiko wrote: On Fri, Dec 18, 2020 at 12:47 PM Jonathan Lemon wrote: From: Jonathan Lemon On some systems, some variant of the following splat is repeatedly seen. The common factor in all traces seems to be the entry point to task_file_seq_next(). With the pa

pull-request: bpf 2020-12-28

2020-12-28 Thread Daniel Borkmann
Hi David, hi Jakub, The following pull-request contains BPF updates for your *net* tree. There is a small merge conflict between bpf tree commit 69ca310f3416 ("bpf: Save correct stopping point in file seq iteration") and net tree commit 66ed594409a1 ("bpf/task_iter: In task_file_seq_get_next use

Re: [PATCH v5 bpf-next 2/2] net: xdp: introduce xdp_prepare_buff utility routine

2020-12-29 Thread Daniel Borkmann
On 12/22/20 10:09 PM, Lorenzo Bianconi wrote: Introduce xdp_prepare_buff utility routine to initialize per-descriptor xdp_buff fields (e.g. xdp_buff pointers). Rely on xdp_prepare_buff() in all XDP capable drivers. Signed-off-by: Lorenzo Bianconi Overall looks good to me, just one small nit i

Re: [PATCH v5 bpf-next 2/2] net: xdp: introduce xdp_prepare_buff utility routine

2020-12-30 Thread Daniel Borkmann
On 12/29/20 7:09 PM, Lorenzo Bianconi wrote: + hard_start = page_address(rx_buffer->page) + + rx_buffer->page_offset - offset; + xdp_prepare_buff(&xdp, hard_start, offset, size, true); #if (PAGE_SIZE > 4096)

Re: [PATCH net v2] net: fix use-after-free when UDP GRO with shared fraglist

2021-01-07 Thread Daniel Borkmann
On 1/7/21 1:39 AM, Dongseok Yi wrote: skbs in fraglist could be shared by a BPF filter loaded at TC. It triggers skb_ensure_writable -> pskb_expand_head -> skb_clone_fraglist -> skb_get on each skb in the fraglist. While tcpdump, sk_receive_queue of PF_PACKET has the original fraglist. But the s

Re: [PATCH net v2] net: fix use-after-free when UDP GRO with shared fraglist

2021-01-07 Thread Daniel Borkmann
On 1/7/21 12:40 PM, Dongseok Yi wrote: On 2021-01-07 20:05, Daniel Borkmann wrote: On 1/7/21 1:39 AM, Dongseok Yi wrote: skbs in fraglist could be shared by a BPF filter loaded at TC. It triggers skb_ensure_writable -> pskb_expand_head -> skb_clone_fraglist -> skb_get on each s

Re: [PATCH net v2] net: fix use-after-free when UDP GRO with shared fraglist

2021-01-07 Thread Daniel Borkmann
On 1/7/21 2:05 PM, Willem de Bruijn wrote: On Thu, Jan 7, 2021 at 7:52 AM Daniel Borkmann wrote: On 1/7/21 12:40 PM, Dongseok Yi wrote: On 2021-01-07 20:05, Daniel Borkmann wrote: On 1/7/21 1:39 AM, Dongseok Yi wrote: skbs in fraglist could be shared by a BPF filter loaded at TC. It

Re: [PATCH net v3] net: fix use-after-free when UDP GRO with shared fraglist

2021-01-08 Thread Daniel Borkmann
8/0x38 [ 4443.426869] el0_svc_common+0xf0/0x1d0 [ 4443.426873] el0_svc_handler+0x74/0x98 [ 4443.426880] el0_svc+0x8/0xc Fixes: 3a1296a38d0c (net: Support GRO/GSO fraglist chaining.) Signed-off-by: Dongseok Yi Acked-by: Willem de Bruijn Acked-by: Daniel Borkmann

Re: [PATCH net v2] net: fix use-after-free when UDP GRO with shared fraglist

2021-01-08 Thread Daniel Borkmann
On 1/7/21 3:44 PM, Willem de Bruijn wrote: On Thu, Jan 7, 2021 at 8:33 AM Daniel Borkmann wrote: On 1/7/21 2:05 PM, Willem de Bruijn wrote: On Thu, Jan 7, 2021 at 7:52 AM Daniel Borkmann wrote: On 1/7/21 12:40 PM, Dongseok Yi wrote: On 2021-01-07 20:05, Daniel Borkmann wrote: On 1/7/21 1

Re: [PATCH RESEND v2 1/3] bpf,x64: pad NOPs to make images converge more easily

2021-01-08 Thread Daniel Borkmann
On 1/7/21 3:16 AM, Gary Lin wrote: The x64 bpf jit expects bpf images converge within the given passes, but it could fail to do so with some corner cases. For example: l0: ja 40 l1: ja 40 [... repeated ja 40 ] l39:ja 40 l40:ret #0 This bpf

Re: [PATCH] Signed-off-by: giladreti

2021-01-11 Thread Daniel Borkmann
Hello Gilad, On 1/11/21 4:31 PM, giladreti wrote: Added support for pointer to mem register spilling, to allow the verifier to track pointer to valid memory addresses. Such pointers are returned for example by a successful call of the bpf_ringbuf_reserve helper. This patch was suggested as a so

[PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex

2021-01-11 Thread Daniel Borkmann
Extend existing cgroup bind4/bind6 tests to add coverage for setting and retrieving SO_MARK, SO_PRIORITY and SO_BINDTOIFINDEX at the bind hook. Signed-off-by: Daniel Borkmann --- .../testing/selftests/bpf/progs/bind4_prog.c | 41 +-- .../testing/selftests/bpf/progs/bind6_prog.c

[PATCH bpf-next 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs

2021-01-11 Thread Daniel Borkmann
priority in particular allow to retrieve the options from BPF cgroup hooks to then implement custom behavior / settings on the syscall hooks compared to other sockets that stick to the defaults, for example. Signed-off-by: Daniel Borkmann --- net/core/filter.c | 25 +++-- 1 file

Re: [PATCH bpf-next 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex

2021-01-11 Thread Daniel Borkmann
On 1/11/21 9:15 PM, Yonghong Song wrote: On 1/11/21 8:17 AM, Daniel Borkmann wrote: Extend existing cgroup bind4/bind6 tests to add coverage for setting and retrieving SO_MARK, SO_PRIORITY and SO_BINDTOIFINDEX at the bind hook. Signed-off-by: Daniel Borkmann Ack with a minor comments below

[PATCH bpf-next v2 2/2] bpf: extend bind v4/v6 selftests for mark/prio/bindtoifindex

2021-01-11 Thread Daniel Borkmann
Extend existing cgroup bind4/bind6 tests to add coverage for setting and retrieving SO_MARK, SO_PRIORITY and SO_BINDTOIFINDEX at the bind hook. Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song --- v1 -> v2: - Add comment on old vs new optval (Yonghong), rest as-is .../testing/selfte

[PATCH bpf-next v2 1/2] bpf: allow to retrieve sol_socket opts from sock_addr progs

2021-01-11 Thread Daniel Borkmann
priority in particular allow to retrieve the options from BPF cgroup hooks to then implement custom behavior / settings on the syscall hooks compared to other sockets that stick to the defaults, for example. Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song --- net/core/filter.c | 25

Re: [PATCH 2/2] selftests/bpf: add verifier test for PTR_TO_MEM spill

2021-01-12 Thread Daniel Borkmann
On 1/12/21 4:35 PM, Gilad Reti wrote: On Tue, Jan 12, 2021 at 4:56 PM KP Singh wrote: On Tue, Jan 12, 2021 at 10:16 AM Gilad Reti wrote: Add test to check that the verifier is able to recognize spilling of PTR_TO_MEM registers. It would be nice to have some explanation of what the test doe

Re: [PATCH v3 bpf-next 5/7] bpf: support BPF ksym variables in kernel modules

2021-01-12 Thread Daniel Borkmann
On 1/12/21 8:55 AM, Andrii Nakryiko wrote: Add support for directly accessing kernel module variables from BPF programs using special ldimm64 instructions. This functionality builds upon vmlinux ksym support, but extends ldimm64 with src_reg=BPF_PSEUDO_BTF_ID to allow specifying kernel module BTF

Re: [PATCH bpf-next 0/2] add xdp_build_skb_from_frame utility routine

2021-01-12 Thread Daniel Borkmann
On 1/12/21 5:08 PM, Lorenzo Bianconi wrote: Introduce __xdp_build_skb_from_frame and xdp_build_skb_from_frame routines to build the skb from a xdp_frame. Respect to __xdp_build_skb_from_frame, xdp_build_skb_from_frame will allocate the skb object. Rely on __xdp_build_skb_from_frame/xdp_build_skb_

Re: [PATCH RFC bpf-next 1/2] bpf_redirect_neigh: Support supplying the nexthop as a helper parameter

2020-10-19 Thread Daniel Borkmann
On 10/15/20 9:34 PM, Toke Høiland-Jørgensen wrote: David Ahern writes: On 10/15/20 9:46 AM, Toke Høiland-Jørgensen wrote: diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index bf5a99d803e4..980cc1363be8 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -3

Re: [PATCH RFC bpf-next 2/2] selftests: Update test_tc_neigh to use the modified bpf_redirect_neigh()

2020-10-19 Thread Daniel Borkmann
On 10/15/20 5:46 PM, Toke Høiland-Jørgensen wrote: From: Toke Høiland-Jørgensen This updates the test_tc_neigh selftest to use the new syntax of bpf_redirect_neigh(). To exercise the helper both with and without the optional parameter, one forwarding direction is changed to do a bpf_fib_lookup(

Re: [PATCH RFC bpf-next 1/2] bpf_redirect_neigh: Support supplying the nexthop as a helper parameter

2020-10-19 Thread Daniel Borkmann
On 10/15/20 5:46 PM, Toke Høiland-Jørgensen wrote: From: Toke Høiland-Jørgensen Based on the discussion in [0], update the bpf_redirect_neigh() helper to accept an optional parameter specifying the nexthop information. This makes it possible to combine bpf_fib_lookup() and bpf_redirect_neigh()

Re: [PATCH RFC bpf-next 1/2] bpf_redirect_neigh: Support supplying the nexthop as a helper parameter

2020-10-19 Thread Daniel Borkmann
On 10/15/20 5:46 PM, Toke Høiland-Jørgensen wrote: [...] +struct bpf_redir_neigh { + /* network family for lookup (AF_INET, AF_INET6) +*/ + __u8nh_family; + /* network address of nexthop; skips fib lookup to find gateway */ + union { + __be32

Re: [PATCH bpf 1/2] bpf_redirect_neigh: Support supplying the nexthop as a helper parameter

2020-10-19 Thread Daniel Borkmann
On 10/19/20 6:04 PM, Toke Høiland-Jørgensen wrote: From: Toke Høiland-Jørgensen Based on the discussion in [0], update the bpf_redirect_neigh() helper to accept an optional parameter specifying the nexthop information. This makes it possible to combine bpf_fib_lookup() and bpf_redirect_neigh()

Re: [PATCH bpf 1/2] bpf_redirect_neigh: Support supplying the nexthop as a helper parameter

2020-10-20 Thread Daniel Borkmann
On 10/20/20 5:12 AM, David Ahern wrote: On 10/19/20 12:23 PM, Daniel Borkmann wrote: Looks good to me, thanks! I'll wait till David gets a chance as well to review. One thing that would have made sense to me (probably worth a v2) is to keep the fib lookup flag you had back then, meanin

Re: [PATCH bpf v2 2/3] bpf_fib_lookup: optionally skip neighbour lookup

2020-10-20 Thread Daniel Borkmann
On 10/20/20 3:49 PM, David Ahern wrote: On 10/20/20 4:51 AM, Toke Høiland-Jørgensen wrote: From: Toke Høiland-Jørgensen The bpf_fib_lookup() helper performs a neighbour lookup for the destination IP and returns BPF_FIB_LKUP_NO_NEIGH if this fails, with the expectation that the BPF program will

Re: [PATCH bpf v2 1/3] bpf_redirect_neigh: Support supplying the nexthop as a helper parameter

2020-10-20 Thread Daniel Borkmann
On 10/20/20 12:51 PM, Toke Høiland-Jørgensen wrote: From: Toke Høiland-Jørgensen [...] BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags) @@ -2455,8 +2487,8 @@ int skb_do_redirect(struct sk_buff *skb) return -EAGAIN; } return flag

Re: [PATCH bpf v2 1/3] bpf_redirect_neigh: Support supplying the nexthop as a helper parameter

2020-10-20 Thread Daniel Borkmann
On 10/20/20 9:01 PM, Jakub Kicinski wrote: On Tue, 20 Oct 2020 20:08:18 +0200 Toke Høiland-Jørgensen wrote: Isn't this backward? The hole could be named in the internal structure. This is a bit of a gray area, but if you name this hole in uAPI and programs start referring to it you will never be

[PATCH bpf] bpf, doc: Fix patchwork URL to point to kernel.org instance

2020-10-20 Thread Daniel Borkmann
Follow-up on ebb034b15bfa ("bpf: Migrate from patchwork.ozlabs.org to patchwork.kernel.org.") in order to fix up the patchwork URL (Q) in the MAINTAINERS file for BPF subsystem. While at it, also add the official website (W) entry. Signed-off-by: Daniel Borkmann --- MAINTAINERS | 3 +

[PATCH bpf] bpf, libbpf: guard bpf inline asm from bpf_tail_call_static

2020-10-21 Thread Daniel Borkmann
LTS has official LLVM packages all the way up to llvm-10, I did not bother to special case the __bpf_unreachable() inside bpf_tail_call_static() further. Fixes: 0e9f6841f664 ("bpf, libbpf: Add bpf_tail_call_static helper for bpf programs") Reported-by: Yaniv Agm

<    1   2   3   4   5   6   7   8   9   10   >