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 Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux