Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Mar 2024 11:34:23 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        Gleb Smirnoff <glebius@freebsd.org>, Konstantin Belousov <kib@freebsd.org>, src-committers@freebsd.org,  dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: 220ee18f1964 - main - netinet/tcp_var.h: always define IS_FASTOPEN() for kernel compilation env
Message-ID:  <CANCZdfp_f%2B1wA4FHEY_CL%2BPBcCcP2u2mezrgvno%2B=c%2B2DGJQcA@mail.gmail.com>
In-Reply-To: <56f538f1-d406-4095-972a-2022d48ffc73@FreeBSD.org>
References:  <202403132321.42DNLNIX087785@gitrepo.freebsd.org> <ZfJDsRPzASbZ_Cav@cell.glebi.us> <56f538f1-d406-4095-972a-2022d48ffc73@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Thu, Mar 14, 2024 at 11:23 AM John Baldwin <jhb@freebsd.org> wrote:

> On 3/13/24 5:24 PM, Gleb Smirnoff wrote:
> > On Wed, Mar 13, 2024 at 11:21:23PM +0000, Konstantin Belousov wrote:
> > K> diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
> > K> index 6f7f7115c2f4..7b5c57d39213 100644
> > K> --- a/sys/netinet/tcp_var.h
> > K> +++ b/sys/netinet/tcp_var.h
> > K> @@ -812,11 +812,13 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq
> ack)
> > K>  #define   ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY |
> TF_FASTRECOVERY)
> > K>  #define   EXIT_RECOVERY(t_flags) t_flags &= ~(TF_CONGRECOVERY |
> TF_FASTRECOVERY)
> > K>
> > K> -#if defined(_KERNEL) && !defined(TCP_RFC7413)
> > K> +#if defined(_KERNEL)
> > K> +#if !defined(TCP_RFC7413)
> > K>  #define   IS_FASTOPEN(t_flags)            (false)
> > K>  #else
> > K>  #define   IS_FASTOPEN(t_flags)            (t_flags & TF_FASTOPEN)
> > K>  #endif
> > K> +#endif
> > K>
> > K>  #define   BYTES_THIS_ACK(tp, th)  (th->th_ack - tp->snd_una)
> >
> > I know Konstantin in doing that to clear path for IPSEC changes, and the
> patch
> > does improve code.  So the message isn't addressed to him, rather it is
> for
> > other src-committers.
> >
> > Using ifdefs that come from the kernel config inside include files that
> are not
> > ephemeral opt_foo.h is laying out a minefield for the future. Best case
> - for
> > yourself, worst case - for somebody else.
>
> +100
>

+100 as well. I can't tell you how many times I've been burned by this, had
to mop
up for it after the fact, etc over the years.


> > In the best case this ends in cryptic kernel failure builds, where your
> custom
> > kernel doesn't build, but GENERIC builds and it is not clear why. In the
> worst
> > case this creates runtime failures even more cryptic in their nature.
> >
> > In this particular case TCP_RFC7413 comes via opt_inet.h.  Thus, if you
> got a
> > userland tool, e.g. netstat(1) using IS_FASTOPEN() it will always be
> false.
> > Again, netstat would be a best case.  A worst case would be netinet6
> kernel
> > compilation unit that does not include opt_inet.h, but uses
> IS_FASTOPEN().
> >
> > Other than that, we got 32 flags for t_flags and only one is obfuscated
> via a
> > macro.  I'd really like to remove the macro and test the flag directly.
> Any
> > objections?
>
> +1
>

Yea, this macro isn't that special, and  there's no good reason from
looking at
the code it should get such special treatment.

Warner

[-- Attachment #2 --]
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 14, 2024 at 11:23 AM John Baldwin &lt;<a href="mailto:jhb@freebsd.org">jhb@freebsd.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 3/13/24 5:24 PM, Gleb Smirnoff wrote:<br>
&gt; On Wed, Mar 13, 2024 at 11:21:23PM +0000, Konstantin Belousov wrote:<br>
&gt; K&gt; diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h<br>
&gt; K&gt; index 6f7f7115c2f4..7b5c57d39213 100644<br>
&gt; K&gt; --- a/sys/netinet/tcp_var.h<br>
&gt; K&gt; +++ b/sys/netinet/tcp_var.h<br>
&gt; K&gt; @@ -812,11 +812,13 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)<br>
&gt; K&gt;  #define   ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY | TF_FASTRECOVERY)<br>
&gt; K&gt;  #define   EXIT_RECOVERY(t_flags) t_flags &amp;= ~(TF_CONGRECOVERY | TF_FASTRECOVERY)<br>
&gt; K&gt;<br>
&gt; K&gt; -#if defined(_KERNEL) &amp;&amp; !defined(TCP_RFC7413)<br>
&gt; K&gt; +#if defined(_KERNEL)<br>
&gt; K&gt; +#if !defined(TCP_RFC7413)<br>
&gt; K&gt;  #define   IS_FASTOPEN(t_flags)            (false)<br>
&gt; K&gt;  #else<br>
&gt; K&gt;  #define   IS_FASTOPEN(t_flags)            (t_flags &amp; TF_FASTOPEN)<br>
&gt; K&gt;  #endif<br>
&gt; K&gt; +#endif<br>
&gt; K&gt;<br>
&gt; K&gt;  #define   BYTES_THIS_ACK(tp, th)  (th-&gt;th_ack - tp-&gt;snd_una)<br>
&gt; <br>
&gt; I know Konstantin in doing that to clear path for IPSEC changes, and the patch<br>
&gt; does improve code.  So the message isn&#39;t addressed to him, rather it is for<br>
&gt; other src-committers.<br>
&gt; <br>
&gt; Using ifdefs that come from the kernel config inside include files that are not<br>
&gt; ephemeral opt_foo.h is laying out a minefield for the future. Best case - for<br>
&gt; yourself, worst case - for somebody else.<br>
<br>
+100<br></blockquote><div><br></div><div>+100 as well. I can&#39;t tell you how many times I&#39;ve been burned by this, had to mop</div><div>up for it after the fact, etc over the years.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt; In the best case this ends in cryptic kernel failure builds, where your custom<br>
&gt; kernel doesn&#39;t build, but GENERIC builds and it is not clear why. In the worst<br>
&gt; case this creates runtime failures even more cryptic in their nature.<br>
&gt; <br>
&gt; In this particular case TCP_RFC7413 comes via opt_inet.h.  Thus, if you got a<br>
&gt; userland tool, e.g. netstat(1) using IS_FASTOPEN() it will always be false.<br>
&gt; Again, netstat would be a best case.  A worst case would be netinet6 kernel<br>
&gt; compilation unit that does not include opt_inet.h, but uses IS_FASTOPEN().<br>
&gt; <br>
&gt; Other than that, we got 32 flags for t_flags and only one is obfuscated via a<br>
&gt; macro.  I&#39;d really like to remove the macro and test the flag directly.  Any<br>
&gt; objections?<br>
<br>
+1<br></blockquote><div><br></div><div>Yea, this macro isn&#39;t that special, and  there&#39;s no good reason from looking at</div><div>the code it should get such special treatment.</div><div><br></div><div>Warner</div></div></div>
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfp_f%2B1wA4FHEY_CL%2BPBcCcP2u2mezrgvno%2B=c%2B2DGJQcA>