[PATCH v2 net-next 5/8] bpf: Add BPF_MAP_GET_FD_BY_ID

2017-05-31 Thread Martin KaFai Lau
;id. In the error path of bpf_map_inc_not_zero(), it may have to call __bpf_map_put(map, false) which does not need to take the map_idr_lock when freeing the map->id. It is currently limited to CAP_SYS_ADMIN which we can consider to lift it in followup patches. Signed-off-by: Martin KaFai L

[PATCH v2 net-next 1/8] bpf: Introduce bpf_prog ID

2017-05-31 Thread Martin KaFai Lau
to the prog_idr. After bpf_prog_select_runtime(), the prog is read-only. Hence, the id is stored in 'struct bpf_prog_aux'. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- include

Re: [PATCH net-next 0/8] Introduce bpf ID

2017-05-30 Thread Martin KaFai Lau
On Tue, May 30, 2017 at 06:35:37PM -0600, David Ahern wrote: > On 5/30/17 6:08 PM, Martin KaFai Lau wrote: > > This patch series: > > 1) Introduce ID for both bpf_prog and bpf_map. > > 2) Add bpf commands to iterate the prog IDs and map > >IDs of the system. >

[PATCH net-next 5/8] bpf: Add BPF_MAP_GET_FD_BY_ID

2017-05-30 Thread Martin KaFai Lau
;id. In the error path of bpf_map_inc_not_zero(), it may have to call __bpf_map_put(map, false) which does not need to take the map_idr_lock when freeing the map->id. It is currently limited to CAP_SYS_ADMIN which we can consider to lift it in followup patches. Signed-off-by: Martin KaFai L

[PATCH net-next 6/8] bpf: Add jited_len to struct bpf_prog

2017-05-30 Thread Martin KaFai Lau
Add jited_len to struct bpf_prog. It will be useful for the struct bpf_prog_info which will be added in the later patch. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- arch/arm64/

[PATCH net-next 2/8] bpf: Introduce bpf_map ID

2017-05-30 Thread Martin KaFai Lau
This patch generates an unique ID for each created bpf_map. The approach is similar to the earlier patch for bpf_prog ID. It is worth to note that the bpf_map's ID and bpf_prog's ID are in two independent ID spaces and both have the same valid range: [1, INT_MAX). Signed-off-by: Martin KaFai Lau

[PATCH net-next 3/8] bpf: Add BPF_(PROG|MAP)_GET_NEXT_ID command

2017-05-30 Thread Martin KaFai Lau
. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- include/uapi/linux/bpf.h | 7 +++ kernel/bpf/syscall.c | 38 ++ 2 files changed, 45 inserti

[PATCH net-next 8/8] bpf: Test for bpf ID

2017-05-30 Thread Martin KaFai Lau
Add test to exercise the bpf_prog/map id generation, bpf_(prog|map)_get_next_id(), bpf_(prog|map)_get_fd_by_id() and bpf_get_obj_info_by_fd(). Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> Acked-by: Daniel Borkmann <dan...@iogearbox.

[PATCH net-next 1/8] bpf: Introduce bpf_prog ID

2017-05-30 Thread Martin KaFai Lau
to the prog_idr. After bpf_prog_select_runtime(), the prog is read-only. Hence, the id is stored in 'struct bpf_prog_aux'. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- include

[PATCH net-next 7/8] bpf: Add BPF_OBJ_GET_INFO_BY_FD

2017-05-30 Thread Martin KaFai Lau
the bpf_attr. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- include/linux/filter.h | 2 - include/uapi/linux/bpf.h | 28 kernel/bpf/s

[PATCH net-next 4/8] bpf: Add BPF_PROG_GET_FD_BY_ID

2017-05-30 Thread Martin KaFai Lau
->id. In the error path of bpf_prog_inc_not_zero(), it may have to call __bpf_prog_put(map, false) which does not need to take the prog_idr_lock when freeing the prog->id. It is currently limited to CAP_SYS_ADMIN which we can consider to lift it in followup patches. Signed-off-by: Martin KaF

[PATCH net-next 0/8] Introduce bpf ID

2017-05-30 Thread Martin KaFai Lau
and it is not meant to be a complete list. They can be extended in the future patches. Martin KaFai Lau (8): bpf: Introduce bpf_prog ID bpf: Introduce bpf_map ID bpf: Add BPF_(PROG|MAP)_GET_NEXT_ID command bpf: Add BPF_PROG_GET_FD_BY_ID bpf: Add BPF_MAP_GET_FD_BY_ID bpf: Add

Re: [RFC net-next 0/2] Introduce bpf_prog ID and iteration

2017-04-27 Thread Martin KaFai Lau
On Thu, Apr 27, 2017 at 03:36:59PM +0200, Hannes Frederic Sowa wrote: > It would help a lot if you could pass the prog_id back during program > creation, otherwise it will be kind of difficult to get a hold on which > program is where. ;) Thanks for your feedback :). Make sense. I will look into

Re: [RFC net-next 2/2] bpf: Test for bpf_prog ID and BPF_PROG_GET_NEXT_ID

