Re: [PATCH bpf-next v9 16/23] bpf: Introduce single ownership BPF linked list API

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

 



On Fri, Nov 18, 2022 at 04:25:03AM +0530, Kumar Kartikeya Dwivedi wrote:
> +
> +	if (reg->type == PTR_TO_MAP_VALUE) {
> +		rec = reg->map_ptr->record;
> +	} else /* PTR_TO_BTF_ID | MEM_ALLOC */ {
> +		struct btf_struct_meta *meta;
> +
> +		meta = btf_find_struct_meta(reg->btf, reg->btf_id);
> +		if (!meta) {
> +			verbose(env, "bpf_list_head not found for allocated object\n");
> +			return -EINVAL;
> +		}
> +		rec = meta->record;
> +	}
> +
...
> +static int process_kf_arg_ptr_to_list_node(struct bpf_verifier_env *env,
> +					   struct bpf_reg_state *reg, u32 regno,
> +					   struct bpf_kfunc_call_arg_meta *meta)
> +{
...
> +
> +	struct_meta = btf_find_struct_meta(reg->btf, reg->btf_id);
> +	if (!struct_meta) {
> +		verbose(env, "bpf_list_node not found for allocated object\n");
> +		return -EINVAL;
> +	}
> +	rec = struct_meta->record;

and counting process_spin_lock() there are 3 cases of very similar code.
Could you combine it into a helper?



[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