Re: [PATCH bpf-next v4 2/5] bpf: Use cgroup_{common,current}_func_proto in more hooks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 22, 2022 at 12:45:10PM -0700, Stanislav Fomichev wrote:
> +const struct bpf_func_proto bpf_get_cgroup_classid_curr_proto __weak;
There is a 'ifdef CONFIG_CGROUP_NET_CLASSID' before using this proto.
This should be not needed also.  Please check.

However, a declaration is probably needed in include/linux/bpf.h.

>  const struct bpf_func_proto bpf_get_current_cgroup_id_proto __weak;
> +const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto __weak;
This one should be unnecessary also.

Others lgtm.

Acked-by: Martin KaFai Lau <kafai@xxxxxx>

>  
>  /* Common helpers for cgroup hooks with valid process context. */
>  const struct bpf_func_proto *
> @@ -2496,8 +2524,18 @@ cgroup_current_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
>  	switch (func_id) {
>  	case BPF_FUNC_get_current_uid_gid:
>  		return &bpf_get_current_uid_gid_proto;
> +	case BPF_FUNC_get_current_pid_tgid:
> +		return &bpf_get_current_pid_tgid_proto;
> +	case BPF_FUNC_get_current_comm:
> +		return &bpf_get_current_comm_proto;
>  	case BPF_FUNC_get_current_cgroup_id:
>  		return &bpf_get_current_cgroup_id_proto;
> +	case BPF_FUNC_get_current_ancestor_cgroup_id:
> +		return &bpf_get_current_ancestor_cgroup_id_proto;
> +#ifdef CONFIG_CGROUP_NET_CLASSID
> +	case BPF_FUNC_get_cgroup_classid:
> +		return &bpf_get_cgroup_classid_curr_proto;
> +#endif
>  	default:
>  		return NULL;
>  	}
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 1acfaffeaf32..63e25d8ce501 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -3009,7 +3009,7 @@ BPF_CALL_0(bpf_get_cgroup_classid_curr)
>  	return __task_get_classid(current);
>  }
>  
> -static const struct bpf_func_proto bpf_get_cgroup_classid_curr_proto = {
> +const struct bpf_func_proto bpf_get_cgroup_classid_curr_proto = {
>  	.func		= bpf_get_cgroup_classid_curr,
>  	.gpl_only	= false,
>  	.ret_type	= RET_INTEGER,



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux