Bug 289423 - SO_BINTIME seems to not work for IPv6
Summary: SO_BINTIME seems to not work for IPv6
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.3-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Jonathan T. Looney
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-10 01:09 UTC by Steven Sommars
Modified: 2025-10-14 08:31 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Sommars 2025-09-10 01:09:51 UTC
The NTP distribution supplied by nwtime.org and used in the FreeBSD ports collection makes use of SO_BINTIME on FreeBSD. SO_BINTIME appears broken for IPv6 on FreeBSD 14.3, and earlier versions. [getsockopt confirms that SO_BINTIME is set].  The IPv6 socket also has SO_IPV6ONLY set, if that matters.

An IPv4 socket provides SCM_BINTIME, an IPv6 socket does not (msghdr is NULL).

It would help to know the expected disposition of this issue.
Comment 1 Fabian Wenk 2025-09-10 17:05:19 UTC
Just for completeness, this is related to the bug report https://bugs.ntp.org/show_bug.cgi?id=3989 at ntp.org.

Also see the e-mail "IPv6 and SO_BINTIME" from Harlan Stenn in freebsd-net mailing list at https://lists.freebsd.org/archives/freebsd-net/2025-September/007416.html

Hopefully anybody is able in taking this for further discussion.

PS: I am only involved as Steve has contacted me because he does measurements of NTP Pool servers and some of mine did show some odd behavior and I provided details about the system, software and also a tcpdump ntp traffic capture.
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2025-09-12 16:13:00 UTC
Indeed, as far as I can tell we simply don't implement SO_BINTIME for v6: udp_append() handles it, while udp6_append() does not.  Both implement SO_TIMESTAMP though.
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-09-15 16:50:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cd02a8a9f8be2085d5242606a79668dc3720e7b0

commit cd02a8a9f8be2085d5242606a79668dc3720e7b0
Author:     Jonathan T. Looney <jtl@FreeBSD.org>
AuthorDate: 2025-09-12 17:49:17 +0000
Commit:     Jonathan T. Looney <jtl@FreeBSD.org>
CommitDate: 2025-09-15 16:46:03 +0000

    ip6: add SO_BINTIME support

    This adds support for obtaining timestamps from IPv6 packets using the
    SO_BINTIME socket option, bringing it in parity with IPv4 behavior.

    Enable testing the SO_BINTIME option in the relevant (manual) regression
    test.

    PR:             289423
    Reviewed by:    markj
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D52504

 sys/netinet6/ip6_input.c                           | 53 +++++++++++++++-------
 .../regression/sockets/udp_pingpong/udp_pingpong.c |  8 ++--
 2 files changed, 39 insertions(+), 22 deletions(-)
Comment 4 Jonathan T. Looney freebsd_committer freebsd_triage 2025-09-15 16:53:40 UTC
I committed a fix to main. I will close the bug once it is MFCd. In the meantime, feel free to test with -CURRENT.
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-09-29 15:07:47 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5b59ff1e160727c80686bbfc728dae075fcd0d4f

commit 5b59ff1e160727c80686bbfc728dae075fcd0d4f
Author:     Jonathan T. Looney <jtl@FreeBSD.org>
AuthorDate: 2025-09-12 17:49:17 +0000
Commit:     Jonathan T. Looney <jtl@FreeBSD.org>
CommitDate: 2025-09-29 15:03:02 +0000

    ip6: add SO_BINTIME support

    This adds support for obtaining timestamps from IPv6 packets using the
    SO_BINTIME socket option, bringing it in parity with IPv4 behavior.

    Enable testing the SO_BINTIME option in the relevant (manual) regression
    test.

    PR:             289423
    Reviewed by:    markj
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D52504

    (cherry picked from commit cd02a8a9f8be2085d5242606a79668dc3720e7b0)

 sys/netinet6/ip6_input.c                           | 53 +++++++++++++++-------
 .../regression/sockets/udp_pingpong/udp_pingpong.c |  8 ++--
 2 files changed, 39 insertions(+), 22 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-09-29 15:13:48 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f801346706ea75401614df2dba3f85ecea2af03e

commit f801346706ea75401614df2dba3f85ecea2af03e
Author:     Jonathan T. Looney <jtl@FreeBSD.org>
AuthorDate: 2025-09-12 17:49:17 +0000
Commit:     Jonathan T. Looney <jtl@FreeBSD.org>
CommitDate: 2025-09-29 15:12:49 +0000

    ip6: add SO_BINTIME support

    This adds support for obtaining timestamps from IPv6 packets using the
    SO_BINTIME socket option, bringing it in parity with IPv4 behavior.

    Enable testing the SO_BINTIME option in the relevant (manual) regression
    test.

    PR:             289423
    Reviewed by:    markj
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D52504

    (cherry picked from commit cd02a8a9f8be2085d5242606a79668dc3720e7b0)

 sys/netinet6/ip6_input.c                           | 53 +++++++++++++++-------
 .../regression/sockets/udp_pingpong/udp_pingpong.c |  8 ++--
 2 files changed, 39 insertions(+), 22 deletions(-)
Comment 7 Dave Hart 2025-10-14 08:31:30 UTC
Thank you for adding SO_BINTIME support to FreeBSD's IPv6.  In order to better support FreeBSD before this fix, it seems like it would be nice to change ntpd to use SO_TS_CLOCK and SO_TS_BINTIME in preference to SO_BINTIME on systems which support it, as it seems like FreeBSD IPv6 has had this similarly higher-precision UDP arrival timestamping support in IPv6 for years.

This is mentioned in https://bugs.ntp.org/show_bug.cgi?id=3989#c1