2017-04-27 Thread Martin KaFai Lau
On Thu, Apr 27, 2017 at 09:23:18AM +0200, Alexander Alemayhu wrote: > On Wed, Apr 26, 2017 at 11:24:49PM -0700, Martin KaFai Lau wrote: > > Add test to exercise the bpf_prog id generation > > and iteration. > > > Could test_prog_id be a function in tools/testing/se

[RFC net-next 1/2] bpf: Introduce bpf_prog ID

2017-04-27 Thread Martin KaFai Lau
The ID is generated by the existing idr_alloc_cyclic(). This patch also adds BPF_PROG_GET_NEXT_ID to allow userspace to iterate all bpf_prog id(s). The API is trying to be consistent with the existing BPF_MAP_GET_NEXT_KEY. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- include

[RFC net-next 2/2] bpf: Test for bpf_prog ID and BPF_PROG_GET_NEXT_ID

2017-04-27 Thread Martin KaFai Lau
Add test to exercise the bpf_prog id generation and iteration. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- tools/include/uapi/linux/bpf.h | 6 ++ tools/lib/bpf/bpf.c| 11 tools/lib/bpf/bpf.h| 1 + tools/testing/sel

[RFC net-next 0/2] Introduce bpf_prog ID and iteration

2017-04-27 Thread Martin KaFai Lau
This patchset introduces the bpf_prog ID and a new bpf cmd to iterate all bpf_prog in the system. It is still incomplete. The idea can be extended to bpf_map. Martin KaFai Lau (2): bpf: Introduce bpf_prog ID bpf: Test for bpf_prog ID and BPF_PROG_GET_NEXT_ID include/linux/filter.h

Re: [PATCH v4 net] net: ipv6: regenerate host route if moved to gc list

2017-04-25 Thread Martin KaFai Lau
On Tue, Apr 25, 2017 at 09:17:29AM -0700, David Ahern wrote: [...] > > All of those faults are fixed by regenerating the host route if the > existing one has been moved to the gc list, something that can be > determined by checking if the rt6i_ref counter is 0. Acked-by: Martin K

Re: [PATCH v3 net] net: ipv6: regenerate host route if moved to gc list

2017-04-24 Thread Martin KaFai Lau
On Mon, Apr 24, 2017 at 01:37:00PM -0600, David Ahern wrote: > On 4/24/17 10:39 AM, Eric Dumazet wrote: > > > > Very nice changelog ! > > > Thanks. Given my aggressive brain cell recycling program, I needed to > write down the analysis. > > > > >> diff --git a/net/ipv6/addrconf.c

Re: [PATCH v2 net] net: ipv6: regenerate host route if moved to gc list

2017-04-22 Thread Martin KaFai Lau
On Sat, Apr 22, 2017 at 07:12:34PM -0600, David Ahern wrote: > On 4/22/17 4:00 PM, Martin KaFai Lau wrote: > > On Sat, Apr 22, 2017 at 09:40:37AM -0700, David Ahern wrote: > > [...] > >> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c > >> index

Re: [PATCH v2 net] net: ipv6: regenerate host route if moved to gc list

