1. 24 Apr, 2018 9 commits
    • John Fastabend's avatar
      bpf: sockmap, code sockmap_test in C · 15f66a91
      John Fastabend authored
      By moving sockmap_test from shell script into C we can run it directly
      from selftests, but we can also push the input/output around in proper
      structures.
      
      However, keep the CLI options around because they are useful for
      debugging when a paticular pattern of msghdr or sockmap options
      trips up the sockmap code path.
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      15f66a91
    • Yonghong Song's avatar
      tools/bpf: remove test_sock_addr from TEST_GEN_PROGS · 6595c742
      Yonghong Song authored
      Since test_sock_addr is not supposed to run by itself,
      remove it from TEST_GEN_PROGS and add it to
      TEST_GEN_PROGS_EXTENDED. This way, run_tests will
      not run test_sock_addr. The corresponding test to run
      is test_sock_addr.sh.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      6595c742
    • Anders Roxell's avatar
      selftests: bpf: update .gitignore with missing file · b6fd9cf7
      Anders Roxell authored
      Fixes: c0fa1b6c ("bpf: btf: Add BTF tests")
      Signed-off-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      b6fd9cf7
    • Daniel Borkmann's avatar
      Merge branch 'bpf-map-val-as-key' · 68db35b1
      Daniel Borkmann authored
      Paul Chaignon says:
      
      ====================
      Currently, helpers that expect ARG_PTR_TO_MAP_KEY and ARG_PTR_TO_MAP_VALUE
      can only access stack and packet memory.  This patchset allows these
      helpers to directly access map values by passing registers of type
      PTR_TO_MAP_VALUE.
      
      The first patch changes the verifier; the second adds new test cases.
      
      The first three versions of this patchset were sent on the iovisor-dev
      mailing list only.
      
      Changelogs:
        Changes in v5:
          - Refactor using check_helper_mem_access.
        Changes in v4:
          - Rebase.
        Changes in v3:
          - Bug fixes.
          - Negative test cases.
        Changes in v2:
          - Additional test cases for adjusted maps.
      ====================
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      68db35b1
    • Paul Chaignon's avatar
      tools/bpf: add verifier tests for accesses to map values · 5f90dd6a
      Paul Chaignon authored
      This patch adds new test cases for accesses to map values from map
      helpers.
      Signed-off-by: default avatarPaul Chaignon <paul.chaignon@orange.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      5f90dd6a
    • Paul Chaignon's avatar
      bpf: allow map helpers access to map values directly · d71962f3
      Paul Chaignon authored
      Helpers that expect ARG_PTR_TO_MAP_KEY and ARG_PTR_TO_MAP_VALUE can only
      access stack and packet memory.  Allow these helpers to directly access
      map values by passing registers of type PTR_TO_MAP_VALUE.
      
      This change removes the need for an extra copy to the stack when using a
      map value to perform a second map lookup, as in the following:
      
      struct bpf_map_def SEC("maps") infobyreq = {
          .type = BPF_MAP_TYPE_HASHMAP,
          .key_size = sizeof(struct request *),
          .value_size = sizeof(struct info_t),
          .max_entries = 1024,
      };
      struct bpf_map_def SEC("maps") counts = {
          .type = BPF_MAP_TYPE_HASHMAP,
          .key_size = sizeof(struct info_t),
          .value_size = sizeof(u64),
          .max_entries = 1024,
      };
      SEC("kprobe/blk_account_io_start")
      int bpf_blk_account_io_start(struct pt_regs *ctx)
      {
          struct info_t *info = bpf_map_lookup_elem(&infobyreq, &ctx->di);
          u64 *count = bpf_map_lookup_elem(&counts, info);
          (*count)++;
      }
      Signed-off-by: default avatarPaul Chaignon <paul.chaignon@orange.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      d71962f3
    • Daniel Borkmann's avatar
      Merge branch 'bpf-xfrm-states' · 0e25d14e
      Daniel Borkmann authored
      Eyal Birger says:
      
      ====================
      This patchset adds support for fetching XFRM state information from
      an eBPF program called from TC.
      
      The first patch introduces a helper for fetching an XFRM state from the
      skb's secpath. The XFRM state is modeled using a new virtual struct which
      contains the SPI, peer address, and reqid values of the state; This struct
      can be extended in the future to provide additional state information.
      
      The second patch adds a test example in test_tunnel_bpf.sh. The sample
      validates the correct extraction of state information by the eBPF program.
      
      v3:
        - Kept SPI and peer IPv4 address in state in network byte order
          following suggestion from Alexei Starovoitov
      v2:
        - Fixed two comments by Daniel Borkmann:
          - disallow reserved flags in helper call
          - avoid compiling in helper code when CONFIG_XFRM is off
      ====================
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      0e25d14e
    • Eyal Birger's avatar
      samples/bpf: extend test_tunnel_bpf.sh with xfrm state test · 29a36f9e
      Eyal Birger authored
      Add a test for fetching xfrm state parameters from a tc program running
      on ingress.
      Signed-off-by: default avatarEyal Birger <eyal.birger@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      29a36f9e
    • Eyal Birger's avatar
      bpf: add helper for getting xfrm states · 12bed760
      Eyal Birger authored
      This commit introduces a helper which allows fetching xfrm state
      parameters by eBPF programs attached to TC.
      
      Prototype:
      bpf_skb_get_xfrm_state(skb, index, xfrm_state, size, flags)
      
      skb: pointer to skb
      index: the index in the skb xfrm_state secpath array
      xfrm_state: pointer to 'struct bpf_xfrm_state'
      size: size of 'struct bpf_xfrm_state'
      flags: reserved for future extensions
      
      The helper returns 0 on success. Non zero if no xfrm state at the index
      is found - or non exists at all.
      
      struct bpf_xfrm_state currently includes the SPI, peer IPv4/IPv6
      address and the reqid; it can be further extended by adding elements to
      its end - indicating the populated fields by the 'size' argument -
      keeping backwards compatibility.
      
      Typical usage:
      
      struct bpf_xfrm_state x = {};
      bpf_skb_get_xfrm_state(skb, 0, &x, sizeof(x), 0);
      ...
      Signed-off-by: default avatarEyal Birger <eyal.birger@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      12bed760
  2. 23 Apr, 2018 3 commits
  3. 21 Apr, 2018 10 commits
  4. 20 Apr, 2018 18 commits