Re: [PATCH bpf-next v2 4/4] selftest: bpf: Test copying a sockmap and sockhash

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

 



On Mon, Sep 28, 2020 at 10:08:05AM +0100, Lorenz Bauer wrote:

[ ... ]

>  SEC("iter/sockmap")
> -int count_elems(struct bpf_iter__sockmap *ctx)
> +int copy(struct bpf_iter__sockmap *ctx)
>  {
>  	struct sock *sk = ctx->sk;
>  	__u32 tmp, *key = ctx->key;
>  	int ret;
>  
> -	if (key)
> -		elems++;
> +	if (!key)
> +		return 0;
>  
> -	if (sk)
> +	elems++;
> +
> +	/* We need a temporary buffer on the stack, since the verifier doesn't
> +	 * let us use the pointer from the context as an argument to the helper.
Is it something that can be improved later?

others LGTM.



[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