lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 15 May 2018 14:09:52 -0700
From:   Y Song <ys114321@...il.com>
To:     Daniel Borkmann <daniel@...earbox.net>
Cc:     John Fastabend <john.fastabend@...il.com>,
        Alexei Starovoitov <ast@...nel.org>,
        netdev <netdev@...r.kernel.org>,
        David Miller <davem@...emloft.net>
Subject: Re: [PATCH bpf-next v6 2/4] bpf: sockmap, add hash map support

On Tue, May 15, 2018 at 12:01 PM, Daniel Borkmann <daniel@...earbox.net> wrote:
> On 05/14/2018 07:00 PM, John Fastabend wrote:
>> Sockmap is currently backed by an array and enforces keys to be
>> four bytes. This works well for many use cases and was originally
>> modeled after devmap which also uses four bytes keys. However,
>> this has become limiting in larger use cases where a hash would
>> be more appropriate. For example users may want to use the 5-tuple
>> of the socket as the lookup key.
>>
>> To support this add hash support.
>>
>> Signed-off-by: John Fastabend <john.fastabend@...il.com>
>> Acked-by: David S. Miller <davem@...emloft.net>
>> ---
>>  include/linux/bpf.h       |   8 +
>>  include/linux/bpf_types.h |   1 +
>>  include/uapi/linux/bpf.h  |  52 ++++-
>>  kernel/bpf/core.c         |   1 +
>>  kernel/bpf/sockmap.c      | 494 ++++++++++++++++++++++++++++++++++++++++++++--
>>  kernel/bpf/verifier.c     |  14 +-
>>  net/core/filter.c         |  58 ++++++
>>  7 files changed, 610 insertions(+), 18 deletions(-)
>>
>> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
>> index a38e474..ed0122b 100644
>> --- a/include/linux/bpf.h
>> +++ b/include/linux/bpf.h
>> @@ -668,6 +668,7 @@ static inline void bpf_map_offload_map_free(struct bpf_map *map)
>>
>>  #if defined(CONFIG_STREAM_PARSER) && defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_INET)
>>  struct sock  *__sock_map_lookup_elem(struct bpf_map *map, u32 key);
>> +struct sock  *__sock_hash_lookup_elem(struct bpf_map *map, void *key);
>>  int sock_map_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type);
>>  #else
>>  static inline struct sock  *__sock_map_lookup_elem(struct bpf_map *map, u32 key)
>> @@ -675,6 +676,12 @@ static inline struct sock  *__sock_map_lookup_elem(struct bpf_map *map, u32 key)
>>       return NULL;
>>  }
>>
>> +static inline struct sock  *__sock_hash_lookup_elem(struct bpf_map *map,
>> +                                                 void *key)
>> +{
>> +     return NULL;
>> +}
>> +
>>  static inline int sock_map_prog(struct bpf_map *map,
>>                               struct bpf_prog *prog,
>>                               u32 type)
>> @@ -724,6 +731,7 @@ static inline void __xsk_map_flush(struct bpf_map *map)
>>  extern const struct bpf_func_proto bpf_get_stackid_proto;
>>  extern const struct bpf_func_proto bpf_get_stack_proto;
>>  extern const struct bpf_func_proto bpf_sock_map_update_proto;
>> +extern const struct bpf_func_proto bpf_sock_hash_update_proto;
>>
>>  /* Shared helpers among cBPF and eBPF. */
>>  void bpf_user_rnd_init_once(void);
>> diff --git a/include/linux/bpf_types.h b/include/linux/bpf_types.h
>> index d7df1b32..b67f879 100644
>> --- a/include/linux/bpf_types.h
>> +++ b/include/linux/bpf_types.h
>> @@ -47,6 +47,7 @@
>>  BPF_MAP_TYPE(BPF_MAP_TYPE_DEVMAP, dev_map_ops)
>>  #if defined(CONFIG_STREAM_PARSER) && defined(CONFIG_INET)
>>  BPF_MAP_TYPE(BPF_MAP_TYPE_SOCKMAP, sock_map_ops)
>> +BPF_MAP_TYPE(BPF_MAP_TYPE_SOCKHASH, sock_hash_ops)
>>  #endif
>>  BPF_MAP_TYPE(BPF_MAP_TYPE_CPUMAP, cpu_map_ops)
>>  #if defined(CONFIG_XDP_SOCKETS)
>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
>> index 02e4112..1205d86 100644
>> --- a/include/uapi/linux/bpf.h
>> +++ b/include/uapi/linux/bpf.h
>> @@ -118,6 +118,7 @@ enum bpf_map_type {
>>       BPF_MAP_TYPE_SOCKMAP,
>>       BPF_MAP_TYPE_CPUMAP,
>>       BPF_MAP_TYPE_XSKMAP,
>> +     BPF_MAP_TYPE_SOCKHASH,
>>  };
>>
>>  enum bpf_prog_type {
>> @@ -1855,6 +1856,52 @@ struct bpf_stack_build_id {
>>   *             Egress device index on success, 0 if packet needs to continue
>>   *             up the stack for further processing or a negative error in case
>>   *             of failure.
>> + * int bpf_sock_hash_update(struct bpf_sock_ops_kern *skops, struct bpf_map *map, void *key, u64 flags)
>
> When you rebase please fix this up properly next time and add a newline in between
> the helpers. I fixed this up while applying.

I guess the tools/include/uapi/linux/bpf.h may also need fixup to be
in sync with main bpf.h.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