bpf: sockmap, add hash map support
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@gmail.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:

کامیت شده توسط
Daniel Borkmann

والد
e5cd3abcb3
کامیت
8111038444
@@ -2093,6 +2093,13 @@ static int check_map_func_compatibility(struct bpf_verifier_env *env,
|
||||
func_id != BPF_FUNC_msg_redirect_map)
|
||||
goto error;
|
||||
break;
|
||||
case BPF_MAP_TYPE_SOCKHASH:
|
||||
if (func_id != BPF_FUNC_sk_redirect_hash &&
|
||||
func_id != BPF_FUNC_sock_hash_update &&
|
||||
func_id != BPF_FUNC_map_delete_elem &&
|
||||
func_id != BPF_FUNC_msg_redirect_hash)
|
||||
goto error;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2130,11 +2137,14 @@ static int check_map_func_compatibility(struct bpf_verifier_env *env,
|
||||
break;
|
||||
case BPF_FUNC_sk_redirect_map:
|
||||
case BPF_FUNC_msg_redirect_map:
|
||||
case BPF_FUNC_sock_map_update:
|
||||
if (map->map_type != BPF_MAP_TYPE_SOCKMAP)
|
||||
goto error;
|
||||
break;
|
||||
case BPF_FUNC_sock_map_update:
|
||||
if (map->map_type != BPF_MAP_TYPE_SOCKMAP)
|
||||
case BPF_FUNC_sk_redirect_hash:
|
||||
case BPF_FUNC_msg_redirect_hash:
|
||||
case BPF_FUNC_sock_hash_update:
|
||||
if (map->map_type != BPF_MAP_TYPE_SOCKHASH)
|
||||
goto error;
|
||||
break;
|
||||
default:
|
||||
|
مرجع در شماره جدید
Block a user