From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Thomas Lange <thomas@corelatus.se>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
netdev@vger.kernel.org, jthinz@mailbox.tu-berlin.de,
arnd@arndb.de, deepa.kernel@gmail.com
Subject: Re: net/core/sock.c lacks some SO_TIMESTAMPING_NEW support
Date: Tue, 02 Jan 2024 14:44:16 -0500 [thread overview]
Message-ID: <6594679091ed9_29c0c629495@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <dc642c69-8500-457a-a53e-6a3916ef6dab@corelatus.se>
Thomas Lange wrote:
>
> On 2024-01-02 16:26, Willem de Bruijn wrote:
> > Thomas Lange wrote:
> >> It seems that net/core/sock.c is missing support for SO_TIMESTAMPING_NEW in
> >> some paths.
> >>
> >> I cross compile for a 32bit ARM system using Yocto 4.3.1, which seems to have
> >> 64bit time by default. This maps SO_TIMESTAMPING to SO_TIMESTAMPING_NEW which
> >> is expected AFAIK.
> >>
> >> However, this breaks my application (Chrony) that sends SO_TIMESTAMPING as
> >> a cmsg:
> >>
> >> sendmsg(4, {msg_name={sa_family=AF_INET, sin_port=htons(123), sin_addr=inet_addr("172.16.11.22")}, msg_namelen=16, msg_iov=[{iov_base="#\0\6 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=48}], msg_iovlen=1, msg_control=[{cmsg_len=16, cmsg_level=SOL_SOCKET, cmsg_type=SO_TIMESTAMPING_NEW, cmsg_data=???}], msg_controllen=16, msg_flags=0}, 0) = -1 EINVAL (Invalid argument)
> >>
> >> This is because __sock_cmsg_send() does not support SO_TIMESTAMPING_NEW as-is.
> >>
> >> This patch seems to fix things and the packet is transmitted:
> >>
> >> diff --git a/net/core/sock.c b/net/core/sock.c
> >> index 16584e2dd648..a56ec1d492c9 100644
> >> --- a/net/core/sock.c
> >> +++ b/net/core/sock.c
> >> @@ -2821,6 +2821,7 @@ int __sock_cmsg_send(struct sock *sk, struct cmsghdr *cmsg,
> >> sockc->mark = *(u32 *)CMSG_DATA(cmsg);
> >> break;
> >> case SO_TIMESTAMPING_OLD:
> >> + case SO_TIMESTAMPING_NEW:
> >> if (cmsg->cmsg_len != CMSG_LEN(sizeof(u32)))
> >> return -EINVAL;
> >>
> >> However, looking through the module, it seems that sk_getsockopt() has no
> >> support for SO_TIMESTAMPING_NEW either, but sk_setsockopt() has.
> >> Testing seems to confirm this:
> >>
> >> setsockopt(4, SOL_SOCKET, SO_TIMESTAMPING_NEW, [1048], 4) = 0
> >> getsockopt(4, SOL_SOCKET, SO_TIMESTAMPING_NEW, 0x7ed5db20, [4]) = -1 ENOPROTOOPT (Protocol not available)
> >>
> >> Patching sk_getsockopt() is not as obvious to me though.
> >>
> >> I used a custom 6.6 kernel for my tests.
> >> The relevant code seems unchanged in net-next.git though.
> >>
> >> /Thomas
> >
> > The fix to getsockopt is now merged:
> >
> > https://lore.kernel.org/netdev/20231221231901.67003-1-jthinz@mailbox.tu-berlin.de/T/
> >
> > Do you want to send the above fix to __sock_cmsg_send?
>
> Sure, I can do that. Do you want it sent to [net]?
Yes please. Same destination as the other patch, and same Fixes tag.
prev parent reply other threads:[~2024-01-02 19:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-18 21:28 net/core/sock.c lacks some SO_TIMESTAMPING_NEW support Thomas Lange
2023-12-20 4:00 ` Willem de Bruijn
2023-12-20 9:43 ` Arnd Bergmann
2023-12-20 11:13 ` Jörn-Thorben Hinz
2023-12-20 14:53 ` Willem de Bruijn
2023-12-20 15:06 ` Willem de Bruijn
2023-12-20 15:59 ` Arnd Bergmann
2023-12-21 15:49 ` Jörn-Thorben Hinz
2023-12-21 17:07 ` Willem de Bruijn
2023-12-21 23:32 ` Jörn-Thorben Hinz
2024-01-02 15:26 ` Willem de Bruijn
2024-01-02 19:06 ` Thomas Lange
2024-01-02 19:44 ` Willem de Bruijn [this message]
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=6594679091ed9_29c0c629495@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=arnd@arndb.de \
--cc=deepa.kernel@gmail.com \
--cc=jthinz@mailbox.tu-berlin.de \
--cc=netdev@vger.kernel.org \
--cc=thomas@corelatus.se \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).