RE: [PATCH bpf-next 7/8] selftests/bpf: Check length of recv in test_sockmap

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

 



Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@xxxxxxxxxx>
> 
> The value of recv in msg_loop may be negative, like EWOULDBLOCK, so it's
> necessary to check if it is positive before accumulating it to bytes_recvd.
> 
> Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
> Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
> ---
>  tools/testing/selftests/bpf/test_sockmap.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
> index 3654babfac59..4c7cb206b31d 100644
> --- a/tools/testing/selftests/bpf/test_sockmap.c
> +++ b/tools/testing/selftests/bpf/test_sockmap.c
> @@ -681,7 +681,8 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
>  				}
>  			}
>  
> -			s->bytes_recvd += recv;
> +			if (recv > 0)
> +				s->bytes_recvd += recv;
>  
>  			if (opt->check_recved_len && s->bytes_recvd > total_bytes) {
>  				errno = EMSGSIZE;
> -- 
> 2.43.0
> 

Acked-by: John Fastabend <john.fastabend@xxxxxxxxx>




[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