[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e5a1261d-0366-4459-b78c-86557d6e1834@linux.dev>
Date: Tue, 2 Apr 2024 15:33:18 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Jordan Rife <jrife@...gle.com>
Cc: linux-kselftest@...r.kernel.org, netdev@...r.kernel.org,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman <eddyz87@...il.com>,
Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Mykola Lysenko <mykolal@...com>,
Shuah Khan <shuah@...nel.org>, "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Jesper Dangaard Brouer <hawk@...nel.org>,
Daan De Meyer <daan.j.demeyer@...il.com>, bpf@...r.kernel.org
Subject: Re: [PATCH v1 bpf-next 4/8] selftests/bpf: Add recv_msg_from_client
to network helpers
On 3/29/24 12:18 PM, Jordan Rife wrote:
> +int recvmsg_from_client(int sockfd, struct sockaddr_storage *src_addr)
> +{
> + struct timeval tv;
> + struct msghdr hdr;
> + struct iovec iov;
> + char data[64];
> + fd_set rfds;
> +
> + FD_ZERO(&rfds);
> + FD_SET(sockfd, &rfds);
> +
> + tv.tv_sec = 2;
> + tv.tv_usec = 0;
> +
> + if (select(sockfd + 1, &rfds, NULL, NULL, &tv) <= 0 ||
The socket fd created by the helpers in network_helpers.c should be a blocking
socket and has a 3s default delay. select should not be needed. Try to stay with
the default. If the default turned out to be too flaky in the bpf CI in the
future, one default change is easier.
> + !FD_ISSET(sockfd, &rfds))
> + return -1;
> +
> + memset(&iov, 0, sizeof(iov));
> + iov.iov_base = data;
> + iov.iov_len = sizeof(data);
> +
> + memset(&hdr, 0, sizeof(hdr));
> + hdr.msg_name = src_addr;
> + hdr.msg_namelen = sizeof(struct sockaddr_storage);
> + hdr.msg_iov = &iov;
> + hdr.msg_iovlen = 1;
> +
> + return recvmsg(sockfd, &hdr, 0);
> +}
Powered by blists - more mailing lists