Re: git: 8c0d1eca7834 - main - sockbuf: retain backward compatibility with userland after d59bc188d652

From: Mateusz Guzik <mjguzik_at_gmail.com>
Date: Tue, 31 May 2022 14:33:29 UTC
On 5/30/22, Alexander V. Chernikov <melifaro@ipfw.ru> wrote:
>
>
> 30.05.2022, 16:18, "Mateusz Guzik" <mjguzik@gmail.com>:
>>
>> should probably CTASSERT on size then
>
> Sorry, I’m afraid I don’t get it. Could you please clarify?
>>

diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index 249e0800f915..5fc21206b1bf 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -586,6 +586,14 @@ struct xsocket {
        } so_rcv, so_snd;
 };

+#if _LP64
+_Static_assert(sizeof(struct xsocket) == 240, "bad")
+#elsif _LP32
+....
+#else
+#error "port me"
+#endif
+
 #ifdef _KERNEL
 void   sotoxsocket(struct socket *so, struct xsocket *xso);
 void   sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);

>> On 5/30/22, Alexander V. Chernikov <melifaro@freebsd.org> wrote:
>>>
>>>  The branch main has been updated by melifaro:
>>>
>>>  URL:
>>>  https://cgit.FreeBSD.org/src/commit/?id=8c0d1eca7834bfd5a05c86bf20a7600917057492
>>>
>>>  commit 8c0d1eca7834bfd5a05c86bf20a7600917057492
>>>  Author: Alexander V. Chernikov <melifaro@FreeBSD.org>
>>>  AuthorDate: 2022-05-30 14:56:25 +0000
>>>  Commit: Alexander V. Chernikov <melifaro@FreeBSD.org>
>>>  CommitDate: 2022-05-30 15:10:53 +0000
>>>
>>>      sockbuf: retain backward compatibility with userland after
>>> d59bc188d652
>>>
>>>      Add spare fields to xsockbuf in place of sb_mcnt / sb_ccnt to avoid
>>>       rebuilding userland binaries like sockstat(1).
>>>
>>>      Reviewed by: glebius
>>>  ---
>>>   sys/sys/socketvar.h | 2 ++
>>>   1 file changed, 2 insertions(+)
>>>
>>>  diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
>>>  index 52b9376f0559..249e0800f915 100644
>>>  --- a/sys/sys/socketvar.h
>>>  +++ b/sys/sys/socketvar.h
>>>  @@ -577,6 +577,8 @@ struct xsocket {
>>>                   uint32_t sb_cc;
>>>                   uint32_t sb_hiwat;
>>>                   uint32_t sb_mbcnt;
>>>  + uint32_t sb_spare0; /* was sb_mcnt */
>>>  + uint32_t sb_spare1; /* was sb_ccnt */
>>>                   uint32_t sb_mbmax;
>>>                   int32_t sb_lowat;
>>>                   int32_t sb_timeo;
>>>
>>
>>
>> --
>> Mateusz Guzik <mjguzik gmail.com>
>


-- 
Mateusz Guzik <mjguzik gmail.com>