2017-04-22 Thread Martin KaFai Lau
On Sat, Apr 22, 2017 at 09:40:37AM -0700, David Ahern wrote: [...] > diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c > index 08f9e8ea7a81..97e86158bbcb 100644 > --- a/net/ipv6/addrconf.c > +++ b/net/ipv6/addrconf.c > @@ -3303,14 +3303,24 @@ static void addrconf_gre_config(struct net_device

Re: [PATCH net] net: ipv6: regenerate host route if moved to gc list

2017-04-21 Thread Martin KaFai Lau
On Fri, Apr 21, 2017 at 04:40:30PM -0700, David Ahern wrote: > Taking down the loopback device wreaks havoc on IPv6 routes. By > extension, taking a VRF device wreaks havoc on its table. > > Dmitry and Andrey both reported heap out-of-bounds reports in the IPv6 > FIB code while running syzkaller

[PATCH net v3] net/mlx5e: Fix race in mlx5e_sw_stats and mlx5e_vport_stats

2017-04-20 Thread Martin KaFai Lau
rom mlx5e_update_vport_counters() v1: Use temp and memcpy Fixes: 9218b44dcc05 ("net/mlx5e: Statistics handling refactoring") Suggested-by: Eric Dumazet <eric.duma...@gmail.com> Suggested-by: Saeed Mahameed <sae...@mellanox.com> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- drivers/

Re: [PATCH net] net: ipv6: RTF_PCPU should not be settable from userspace

2017-04-20 Thread Martin KaFai Lau
On Thu, Apr 20, 2017 at 04:37:18PM -0700, Cong Wang wrote: > On Thu, Apr 20, 2017 at 3:43 PM, David Ahern wrote: > > > > I scanned the others. It is not clear that others should fail with > > EINVAL. Certainly a mask of unused flags can be added, but to me that is > > on

Re: [PATCH net] net: ipv6: RTF_PCPU should not be settable from userspace

2017-04-20 Thread Martin KaFai Lau
On Thu, Apr 20, 2017 at 04:43:03PM -0600, David Ahern wrote: > On 4/20/17 4:39 PM, Cong Wang wrote: > > On Wed, Apr 19, 2017 at 2:19 PM, David Ahern > > wrote: > >> > >> Fix by checking for the flag and failing with EINVAL. > >> > > > > I am still not sure about this.

Re: [PATCH net v2] net/mlx5e: Fix race in mlx5e_sw_stats and mlx5e_vport_stats

2017-04-20 Thread Martin KaFai Lau
On Thu, Apr 20, 2017 at 08:00:41AM -0700, Eric Dumazet wrote: > On Thu, 2017-04-20 at 07:15 -0700, Martin KaFai Lau wrote: > > > A follow-up patch approach by Gal will be nice. > > Note that I had a similar issue on mlx4. > > Stats are cleared/reset at open time, bu

Re: [PATCH net v2] net/mlx5e: Fix race in mlx5e_sw_stats and mlx5e_vport_stats

2017-04-20 Thread Martin KaFai Lau
On Thu, Apr 20, 2017 at 05:00:13PM +0300, Saeed Mahameed wrote: > On Thu, Apr 20, 2017 at 2:32 AM, Martin KaFai Lau <ka...@fb.com> wrote: > > We have observed a sudden spike in rx/tx_packets and rx/tx_bytes > > reported under /proc/net/dev. There is a race in mlx5e_update

[PATCH net v2] net/mlx5e: Fix race in mlx5e_sw_stats and mlx5e_vport_stats

2017-04-19 Thread Martin KaFai Lau
> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 66c133757a5e

Re: [RFC PATCH net] net/mlx5e: Race between mlx5e_update_stats() and getting the stats

2017-04-19 Thread Martin KaFai Lau
On Wed, Apr 19, 2017 at 01:24:38PM -0700, Eric Dumazet wrote: > On Wed, 2017-04-19 at 11:29 -0700, Martin KaFai Lau wrote: > > We have observed a sudden spike in rx/tx_packets and rx/tx_bytes > > reported under /proc/net/dev. It seems there is a race in > > mlx5e_up

Re: [PATCH net] net: ipv6: RTF_PCPU should not be settable from userspace

2017-04-19 Thread Martin KaFai Lau
ly inserted route appear > as though it is a per-cpu route. ip6_rt_cache_alloc sees the flag set > and expects rt->dst.from to be set - which it is not since it is not > really a per-cpu copy. The subsequent call to __ip6_dst_alloc then > generates the fault. > > Fix by checking

[RFC PATCH net] net/mlx5e: Race between mlx5e_update_stats() and getting the stats

2017-04-19 Thread Martin KaFai Lau
tries to show what I have suspected and start the discussion. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Cc: Saeed Mahameed <sae...@mellanox.com> --- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 +-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c| 3 +++ 2 file

[PATCH net-next 1/6] bpf: lru: Add test_lru_sanity6 for BPF_F_NO_COMMON_LRU

2017-04-14 Thread Martin KaFai Lau
test_lru_sanity3 is not applicable to BPF_F_NO_COMMON_LRU. It just happens to work when PERCPU_FREE_TARGET == 16. This patch: 1) Disable test_lru_sanity3 for BPF_F_NO_COMMON_LRU 2) Add test_lru_sanity6 to test list rotation for the BPF_F_NO_COMMON_LRU map. Signed-off-by: Martin KaFai Lau <

[PATCH net-next 6/6] bpf: lru: Add map-in-map LRU example

2017-04-14 Thread Martin KaFai Lau
962743 (9.96M/s) Notes that the max_entries for the map-in-map LRU test is 126 which is the max_entries for each inner LRU map. 8 processes have been started, so 8 * 126 = 1008 (~10M) which is close to what is used in the BPF_F_NO_COMMON_LRU test. Signed-off-by: Martin KaFai Lau <ka.

[PATCH net-next 0/6] bpf: LRU performance and test-program improvements

2017-04-14 Thread Martin KaFai Lau
The first 4 patches make a few improvements to the LRU tests. Patch 5/6 is to improve the performance of BPF_F_NO_COMMON_LRU map. Patch 6/6 adds an example in using LRU map with map-in-map. Martin KaFai Lau (6): bpf: lru: Add test_lru_sanity6 for BPF_F_NO_COMMON_LRU bpf: lru: Cleanup

[PATCH net-next 3/6] bpf: lru: Refactor LRU map tests in map_perf_test

2017-04-14 Thread Martin KaFai Lau
to nocommon_lru_hash_map to avoid the confusion with percpu_hash_map. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- samples/bpf/map_perf_test_kern.c | 43 +++

[PATCH net-next 5/6] bpf: lru: Lower the PERCPU_NR_SCANS from 16 to 4

2017-04-14 Thread Martin KaFai Lau
0k.a0_01.out 4 1 nr_misses: 67036 (Before) vs 67031 (After) Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- kernel/bpf/bpf_lru_list.c | 2 +- tools/testing/se

[PATCH net-next 4/6] bpf: Allow bpf sample programs (*_user.c) to change bpf_map_def

2017-04-14 Thread Martin KaFai Lau
the max_entries as a cmdline arg and then configure the bpf_map_def during runtime. This patch adds two cmdline args. One is to configure the map's max_entries. Another is to configure the max_cnt which controls how many times a syscall is called. Signed-off-by: Martin KaFai Lau <ka...@fb.com>

[PATCH net-next 2/6] bpf: lru: Cleanup test_lru_map.c

