Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sockmap iterator #17

Closed
wants to merge 4 commits into from
Closed

Sockmap iterator #17

wants to merge 4 commits into from

Commits on Sep 9, 2020

  1. adding ci files

    kernel-patches-bot committed Sep 9, 2020
    Configuration menu
    Copy the full SHA
    fef5317 View commit details
    Browse the repository at this point in the history
  2. The lookup paths for sockmap and sockhash currently include a check

    that returns NULL if the socket we just found is not a full socket.
    However, this check is not necessary. On insertion we ensure that
    we have a full socket (caveat around sock_ops), so request sockets
    are not a problem. Time-wait sockets are allocated separate from
    the original socket and then fed into the hashdance. They don't
    affect the sockets already stored in the sockmap.
    
    Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
    Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
    ---
     net/core/sock_map.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    lmb authored and kernel-patches-bot committed Sep 9, 2020
    Configuration menu
    Copy the full SHA
    705843c View commit details
    Browse the repository at this point in the history
  3. Add bpf_iter support for sockmap / sockhash, based on the bpf_sk_stor…

    …age and
    
    hashtable implementation. sockmap and sockhash share the same iteration
    context: a pointer to an arbitrary key and a pointer to a socket. Both
    pointers may be NULL, and so BPF has to perform a NULL check before accessing
    them. Technically it's not possible for sockhash iteration to yield a NULL
    socket, but we ignore this to be able to use a single iteration point.
    
    Iteration will visit all keys that remain unmodified during the lifetime of
    the iterator. It may or may not visit newly added ones.
    
    Switch from using rcu_dereference_raw to plain rcu_dereference, so we gain
    another guard rail if CONFIG_PROVE_RCU is enabled.
    
    Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
    ---
     net/core/sock_map.c | 280 +++++++++++++++++++++++++++++++++++++++++++-
     1 file changed, 278 insertions(+), 2 deletions(-)
    lmb authored and kernel-patches-bot committed Sep 9, 2020
    Configuration menu
    Copy the full SHA
    31a304c View commit details
    Browse the repository at this point in the history
  4. Add a test that exercises a basic sockmap / sockhash iteration. For

    now we simply count the number of elements seen. Once sockmap update
    from iterators works we can extend this to perform a full copy.
    
    Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
    ---
     .../selftests/bpf/prog_tests/sockmap_basic.c  | 89 +++++++++++++++++++
     tools/testing/selftests/bpf/progs/bpf_iter.h  |  9 ++
     .../selftests/bpf/progs/bpf_iter_sockmap.c    | 43 +++++++++
     .../selftests/bpf/progs/bpf_iter_sockmap.h    |  3 +
     4 files changed, 144 insertions(+)
     create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_sockmap.c
     create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_sockmap.h
    lmb authored and kernel-patches-bot committed Sep 9, 2020
    Configuration menu
    Copy the full SHA
    2fe0619 View commit details
    Browse the repository at this point in the history