From nobody Thu Mar 14 17:34:23 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TwZJF5QGsz5DSt7 for ; Thu, 14 Mar 2024 17:34:37 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TwZJF3ZTkz4FWW for ; Thu, 14 Mar 2024 17:34:37 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a46692ec303so169429766b.1 for ; Thu, 14 Mar 2024 10:34:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1710437675; x=1711042475; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0xsFrvZFnflqLs9vZ2LdnHyafdvJwRt3mY3Az5BshKg=; b=kaVEwtj4yFYq6lIsua2B47pABIXQeU1BLd5h73zUFDKMN2KIJPZ1LZFqzncyKPi1zA fXJ4Ap4C7mV7Ax8wLakQk7L4WZEOZ3SNyH6gm48MUGRAT0UgzQlEo+xED513vJOFZWeJ 5+inQp6Km4MVVL3UmIPt6+SxorMG5u0ljVkOsuq0ZGUG9kMFeglXs52XYy1m4l/nIh8Q Av7bUToYZhMfJ0sGo2roku4//SSVWHxu42RrHP3I+qdIfl7X2Cz9iN4BLY4al5+/4sYg hzZTVAM3azIXm/p9x/0W56tQjqTE9Msr7JDQEX/aRvBr4sFVb6RyVH3TLJUaAzyVh/Hp xp9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710437675; x=1711042475; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0xsFrvZFnflqLs9vZ2LdnHyafdvJwRt3mY3Az5BshKg=; b=NG5xOblDpIbnPyjoKM1U4w1Gz8tMf2gOjUhdZJqTcFYTRWTCTGH1qCRRI39VuavEsJ Fzml0YYxod8BcKEJjKk8p7agnH2r1tyOc5fxaiyUbgBRAsAoHUZvDsZXinL1WoSwA243 7VJzLC62j8fBawMnkD26JjWKjyVUX4BRzh+lWrPDRkls+NHswlH53HWHPwpKyxb1OtrM d7tZ6n5T7OUrpXEcdukr65C4bgVSvkUPJpW5rSvJ1lhTlfQGV1fgpVCfPCPEStz4DpZm U4fae5/1KLmc8GQYYUNMk9v5C0KMw2vDdl83SWK9ksOqvNxZ7UaejAySOedBJgwJFbsm SQEA== X-Forwarded-Encrypted: i=1; AJvYcCUJmzLPv+jfM6Oj2nEarLt2XZyvvOQvEFzPD6E/6fkZOrpoFb8V9UuCWEJQfL3FQYeDsyQ3BA9AjiVIY/Gz9Jep5kh1HrwZru9suSUgWvgV X-Gm-Message-State: AOJu0Yyo+4a54gfG7c6v6VuzJU4nLP360uJ1EpGQGr1NLd/KYva6ehW7 M3+z/IN2ZgLILDtQtd+MMJpufoHBM7nN3+WEV0r2X2vyPdLQ62hN9vtTmAbJ3+I0wM0D35AAUmz R+YyAZhSgqQ0XZO1OGFJHhxGrwpiRRl1ijtZJjA== X-Google-Smtp-Source: AGHT+IEo/4DceIPZebvupagBXLp7XNqngudFw+dXck5et26R3gDpeZ7JF6mzu60lgUbhdEeXKkwS0UM4co0FM5LcAFY= X-Received: by 2002:a17:906:f145:b0:a45:f352:73b0 with SMTP id gw5-20020a170906f14500b00a45f35273b0mr1720262ejb.65.1710437674773; Thu, 14 Mar 2024 10:34:34 -0700 (PDT) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 References: <202403132321.42DNLNIX087785@gitrepo.freebsd.org> <56f538f1-d406-4095-972a-2022d48ffc73@FreeBSD.org> In-Reply-To: <56f538f1-d406-4095-972a-2022d48ffc73@FreeBSD.org> From: Warner Losh Date: Thu, 14 Mar 2024 11:34:23 -0600 Message-ID: Subject: Re: git: 220ee18f1964 - main - netinet/tcp_var.h: always define IS_FASTOPEN() for kernel compilation env To: John Baldwin Cc: Gleb Smirnoff , Konstantin Belousov , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000040c370613a24e5b" X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4TwZJF3ZTkz4FWW --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 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


=
On Thu, Mar 14, 2024 at 11:23=E2=80= =AFAM 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>=C2=A0 #define=C2=A0 =C2=A0ENTER_RECOVERY(t_flags) t_flags |=3D (= TF_CONGRECOVERY | TF_FASTRECOVERY)
> K>=C2=A0 #define=C2=A0 =C2=A0EXIT_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>=C2=A0 #define=C2=A0 =C2=A0IS_FASTOPEN(t_flags)=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (false)
> K>=C2=A0 #else
> 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)
> K>=C2=A0 #endif
> K> +#endif
> K>
> K>=C2=A0 #define=C2=A0 =C2=A0BYTES_THIS_ACK(tp, th)=C2=A0 (th->t= h_ack - tp->snd_una)
>
> I know Konstantin in doing that to clear path for IPSEC changes, and t= he patch
> does improve code.=C2=A0 So the message isn't addressed to him, ra= ther it is for
> other src-committers.
>
> Using ifdefs that come from the kernel config inside include files tha= t are not
> ephemeral opt_foo.h is laying out a minefield for the future. Best cas= e - for
> yourself, worst case - for somebody else.

+100

> In the best case this ends in cryptic kernel failure builds, where you= r 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.<= br> >
> In this particular case TCP_RFC7413 comes via opt_inet.h.=C2=A0 Thus, = if you got a
> userland tool, e.g. netstat(1) using IS_FASTOPEN() it will always be f= alse.
> Again, netstat would be a best case.=C2=A0 A worst case would be netin= et6 kernel
> compilation unit that does not include opt_inet.h, but uses IS_FASTOPE= N().
>
> Other than that, we got 32 flags for t_flags and only one is obfuscate= d via a
> macro.=C2=A0 I'd really like to remove the macro and test the flag= directly.=C2=A0 Any
> objections?

+1


--000000000000040c370613a24e5b--