All of lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: "Iwashima, Kuniyuki" <kuniyu@amazon.co.jp>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"dsahern@kernel.org" <dsahern@kernel.org>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>, "leit@fb.com" <leit@fb.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>
Subject: Re: [PATCH RESEND net-next] tcp: socket-specific version of WARN_ON_ONCE()
Date: Wed, 30 Nov 2022 05:18:20 -0800	[thread overview]
Message-ID: <Y4dYHLMTtr+QqeLm@gmail.com> (raw)
In-Reply-To: <A5D7EBCF-CC49-4575-9DA7-0419BA1F0E9B@amazon.co.jp>

On Tue, Nov 29, 2022 at 09:16:16PM +0000, Iwashima, Kuniyuki wrote:
> > On Nov 29, 2022, at 21:48, Breno Leitao <leitao@debian.org> wrote:
> >> On Tue, Nov 29, 2022 at 10:00:55AM +0900, Kuniyuki Iwashima wrote:

<snip>

> >>> +void tcp_sock_warn(const struct tcp_sock *tp)
> >>> +{
> >>> +   const struct sock *sk = (const struct sock *)tp;
> >>> +   struct inet_sock *inet = inet_sk(sk);
> >>> +   struct inet_connection_sock *icsk = inet_csk(sk);
> >>> +
> >>> +   WARN_ON(1);
> >>> +
> >>> +   if (!tp)
> >> 
> >> Is this needed ?
> > 
> > We are de-referencing tp/sk in the lines below, so, I think it is safe to
> > check if they are not NULL before the de-refencing it.
> 
> tp->snd_cwnd is accessed just after this WARN, 
> so I thought there were no cases where tp is NULL.

Oh, important to say that we want to re-use this macro on other places
as well. This initial usage (on tcp_snd_cwnd_set()) is just for the
initial patch. I see value replacing some WARN_ON_*() by
TCP_SOCK_WARN_ON_ONCE() in other parts of the code, so, this check is to
protect this warning when TCP_SOCK_WARN_ON_ONCE() is called from
different places.

Anyway, I definitely can remove the check here, but, we might want to
re-add it later, as we replace some WARN_ON_* by TCP_SOCK_WARN_ON_*();

> I think this additional if could confuse future readers and 
> want to make sure if there is such a case.

How come checking if a pointer is valid before de-refencing it could
confuse readers?

Thank you for the review!

  reply	other threads:[~2022-11-30 13:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 11:22 [PATCH RESEND net-next] tcp: socket-specific version of WARN_ON_ONCE() Breno Leitao
2022-11-29  1:00 ` Kuniyuki Iwashima
2022-11-29 12:47   ` Breno Leitao
2022-11-29 21:16     ` Iwashima, Kuniyuki
2022-11-30 13:18       ` Breno Leitao [this message]
2022-11-29 10:18 ` Paolo Abeni
2022-11-30  2:28   ` Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2022-08-31 13:37 Breno Leitao
2022-09-03 16:42 ` Eric Dumazet
2022-09-05 13:44   ` Breno Leitao
2022-12-07 17:37   ` Breno Leitao
2022-12-07 17:59     ` Eric Dumazet
2022-12-08 15:44       ` Breno Leitao
2022-12-09  8:39         ` Eric Dumazet

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=Y4dYHLMTtr+QqeLm@gmail.com \
    --to=leitao@debian.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.co.jp \
    --cc=leit@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yoshfuji@linux-ipv6.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.