2017-04-14 Thread Martin KaFai Lau
This patch does the following cleanup on test_lru_map.c 1) Fix indentation (Replace spaces by tabs) 2) Remove redundant BPF_F_NO_COMMON_LRU test 3) Simplify some comments Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel B

[PATCH net-next 2/4] bpf: Add array of maps support

2017-03-22 Thread Martin KaFai Lau
s not depend on the outer_map. The inner_map_fd is merely used to initialize the inner_map_meta of the outer_map. Also, for the outer_map: * It allows element update and delete from syscall * It allows element lookup from bpf_prog The above is similar to the current fd_array pattern. Signed-off-by:

[PATCH net-next 0/4] bpf: Add map-in-map support

2017-03-22 Thread Martin KaFai Lau
This patchset adds map-in-map support (map->map). One use case is the (vips -> webservers) in the L4 load balancer so that different vips can be backed by different set of webservers. Please refer to the individual commit log for details. Martin KaFai Lau (4): bpf: Fix and simplific

[PATCH net-next 4/4] bpf: Add tests for map-in-map

2017-03-22 Thread Martin KaFai Lau
Test cases for array of maps and hash of maps. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> --- samples/bpf/Makefile| 4 + samples/bpf/bpf_helpers.h | 1 + samples/bp

[PATCH net-next 1/4] bpf: Fix and simplifications on inline map lookup

2017-03-22 Thread Martin KaFai Lau
: 1. Calculate elem_size from map->value_size. It removes the need for 'struct bpf_array' which makes the later map-in-map implementation easier. 2. Remove the 'elem_size == 1' test Fixes: 81ed18ab3098 ("bpf: add helper inlining infra and optimize map_array lookup") Signed

[PATCH net-next 3/4] bpf: Add hash of maps support

2017-03-22 Thread Martin KaFai Lau
e without disallowing BPF_PROG_TYPE_PERF_EVENT from using map-in-map first. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Daniel Borkmann <dan...@iogearbox.net> --- include/linux/bpf.h | 2 + include/uapi/linux/bpf.h |

Re: [Patch net v3] ipv6: check for ip6_null_entry in __ip6_del_rt_siblings()

2017-03-01 Thread Martin KaFai Lau
On Wed, Mar 01, 2017 at 04:07:38PM -0800, David Ahern wrote: > On 3/1/17 3:16 PM, Martin KaFai Lau wrote: > > [ An unrelated topic. I wonder ip -6 r del xyz::/0 would delete > > the gateway route...] > > a very related question ... > > ip -6 r del x::/0 comes down to

Re: [Patch net v3] ipv6: check for ip6_null_entry in __ip6_del_rt_siblings()

2017-03-01 Thread Martin KaFai Lau
On Mon, Feb 27, 2017 at 04:14:04PM -0800, David Ahern wrote: > On 2/27/17 4:07 PM, Cong Wang wrote: > > Andrey reported a NULL pointer deref bug in ipv6_route_ioctl() > > -> ip6_route_del() -> __ip6_del_rt_siblings() code path. This is > > because ip6_null_entry is returned in this path since

[PATCH net] bpf: Fix bpf_xdp_event_output

2017-02-23 Thread Martin KaFai Lau
itov <a...@kernel.org> Cc: Daniel Borkmann <dan...@iogearbox.net> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- net/core/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index e466e0040137..ebaeaf2e46e8 10

[PATCH net v2 1/2] mlx4: Fix memory leak after mlx4_en_update_priv()

2017-01-31 Thread Martin KaFai Lau
e_tx; 2153} 2154} Fixes: ec25bc04ed8e ("net/mlx4_en: Add resilience in low memory systems") Cc: Eugenia Emantayev <euge...@mellanox.com> Cc: Saeed Mahameed <sae...@mellanox.com> Cc: Tariq Toukan <tar...@mellanox.com> Signed-off-by: Martin KaFai La

[PATCH net v2 2/2] mlx4: xdp_prog becomes inactive after ethtool '-L' or '-G'

2017-01-31 Thread Martin KaFai Lau
pport for fast rx drop bpf program") Cc: Brenden Blanco <bbla...@plumgrid.com> Cc: Saeed Mahameed <sae...@mellanox.com> Cc: Tariq Toukan <tar...@mellanox.com> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 4 ++--

[PATCH net v2 0/2] mlx4: Misc bug fixes after reinitializing queues

2017-01-31 Thread Martin KaFai Lau
This patchset fixes misc bugs after reinitializing queues (e.g. by ethtool -L). v2: * Add another fix to mem leak in tx_ring[t] and tx_cq[t] * In mlx4_en_try_alloc_resources(), move all xdp_prog logic after calling mlx4_en_alloc_resources() Martin KaFai Lau (2): mlx4: Fix memory leak after

Re: [PATCH net] mlx4: xdp_prog becomes inactive after ethtool '-L' or '-G'

2017-01-31 Thread Martin KaFai Lau
On Mon, Jan 30, 2017 at 07:18:28PM +0200, Tariq Toukan wrote: > Hi Martin, > > Thanks for your patch. > > It looks good to me, in general. > I just have one small comment below. Thanks for your feedback and sorry for the delay. > > On 28/01/2017 9:40 AM, Martin KaFai

Re: [PATCH net] mlx4: xdp_prog becomes inactive after ethtool '-L' or '-G'

2017-01-31 Thread Martin KaFai Lau
On Tue, Jan 31, 2017 at 01:11:40PM -0500, David Miller wrote: > From: Tariq Toukan > Date: Mon, 30 Jan 2017 19:18:28 +0200 > > > It looks good to me, in general. > > I just have one small comment below. > > Martin, please address Tariq's feedback. Sorry for the delay. I am

[PATCH net] mlx4: xdp_prog becomes inactive after ethtool '-L' or '-G'

2017-01-28 Thread Martin KaFai Lau
pport for fast rx drop bpf program") Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 4 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 52 - drivers/net/ethernet/mellanox/mlx4/mlx4_en.h| 3 +- 3 f

[PATCH net-next v2] net/mlx5e: Support bpf_xdp_adjust_head()

2017-01-17 Thread Martin KaFai Lau
moved from en_main.c to en.h. MLX5E_HW2SW_MTU is also moved to en.h for symmetric reason but it is not a must. v2: - Keep the xdp specific logic in mlx5e_xdp_handle() - Update dma_len after the sanity checks in mlx5e_xmit_xdp_frame() Signed-off-by: Martin KaFai Lau <ka...@fb.com> ---

[PATCH] bpf: Fix test_lru_sanity5() in test_lru_map.c

2017-01-16 Thread Martin KaFai Lau
989f ("bpf: Add tests for the LRU bpf_htab") Reported-by: Daniel Borkmann <dan...@iogearbox.net> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- tools/testing/selftests/bpf/test_lru_map.c | 53 +++--- 1 file changed, 27 insertions(+), 26 deletion

Re: [PATCH net-next] net/mlx5e: Support bpf_xdp_adjust_head()

2017-01-13 Thread Martin KaFai Lau
On Fri, Jan 13, 2017 at 03:58:46PM +0200, Saeed Mahameed wrote: > >> > @@ -680,7 +687,7 @@ static inline void mlx5e_xmit_xdp_frame(struct > >> > mlx5e_rq *rq, > >> > memset(wqe, 0, sizeof(*wqe)); > >> > > >> > /* copy the inline part */ > >> > -

[PATCH net-next] net/mlx5e: Support bpf_xdp_adjust_head()

2017-01-11 Thread Martin KaFai Lau
moved from en_main.c to en.h. MLX5E_HW2SW_MTU is also moved to en.h for symmetric reason but it is not a must. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 ++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 18 +++

Re: [PATCH net-next] bpf: Remove unused but set variable in __bpf_lru_list_shrink_inactive()

2017-01-10 Thread Martin KaFai Lau
first_node’ set but > not used [-Wunused-but-set-variable] > > Cc: Martin KaFai Lau <ka...@fb.com> > Signed-off-by: Tobias Klauser <tklau...@distanz.ch> > --- > kernel/bpf/bpf_lru_list.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/kernel/

Re: [PATCH net-next] bpf: Remove unused but set variable in __bpf_lru_list_shrink_inactive()

2017-01-10 Thread Martin KaFai Lau
t; building with 'W=1': > > > > kernel/bpf/bpf_lru_list.c:216:41: warning: variable ‘first_node’ set but > > not used [-Wunused-but-set-variable] > > > > Cc: Martin KaFai Lau <ka...@fb.com> > > Signed-off-by: Tobias Klauser <tklau...@distanz.ch> > >

Re: [PATCH net-next] bpf: Make unnecessarily global functions static

2017-01-10 Thread Martin KaFai Lau
ru_list.c:577:6: warning: no previous prototype for > > ‘bpf_percpu_lru_populate’ [-Wmissing-prototypes] > > > > Cc: Martin KaFai Lau <ka...@fb.com> > > Signed-off-by: Tobias Klauser <tklau...@distanz.ch> > > Acked-by: Alexei Starovoitov <a...@kernel.org> Thanks for the patch. Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [PATCH net v2] mlx4: Return EOPNOTSUPP instead of ENOTSUPP

2017-01-10 Thread Martin KaFai Lau
On Tue, Jan 10, 2017 at 10:04:55PM +0200, Saeed Mahameed wrote: > On Tue, Jan 10, 2017 at 7:41 PM, Martin KaFai Lau <ka...@fb.com> wrote: > > In commit b45f0674b997 ("mlx4: xdp: Allow raising MTU up to one page minus > > eth and vlan hdrs"), > > it chan

Re: [PATCH net] mlx4: Return EOPNOTSUPP instead of ENOTSUPP

2017-01-10 Thread Martin KaFai Lau
On Tue, Jan 10, 2017 at 03:43:39PM +0300, Sergei Shtylyov wrote: > Hello! > > On 01/10/2017 01:13 AM, Martin KaFai Lau wrote: > > >In commit b45f0674b997 ("mlx4: xdp: Allow raising MTU up to one page minus > >eth and vlan hdrs"), > >it changed ENOTSUPP to

[PATCH net v2] mlx4: Return EOPNOTSUPP instead of ENOTSUPP

2017-01-10 Thread Martin KaFai Lau
In commit b45f0674b997 ("mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs"), it changed EOPNOTSUPP to ENOTSUPP by mistake. This patch fixes it. Fixes: b45f0674b997 ("mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs") Signed-off-by:

[PATCH net] mlx4: Return EOPNOTSUPP instead of ENOTSUPP

2017-01-09 Thread Martin KaFai Lau
In commit b45f0674b997 ("mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs"), it changed ENOTSUPP to EOPNOTSUPP by mistake. This patch fixes it. Fixes: b45f0674b997 ("mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs") Signed-off-by:

Re: mlx4: Bug in XDP_TX + 16 rx-queues

2016-12-20 Thread Martin KaFai Lau
On Tue, Dec 20, 2016 at 02:02:05PM +0200, Tariq Toukan wrote: > Thanks Martin, nice catch! > > > On 20/12/2016 1:37 AM, Martin KaFai Lau wrote: > >Hi Tariq, > > > >On Sat, Dec 17, 2016 at 02:18:03AM -0800, Martin KaFai Lau wrote: > >>Hi All, > >>

Re: mlx4: Bug in XDP_TX + 16 rx-queues

2016-12-19 Thread Martin KaFai Lau
Hi Tariq, On Sat, Dec 17, 2016 at 02:18:03AM -0800, Martin KaFai Lau wrote: > Hi All, > > I have been debugging with XDP_TX and 16 rx-queues. > > 1) When 16 rx-queues is used and an XDP prog is doing XDP_TX, > it seems that the packet cannot be XDP_TX out if the pkt >

Re: mlx4: Bug in XDP_TX + 16 rx-queues

2016-12-18 Thread Martin KaFai Lau
On Sun, Dec 18, 2016 at 12:31:30PM +0200, Tariq Toukan wrote: > Hi Martin, > > > On 17/12/2016 12:18 PM, Martin KaFai Lau wrote: > >Hi All, > > > >I have been debugging with XDP_TX and 16 rx-queues. > > > >1) When 16 rx-queues is used and an XDP prog is

mlx4: Bug in XDP_TX + 16 rx-queues

2016-12-17 Thread Martin KaFai Lau
Hi All, I have been debugging with XDP_TX and 16 rx-queues. 1) When 16 rx-queues is used and an XDP prog is doing XDP_TX, it seems that the packet cannot be XDP_TX out if the pkt is received from some particular CPUs (/rx-queues). 2) If 8 rx-queues is used, it does not have problem. 3) The 16

[PATCH v4 net-next 0/4]: Allow head adjustment in XDP prog

2016-12-07 Thread Martin KaFai Lau
ead() in patch 1 2. Ensure no less than ETH_HLEN data in bpf_xdp_adjust_head() in patch 1 3. Some clarifications in commit log messages of patch 2 and 3 Thanks, Martin Martin KaFai Lau (4): bpf: xdp: Allow head adjustment in XDP prog mlx4: xdp: Allow raising MTU up to one page minus eth and vlan h

[PATCH v4 net-next 4/4] bpf: xdp: Add XDP example for head adjustment

2016-12-07 Thread Martin KaFai Lau
rgs of the user prog. Acked-by: Alexei Starovoitov <a...@kernel.org> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- samples/bpf/Makefile | 4 + samples/bpf/bpf_helpers.h| 2 + samples/bpf/bpf_load.c | 94 + samples

[PATCH v4 net-next 2/4] mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs

2016-12-07 Thread Martin KaFai Lau
this patch is doing. It will be useful in the next patch which allows XDP program to extend the packet by adding new header(s). Note: In the earlier XDP patches, there is already existing guard to ensure the page/pkt scheme only applies when XDP is active in mlx4. Signed-off-by: Martin KaFai Lau <

