[RFC PATCH bpf-next] bpf: POC on local_storage charge and uncharge map_ops

KP Singh kpsingh at chromium.org
Mon Jul 27 20:26:53 UTC 2020


Thanks for this, I was able to update the series with this patch and it works.
One minor comment though.

I was wondering how should I send it as a part of the series. I will keep the
original commit description + mention this thread and add your Co-Developed-by:
tag and then you can add your Signed-off-by: as well. I am not sure of the 
canonical way here and am open to suggestions :)

- KP

On 25.07.20 03:30, Martin KaFai Lau wrote:
> It is a direct replacement of the patch 3 in discussion [1]
> and to test out the idea on adding
> map_local_storage_charge, map_local_storage_uncharge,
> and map_owner_storage_ptr.
> 
> It is only compiler tested to demo the idea.
> 
> [1]: https://patchwork.ozlabs.org/project/netdev/patch/20200723115032.460770-4-kpsingh@chromium.org/
> 
> Signed-off-by: Martin KaFai Lau <kafai at fb.com>
> ---
>  include/linux/bpf.h            |  10 ++
>  include/net/bpf_sk_storage.h   |  51 +++++++
>  include/uapi/linux/bpf.h       |   8 +-

[...]

> +
> +static void sk_storage_uncharge(struct bpf_local_storage_map *smap,
> +				void *owner, u32 size)
> +{
> +	struct sock *sk = owner;
> +
> +	atomic_sub(size, &sk->sk_omem_alloc);
> +}
> +
> +static struct bpf_local_storage __rcu **
> +sk_storage_ptr(struct bpf_local_storage_map *smap, void *owner)

Do we need an smap pointer here? It's not being used and is also not
used for inode as well.

- KP

> +{
> +	struct sock *sk = owner;
> +
> +	return &sk->sk_bpf_storage;
> +}
> +

[...]

> -/* BPF_FUNC_sk_storage_get flags */
> +/* BPF_FUNC_<local>_storage_get flags */
>  enum {
> -	BPF_SK_STORAGE_GET_F_CREATE	= (1ULL << 0),
> +	BPF_LOCAL_STORAGE_GET_F_CREATE	= (1ULL << 0),
> +	/* BPF_SK_STORAGE_GET_F_CREATE is only kept for backward compatibility
> +	 * and BPF_LOCAL_STORAGE_GET_F_CREATE must be used instead.
> +	 */
> +	BPF_SK_STORAGE_GET_F_CREATE  = BPF_LOCAL_STORAGE_GET_F_CREATE,
>  };
>  
>  /* BPF_FUNC_read_branch_records flags. */
> 



More information about the Linux-security-module-archive mailing list