From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Fastabend Subject: [bpf-next PATCH v2 0/3] Hash support for sock Date: Fri, 27 Apr 2018 16:24:27 -0700 Message-ID: <20180427232047.9985.3540.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: ast@kernel.org, daniel@iogearbox.net Return-path: Received: from [184.63.162.180] ([184.63.162.180]:34730 "EHLO john-Precision-Tower-5810" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S933033AbeD0XYb (ORCPT ); Fri, 27 Apr 2018 19:24:31 -0400 Sender: netdev-owner@vger.kernel.org List-ID: In the original sockmap implementation we got away with using an array similar to devmap. However, unlike devmap where an ifindex has a nice 1:1 function into the map we have found some use cases with sockets that need to be referenced using longer keys. This series adds support for a sockhash map reusing as much of the sockmap code as possible. I made the decision to add sockhash specific helpers vs trying to generalize the existing helpers because (a) they have sockmap in the name and (b) the keys are different types. I prefer to be explicit here rather than play type games or do something else tricky. To test this we duplicate all the sockmap testing except swap out the sockmap with a sockhash. v2: fix file stats and add v2 tag --- John Fastabend (3): bpf: sockmap, refactor sockmap routines to work with hashmap bpf: sockmap, add hash map support bpf: selftest additions for SOCKHASH include/linux/bpf.h | 8 include/linux/bpf_types.h | 1 include/linux/filter.h | 3 include/net/tcp.h | 3 include/uapi/linux/bpf.h | 6 kernel/bpf/core.c | 1 kernel/bpf/sockmap.c | 638 +++++++++++++++++++--- kernel/bpf/verifier.c | 14 net/core/filter.c | 89 ++- tools/bpf/bpftool/map.c | 1 tools/include/uapi/linux/bpf.h | 6 tools/testing/selftests/bpf/Makefile | 3 tools/testing/selftests/bpf/test_sockhash_kern.c | 4 tools/testing/selftests/bpf/test_sockmap.c | 27 + tools/testing/selftests/bpf/test_sockmap_kern.c | 340 ------------ tools/testing/selftests/bpf/test_sockmap_kern.h | 340 ++++++++++++ 16 files changed, 1034 insertions(+), 450 deletions(-) create mode 100644 tools/testing/selftests/bpf/test_sockhash_kern.c create mode 100644 tools/testing/selftests/bpf/test_sockmap_kern.h