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>
next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000040c370613a24e5b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 14, 2024 at 11:23=E2=80=AFAM John Baldwin <jhb@freebsd.org> wro= te: > 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 |=3D (TF_CONGRECOVERY | > TF_FASTRECOVERY) > > K> #define EXIT_RECOVERY(t_flags) t_flags &=3D ~(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 th= e > 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 th= e > 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 --000000000000040c370613a24e5b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">= <div dir=3D"ltr" class=3D"gmail_attr">On Thu, Mar 14, 2024 at 11:23=E2=80= =AFAM John Baldwin <<a href=3D"mailto:jhb@freebsd.org">jhb@freebsd.org</= a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0p= x 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> > On Wed, Mar 13, 2024 at 11:21:23PM +0000, Konstantin Belousov wrote:<b= r> > K> diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h<br> > K> index 6f7f7115c2f4..7b5c57d39213 100644<br> > K> --- a/sys/netinet/tcp_var.h<br> > K> +++ b/sys/netinet/tcp_var.h<br> > K> @@ -812,11 +812,13 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp= _seq ack)<br> > K>=C2=A0 #define=C2=A0 =C2=A0ENTER_RECOVERY(t_flags) t_flags |=3D (= TF_CONGRECOVERY | TF_FASTRECOVERY)<br> > K>=C2=A0 #define=C2=A0 =C2=A0EXIT_RECOVERY(t_flags) t_flags &= =3D ~(TF_CONGRECOVERY | TF_FASTRECOVERY)<br> > K><br> > K> -#if defined(_KERNEL) && !defined(TCP_RFC7413)<br> > K> +#if defined(_KERNEL)<br> > K> +#if !defined(TCP_RFC7413)<br> > K>=C2=A0 #define=C2=A0 =C2=A0IS_FASTOPEN(t_flags)=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (false)<br> > K>=C2=A0 #else<br> > K>=C2=A0 #define=C2=A0 =C2=A0IS_FASTOPEN(t_flags)=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (t_flags & TF_FASTOPEN)<br> > K>=C2=A0 #endif<br> > K> +#endif<br> > K><br> > K>=C2=A0 #define=C2=A0 =C2=A0BYTES_THIS_ACK(tp, th)=C2=A0 (th->t= h_ack - tp->snd_una)<br> > <br> > I know Konstantin in doing that to clear path for IPSEC changes, and t= he patch<br> > does improve code.=C2=A0 So the message isn't addressed to him, ra= ther it is for<br> > other src-committers.<br> > <br> > Using ifdefs that come from the kernel config inside include files tha= t are not<br> > ephemeral opt_foo.h is laying out a minefield for the future. Best cas= e - for<br> > yourself, worst case - for somebody else.<br> <br> +100<br></blockquote><div><br></div><div>+100 as well. I can't tell you= how many times I've been burned by this, had to mop</div><div>up for i= t after the fact, etc over the years.</div><div>=C2=A0</div><blockquote cla= ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid = rgb(204,204,204);padding-left:1ex"> > In the best case this ends in cryptic kernel failure builds, where you= r custom<br> > kernel doesn't build, but GENERIC builds and it is not clear why. = In the worst<br> > case this creates runtime failures even more cryptic in their nature.<= br> > <br> > In this particular case TCP_RFC7413 comes via opt_inet.h.=C2=A0 Thus, = if you got a<br> > userland tool, e.g. netstat(1) using IS_FASTOPEN() it will always be f= alse.<br> > Again, netstat would be a best case.=C2=A0 A worst case would be netin= et6 kernel<br> > compilation unit that does not include opt_inet.h, but uses IS_FASTOPE= N().<br> > <br> > Other than that, we got 32 flags for t_flags and only one is obfuscate= d via a<br> > macro.=C2=A0 I'd really like to remove the macro and test the flag= directly.=C2=A0 Any<br> > objections?<br> <br> +1<br></blockquote><div><br></div><div>Yea, this macro isn't that speci= al, and=C2=A0 there'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> --000000000000040c370613a24e5b--
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>