Netdev List
 help / color / mirror / Atom feed
* fore200e DMA cleanups and fixes
From: Christoph Hellwig @ 2018-10-09 14:57 UTC (permalink / raw)
  To: Chas Williams, netdev; +Cc: linux-atm-general, linux-kernel

The fore200e driver came up during some dma-related audits, so
here is the fallout.  Compile tested (x86 & sparc) only.

^ permalink raw reply

* Re: [PATCH net-next] tcp: forbid direct reclaim if MSG_DONTWAIT is set in send path
From: Yafang Shao @ 2018-10-09 14:52 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, LKML
In-Reply-To: <CANn89iL1BMCx3Mbsj3TijR3Srjji95q86px0k98r7JYJbwLzcw@mail.gmail.com>

On Tue, Oct 9, 2018 at 10:12 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Tue, Oct 9, 2018 at 5:05 AM Yafang Shao <laoar.shao@gmail.com> wrote:
> >
> > By default, the sk->sk_allocation is GFP_KERNEL, that means if there's
> > no enough memory it will do both direct reclaim and background reclaim.
> > If the size of system memory is great, the direct reclaim may cause great
> > latency spike.
> >
> > When we set MSG_DONTWAIT in send syscalls, we really don't want it to be
> > blocked, so we'd better clear __GFP_DIRECT_RECLAIM when allocate skb in the
> > send path. Then, it will return immediately if there's no enough memory to
> > be allocated, and then the appliation has a chance to do some other stuffs
> > instead of being blocked here.
> >
> > Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> > ---
> >  net/ipv4/tcp.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> > index 43ef83b..fe4f5ce 100644
> > --- a/net/ipv4/tcp.c
> > +++ b/net/ipv4/tcp.c
> > @@ -1182,6 +1182,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> >         bool process_backlog = false;
> >         bool zc = false;
> >         long timeo;
> > +       gfp_t gfp;
> >
> >         flags = msg->msg_flags;
> >
> > @@ -1255,6 +1256,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> >         /* Ok commence sending. */
> >         copied = 0;
> >
> > +       gfp = flags & MSG_DONTWAIT ? sk->sk_allocation & ~__GFP_DIRECT_RECLAIM :
> > +             sk->sk_allocation;
> > +
> >  restart:
> >         mss_now = tcp_send_mss(sk, &size_goal, flags);
> >
> > @@ -1283,8 +1287,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> >                         }
> >                         first_skb = tcp_rtx_and_write_queues_empty(sk);
> >                         linear = select_size(first_skb, zc);
> > -                       skb = sk_stream_alloc_skb(sk, linear, sk->sk_allocation,
> > -                                                 first_skb);
> > +                       skb = sk_stream_alloc_skb(sk, linear, gfp, first_skb);
> >                         if (!skb)
> >                                 goto wait_for_memory;
>
>
> How have you tested this patch exactly ?
>
There was a network latency (hunreds msecs or even one sec ) recently
on our production enviroment.
And finally I diagnosed that this latency was caused by direct reclaim
in tcp_sendmsg.
That issue could be resovled by keeping a reserved memory.
But I think deeply that why not forbid direct reclaim if we set MSG_DONWAIT.
So I did this change and tested it. The application got a errno
returned instead of being blocked in send path.
That's why I sumbit this patch.

> Most of TCP payloads are added in page fragments, and you have not
> changed the page allocation fragments.
>
> Also, I do not see how an application will get future notifications
> that it can retry the failed system call ?
> How are you really going to deal with this in high performance applications ?
>

I think that immdiately return with errno is better than being blocked.
Maybe this solution is not good enough.
At least it could tell the application that something is wrong and it
can't send now.

> I would rather prefer a socket setsockopt() to eventually be able to
> flip __GFP_DIRECT_RECLAIM in sk->sk_allocation,
> to not add all these tests in fast path, but honestly I do not see how
> applications can really make use of this.

Maybe an event is needed to tell the application it can send now.
I don't have better idea neither.

Thanks
Yafang

^ permalink raw reply

* Re: [RFC PATCH 02/11] dt-bindings: phy: add cpsw port interface mode selection phy bindings
From: Tony Lindgren @ 2018-10-09 14:40 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: David S. Miller, netdev, Rob Herring, Kishon Vijay Abraham I,
	Sekhar Nori, linux-kernel, linux-omap, devicetree
In-Reply-To: <20181008234949.15416-3-grygorii.strashko@ti.com>

* Grygorii Strashko <grygorii.strashko@ti.com> [181008 23:54]:
> +Examples:
> +	phy_gmii_sel: phy-gmii-sel {
> +		compatible = "ti,am3352-phy-gmii-sel";
> +		syscon-scm = <&scm_conf>;
> +		#phy-cells = <2>;
> +	};

Now that this driver can live in it's proper place in the
dts, you may want to consider just using standard reg
property for it instead of the syscon-scm. And also get
rid of the syscon reads and writes.

Regards,

Tony

^ permalink raw reply

* Re: [RFC PATCH 00/11] net: ethernet: ti: cpsw: replace cpsw-phy-sel with phy driver
From: Tony Lindgren @ 2018-10-09 14:36 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: David S. Miller, netdev, Rob Herring, Kishon Vijay Abraham I,
	Sekhar Nori, linux-kernel, linux-omap, devicetree
In-Reply-To: <20181008234949.15416-1-grygorii.strashko@ti.com>

* Grygorii Strashko <grygorii.strashko@ti.com> [181008 23:54]:
> 2) introduce new PHY API for network interface mode selection which will use
> already defined set of modes from phy_interface_t.
> 
> Option 2 was selected for this series.

Looks good to me :) The dts files will cause merge conflicts with
what I have pending for the ti-sysc changes so please send the dts
changes in a separate series when posting without RFC.

Thanks,

Tony

^ permalink raw reply

* [PATCH  v2 2/2] net: if_arp: use define instead of hard-coded value
From: Håkon Bugge @ 2018-10-09 14:27 UTC (permalink / raw)
  To: netdev
  Cc: stephen, David S . Miller, Kate Stewart, Thomas Gleixner,
	Greg Kroah-Hartman, Philippe Ombredanne, linux-kernel
In-Reply-To: <20181009142724.2213012-1-Haakon.Bugge@oracle.com>

Let uapi/linux/if_arp.h include uapi/linux/if.h, where IFNAMSIZ is
defined. Then, use it in this file instead of hard-coded value.

This way, we are using an uapi defined constant, and as such,
user-space should be good.

Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
Tested-by: Stephen Hemminger <stephen@networkplumber.org>

---

v1 -> v2:
   * Include uapi/linux/if.h
   * Add Stephen's t-b
---
 include/uapi/linux/if_arp.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/if_arp.h b/include/uapi/linux/if_arp.h
index b68b4b3d9172..f5d2dab3f610 100644
--- a/include/uapi/linux/if_arp.h
+++ b/include/uapi/linux/if_arp.h
@@ -24,6 +24,7 @@
 #ifndef _UAPI_LINUX_IF_ARP_H
 #define _UAPI_LINUX_IF_ARP_H
 
+#include <linux/if.h>
 #include <linux/netdevice.h>
 
 /* ARP protocol HARDWARE identifiers. */
@@ -118,7 +119,7 @@ struct arpreq {
 	struct sockaddr	arp_ha;		/* hardware address		 */
 	int		arp_flags;	/* flags			 */
 	struct sockaddr arp_netmask;    /* netmask (only for proxy arps) */
-	char		arp_dev[16];
+	char		arp_dev[IFNAMSIZ];
 };
 
 struct arpreq_old {
-- 
2.14.3

^ permalink raw reply related

* [PATCH  v2 0/2] net: if_arp: use define instead of hard-coded value
From: Håkon Bugge @ 2018-10-09 14:27 UTC (permalink / raw)
  To: netdev
  Cc: stephen, David S . Miller, Kate Stewart, Thomas Gleixner,
	Greg Kroah-Hartman, Philippe Ombredanne, linux-kernel

Struct arpreq contains the name of the device. All other places in the
kernel, the define IFNAMSIZ is used to designate its size. But in
if_arp.h, a literal constant is used.

Fixed by explicitly including uapi/linu/if.h, where IFNAMSIZ is defined.

The series also fixes some incorrect indents.


v1 -> v2:
   * Include uapi/linux/if.h from if_arp.h
   * Added Stephen's t-b

Håkon Bugge (2):
  net: if_arp: Fix incorrect indents
  net: if_arp: use define instead of hard-coded value

 include/uapi/linux/if_arp.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

--
2.14.3



>From a36b99413ea5beca1539f4faf065f33c7c19e6a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A5kon=20Bugge?= <Haakon.Bugge@oracle.com>
Date: Fri, 21 Sep 2018 11:28:36 +0200
Subject: [PATCH 0/2]
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Struct arpreq contains the name of the device. All other places in the
kernel, the define IFNAMSIZ is used to designate its size. But in
if_arp.h, a literal constant is used.

As it could be good reasons to use constants instead of the defines in
include files under uapi, it seems to be OK to use the define here,
without opening a can of worms in user-land.

This because if_arp.h includes netdevice.h, which also uses
IFNAMSIZ. For the distros I have checked, this also holds true for the
use-land side.

The series also fixes some incorrect indents.

Håkon Bugge (2):
  net: if_arp: Fix incorrect indents
  net: if_arp: use define instead of hard-coded value

 include/uapi/linux/if_arp.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

--
2.14.3

^ permalink raw reply

* Re: [PATCH v8 02/15] octeontx2-af: Reset all RVU blocks
From: Sunil Kovvuri @ 2018-10-09  7:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux Netdev List, David S. Miller, linux-soc, Sunil Goutham
In-Reply-To: <CAK8P3a1JmbeSvt_vdbBA2kkGFRew0p3JWKHzwoE=b_4NOf-UyQ@mail.gmail.com>

On Mon, Oct 8, 2018 at 5:46 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Sun, Oct 7, 2018 at 5:00 PM <sunil.kovvuri@gmail.com> wrote:
> >
> > From: Sunil Goutham <sgoutham@marvell.com>
> >
> > Go through all BLKADDRs and check which ones are implemented
> > on this silicon and do a HW reset of each implemented block.
> > Also added all RVU AF and PF register offsets.
> >
>
> >
> > +/* Poll a RVU block's register 'offset', for a 'zero'
> > + * or 'nonzero' at bits specified by 'mask'
> > + */
> > +int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero)
> > +{
> > +       void __iomem *reg;
> > +       int timeout = 100;
> > +       u64 reg_val;
> > +
> > +       reg = rvu->afreg_base + ((block << 28) | offset);
> > +       while (timeout) {
> > +               reg_val = readq(reg);
> > +               if (zero && !(reg_val & mask))
> > +                       return 0;
> > +               if (!zero && (reg_val & mask))
> > +                       return 0;
> > +               udelay(1);
> > +               cpu_relax();
> > +               timeout--;
> > +       }
> > +       return -EBUSY;
> > +}
>
> This can be a fairly long wait of multiple milliseconds, given that
> you call it nine times in a row, that each udelay() can take
> multiple microseconds (plus the time for the readq()), and
> you look 100 times.
>
> It seems this is only called from probe(), which is not in atomic
> context, and you don't hold any locks, so why not change the
> udelay() to an msleep() or usleep_range() to let some other
> process run?
>
>        Arnd

Sure, usleep_range seems to be a better option, will change.

Thanks,
Sunil.

^ permalink raw reply

* Re: [PATCH v8 10/15] octeontx2-af: Reconfig MSIX base with IOVA
From: Sunil Kovvuri @ 2018-10-09  7:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux Netdev List, David S. Miller, linux-soc, Geetha sowjanya,
	Sunil Goutham
In-Reply-To: <CAK8P3a2KD_ykmwtCYmLAGBAxgLQ4r-UWp00bBejaFZSSi=-cNA@mail.gmail.com>

On Mon, Oct 8, 2018 at 5:38 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Sun, Oct 7, 2018 at 5:01 PM <sunil.kovvuri@gmail.com> wrote:
>
> >
> > +       /* HW interprets RVU_AF_MSIXTR_BASE address as an IOVA, hence
> > +        * create a IOMMU mapping for the physcial address configured by
> > +        * firmware and reconfig RVU_AF_MSIXTR_BASE with IOVA.
> > +        */
> > +       cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_CONST);
> > +       max_msix = cfg & 0xFFFFF;
> > +       phy_addr = rvu_read64(rvu, BLKADDR_RVUM, RVU_AF_MSIXTR_BASE);
> > +       iova = dma_map_single(rvu->dev, (void *)phy_addr,
> > +                             max_msix * PCI_MSIX_ENTRY_SIZE,
> > +                             DMA_BIDIRECTIONAL);
> > +       if (dma_mapping_error(rvu->dev, iova))
> > +               return -ENOMEM;
> > +
> > +       rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_MSIXTR_BASE, (u64)iova);
> > +       rvu->msix_base_iova = iova;
> > +
>
> I'm a bit puzzled by how this works. Does this rely on a specific iommu
> driver implementation? Normally a physical  address makes no sense to the
> implementation backing dma_map_single() that tries to convert a
> linear kernel virtual address into a physical address.
>
>         Arnd

I understand what you are pointing at, but we did test this.
IOMMU on this silicon is standard ARM64 SMMUv3.

All dma_map_single does is virt_to_page and iommu_dma_map_page
converts it back i.e page_to_phys.
So the IOMMU driver gets the same physical address passed above and
creates a iova translation mapping.

For reference below is the captured debug info for the same
=====
[   19.435968] rvu_setup_msix_resources: phy_addr 0x3200000 iova 0xfff80000
[   19.436967] rvu_setup_msix_resources: virt_to_page(phy_addr)
0xffff7fe00000c800 page_to_phys(page) 0x3200000
offset_in_page(phy_addr) 0x00
=====

Thanks,
Sunil.

^ permalink raw reply