[PATCH v4 net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog

2016-12-07 Thread Martin KaFai Lau
on skb. This patch adds one "xdp_adjust_head" bit to bpf_prog for the XDP-capable driver to check if the XDP prog requires bpf_xdp_adjust_head() support. The driver can then decide to error out during XDP_SETUP_PROG. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- arch/powerpc/ne

[PATCH v4 net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active

2016-12-07 Thread Martin KaFai Lau
Reserve XDP_PACKET_HEADROOM for packet and enable bpf_xdp_adjust_head() support. This patch only affects the code path when XDP is active. After testing, the tx_dropped counter is incremented if the xdp_prog sends more than wire MTU. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- d

Re: [PATCH v3 net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog

2016-12-07 Thread Martin KaFai Lau
On Wed, Dec 07, 2016 at 08:37:58AM -0800, Alexei Starovoitov wrote: > On Wed, Dec 07, 2016 at 11:41:12AM +, Jakub Kicinski wrote: > > > I see nothing wrong if this is exposed/made visible in the usual way > > > through > > > ethtool -k as well. I guess at least that would be the expected way

[PATCH v3 net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog

2016-12-06 Thread Martin KaFai Lau
g> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- arch/powerpc/net/bpf_jit_comp64.c | 4 ++-- arch/s390/net/bpf_jit_comp.c | 2 +- arch/x86/net/bpf_jit_comp.c| 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 3 +++

[PATCH v3 net-next 4/4] bpf: xdp: Add XDP example for head adjustment

2016-12-06 Thread Martin KaFai Lau
rgs of the user prog. Acked-by: Alexei Starovoitov <a...@kernel.org> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- samples/bpf/Makefile | 4 + samples/bpf/bpf_helpers.h | 2 + samples/bpf/bpf_load.c| 94 ++ samples/bpf/bpf_load.h

[PATCH v3 net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active

2016-12-06 Thread Martin KaFai Lau
Reserve XDP_PACKET_HEADROOM for packet and enable bpf_xdp_adjust_head() support. This patch only affects the code path when XDP is active. After testing, the tx_dropped counter is incremented if the xdp_prog sends more than wire MTU. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- d

[PATCH v3 net-next 0/4]: Allow head adjustment in XDP prog

2016-12-06 Thread Martin KaFai Lau
3of4 v2: 1. Make a variable name change in bpf_xdp_adjust_head() in patch 1 2. Ensure no less than ETH_HLEN data in bpf_xdp_adjust_head() in patch 1 3. Some clarifications in commit log messages of patch 2 and 3 Thanks, Martin Martin KaFai Lau (4): bpf: xdp: Allow head adjustment in XDP prog

[PATCH v3 net-next 2/4] mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs

2016-12-06 Thread Martin KaFai Lau
this patch is doing. It will be useful in the next patch which allows XDP program to extend the packet by adding new header(s). Note: In the earlier XDP patches, there is already existing guard to ensure the page/pkt scheme only applies when XDP is active in mlx4. Signed-off-by: Martin KaFai Lau <

Re: [PATCH v2 net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active

2016-12-06 Thread Martin KaFai Lau
On Tue, Dec 06, 2016 at 11:40:19PM +0200, Saeed Mahameed wrote: > On Tue, Dec 6, 2016 at 8:27 PM, Martin KaFai Lau <ka...@fb.com> wrote: > > On Tue, Dec 06, 2016 at 06:50:47PM +0200, Saeed Mahameed wrote: > >> On Mon, Dec 5, 2016 at 9:55 PM, Martin KaFai Lau <ka...@f

Re: [PATCH v2 net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog

2016-12-06 Thread Martin KaFai Lau
On Tue, Dec 06, 2016 at 09:35:31AM -0800, John Fastabend wrote: > On 16-12-03 07:17 PM, Martin KaFai Lau wrote: > > This patch allows XDP prog to extend/remove the packet > > data at the head (like adding or removing header). It is > > done by adding a new XDP helpe

Re: [PATCH v2 net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active

2016-12-06 Thread Martin KaFai Lau
On Tue, Dec 06, 2016 at 06:50:47PM +0200, Saeed Mahameed wrote: > On Mon, Dec 5, 2016 at 9:55 PM, Martin KaFai Lau <ka...@fb.com> wrote: > > On Mon, Dec 05, 2016 at 02:54:06AM +0200, Saeed Mahameed wrote: > >> On Sun, Dec 4, 2016 at 5:17 AM, Martin KaFai Lau <ka...@fb

Re: [PATCH v2 net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active

2016-12-05 Thread Martin KaFai Lau
On Mon, Dec 05, 2016 at 02:54:06AM +0200, Saeed Mahameed wrote: > On Sun, Dec 4, 2016 at 5:17 AM, Martin KaFai Lau <ka...@fb.com> wrote: > > Reserve XDP_PACKET_HEADROOM and honor bpf_xdp_adjust_head() > > when XDP prog is active. This patch only affects the code > &

Re: [PATCH net-next 2/4] mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs

2016-12-03 Thread Martin KaFai Lau
On Fri, Dec 02, 2016 at 04:07:09PM -0800, Rick Jones wrote: > On 12/02/2016 03:23 PM, Martin KaFai Lau wrote: > >When XDP prog is attached, it is currently limiting > >MTU to be FRAG_SZ0 - ETH_HLEN - (2 * VLAN_HLEN) which is 1514 > >in x86. > > > >AFAICT, since

[PATCH v2 net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active

2016-12-03 Thread Martin KaFai Lau
Reserve XDP_PACKET_HEADROOM and honor bpf_xdp_adjust_head() when XDP prog is active. This patch only affects the code path when XDP is active. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 17 +++-- drivers/net/ethernet/me

[PATCH v2 net-next 4/4] bpf: xdp: Add XDP example for head adjustment

2016-12-03 Thread Martin KaFai Lau
rgs of the user prog. Acked-by: Alexei Starovoitov <a...@kernel.org> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- samples/bpf/Makefile | 4 + samples/bpf/bpf_helpers.h | 2 + samples/bpf/bpf_load.c| 94 ++ samples/bpf/bpf_load.h

[PATCH v2 net-next 0/4]: Allow head adjustment in XDP prog

2016-12-03 Thread Martin KaFai Lau
This series adds a helper to allow head adjusting in XDP prog. mlx4 driver has been modified to support this feature. An example is written to encapsulate a packet with an IPv4/v6 header and then XDP_TX it out. v2: 1. Make a variable name change in bpf_xdp_adjust_head() in patch 1 2. Ensure no

[PATCH v2 net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog

2016-12-03 Thread Martin KaFai Lau
on skb. Acked-by: Alexei Starovoitov <a...@kernel.org> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- arch/powerpc/net/bpf_jit_comp64.c | 4 ++-- arch/s390/net/bpf_jit_comp.c | 2 +- arch/x86/net/bpf_jit_comp.c | 2 +- include/linux/filter.h| 2 +- includ

[PATCH v2 net-next 2/4] mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs

2016-12-03 Thread Martin KaFai Lau
this patch is doing. It will be useful in the next patch which allows XDP program to extend the packet by adding new header(s). Note: In the earlier XDP patches, there is already existing guard to ensure the page/pkt scheme only applies when XDP is active in mlx4. Signed-off-by: Martin KaFai Lau <

Re: [PATCH net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog

2016-12-03 Thread Martin KaFai Lau
On Sat, Dec 03, 2016 at 04:24:13PM +0100, Jesper Dangaard Brouer wrote: > On Fri, 2 Dec 2016 15:23:30 -0800 > Martin KaFai Lau <ka...@fb.com> wrote: > > > -bool bpf_helper_changes_skb_data(void *func) > > +BPF_CALL_2(bpf_xdp_adjust_head, struct xdp_buff *, xdp, int, off

Re: [PATCH net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog

2016-12-02 Thread Martin KaFai Lau
On Sat, Dec 03, 2016 at 01:22:05AM +0100, Daniel Borkmann wrote: > On 12/03/2016 12:23 AM, Martin KaFai Lau wrote: > >This patch allows XDP prog to extend/remove the packet > >data at the head (like adding or removing header). It is > >done by adding a new XDP helpe

Re: [PATCH net-next 2/4] mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs

2016-12-02 Thread Martin KaFai Lau
On Fri, Dec 02, 2016 at 06:15:26PM -0800, Eric Dumazet wrote: > On Fri, 2016-12-02 at 16:53 -0800, Alexei Starovoitov wrote: > > On 12/2/16 4:38 PM, Eric Dumazet wrote: > > > On Fri, 2016-12-02 at 15:23 -0800, Martin KaFai Lau wrote: > > >> When XDP prog is atta

[PATCH net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active

2016-12-02 Thread Martin KaFai Lau
Reserve XDP_PACKET_HEADROOM when XDP prog is active. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 17 +++-- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 23 +-- drivers/net/ethernet/mellanox/mlx4/e

[PATCH net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog

2016-12-02 Thread Martin KaFai Lau
on skb. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- arch/powerpc/net/bpf_jit_comp64.c | 4 ++-- arch/s390/net/bpf_jit_comp.c | 2 +- arch/x86/net/bpf_jit_comp.c | 2 +- include/linux/filter.h| 2 +- include/uapi/linux/bpf.h | 11 ++- kernel/bpf/

[PATCH net-next 2/4] mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs

2016-12-02 Thread Martin KaFai Lau
. It will be useful in the next patch which allows XDP program to extend the packet by adding new header(s). Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 28 +++- drivers/net/ethernet/mellanox/mlx4/en_rx.c

[PATCH net-next 4/4] bpf: xdp: Add XDP example for head adjustment

2016-12-02 Thread Martin KaFai Lau
rgs of the user prog. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- samples/bpf/Makefile | 4 + samples/bpf/bpf_helpers.h | 2 + samples/bpf/bpf_load.c| 94 ++ samples/bpf/bpf_load.h| 1 + samples/bpf/xdp1_user.c

[PATCH net-next 0/4]: Allow head adjustment in XDP prog

2016-12-02 Thread Martin KaFai Lau
This series adds a helper to allow head adjustment in XDP prog. mlx4 driver has been modified to support this feature. An example is written to encapsulate a packet with an IPv4/v6 header and then XDP_TX it out. Thanks, --Martin

Re: linux-next: build warning after merge of the net-next tree

2016-11-15 Thread Martin KaFai Lau
On Wed, Nov 16, 2016 at 11:36:47AM +1100, Stephen Rothwell wrote: > Hi all, > > After merging the net-next tree, today's linux-next build (x86_64 > allmodconfig) produced this warning: > > kernel/bpf/bpf_lru_list.c: In function > '__bpf_lru_list_rotate_inactive.isra.3': >

[PATCH net-next] bpf: Fix compilation warning in __bpf_lru_list_rotate_inactive

2016-11-15 Thread Martin KaFai Lau
ile() loop which must have >=1 iterations. This patch initializes next to get rid of the compiler warning. Fixes: 3a08c2fd7634 ("bpf: LRU List") Reported-by: David Miller <da...@davemloft.net> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- kernel/bpf/bpf_lru_list.c | 2 +-

Re: [PATCH v2 net-next 0/6] bpf: LRU map

2016-11-15 Thread Martin KaFai Lau
On Tue, Nov 15, 2016 at 11:59:24AM -0500, David Miller wrote: > From: David Miller <da...@redhat.com> > Date: Tue, 15 Nov 2016 11:51:23 -0500 (EST) > > > From: Martin KaFai Lau <ka...@fb.com> > > Date: Fri, 11 Nov 2016 10:55:05 -0800 > > > >

[PATCH v2 net-next 6/6] bpf: Add tests for the LRU bpf_htab

2016-11-11 Thread Martin KaFai Lau
t 32 $i | awk '{r += $3}END{print r " updates"}'; done 1 cpus: 2896553 updates 4 cpus: 9766395 updates 8 cpus: 17460553 updates Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- samples/bpf/Makefile | 2 + samples/bpf/map_perf_test_kern.c

<    1   2   3   4   5   6   7   8   >