Re: [PATCH -next 2/5] bpf: Remove map_push_elem callbacks with -EOPNOTSUPP

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

 




On 2/17/2025 9:41 AM, Xiaomeng Zhang wrote:
> Remove redundant map_push_elem callbacks with return -EOPNOTSUPP. We can
> directly return -EOPNOTSUPP when calling the unimplemented callbacks.
>
>
>  BPF_CALL_3(bpf_map_push_elem, struct bpf_map *, map, void *, value, u64, flags)
>  {
> -	return map->ops->map_push_elem(map, value, flags);
> +	if (map->ops->map_push_elem)
> +		return map->ops->map_push_elem(map, value, flags);
> +	else
> +		return -EOPNOTSUPP;
>  }

Similar with the previous patch, the modifications in both
bpf_map_push_elem() and bpf_map_update_valu() are unnecessary.
>  
>  const struct bpf_func_proto bpf_map_push_elem_proto = {
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index e6e859f71c5d..79a118ea9270 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -281,7 +281,10 @@ static int bpf_map_update_value(struct bpf_map *map, struct file *map_file,
>  	} else if (map->map_type == BPF_MAP_TYPE_QUEUE ||
>  		   map->map_type == BPF_MAP_TYPE_STACK ||
>  		   map->map_type == BPF_MAP_TYPE_BLOOM_FILTER) {
> -		err = map->ops->map_push_elem(map, value, flags);
> +		if (map->ops->map_push_elem)
> +			err = map->ops->map_push_elem(map, value, flags);
> +		else
> +			err = -EOPNOTSUPP;
>  	} else {
>  		err = bpf_obj_pin_uptrs(map->record, value);
>  		if (!err) {





[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