* Re: [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog
From: Song Liu @ 2018-10-09  7:02 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking
In-Reply-To: <20181009010454.6652-7-bhole_prashant_q7@lab.ntt.co.jp>

On Mon, Oct 8, 2018 at 6:07 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> map_lookup_elem isn't supported by certain map types like:
> - BPF_MAP_TYPE_PROG_ARRAY
> - BPF_MAP_TYPE_STACK_TRACE
> - BPF_MAP_TYPE_XSKMAP
> - BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH
> Let's add verfier tests to check whether verifier prevents
> bpf_map_lookup_elem call on above programs from bpf program.
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  tools/testing/selftests/bpf/test_verifier.c | 121 +++++++++++++++++++-
>  1 file changed, 120 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index 65ae44c85d27..cf4cd32b6772 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -48,7 +48,7 @@
>
>  #define MAX_INSNS      BPF_MAXINSNS
>  #define MAX_FIXUPS     8
> -#define MAX_NR_MAPS    8
> +#define MAX_NR_MAPS    13
>  #define POINTER_VALUE  0xcafe4all
>  #define TEST_DATA_LEN  64
>
> @@ -65,6 +65,10 @@ struct bpf_test {
>         int fixup_map_hash_48b[MAX_FIXUPS];
>         int fixup_map_hash_16b[MAX_FIXUPS];
>         int fixup_map_array_48b[MAX_FIXUPS];
> +       int fixup_map_sockmap[MAX_FIXUPS];
> +       int fixup_map_sockhash[MAX_FIXUPS];
> +       int fixup_map_xskmap[MAX_FIXUPS];
> +       int fixup_map_stacktrace[MAX_FIXUPS];
>         int fixup_prog1[MAX_FIXUPS];
>         int fixup_prog2[MAX_FIXUPS];
>         int fixup_map_in_map[MAX_FIXUPS];
> @@ -4541,6 +4545,85 @@ static struct bpf_test tests[] = {
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> +       {
> +               "prevent map lookup in sockmap",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_map_sockmap = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 15 into func bpf_map_lookup_elem",
> +               .prog_type = BPF_PROG_TYPE_SOCK_OPS,
> +       },
> +       {
> +               "prevent map lookup in sockhash",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_map_sockhash = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 18 into func bpf_map_lookup_elem",
> +               .prog_type = BPF_PROG_TYPE_SOCK_OPS,
> +       },
> +       {
> +               "prevent map lookup in xskmap",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_map_xskmap = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 17 into func bpf_map_lookup_elem",
> +               .prog_type = BPF_PROG_TYPE_XDP,
> +       },
> +       {
> +               "prevent map lookup in stack trace",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_map_stacktrace = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 7 into func bpf_map_lookup_elem",
> +               .prog_type = BPF_PROG_TYPE_PERF_EVENT,
> +       },
> +       {
> +               "prevent map lookup in prog array",
> +               .insns = {
> +                       BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
> +                       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> +                       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
> +                       BPF_LD_MAP_FD(BPF_REG_1, 0),
> +                       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                                    BPF_FUNC_map_lookup_elem),
> +                       BPF_EXIT_INSN(),
> +               },
> +               .fixup_prog2 = { 3 },
> +               .result = REJECT,
> +               .errstr = "cannot pass map_type 3 into func bpf_map_lookup_elem",
> +       },
>         {
>                 "valid map access into an array with a constant",
>                 .insns = {
> @@ -13515,6 +13598,10 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
>         int *fixup_map_hash_48b = test->fixup_map_hash_48b;
>         int *fixup_map_hash_16b = test->fixup_map_hash_16b;
>         int *fixup_map_array_48b = test->fixup_map_array_48b;
> +       int *fixup_map_sockmap = test->fixup_map_sockmap;
> +       int *fixup_map_sockhash = test->fixup_map_sockhash;
> +       int *fixup_map_xskmap = test->fixup_map_xskmap;
> +       int *fixup_map_stacktrace = test->fixup_map_stacktrace;
>         int *fixup_prog1 = test->fixup_prog1;
>         int *fixup_prog2 = test->fixup_prog2;
>         int *fixup_map_in_map = test->fixup_map_in_map;
> @@ -13603,6 +13690,38 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_map_type prog_type,
>                         fixup_percpu_cgroup_storage++;
>                 } while (*fixup_percpu_cgroup_storage);
>         }
> +       if (*fixup_map_sockmap) {
> +               map_fds[9] = create_map(BPF_MAP_TYPE_SOCKMAP, sizeof(int),
> +                                       sizeof(int), 1);
> +               do {
> +                       prog[*fixup_map_sockmap].imm = map_fds[9];
> +                       fixup_map_sockmap++;
> +               } while (*fixup_map_sockmap);
> +       }
> +       if (*fixup_map_sockhash) {
> +               map_fds[10] = create_map(BPF_MAP_TYPE_SOCKHASH, sizeof(int),
> +                                       sizeof(int), 1);
> +               do {
> +                       prog[*fixup_map_sockhash].imm = map_fds[10];
> +                       fixup_map_sockhash++;
> +               } while (*fixup_map_sockhash);
> +       }
> +       if (*fixup_map_xskmap) {
> +               map_fds[11] = create_map(BPF_MAP_TYPE_XSKMAP, sizeof(int),
> +                                       sizeof(int), 1);
> +               do {
> +                       prog[*fixup_map_xskmap].imm = map_fds[11];
> +                       fixup_map_xskmap++;
> +               } while (*fixup_map_xskmap);
> +       }
> +       if (*fixup_map_stacktrace) {
> +               map_fds[12] = create_map(BPF_MAP_TYPE_STACK_TRACE, sizeof(u32),
> +                                        sizeof(u64), 1);
> +               do {
> +                       prog[*fixup_map_stacktrace].imm = map_fds[12];
> +                       fixup_map_stacktrace++;
> +               } while (fixup_map_stacktrace);
> +       }
>  }
>
>  static void do_test_single(struct bpf_test *test, bool unpriv,
> --
> 2.17.1
>
>

^ permalink raw reply

* Re: [PATCH bpf-next 5/6] selftests/bpf: test_verifier, change names of fixup maps
From: Song Liu @ 2018-10-09  7:01 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking
In-Reply-To: <20181009010454.6652-6-bhole_prashant_q7@lab.ntt.co.jp>

On Mon, Oct 8, 2018 at 6:07 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> Currently fixup map are named like fixup_map1, fixup_map2, and so on.
> As suggested by Alexei let's change change map names such that we can
> identify map type by looking at the name.
>
> This patch is basically a find and replace change:
> fixup_map1  ->  fixup_map_hash_8b
> fixup_map2  ->  fixup_map_hash_48b
> fixup_map3  ->  fixup_map_hash_16b
> fixup_map4  ->  fixup_map_array_48b
>
> Suggested-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>


> ---
>  tools/testing/selftests/bpf/test_verifier.c | 380 ++++++++++----------
>  1 file changed, 190 insertions(+), 190 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index bc9cd8537467..65ae44c85d27 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -61,10 +61,10 @@ static bool unpriv_disabled = false;
>  struct bpf_test {
>         const char *descr;
>         struct bpf_insn insns[MAX_INSNS];
> -       int fixup_map1[MAX_FIXUPS];
> -       int fixup_map2[MAX_FIXUPS];
> -       int fixup_map3[MAX_FIXUPS];
> -       int fixup_map4[MAX_FIXUPS];
> +       int fixup_map_hash_8b[MAX_FIXUPS];
> +       int fixup_map_hash_48b[MAX_FIXUPS];
> +       int fixup_map_hash_16b[MAX_FIXUPS];
> +       int fixup_map_array_48b[MAX_FIXUPS];
>         int fixup_prog1[MAX_FIXUPS];
>         int fixup_prog2[MAX_FIXUPS];
>         int fixup_map_in_map[MAX_FIXUPS];
> @@ -876,7 +876,7 @@ static struct bpf_test tests[] = {
>                                      BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 2 },
> +               .fixup_map_hash_8b = { 2 },
>                 .errstr = "invalid indirect read from stack",
>                 .result = REJECT,
>         },
> @@ -1110,7 +1110,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "R0 invalid mem access 'map_value_or_null'",
>                 .result = REJECT,
>         },
> @@ -1127,7 +1127,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 4, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "misaligned value access",
>                 .result = REJECT,
>                 .flags = F_LOAD_WITH_STRICT_ALIGNMENT,
> @@ -1147,7 +1147,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 1),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "R0 invalid mem access",
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = REJECT,
> @@ -1237,7 +1237,7 @@ static struct bpf_test tests[] = {
>                                      BPF_FUNC_map_delete_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 24 },
> +               .fixup_map_hash_8b = { 24 },
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -1391,7 +1391,7 @@ static struct bpf_test tests[] = {
>                                     offsetof(struct __sk_buff, pkt_type)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr = "different pointers",
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result = REJECT,
> @@ -1414,7 +1414,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
>                         BPF_JMP_IMM(BPF_JA, 0, 0, -12),
>                 },
> -               .fixup_map1 = { 6 },
> +               .fixup_map_hash_8b = { 6 },
>                 .errstr = "different pointers",
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result = REJECT,
> @@ -1438,7 +1438,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
>                         BPF_JMP_IMM(BPF_JA, 0, 0, -13),
>                 },
> -               .fixup_map1 = { 7 },
> +               .fixup_map_hash_8b = { 7 },
>                 .errstr = "different pointers",
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result = REJECT,
> @@ -2575,7 +2575,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr_unpriv = "R4 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -2592,7 +2592,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "invalid indirect read from stack off -8+0 size 8",
>                 .result = REJECT,
>         },
> @@ -2894,7 +2894,7 @@ static struct bpf_test tests[] = {
>                         BPF_STX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -2934,7 +2934,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .errstr_unpriv = "R1 pointer comparison",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4073,7 +4073,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 5 },
> +               .fixup_map_hash_8b = { 5 },
>                 .result_unpriv = ACCEPT,
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_XDP,
> @@ -4089,7 +4089,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_XDP,
> @@ -4117,7 +4117,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 11 },
> +               .fixup_map_hash_8b = { 11 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_XDP,
>         },
> @@ -4139,7 +4139,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 7 },
> +               .fixup_map_hash_8b = { 7 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_XDP,
> @@ -4161,7 +4161,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 6 },
> +               .fixup_map_hash_8b = { 6 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_XDP,
> @@ -4184,7 +4184,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 5 },
> +               .fixup_map_hash_8b = { 5 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -4199,7 +4199,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> @@ -4227,7 +4227,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 11 },
> +               .fixup_map_hash_8b = { 11 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -4249,7 +4249,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 7 },
> +               .fixup_map_hash_8b = { 7 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> @@ -4271,7 +4271,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 6 },
> +               .fixup_map_hash_8b = { 6 },
>                 .result = REJECT,
>                 .errstr = "invalid access to packet",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> @@ -4555,7 +4555,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4577,7 +4577,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4601,7 +4601,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4629,7 +4629,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -4649,7 +4649,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=48 size=8",
>                 .result = REJECT,
>         },
> @@ -4670,7 +4670,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 min value is outside of the array range",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -4692,7 +4692,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 unbounded memory access, make sure to bounds check any array access into a map",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -4717,7 +4717,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .errstr = "R0 unbounded memory access",
>                 .result_unpriv = REJECT,
> @@ -4744,7 +4744,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .errstr = "invalid access to map value, value_size=48 off=44 size=8",
>                 .result_unpriv = REJECT,
> @@ -4774,7 +4774,7 @@ static struct bpf_test tests[] = {
>                                     offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3, 11 },
> +               .fixup_map_hash_48b = { 3, 11 },
>                 .errstr = "R0 pointer += pointer",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -4807,7 +4807,7 @@ static struct bpf_test tests[] = {
>                         BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 1),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .result = REJECT,
>                 .errstr = "cannot pass map_type 1 into func bpf_get_local_storage",
>                 .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
> @@ -4922,7 +4922,7 @@ static struct bpf_test tests[] = {
>                         BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 1),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .result = REJECT,
>                 .errstr = "cannot pass map_type 1 into func bpf_get_local_storage",
>                 .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
> @@ -5024,7 +5024,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
>         },
> @@ -5045,7 +5045,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr = "R4 pointer arithmetic on map_value_or_null",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
> @@ -5066,7 +5066,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr = "R4 pointer arithmetic on map_value_or_null",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
> @@ -5087,7 +5087,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr = "R4 pointer arithmetic on map_value_or_null",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
> @@ -5113,7 +5113,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .result = REJECT,
>                 .errstr = "R4 !read_ok",
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
> @@ -5141,7 +5141,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_4, 0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS
>         },
> @@ -5162,7 +5162,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 unbounded memory access",
>                 .result = REJECT,
>                 .errstr_unpriv = "R0 leaks addr",
> @@ -5412,7 +5412,7 @@ static struct bpf_test tests[] = {
>                                       offsetof(struct __sk_buff, cb[0])),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 2 },
> +               .fixup_map_hash_8b = { 2 },
>                 .errstr_unpriv = "R2 leaks addr into mem",
>                 .result_unpriv = REJECT,
>                 .result = REJECT,
> @@ -5442,7 +5442,7 @@ static struct bpf_test tests[] = {
>                                       offsetof(struct __sk_buff, cb[0])),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 1 },
> +               .fixup_map_hash_8b = { 1 },
>                 .errstr_unpriv = "R2 leaks addr into ctx",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -5464,7 +5464,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 4 },
> +               .fixup_map_hash_8b = { 4 },
>                 .errstr_unpriv = "R6 leaks addr into mem",
>                 .result_unpriv = REJECT,
>                 .result = ACCEPT,
> @@ -5484,7 +5484,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5503,7 +5503,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5521,7 +5521,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_trace_printk),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=0 size=0",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5541,7 +5541,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=0 size=56",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5561,7 +5561,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5585,7 +5585,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5606,7 +5606,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5626,7 +5626,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_trace_printk),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=4 size=0",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5650,7 +5650,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=4 size=52",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5672,7 +5672,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5694,7 +5694,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5719,7 +5719,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5741,7 +5741,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5761,7 +5761,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_trace_printk),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R1 min value is outside of the array range",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5786,7 +5786,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=4 size=52",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5809,7 +5809,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5832,7 +5832,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R2 min value is negative",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5858,7 +5858,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5881,7 +5881,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5903,7 +5903,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_trace_printk),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R1 min value is outside of the array range",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5925,7 +5925,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R1 unbounded memory access",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5951,7 +5951,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=4 size=45",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -5975,7 +5975,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -5998,7 +5998,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = REJECT,
>                 .errstr = "R1 unbounded memory access",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6022,7 +6022,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6045,7 +6045,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = REJECT,
>                 .errstr = "R1 unbounded memory access",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6070,7 +6070,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6094,7 +6094,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6118,7 +6118,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = REJECT,
>                 .errstr = "R1 min value is negative",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6143,7 +6143,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6167,7 +6167,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6191,7 +6191,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = REJECT,
>                 .errstr = "R1 min value is negative",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6210,7 +6210,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 8 },
> +               .fixup_map_hash_16b = { 3, 8 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6230,7 +6230,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_update_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6250,8 +6250,8 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_update_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> -               .fixup_map3 = { 10 },
> +               .fixup_map_hash_8b = { 3 },
> +               .fixup_map_hash_16b = { 10 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=8 off=0 size=16",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6272,7 +6272,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 9 },
> +               .fixup_map_hash_16b = { 3, 9 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6292,7 +6292,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 9 },
> +               .fixup_map_hash_16b = { 3, 9 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=12 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6312,7 +6312,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 9 },
> +               .fixup_map_hash_16b = { 3, 9 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=-4 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6334,7 +6334,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6355,7 +6355,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=12 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6376,7 +6376,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=-4 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6399,7 +6399,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 11 },
> +               .fixup_map_hash_16b = { 3, 11 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6419,7 +6419,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 10 },
> +               .fixup_map_hash_16b = { 3, 10 },
>                 .result = REJECT,
>                 .errstr = "R2 unbounded memory access, make sure to bounds check any array access into a map",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6442,7 +6442,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map3 = { 3, 11 },
> +               .fixup_map_hash_16b = { 3, 11 },
>                 .result = REJECT,
>                 .errstr = "invalid access to map value, value_size=16 off=9 size=8",
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6464,7 +6464,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6485,7 +6485,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6502,7 +6502,7 @@ static struct bpf_test tests[] = {
>                         BPF_STX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R1 !read_ok",
>                 .errstr = "R1 !read_ok",
>                 .result = REJECT,
> @@ -6536,7 +6536,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_7, -4, 24),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6564,7 +6564,7 @@ static struct bpf_test tests[] = {
>                         BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_0, 4),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6583,7 +6583,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 bitwise operator &= on pointer",
>                 .result = REJECT,
>         },
> @@ -6600,7 +6600,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 32-bit pointer arithmetic prohibited",
>                 .result = REJECT,
>         },
> @@ -6617,7 +6617,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 pointer arithmetic with /= operator",
>                 .result = REJECT,
>         },
> @@ -6634,7 +6634,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 pointer arithmetic prohibited",
>                 .errstr = "invalid mem access 'inv'",
>                 .result = REJECT,
> @@ -6658,7 +6658,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 invalid mem access 'inv'",
>                 .result = REJECT,
>         },
> @@ -6681,7 +6681,7 @@ static struct bpf_test tests[] = {
>                         BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr_unpriv = "R0 leaks addr",
>                 .result = ACCEPT,
>                 .result_unpriv = REJECT,
> @@ -6927,7 +6927,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -6953,7 +6953,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "invalid access to map value, value_size=48 off=0 size=49",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -6981,7 +6981,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -7008,7 +7008,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R1 min value is outside of the array range",
>                 .result = REJECT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
> @@ -7080,7 +7080,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_csum_diff),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -7105,7 +7105,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_csum_diff),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -7128,7 +7128,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_csum_diff),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         },
> @@ -7209,7 +7209,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -7230,7 +7230,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -7250,7 +7250,7 @@ static struct bpf_test tests[] = {
>                         BPF_EMIT_CALL(BPF_FUNC_probe_read),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>                 .prog_type = BPF_PROG_TYPE_TRACEPOINT,
>         },
> @@ -7325,7 +7325,7 @@ static struct bpf_test tests[] = {
>                                    offsetof(struct test_val, foo)),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 max value is outside of the array range",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -7355,7 +7355,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_REG(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map2 = { 3 },
> +               .fixup_map_hash_48b = { 3 },
>                 .errstr = "R0 max value is outside of the array range",
>                 .result = REJECT,
>                 .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
> @@ -7708,7 +7708,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7732,7 +7732,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7758,7 +7758,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7783,7 +7783,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7807,7 +7807,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>         },
>         {
> @@ -7831,7 +7831,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7877,7 +7877,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>         },
>         {
> @@ -7902,7 +7902,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7928,7 +7928,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .result = ACCEPT,
>         },
>         {
> @@ -7953,7 +7953,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -7980,7 +7980,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -8006,7 +8006,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>                 .result = REJECT,
>         },
> @@ -8035,7 +8035,7 @@ static struct bpf_test tests[] = {
>                         BPF_MOV64_IMM(BPF_REG_0, 0),
>                         BPF_EXIT_INSN(),
>                 },
> -               .fixup_map1 = { 3 },
> +               .fixup_map_hash_8b = { 3 },
>                 .errstr = "unbounded min value",
>

^ permalink raw reply

* Re: [PATCH bpf-next 4/6] tools/bpf: bpftool, print strerror when map lookup error occurs
From: Song Liu @ 2018-10-09  7:00 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking
In-Reply-To: <20181009010454.6652-5-bhole_prashant_q7@lab.ntt.co.jp>

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> Since map lookup error can be ENOENT or EOPNOTSUPP, let's print
> strerror() as error message in normal and JSON output.
>
> This patch adds helper function print_entry_error() to print
> entry from lookup error occurs
>
> Example: Following example dumps a map which does not support lookup.
>
> Output before:
> root# bpftool map -jp dump id 40
> [
>     "key": ["0x0a","0x00","0x00","0x00"
>     ],
>     "value": {
>         "error": "can\'t lookup element"
>     },
>     "key": ["0x0b","0x00","0x00","0x00"
>     ],
>     "value": {
>         "error": "can\'t lookup element"
>     }
> ]
>
> root# bpftool map dump id 40
> can't lookup element with key:
> 0a 00 00 00
> can't lookup element with key:
> 0b 00 00 00
> Found 0 elements
>
> Output after changes:
> root# bpftool map dump -jp  id 45
> [
>     "key": ["0x0a","0x00","0x00","0x00"
>     ],
>     "value": {
>         "error": "Operation not supported"
>     },
>     "key": ["0x0b","0x00","0x00","0x00"
>     ],
>     "value": {
>         "error": "Operation not supported"
>     }
> ]
>
> root# bpftool map dump id 45
> key:
> 0a 00 00 00
> value:
> Operation not supported
> key:
> 0b 00 00 00
> value:
> Operation not supported
> Found 0 elements
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  tools/bpf/bpftool/map.c | 29 ++++++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index 28d365435fea..9f5de48f8a99 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -336,6 +336,25 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key,
>         jsonw_end_object(json_wtr);
>  }
>
> +static void print_entry_error(struct bpf_map_info *info, unsigned char *key,
> +                             const char *value)
> +{
> +       int value_size = strlen(value);
> +       bool single_line, break_names;
> +
> +       break_names = info->key_size > 16 || value_size > 16;
> +       single_line = info->key_size + value_size <= 24 && !break_names;
> +
> +       printf("key:%c", break_names ? '\n' : ' ');
> +       fprint_hex(stdout, key, info->key_size, " ");
> +
> +       printf(single_line ? "  " : "\n");
> +
> +       printf("value:%c%s", break_names ? '\n' : ' ', value);
> +
> +       printf("\n");
> +}
> +
>  static void print_entry_plain(struct bpf_map_info *info, unsigned char *key,
>                               unsigned char *value)
>  {
> @@ -663,6 +682,7 @@ static int dump_map_elem(int fd, void *key, void *value,
>                          json_writer_t *btf_wtr)
>  {
>         int num_elems = 0;
> +       int lookup_errno;
>
>         if (!bpf_map_lookup_elem(fd, key, value)) {
>                 if (json_output) {
> @@ -685,6 +705,8 @@ static int dump_map_elem(int fd, void *key, void *value,
>         }
>
>         /* lookup error handling */
> +       lookup_errno = errno;
> +
>         if (map_is_map_of_maps(map_info->type) ||
>             map_is_map_of_progs(map_info->type))
>                 return 0;
> @@ -694,13 +716,10 @@ static int dump_map_elem(int fd, void *key, void *value,
>                 print_hex_data_json(key, map_info->key_size);
>                 jsonw_name(json_wtr, "value");
>                 jsonw_start_object(json_wtr);
> -               jsonw_string_field(json_wtr, "error",
> -                                  "can't lookup element");
> +               jsonw_string_field(json_wtr, "error", strerror(lookup_errno));
>                 jsonw_end_object(json_wtr);
>         } else {
> -               p_info("can't lookup element with key: ");
> -               fprint_hex(stderr, key, map_info->key_size, " ");
> -               fprintf(stderr, "\n");
> +               print_entry_error(map_info, key, strerror(lookup_errno));
>         }
>
>         return 0;
> --
> 2.17.1
>
>

^ permalink raw reply

* Re: [PATCH bpf-next 3/6] tools/bpf: bpftool, split the function do_dump()
From: Song Liu @ 2018-10-09  6:58 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking
In-Reply-To: <20181009010454.6652-4-bhole_prashant_q7@lab.ntt.co.jp>

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> do_dump() function in bpftool/map.c has deep indentations. In order
> to reduce deep indent, let's move element printing code out of
> do_dump() into dump_map_elem() function.
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  tools/bpf/bpftool/map.c | 83 ++++++++++++++++++++++++-----------------
>  1 file changed, 49 insertions(+), 34 deletions(-)
>
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index 6003e9598973..28d365435fea 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -658,6 +658,54 @@ static int do_show(int argc, char **argv)
>         return errno == ENOENT ? 0 : -1;
>  }
>
> +static int dump_map_elem(int fd, void *key, void *value,
> +                        struct bpf_map_info *map_info, struct btf *btf,
> +                        json_writer_t *btf_wtr)
> +{
> +       int num_elems = 0;
> +
> +       if (!bpf_map_lookup_elem(fd, key, value)) {
> +               if (json_output) {
> +                       print_entry_json(map_info, key, value, btf);
> +               } else {
> +                       if (btf) {
> +                               struct btf_dumper d = {
> +                                       .btf = btf,
> +                                       .jw = btf_wtr,
> +                                       .is_plain_text = true,
> +                               };
> +
> +                               do_dump_btf(&d, map_info, key, value);
> +                       } else {
> +                               print_entry_plain(map_info, key, value);
> +                       }
> +                       num_elems++;
> +               }
> +               return num_elems;
> +       }
> +
> +       /* lookup error handling */
> +       if (map_is_map_of_maps(map_info->type) ||
> +           map_is_map_of_progs(map_info->type))
> +               return 0;
> +
> +       if (json_output) {
> +               jsonw_name(json_wtr, "key");
> +               print_hex_data_json(key, map_info->key_size);
> +               jsonw_name(json_wtr, "value");
> +               jsonw_start_object(json_wtr);
> +               jsonw_string_field(json_wtr, "error",
> +                                  "can't lookup element");
> +               jsonw_end_object(json_wtr);
> +       } else {
> +               p_info("can't lookup element with key: ");
> +               fprint_hex(stderr, key, map_info->key_size, " ");
> +               fprintf(stderr, "\n");
> +       }
> +
> +       return 0;
> +}
> +
>  static int do_dump(int argc, char **argv)
>  {
>         struct bpf_map_info info = {};
> @@ -713,40 +761,7 @@ static int do_dump(int argc, char **argv)
>                                 err = 0;
>                         break;
>                 }
> -
> -               if (!bpf_map_lookup_elem(fd, key, value)) {
> -                       if (json_output)
> -                               print_entry_json(&info, key, value, btf);
> -                       else
> -                               if (btf) {
> -                                       struct btf_dumper d = {
> -                                               .btf = btf,
> -                                               .jw = btf_wtr,
> -                                               .is_plain_text = true,
> -                                       };
> -
> -                                       do_dump_btf(&d, &info, key, value);
> -                               } else {
> -                                       print_entry_plain(&info, key, value);
> -                               }
> -                       num_elems++;
> -               } else if (!map_is_map_of_maps(info.type) &&
> -                          !map_is_map_of_progs(info.type)) {
> -                       if (json_output) {
> -                               jsonw_name(json_wtr, "key");
> -                               print_hex_data_json(key, info.key_size);
> -                               jsonw_name(json_wtr, "value");
> -                               jsonw_start_object(json_wtr);
> -                               jsonw_string_field(json_wtr, "error",
> -                                                  "can't lookup element");
> -                               jsonw_end_object(json_wtr);
> -                       } else {
> -                               p_info("can't lookup element with key: ");
> -                               fprint_hex(stderr, key, info.key_size, " ");
> -                               fprintf(stderr, "\n");
> -                       }
> -               }
> -
> +               num_elems += dump_map_elem(fd, key, value, &info, btf, btf_wtr);
>                 prev_key = key;
>         }
>
> --
> 2.17.1
>
>

^ permalink raw reply

* Re: [PATCH bpf-next 2/6] bpf: return EOPNOTSUPP when map lookup isn't supported
From: Song Liu @ 2018-10-09  6:58 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking
In-Reply-To: <20181009010454.6652-3-bhole_prashant_q7@lab.ntt.co.jp>

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> Return ERR_PTR(-EOPNOTSUPP) from map_lookup_elem() methods of below
> map types:
> - BPF_MAP_TYPE_PROG_ARRAY
> - BPF_MAP_TYPE_STACK_TRACE
> - BPF_MAP_TYPE_XSKMAP
> - BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
> ---
>  kernel/bpf/arraymap.c | 2 +-
>  kernel/bpf/sockmap.c  | 2 +-
>  kernel/bpf/stackmap.c | 2 +-
>  kernel/bpf/xskmap.c   | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
> index dded84cbe814..24583da9ffd1 100644
> --- a/kernel/bpf/arraymap.c
> +++ b/kernel/bpf/arraymap.c
> @@ -449,7 +449,7 @@ static void fd_array_map_free(struct bpf_map *map)
>
>  static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key)
>  {
> -       return NULL;
> +       return ERR_PTR(-EOPNOTSUPP);
>  }
>
>  /* only called from syscall */
> diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
> index d37a1a0a6e1e..5d0677d808ae 100644
> --- a/kernel/bpf/sockmap.c
> +++ b/kernel/bpf/sockmap.c
> @@ -2096,7 +2096,7 @@ int sockmap_get_from_fd(const union bpf_attr *attr, int type,
>
>  static void *sock_map_lookup(struct bpf_map *map, void *key)
>  {
> -       return NULL;
> +       return ERR_PTR(-EOPNOTSUPP);
>  }
>
>  static int sock_map_update_elem(struct bpf_map *map,
> diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
> index 8061a439ef18..b2ade10f7ec3 100644
> --- a/kernel/bpf/stackmap.c
> +++ b/kernel/bpf/stackmap.c
> @@ -505,7 +505,7 @@ const struct bpf_func_proto bpf_get_stack_proto = {
>  /* Called from eBPF program */
>  static void *stack_map_lookup_elem(struct bpf_map *map, void *key)
>  {
> -       return NULL;
> +       return ERR_PTR(-EOPNOTSUPP);
>  }
>
>  /* Called from syscall */
> diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
> index 9f8463afda9c..ef0b7b6ef8a5 100644
> --- a/kernel/bpf/xskmap.c
> +++ b/kernel/bpf/xskmap.c
> @@ -154,7 +154,7 @@ void __xsk_map_flush(struct bpf_map *map)
>
>  static void *xsk_map_lookup_elem(struct bpf_map *map, void *key)
>  {
> -       return NULL;
> +       return ERR_PTR(-EOPNOTSUPP);
>  }
>
>  static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
> --
> 2.17.1
>
>

^ permalink raw reply

* Re: [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem isn't supported
From: Song Liu @ 2018-10-09  6:57 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Jakub Kicinski,
	David S . Miller, Quentin Monnet, Networking
In-Reply-To: <20181009010454.6652-2-bhole_prashant_q7@lab.ntt.co.jp>

On Mon, Oct 8, 2018 at 6:06 PM Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp> wrote:
>
> The error value returned by map_lookup_elem doesn't differentiate
> whether lookup was failed because of invalid key or lookup is not
> supported.
>
> Lets add handling for -EOPNOTSUPP return value of map_lookup_elem()
> method of map, with expectation from map's implementation that it
> should return -EOPNOTSUPP if lookup is not supported.
>
> The errno for bpf syscall for BPF_MAP_LOOKUP_ELEM command will be set
> to EOPNOTSUPP if map lookup is not supported.
>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  kernel/bpf/syscall.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 5742df21598c..4f416234251f 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -719,10 +719,15 @@ static int map_lookup_elem(union bpf_attr *attr)
>         } else {
>                 rcu_read_lock();
>                 ptr = map->ops->map_lookup_elem(map, key);
> -               if (ptr)
> +               if (IS_ERR(ptr)) {
> +                       err = PTR_ERR(ptr);
> +               } else if (!ptr) {
> +                       err = -ENOENT;
> +               } else {
> +                       err = 0;
>                         memcpy(value, ptr, value_size);
> +               }
>                 rcu_read_unlock();
> -               err = ptr ? 0 : -ENOENT;
>         }
>
>         if (err)
> --
> 2.17.1
>
>

^ permalink raw reply

* Re: [PATCH v4 net-next 8/9] devlink: Add Documentation/networking/devlink-params.txt
From: Vasundhara Volam @ 2018-10-09  6:47 UTC (permalink / raw)
  To: saeedm
  Cc: David Miller, Netdev, Jiri Pirko, jakub.kicinski, gerlitz.or,
	michael.chan@broadcom.com
In-Reply-To: <389316c10115ddbb06d4895def185b45d3a60954.camel@mellanox.com>

On Tue, Oct 9, 2018 at 11:51 AM Saeed Mahameed <saeedm@mellanox.com> wrote:
>
> On Thu, 2018-10-04 at 11:13 +0530, Vasundhara Volam wrote:
> > This patch adds a new file to add information about some of the
> > generic configuration parameters set via devlink.
> >
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Cc: Jonathan Corbet <corbet@lwn.net>
> > Cc: linux-doc@vger.kernel.org
> > Cc: Jiri Pirko <jiri@mellanox.com>
> > Cc: Michael Chan <michael.chan@broadcom.com>
> > Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
> > ---
> >  Documentation/networking/devlink-params.txt | 42
> > +++++++++++++++++++++++++++++
> >  1 file changed, 42 insertions(+)
> >  create mode 100644 Documentation/networking/devlink-params.txt
> >
> > diff --git a/Documentation/networking/devlink-params.txt
> > b/Documentation/networking/devlink-params.txt
> > new file mode 100644
> > index 0000000..ae444ff
> > --- /dev/null
> > +++ b/Documentation/networking/devlink-params.txt
> > @@ -0,0 +1,42 @@
> > +Devlink configuration parameters
> > +================================
> > +Following is the list of configuration parameters via devlink
> > interface.
> > +Each parameter can be generic or driver specific and are device
> > level
> > +parameters.
> > +
> > +Note that the driver-specific files should contain the generic
> > params
> > +they support to, with supported config modes.
> > +
> > +Each parameter can be set in different configuration modes:
> > +     runtime         - set while driver is running, no reset
> > required.
> > +     driverinit      - applied while driver initializes, requires
> > restart
> > +                     driver by devlink reload command.
> > +     permanent       - written to device's non-volatile memory, hard reset
> > +                     required.
> > +
> > +Following is the list of parameters:
> > +====================================
> > +enable_sriov         [DEVICE, GENERIC]
> > +                     Enable Single Root I/O Virtualisation (SRIOV)
> > in
> > +                     the device.
> > +                     Type: Boolean
> > +
> > +ignore_ari           [DEVICE, GENERIC]
> > +                     Ignore Alternative Routing-ID Interpretation
> > (ARI)
> > +                     capability. If enabled, adapter will ignore ARI
> > +                     capability even when platforms has the support
> > +                     enabled and creates same number of partitions
> > when
> > +                     platform does not support ARI.
> > +                     Type: Boolean
> > +
> > +msix_vec_per_pf_max  [DEVICE, GENERIC]
> > +                     Provides the maximum number of MSIX interrupts
> > that
> > +                     a device can create. Value is same across all
> > +                     physical functions (PFs) in the device.
> > +                     Type: u32
> > +
> > +msix_vec_per_pf_min  [DEVICE, GENERIC]
> > +                     Provides the minimum number of MSIX interrupts
> > required
> > +                     for the device initialization. Value is same
> > across all
> > +                     physical functions (PFs) in the device.
> > +                     Type: u32
>
> some parameters can't be dynamic, meaning they can't support all
> configuration modes listed above, for example msix min/max can only be
> satisfied at driver boot, so runtime configuration doesn't make sense.
> shouldn't we have this documented in here ? i mean which parameters
> support which modes ?
All three configuration modes are not applicable for each parameter.
Driver which uses the parameter, will list the configuration mode used in
that driver and also is updated in individual driver devlink parameter
documentation.

^ permalink raw reply

* Re: pull-request: bpf-next 2018-10-08
From: David Miller @ 2018-10-09  6:45 UTC (permalink / raw)
  To: ast; +Cc: daniel, netdev, kernel-team
In-Reply-To: <20181009055347.1610223-1-ast@kernel.org>

From: Alexei Starovoitov <ast@kernel.org>
Date: Mon, 8 Oct 2018 22:53:47 -0700

> The following pull-request contains BPF updates for your *net-next*
> tree.

Pulled, thanks Alexei.

^ permalink raw reply

* Re: [PATCH net 02/10] rxrpc: Fix the data_ready handler
From: David Howells @ 2018-10-09 14:00 UTC (permalink / raw)
  To: eric.dumazet; +Cc: dhowells, netdev, pabeni, linux-afs, linux-kernel
In-Reply-To: <153903885366.17944.9795992149237942599.stgit@warthog.procyon.org.uk>

Hi Eric,

Note that although the loop you objected to is still here in this patch, it's
discarded entirely in patch 3.  I've kept the patches 2 and 10 separate since
they fix separate bugs, and 3 works around some of those in 2 entirely, but if
you want I should be able to push 2, 3 and 10 to the end and I could also
merge them, if that would help.

David

^ permalink raw reply

* Re: [PATCH v3 net-next] inet: remove redundant backlog setting in listen(2)
From: Eric Dumazet @ 2018-10-09 14:00 UTC (permalink / raw)
  To: Yafang Shao; +Cc: David Miller, netdev, LKML
In-Reply-To: <1539086718-4119-1-git-send-email-laoar.shao@gmail.com>

On Tue, Oct 9, 2018 at 5:05 AM Yafang Shao <laoar.shao@gmail.com> wrote:
>
> The sk_max_ack_backlog will be set in the caller inet_listen() and
> dccp_listen_start(), so it is redundant to set it in
> inet_csk_listen_start().
> Just remove this setting.
>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
>  net/ipv4/inet_connection_sock.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> index dfd5009..cdd5c95 100644
> --- a/net/ipv4/inet_connection_sock.c
> +++ b/net/ipv4/inet_connection_sock.c
> @@ -871,7 +871,6 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
>
>         reqsk_queue_alloc(&icsk->icsk_accept_queue);
>
> -       sk->sk_max_ack_backlog = backlog;
>         sk->sk_ack_backlog = 0;
>         inet_csk_delack_init(sk);


You got it wrong again. Can you read my feedbacks one more time ?

This setting is not redundant, unless you move the ones in
inet_listen() and inet_dccp_listen() earlier.

^ permalink raw reply

* Re: [PATCH bpf-next 0/6] Consistent prefixes for libbpf interfaces
From: Yonghong Song @ 2018-10-09  6:43 UTC (permalink / raw)
  To: Daniel Borkmann, Andrey Ignatov, netdev@vger.kernel.org
  Cc: ast@kernel.org, Kernel Team
In-Reply-To: <00774c65-e7f2-972a-ff44-f1f5c08f4401@iogearbox.net>



On 10/4/18 7:22 AM, Daniel Borkmann wrote:
> [ +Yonghong ]
> 
> On 10/04/2018 12:26 AM, Andrey Ignatov wrote:
>> This patch set renames a few interfaces in libbpf, mostly netlink related,
>> so that all symbols provided by the library have only three possible
>> prefixes:
>>
>> % nm -D tools/lib/bpf/libbpf.so  | \
>>      awk '$2 == "T" {sub(/[_\(].*/, "", $3); if ($3) print $3}' | \
>>      sort | \
>>      uniq -c
>>       91 bpf
>>        8 btf
>>       14 libbpf
>>
>> libbpf is used more and more outside kernel tree. That means the library
>> should follow good practices in library design and implementation to
>> play well with third party code that uses it.
>>
>> One of such practices is to have a common prefix (or a few) for every
>> interface, function or data structure, library provides. It helps to
>> avoid name conflicts with other libraries and keeps API/ABI consistent.
>>
>> Inconsistent names in libbpf already cause problems in real life. E.g.
>> an application can't use both libbpf and libnl due to conflicting
>> symbols (specifically nla_parse, nla_parse_nested and a few others).
>>
>> Some of problematic global symbols are not part of ABI and can be
>> restricted from export with either visibility attribute/pragma or export
>> map (what is useful by itself and can be done in addition). That won't
>> solve the problem for those that are part of ABI though. Also export
>> restrictions would help only in DSO case. If third party application links
>> libbpf statically it won't help, and people do it (e.g. Facebook links
>> most of libraries statically, including libbpf).
>>
>> libbpf already uses the following prefixes for its interfaces:
>> * bpf_ for bpf system call wrappers, program/map/elf-object
>>    abstractions and a few other things;
>> * btf_ for BTF related API;
>> * libbpf_ for everything else.
>>
>> The patch adds libbpf_ prefix to interfaces that use none of mentioned
>> above prefixes and don't fit well into the first two categories.
>>
>> Long term benefits of having common prefix should outweigh possible
>> inconvenience of changing API for those functions now.
>>
>> Patches 2-4 add libbpf_ prefix to libbpf interfaces: separate patch per
>> header. Other patches are simple improvements in API.
>>
>>
>> Andrey Ignatov (6):
>>    libbpf: Move __dump_nlmsg_t from API to implementation
>>    libbpf: Consistent prefixes for interfaces in libbpf.h.
>>    libbpf: Consistent prefixes for interfaces in nlattr.h.
>>    libbpf: Consistent prefixes for interfaces in str_error.h.
>>    libbpf: Make include guards consistent
>>    libbpf: Use __u32 instead of u32 in bpf_program__load
>>
>>   tools/bpf/bpftool/net.c            | 41 ++++++++++---------
>>   tools/bpf/bpftool/netlink_dumper.c | 32 ++++++++-------
>>   tools/lib/bpf/bpf.h                |  6 +--
>>   tools/lib/bpf/btf.h                |  6 +--
>>   tools/lib/bpf/libbpf.c             | 22 +++++-----
>>   tools/lib/bpf/libbpf.h             | 31 +++++++-------
>>   tools/lib/bpf/netlink.c            | 48 ++++++++++++----------
>>   tools/lib/bpf/nlattr.c             | 64 +++++++++++++++--------------
>>   tools/lib/bpf/nlattr.h             | 65 +++++++++++++++---------------
>>   tools/lib/bpf/str_error.c          |  2 +-
>>   tools/lib/bpf/str_error.h          |  8 ++--
>>   11 files changed, 171 insertions(+), 154 deletions(-)
> 
> Overall agree that this is needed, and I've therefore applied the
> set, thanks for cleaning up, Andrey!
> 
> But, I would actually like to see this going one step further, in
> particular, we should keep all the netlink related stuff inside
> libbpf-/only/. Meaning, the goal of libbpf is not to provide yet
> another set of netlink primitives but instead e.g. for the bpftool
> dumper this should be abstracted away such that we pass in a callback
> from bpftool side and have an iterator object which will then be
> populated from inside the libbpf logic, meaning, bpftool shouldn't
> even be aware of anything netlink there.

Agreed. This indeed make sense, the user really only cares a few fields
like devname/id, attachment_type, prog_id, etc. I will take a look at
this later if nobody works on it.

> 
> Thanks,
> Daniel
> 

^ permalink raw reply

* Re: [PATCH v4 net-next 8/9] devlink: Add Documentation/networking/devlink-params.txt
From: Saeed Mahameed @ 2018-10-09  6:21 UTC (permalink / raw)
  To: davem@davemloft.net, vasundhara-v.volam@broadcom.com
  Cc: netdev@vger.kernel.org, Jiri Pirko, jakub.kicinski@netronome.com,
	gerlitz.or@gmail.com, michael.chan@broadcom.com
In-Reply-To: <1538631832-15481-9-git-send-email-vasundhara-v.volam@broadcom.com>

On Thu, 2018-10-04 at 11:13 +0530, Vasundhara Volam wrote:
> This patch adds a new file to add information about some of the
> generic configuration parameters set via devlink.
> 
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: linux-doc@vger.kernel.org
> Cc: Jiri Pirko <jiri@mellanox.com>
> Cc: Michael Chan <michael.chan@broadcom.com>
> Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
> ---
>  Documentation/networking/devlink-params.txt | 42
> +++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
>  create mode 100644 Documentation/networking/devlink-params.txt
> 
> diff --git a/Documentation/networking/devlink-params.txt
> b/Documentation/networking/devlink-params.txt
> new file mode 100644
> index 0000000..ae444ff
> --- /dev/null
> +++ b/Documentation/networking/devlink-params.txt
> @@ -0,0 +1,42 @@
> +Devlink configuration parameters
> +================================
> +Following is the list of configuration parameters via devlink
> interface.
> +Each parameter can be generic or driver specific and are device
> level
> +parameters.
> +
> +Note that the driver-specific files should contain the generic
> params
> +they support to, with supported config modes.
> +
> +Each parameter can be set in different configuration modes:
> +	runtime		- set while driver is running, no reset
> required.
> +	driverinit	- applied while driver initializes, requires
> restart
> +			driver by devlink reload command.
> +	permanent	- written to device's non-volatile memory, hard reset
> +			required.
> +
> +Following is the list of parameters:
> +====================================
> +enable_sriov		[DEVICE, GENERIC]
> +			Enable Single Root I/O Virtualisation (SRIOV)
> in
> +			the device.
> +			Type: Boolean
> +
> +ignore_ari		[DEVICE, GENERIC]
> +			Ignore Alternative Routing-ID Interpretation
> (ARI)
> +			capability. If enabled, adapter will ignore ARI
> +			capability even when platforms has the support
> +			enabled and creates same number of partitions
> when
> +			platform does not support ARI.
> +			Type: Boolean
> +
> +msix_vec_per_pf_max	[DEVICE, GENERIC]
> +			Provides the maximum number of MSIX interrupts
> that
> +			a device can create. Value is same across all
> +			physical functions (PFs) in the device.
> +			Type: u32
> +
> +msix_vec_per_pf_min	[DEVICE, GENERIC]
> +			Provides the minimum number of MSIX interrupts
> required
> +			for the device initialization. Value is same
> across all
> +			physical functions (PFs) in the device.
> +			Type: u32

some parameters can't be dynamic, meaning they can't support all
configuration modes listed above, for example msix min/max can only be
satisfied at driver boot, so runtime configuration doesn't make sense. 
shouldn't we have this documented in here ? i mean which parameters
support which modes ? 

^ permalink raw reply

* Re: [PATCH 2/2] 9p/trans_fd: put worker reqs on destroy
From: Tomas Bortoli @ 2018-10-09 13:19 UTC (permalink / raw)
  To: Dominique Martinet
  Cc: Dominique Martinet, v9fs-developer, netdev, LKML,
	Eric Van Hensbergen, Latchesar Ionkov
In-Reply-To: <1539057956-23741-2-git-send-email-asmadeus@codewreck.org>

Il giorno mar 9 ott 2018 alle ore 06:06 Dominique Martinet
<asmadeus@codewreck.org> ha scritto:
>
> From: Dominique Martinet <dominique.martinet@cea.fr>
>
> p9_read_work/p9_write_work might still hold references to a req after
> having been cancelled; make sure we put any of these to avoid potential
> request leak on disconnect.
>
> Fixes: 728356dedeff8 ("9p: Add refcount to p9_req_t")
> Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
> Cc: Eric Van Hensbergen <ericvh@gmail.com>
> Cc: Latchesar Ionkov <lucho@ionkov.net>
> Cc: Tomas Bortoli <tomasbortoli@gmail.com>
Reviewed-by: Tomas Bortoli <tomasbortoli@gmail.com>
> ---
> Noticed we could leak a ref while looking at the syzbot report,
> this should be safe enough after the work has been cancelled...
> Probably.
>
>  net/9p/trans_fd.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
> index a0317d459cde..f868cf6fba79 100644
> --- a/net/9p/trans_fd.c
> +++ b/net/9p/trans_fd.c
> @@ -876,7 +876,15 @@ static void p9_conn_destroy(struct p9_conn *m)
>
>         p9_mux_poll_stop(m);
>         cancel_work_sync(&m->rq);
> +       if (m->rreq) {
> +               p9_req_put(m->rreq);
> +               m->rreq = NULL;
> +       }
>         cancel_work_sync(&m->wq);
> +       if (m->wreq) {
> +               p9_req_put(m->wreq);
> +               m->wreq = NULL;
> +       }
>
>         p9_conn_cancel(m, -ECONNRESET);
>
> --
> 2.19.1
>

LGTM
--
Tomas

^ permalink raw reply

* pull-request: bpf-next 2018-10-08
From: Alexei Starovoitov @ 2018-10-09  5:53 UTC (permalink / raw)
  To: David S . Miller; +Cc: daniel, netdev, kernel-team

Hi David,

The following pull-request contains BPF updates for your *net-next* tree.

The main changes are:

1) sk_lookup_[tcp|udp] and sk_release helpers from Joe Stringer which allow
BPF programs to perform lookups for sockets in a network namespace. This would
allow programs to determine early on in processing whether the stack is
expecting to receive the packet, and perform some action (eg drop,
forward somewhere) based on this information.

2) per-cpu cgroup local storage from Roman Gushchin.
Per-cpu cgroup local storage is very similar to simple cgroup storage
except all the data is per-cpu. The main goal of per-cpu variant is to
implement super fast counters (e.g. packet counters), which don't require
neither lookups, neither atomic operations in a fast path.
The example of these hybrid counters is in selftests/bpf/netcnt_prog.c

3) allow HW offload of programs with BPF-to-BPF function calls from Quentin Monnet

4) support more than 64-byte key/value in HW offloaded BPF maps from Jakub Kicinski

5) rename of libbpf interfaces from Andrey Ignatov.
libbpf is maturing as a library and should follow good practices in
library design and implementation to play well with other libraries.
This patch set brings consistent naming convention to global symbols.

6) relicense libbpf as LGPL-2.1 OR BSD-2-Clause from Alexei Starovoitov
to let Apache2 projects use libbpf

7) various AF_XDP fixes from Björn and Magnus

Please consider pulling these changes from:

  git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

Thanks a lot!

----------------------------------------------------------------

The following changes since commit 1042caa79e9351b81ed19dc8d2d7fd6ff51a4422:

  net-ipv4: remove 2 always zero parameters from ipv4_redirect() (2018-09-26 20:30:55 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git 

for you to fetch changes up to df3f94a0bbeb6cb6a02eb16b8e76f16b33cb2f8f:

  bpf: fix building without CONFIG_INET (2018-10-09 00:49:44 +0200)

----------------------------------------------------------------
Alexei Starovoitov (1):
      libbpf: relicense libbpf as LGPL-2.1 OR BSD-2-Clause

Andrey Ignatov (12):
      bpftool: Fix bpftool net output
      libbpf: Introduce libbpf_attach_type_by_name
      libbpf: Support cgroup_skb/{e,in}gress section names
      libbpf: Support sk_skb/stream_{parser, verdict} section names
      selftests/bpf: Use libbpf_attach_type_by_name in test_socket_cookie
      selftests/bpf: Test libbpf_{prog,attach}_type_by_name
      libbpf: Move __dump_nlmsg_t from API to implementation
      libbpf: Consistent prefixes for interfaces in libbpf.h.
      libbpf: Consistent prefixes for interfaces in nlattr.h.
      libbpf: Consistent prefixes for interfaces in str_error.h.
      libbpf: Make include guards consistent
      libbpf: Use __u32 instead of u32 in bpf_program__load

Arnd Bergmann (1):
      bpf: fix building without CONFIG_INET

Arthur Fabre (1):
      bpf, doc: Document Jump X addressing mode

Björn Töpel (1):
      xsk: proper AF_XDP socket teardown ordering

Bo YU (1):
      bpf, tracex3_user: erase "ARRAY_SIZE" redefined

Daniel Borkmann (7):
      Merge branch 'bpf-libbpf-attach-by-name'
      Merge branch 'bpf-per-cpu-cgroup-storage'
      Merge branch 'bpf-big-map-entries'
      Merge branch 'bpf-sk-lookup'
      Merge branch 'bpf-libbpf-consistent-iface'
      Merge branch 'bpf-xsk-fix-mixed-mode'
      Merge branch 'bpf-to-bpf-calls-nfp'

Jakub Kicinski (5):
      nfp: bpf: parse global BPF ABI version capability
      nfp: allow apps to request larger MTU on control vNIC
      nfp: bpf: allow control message sizing for map ops
      ethtool: rename local variable max -> curr
      ethtool: don't allow disabling queues with umem installed

Joe Stringer (14):
      bpf: Add iterator for spilled registers
      bpf: Simplify ptr_min_max_vals adjustment
      bpf: Reuse canonical string formatter for ctx errs
      bpf: Generalize ptr_or_null regs check
      bpf: Add PTR_TO_SOCKET verifier type
      bpf: Macrofy stack state copy
      bpf: Add reference tracking to verifier
      bpf: Add helper to retrieve socket in BPF
      selftests/bpf: Generalize dummy program types
      selftests/bpf: Add tests for reference tracking
      libbpf: Support loading individual progs
      selftests/bpf: Add C tests for reference tracking
      Documentation: Describe bpf reference tracking
      net: core: Fix build with CONFIG_IPV6=m

Konrad Djimeli (1):
      bpf: typo fix in Documentation/networking/af_xdp.rst

Magnus Karlsson (3):
      net: add umem reference in netdev{_rx}_queue
      xsk: fix bug when trying to use both copy and zero-copy on one queue id
      xsk: simplify xdp_clear_umem_at_qid implementation

Quentin Monnet (12):
      bpf: add verifier callback to get stack usage info for offloaded progs
      nfp: bpf: rename nfp_prog->stack_depth as nfp_prog->stack_frame_depth
      nfp: bpf: copy eBPF subprograms information from kernel verifier
      nfp: bpf: ignore helper-related checks for BPF calls in nfp verifier
      nfp: bpf: account for BPF-to-BPF calls when preparing nfp JIT
      nfp: bpf: add main logics for BPF-to-BPF calls support in nfp driver
      nfp: bpf: account for additional stack usage when checking stack limit
      nfp: bpf: update fixup function for BPF-to-BPF calls support
      nfp: bpf: fix return address from register-saving subroutine to callee
      nfp: bpf: optimise save/restore for R6~R9 based on register usage
      nfp: bpf: support pointers to other stack frames for BPF-to-BPF calls
      bpf: allow offload of programs with BPF-to-BPF function calls

Roman Gushchin (10):
      bpf: extend cgroup bpf core to allow multiple cgroup storage types
      bpf: rework cgroup storage pointer passing
      bpf: introduce per-cpu cgroup local storage
      bpf: don't allow create maps of per-cpu cgroup local storages
      bpf: sync include/uapi/linux/bpf.h to tools/include/uapi/linux/bpf.h
      bpftool: add support for PERCPU_CGROUP_STORAGE maps
      selftests/bpf: add verifier per-cpu cgroup storage tests
      selftests/bpf: extend the storage test to test per-cpu cgroup storage
      samples/bpf: extend test_cgrp2_attach2 test to use per-cpu cgroup storage
      selftests/bpf: cgroup local storage-based network counters

Song Liu (1):
      bpf: test_bpf: add init_net to dev for flow_dissector

Yonghong Song (1):
      bpf: permit CGROUP_DEVICE programs accessing helper bpf_get_current_cgroup_id()

 Documentation/networking/af_xdp.rst                |    4 +-
 Documentation/networking/filter.txt                |   94 +-
 drivers/net/ethernet/netronome/nfp/bpf/cmsg.c      |   71 +-
 drivers/net/ethernet/netronome/nfp/bpf/fw.h        |   11 +-
 drivers/net/ethernet/netronome/nfp/bpf/jit.c       |  381 ++++++-
 drivers/net/ethernet/netronome/nfp/bpf/main.c      |   52 +-
 drivers/net/ethernet/netronome/nfp/bpf/main.h      |   63 +-
 drivers/net/ethernet/netronome/nfp/bpf/offload.c   |   11 +-
 drivers/net/ethernet/netronome/nfp/bpf/verifier.c  |  141 ++-
 drivers/net/ethernet/netronome/nfp/nfp_app.h       |    4 +
 drivers/net/ethernet/netronome/nfp/nfp_asm.h       |    9 +
 .../net/ethernet/netronome/nfp/nfp_net_common.c    |   14 +-
 drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h  |    1 -
 drivers/net/netdevsim/bpf.c                        |    8 +-
 include/linux/bpf-cgroup.h                         |   55 +-
 include/linux/bpf.h                                |   47 +-
 include/linux/bpf_types.h                          |    1 +
 include/linux/bpf_verifier.h                       |   38 +-
 include/linux/netdevice.h                          |    6 +
 include/net/xdp_sock.h                             |    7 +
 include/uapi/linux/bpf.h                           |   94 +-
 kernel/bpf/cgroup.c                                |   76 +-
 kernel/bpf/helpers.c                               |   25 +-
 kernel/bpf/local_storage.c                         |  169 +++-
 kernel/bpf/map_in_map.c                            |    3 +-
 kernel/bpf/offload.c                               |   18 +
 kernel/bpf/syscall.c                               |   20 +-
 kernel/bpf/verifier.c                              |  640 +++++++++---
 lib/test_bpf.c                                     |    1 +
 net/bpf/test_run.c                                 |   20 +-
 net/core/ethtool.c                                 |   23 +-
 net/core/filter.c                                  |  187 +++-
 net/xdp/xdp_umem.c                                 |   98 +-
 net/xdp/xdp_umem.h                                 |    2 +-
 net/xdp/xsk.c                                      |   20 +-
 samples/bpf/test_cgrp2_attach2.c                   |   19 +-
 samples/bpf/tracex3_user.c                         |    2 -
 tools/bpf/bpftool/map.c                            |    4 +-
 tools/bpf/bpftool/net.c                            |   41 +-
 tools/bpf/bpftool/netlink_dumper.c                 |   32 +-
 tools/bpf/bpftool/netlink_dumper.h                 |   18 +-
 tools/include/uapi/linux/bpf.h                     |   94 +-
 tools/lib/bpf/Makefile                             |    2 +-
 tools/lib/bpf/bpf.c                                |    2 +-
 tools/lib/bpf/bpf.h                                |    8 +-
 tools/lib/bpf/btf.c                                |    2 +-
 tools/lib/bpf/btf.h                                |    8 +-
 tools/lib/bpf/libbpf.c                             |  170 ++--
 tools/lib/bpf/libbpf.h                             |   49 +-
 tools/lib/bpf/libbpf_errno.c                       |   15 +-
 tools/lib/bpf/netlink.c                            |   50 +-
 tools/lib/bpf/nlattr.c                             |   71 +-
 tools/lib/bpf/nlattr.h                             |   72 +-
 tools/lib/bpf/str_error.c                          |    4 +-
 tools/lib/bpf/str_error.h                          |   10 +-
 tools/testing/selftests/bpf/Makefile               |    6 +-
 tools/testing/selftests/bpf/bpf_helpers.h          |   12 +
 tools/testing/selftests/bpf/netcnt_common.h        |   24 +
 tools/testing/selftests/bpf/netcnt_prog.c          |   71 ++
 tools/testing/selftests/bpf/test_cgroup_storage.c  |   60 +-
 tools/testing/selftests/bpf/test_netcnt.c          |  158 +++
 tools/testing/selftests/bpf/test_progs.c           |   38 +
 tools/testing/selftests/bpf/test_section_names.c   |  208 ++++
 tools/testing/selftests/bpf/test_sk_lookup_kern.c  |  180 ++++
 tools/testing/selftests/bpf/test_socket_cookie.c   |    6 +-
 tools/testing/selftests/bpf/test_verifier.c        | 1041 ++++++++++++++++++--
 66 files changed, 4184 insertions(+), 707 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/netcnt_common.h
 create mode 100644 tools/testing/selftests/bpf/netcnt_prog.c
 create mode 100644 tools/testing/selftests/bpf/test_netcnt.c
 create mode 100644 tools/testing/selftests/bpf/test_section_names.c
 create mode 100644 tools/testing/selftests/bpf/test_sk_lookup_kern.c

^ permalink raw reply

* Re: [RFC PATCH 01/11] phy: core add phy_set_netif_mode() api
From: Kishon Vijay Abraham I @ 2018-10-09  5:22 UTC (permalink / raw)
  To: Grygorii Strashko, David S. Miller, netdev, Tony Lindgren,
	Rob Herring
  Cc: Sekhar Nori, linux-kernel, linux-omap, devicetree
In-Reply-To: <20181008234949.15416-2-grygorii.strashko@ti.com>

Hi Grygorii,

On Tuesday 09 October 2018 05:19 AM, Grygorii Strashko wrote:
> Add new API phy_set_netif_mode(struct phy *phy, phy_interface_t mode) and
> new PHY operation callback .set_netif_mode() which intended to be implemnte
> by PHY drivers which supports Network interrfaces mode selection. Both
> accepts phy_interface_t vlaue as input parameter.
> 
> Cc: Kishon Vijay Abraham I <kishon@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> ---
>  drivers/phy/phy-core.c  | 15 +++++++++++++++
>  include/linux/phy/phy.h | 12 ++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 35fd38c..d9aba1a 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -377,6 +377,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode)
>  }
>  EXPORT_SYMBOL_GPL(phy_set_mode);
>  
> +int phy_set_netif_mode(struct phy *phy, phy_interface_t mode)
> +{
> +	int ret;
> +
> +	if (!phy || !phy->ops->set_netif_mode)
> +		return 0;
> +
> +	mutex_lock(&phy->mutex);
> +	ret = phy->ops->set_netif_mode(phy, mode);
> +	mutex_unlock(&phy->mutex);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(phy_set_netif_mode);

We should try to add only generic PHY APIs and not subsystem specific APIs. In
this case I think phy_set_mode should suffice.

Thanks
Kishon

> +
>  int phy_reset(struct phy *phy)
>  {
>  	int ret;
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index 9713aeb..bc73d2b 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -17,6 +17,7 @@
>  #include <linux/err.h>
>  #include <linux/of.h>
>  #include <linux/device.h>
> +#include <linux/phy.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/regulator/consumer.h>
>  
> @@ -49,6 +50,7 @@ enum phy_mode {
>   * @power_on: powering on the phy
>   * @power_off: powering off the phy
>   * @set_mode: set the mode of the phy
> + * @set_netif_mode: set the mode of the net interface phy
>   * @reset: resetting the phy
>   * @calibrate: calibrate the phy
>   * @owner: the module owner containing the ops
> @@ -59,6 +61,7 @@ struct phy_ops {
>  	int	(*power_on)(struct phy *phy);
>  	int	(*power_off)(struct phy *phy);
>  	int	(*set_mode)(struct phy *phy, enum phy_mode mode);
> +	int	(*set_netif_mode)(struct phy *phy, phy_interface_t mode);
>  	int	(*reset)(struct phy *phy);
>  	int	(*calibrate)(struct phy *phy);
>  	struct module *owner;
> @@ -163,6 +166,7 @@ int phy_exit(struct phy *phy);
>  int phy_power_on(struct phy *phy);
>  int phy_power_off(struct phy *phy);
>  int phy_set_mode(struct phy *phy, enum phy_mode mode);
> +int phy_set_netif_mode(struct phy *phy, phy_interface_t mode);
>  static inline enum phy_mode phy_get_mode(struct phy *phy)
>  {
>  	return phy->attrs.mode;
> @@ -283,6 +287,14 @@ static inline int phy_set_mode(struct phy *phy, enum phy_mode mode)
>  	return -ENOSYS;
>  }
>  
> +static inline int phy_set_netif_mode(struct phy *phy,
> +				     phy_interface_t mode)
> +{
> +	if (!phy)
> +		return 0;
> +	return -ENOTSUPP;
> +}
> +
>  static inline enum phy_mode phy_get_mode(struct phy *phy)
>  {
>  	return PHY_MODE_INVALID;
> 

^ permalink raw reply

* Re: [PATCH v2 ipsec] Clear secpath on loopback_xmit
From: Steffen Klassert @ 2018-10-09  5:12 UTC (permalink / raw)
  To: Benedict Wong; +Cc: netdev, nharold, lorenzo
In-Reply-To: <20181008181335.178295-1-benedictwong@google.com>

On Mon, Oct 08, 2018 at 11:13:36AM -0700, Benedict Wong wrote:
> This patch clears the skb->sp when transmitted over loopback. This
> ensures that the loopback-ed packet does not have any secpath
> information from the outbound transforms.
> 
> At present, this causes XFRM tunnel mode packets to be dropped with
> XFRMINNOPOLS, due to the outbound state being in the secpath, without
> a matching inbound policy. Clearing the secpath ensures that all states
> added to the secpath are exclusively from the inbound processing.
> 
> Tests: xfrm tunnel mode tests added for loopback:
>     https://android-review.googlesource.com/c/kernel/tests/+/777328
> Fixes: 8fe7ee2ba983 ("[IPsec]: Strengthen policy checks")

This patch is from 2003, it predates our git history.
The fixes tag is mainly to ensure proper backporting.
The commit you mentioned can't be found in the mainline
git repo, so it does not help much.

If this bug was really introduced in pre git times,
use the very first git commit in our history.

It should look like:

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

But I doubt that this commit introduced the bug. We started to
use outbound secpaths when we added offloading support, so I
think one of the offloading patches introduced it.

Do you have CONFIG_INET_ESP_OFFLOAD or CONFIG_INET6_ESP_OFFLOAD
enabled? Do you see the bug without these two config options
enabled?

> Signed-off-by: Benedict Wong <benedictwong@google.com>
> ---
>  drivers/net/loopback.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
> index 30612497643c..a6bf54df94bd 100644
> --- a/drivers/net/loopback.c
> +++ b/drivers/net/loopback.c
> @@ -50,6 +50,7 @@
>  #include <linux/ethtool.h>
>  #include <net/sock.h>
>  #include <net/checksum.h>
> +#include <net/xfrm.h>
>  #include <linux/if_ether.h>	/* For the statistics structure. */
>  #include <linux/if_arp.h>	/* For ARPHRD_ETHER */
>  #include <linux/ip.h>
> @@ -82,6 +83,9 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
>  	 */
>  	skb_dst_force(skb);
>  
> +	// Clear secpath to ensure xfrm policy check not tainted by outbound SAs.

Please align your comment to the format of the other comments in this file.
It should look like this:

	/* Clear secpath to ensure xfrm policy check not tainted by
	 * outbound SAs.
	 */

> +	secpath_reset(skb);
> +
>  	skb->protocol = eth_type_trans(skb, dev);
>  
>  	/* it's OK to use per_cpu_ptr() because BHs are off */
> -- 
> 2.19.0.605.g01d371f741-goog

^ permalink raw reply

* [PATCH net-next] tcp: forbid direct reclaim if MSG_DONTWAIT is set in send path
From: Yafang Shao @ 2018-10-09 12:05 UTC (permalink / raw)
  To: edumazet, davem; +Cc: netdev, linux-kernel, Yafang Shao
In-Reply-To: <1539086718-4119-1-git-send-email-laoar.shao@gmail.com>

By default, the sk->sk_allocation is GFP_KERNEL, that means if there's
no enough memory it will do both direct reclaim and background reclaim.
If the size of system memory is great, the direct reclaim may cause great
latency spike.

When we set MSG_DONTWAIT in send syscalls, we really don't want it to be
blocked, so we'd better clear __GFP_DIRECT_RECLAIM when allocate skb in the
send path. Then, it will return immediately if there's no enough memory to
be allocated, and then the appliation has a chance to do some other stuffs
instead of being blocked here.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 net/ipv4/tcp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 43ef83b..fe4f5ce 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1182,6 +1182,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
 	bool process_backlog = false;
 	bool zc = false;
 	long timeo;
+	gfp_t gfp;
 
 	flags = msg->msg_flags;
 
@@ -1255,6 +1256,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
 	/* Ok commence sending. */
 	copied = 0;
 
+	gfp = flags & MSG_DONTWAIT ? sk->sk_allocation & ~__GFP_DIRECT_RECLAIM :
+	      sk->sk_allocation;
+
 restart:
 	mss_now = tcp_send_mss(sk, &size_goal, flags);
 
@@ -1283,8 +1287,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
 			}
 			first_skb = tcp_rtx_and_write_queues_empty(sk);
 			linear = select_size(first_skb, zc);
-			skb = sk_stream_alloc_skb(sk, linear, sk->sk_allocation,
-						  first_skb);
+			skb = sk_stream_alloc_skb(sk, linear, gfp, first_skb);
 			if (!skb)
 				goto wait_for_memory;
 
-- 
1.8.3.1

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox