From: Stanislav Fomichev <stfomichev@gmail.com>
To: Mina Almasry <almasrymina@google.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Neal Cardwell <ncardwell@google.com>,
Kuniyuki Iwashima <kuniyu@amazon.com>,
David Ahern <dsahern@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Shuah Khan <shuah@kernel.org>,
sdf@fomichev.me, ap420073@gmail.com, praan@google.com,
shivajikant@google.com
Subject: Re: [PATCH net-next v1 3/9] net: devmem: preserve sockc_err
Date: Mon, 19 May 2025 08:21:36 -0700 [thread overview]
Message-ID: <aCtMgDGQBbs0KkxZ@mini-arch> (raw)
In-Reply-To: <20250519023517.4062941-4-almasrymina@google.com>
On 05/19, Mina Almasry wrote:
> Preserve the error code returned by sock_cmsg_send and return that on
> err.
>
> Signed-off-by: Mina Almasry <almasrymina@google.com>
> ---
> net/ipv4/tcp.c | 24 ++++++++++--------------
> 1 file changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index b7b6ab41b496..45abe5772157 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1067,7 +1067,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> int flags, err, copied = 0;
> int mss_now = 0, size_goal, copied_syn = 0;
> int process_backlog = 0;
> - bool sockc_valid = true;
> + int sockc_err = 0;
> int zc = 0;
> long timeo;
>
> @@ -1075,13 +1075,10 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
>
> sockc = (struct sockcm_cookie){ .tsflags = READ_ONCE(sk->sk_tsflags) };
> if (msg->msg_controllen) {
> - err = sock_cmsg_send(sk, msg, &sockc);
> - if (unlikely(err))
> - /* Don't return error until MSG_FASTOPEN has been
> - * processed; that may succeed even if the cmsg is
> - * invalid.
> - */
> - sockc_valid = false;
> + sockc_err = sock_cmsg_send(sk, msg, &sockc);
> + /* Don't return error until MSG_FASTOPEN has been processed;
> + * that may succeed even if the cmsg is invalid.
> + */
> }
>
> if ((flags & MSG_ZEROCOPY) && size) {
> @@ -1092,7 +1089,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> } else if (sock_flag(sk, SOCK_ZEROCOPY)) {
> skb = tcp_write_queue_tail(sk);
> uarg = msg_zerocopy_realloc(sk, size, skb_zcopy(skb),
> - sockc_valid && !!sockc.dmabuf_id);
> + !sockc_err && !!sockc.dmabuf_id);
Why have these extra !! here? Other places below simply do '&& sockc.dmabuf_id',
why not the same here?
> if (!uarg) {
> err = -ENOBUFS;
> goto out_err;
> @@ -1102,7 +1099,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> else
> uarg_to_msgzc(uarg)->zerocopy = 0;
>
> - if (sockc_valid && sockc.dmabuf_id) {
> + if (!sockc_err && sockc.dmabuf_id) {
> binding = net_devmem_get_binding(sk, sockc.dmabuf_id);
> if (IS_ERR(binding)) {
> err = PTR_ERR(binding);
> @@ -1116,7 +1113,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> zc = MSG_SPLICE_PAGES;
> }
>
> - if (sockc_valid && sockc.dmabuf_id &&
> + if (!sockc_err && sockc.dmabuf_id &&
> (!(flags & MSG_ZEROCOPY) || !sock_flag(sk, SOCK_ZEROCOPY))) {
> err = -EINVAL;
> goto out_err;
> @@ -1160,9 +1157,8 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> /* 'common' sending to sendq */
> }
>
> - if (!sockc_valid) {
> - if (!err)
> - err = -EINVAL;
> + if (!!sockc_err) {
Same here, I don't think we need these extra !! ?
next prev parent reply other threads:[~2025-05-19 15:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-19 2:35 [PATCH net-next v1 0/9] Devmem TCP minor cleanups and ksft improvements Mina Almasry
2025-05-19 2:35 ` [PATCH net-next v1 1/9] net: devmem: move list_add to net_devmem_bind_dmabuf Mina Almasry
2025-05-19 6:45 ` Taehee Yoo
2025-05-19 2:35 ` [PATCH net-next v1 2/9] page_pool: fix ugly page_pool formatting Mina Almasry
2025-05-19 2:35 ` [PATCH net-next v1 3/9] net: devmem: preserve sockc_err Mina Almasry
2025-05-19 15:21 ` Stanislav Fomichev [this message]
2025-05-19 2:35 ` [PATCH net-next v1 4/9] net: devmem: ksft: remove ksft_disruptive Mina Almasry
2025-05-19 15:25 ` Stanislav Fomichev
2025-05-19 17:30 ` Mina Almasry
2025-05-19 20:18 ` Stanislav Fomichev
2025-05-19 23:41 ` Jakub Kicinski
2025-05-19 2:35 ` [PATCH net-next v1 5/9] net: devmem: ksft: add ipv4 support Mina Almasry
2025-05-19 15:32 ` Stanislav Fomichev
2025-05-19 17:31 ` Mina Almasry
2025-05-19 20:26 ` Stanislav Fomichev
2025-05-19 23:48 ` Jakub Kicinski
2025-05-19 2:35 ` [PATCH net-next v1 6/9] net: devmem: ksft: add exit_wait to make rx test pass Mina Almasry
2025-05-19 15:32 ` Stanislav Fomichev
2025-05-19 2:35 ` [PATCH net-next v1 7/9] net: devmem: ksft: add 5 tuple FS support Mina Almasry
2025-05-19 15:37 ` Stanislav Fomichev
2025-05-19 17:32 ` Mina Almasry
2025-05-19 20:26 ` Stanislav Fomichev
2025-05-19 2:35 ` [PATCH net-next v1 8/9] net: devmem: ksft: upgrade rx test to send 1K data Mina Almasry
2025-05-19 15:37 ` Stanislav Fomichev
2025-05-19 2:35 ` [PATCH net-next v1 9/9] net: devmem: ncdevmem: remove unused variable Mina Almasry
2025-05-19 15:37 ` Stanislav Fomichev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aCtMgDGQBbs0KkxZ@mini-arch \
--to=stfomichev@gmail.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=praan@google.com \
--cc=sdf@fomichev.me \
--cc=shivajikant@google.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.