NetBSD Problem Report #57955
From mouse@Stone.Rodents-Montreal.ORG Fri Feb 23 16:12:09 2024
Return-Path: <mouse@Stone.Rodents-Montreal.ORG>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id C23C31A9239
for <gnats-bugs@www46.NetBSD.org>; Fri, 23 Feb 2024 16:12:08 +0000 (UTC)
Message-Id: <202402231611.LAA21959@Stone.Rodents-Montreal.ORG>
Date: Fri, 23 Feb 2024 11:11:56 -0500 (EST)
From: Mouse <mouse@Rodents-Montreal.ORG>
Reply-To: mouse@Rodents-Montreal.ORG
To: gnats-bugs@www46.NetBSD.org
Subject: SO_TIMESTAMP doesn't work for ICMP6
X-Send-Pr-Version: 3.95
>Number: 57955
>Category: kern
>Synopsis: Enabling SO_TIMESTAMP on ICMP6 socket doesn't work
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 23 16:15:00 +0000 2024
>Closed-Date: Mon Mar 11 22:22:53 +0000 2024
>Last-Modified: Mon Mar 11 22:22:53 +0000 2024
>Originator: Mouse
>Release: Various: 4.0.1+, 5.2+, 9.1, and reportedly -current
>Organization:
Dis-
>Environment:
First noticed on
System: NetBSD Border.Rodents-Montreal.ORG 4.0.1 NetBSD 4.0.1 (BORDER) #0: Mon Jun 12 22:01:38 EDT 2023 mouse@Border.Rodents-Montreal.ORG:/home/mouse/kbuild/BORDER i386
Architecture: i386
Machine: i386
Also observed on 5.2/amd64, 9.1/amd64, and, according to Martin
Husemann on tech-net <20240223152756.GC9658@mail.duskware.de>,
current on some unspecified architecture.
>Description:
Enabling timestamps with setsockopt SOL_SOCKET/SO_TIMESTAMP
doesn't work for AF_INET6/SOCK_RAW/IPPROTO_ICMPV6 sockets. I
suspect it will fail for other v6 sockets, but haven't tested
it.
"Doesn't work" here means, as far as I can tell, "is ignored as
far as returned control messages are concerned"; with no other
reason to generate control data, I get zero bytes of control
data from recvmsg().
>How-To-Repeat:
Fetch {ftp,http}://ftp.rodents-montreal.org/mouse/misc/test-icmp6.c
Read it over, unless you trust me and the network between us to
be non-malicious. (It should have MD5
801a051030b1b311c00ebdcaeac40f1e, SHA256
07ece2c4590ff9a6d73e917a2cb071fa338dab418a110d90f5c2965c993e7f9a.)
Build it.
Run it (as root; it needs to create raw sockets - this is why I
said to read it over first).
Get "data 64, ctl 0" instead of ctl data containing a struct
timeval. (On my test 4.0.1 machine with the patch below, I get
ctl 24.)
>Fix:
This works for me on 4.0.1. A quick glance at cvsweb makes me
suspect something similar might work for -current.
Even if it works, I am far from convinced this is the right
fix. I would not recommend committing it as-is unless someone
who knows the v6 stack signs off on it.
commit fcfe8180a98fae5ae07d96c291088fd147db42c6
Author: Mouse <mouse@Rodents-Montreal.ORG>
Date: Fri Feb 23 10:58:18 2024 -0500
Make SO_TIMESTAMP work with ICMP6 (and other v6?) sockets.
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index edc09f6..4112bda 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1924,7 +1924,8 @@ icmp6_rip6_input(mp, off)
if (last) {
struct mbuf *n;
if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if ( (last->in6p_flags & IN6P_CONTROLOPTS) ||
+ (last->in6p_socket->so_options & SO_TIMESTAMP) )
ip6_savecontrol(last, &opts, ip6, n);
/* strip intermediate headers */
m_adj(n, off);
@@ -1943,7 +1944,8 @@ icmp6_rip6_input(mp, off)
last = in6p;
}
if (last) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if ( (last->in6p_flags & IN6P_CONTROLOPTS) ||
+ (last->in6p_socket->so_options & SO_TIMESTAMP) )
ip6_savecontrol(last, &opts, ip6, m);
/* strip intermediate headers */
m_adj(m, off);
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 0a467e1..592de93 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -217,7 +217,8 @@ rip6_input(mp, offp, proto)
if (!ipsec6_in_reject(m,last))
#endif /* FAST_IPSEC */
if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if ( (last->in6p_flags & IN6P_CONTROLOPTS) ||
+ (last->in6p_socket->so_options & SO_TIMESTAMP) )
ip6_savecontrol(last, &opts, ip6, n);
/* strip intermediate headers */
m_adj(n, *offp);
@@ -261,7 +262,8 @@ rip6_input(mp, offp, proto)
} else
#endif /* FAST_IPSEC */
if (last) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if ( (last->in6p_flags & IN6P_CONTROLOPTS) ||
+ (last->in6p_socket->so_options & SO_TIMESTAMP) )
ip6_savecontrol(last, &opts, ip6, m);
/* strip intermediate headers */
m_adj(m, *offp);
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
>Release-Note:
>Audit-Trail:
From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57955 CVS commit: src/sys/netinet6
Date: Sat, 24 Feb 2024 21:41:13 +0000
Module Name: src
Committed By: mlelstv
Date: Sat Feb 24 21:41:13 UTC 2024
Modified Files:
src/sys/netinet6: icmp6.c raw_ip6.c
Log Message:
Deliver timestamps also to raw sockets.
Fixes PR 57955
To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.183 -r1.184 src/sys/netinet6/raw_ip6.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 24 Feb 2024 22:48:21 +0000
State-Changed-Why:
fixed in HEAD, needs pullup-10, pullup-9, pullup-8
State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Fri, 01 Mar 2024 15:14:01 +0000
State-Changed-Why:
pullup-10 #615
pullup-9 #1809
patch doesn't apply cleanly or with easy changes to netbsd-8, so if
this is important, someone else will have to come by to backport it
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57955 CVS commit: [netbsd-10] src/sys/netinet6
Date: Sun, 10 Mar 2024 18:51:54 +0000
Module Name: src
Committed By: martin
Date: Sun Mar 10 18:51:54 UTC 2024
Modified Files:
src/sys/netinet6 [netbsd-10]: icmp6.c raw_ip6.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #615):
sys/netinet6/raw_ip6.c: revision 1.184
sys/netinet6/icmp6.c: revision 1.256
Deliver timestamps also to raw sockets.
Fixes PR 57955
To generate a diff of this commit:
cvs rdiff -u -r1.254.2.1 -r1.254.2.2 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.182.2.1 -r1.182.2.2 src/sys/netinet6/raw_ip6.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57955 CVS commit: [netbsd-9] src/sys/netinet6
Date: Sun, 10 Mar 2024 18:54:41 +0000
Module Name: src
Committed By: martin
Date: Sun Mar 10 18:54:41 UTC 2024
Modified Files:
src/sys/netinet6 [netbsd-9]: icmp6.c raw_ip6.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1809):
sys/netinet6/raw_ip6.c: revision 1.184 (patch)
sys/netinet6/icmp6.c: revision 1.256 (patch)
Deliver timestamps also to raw sockets.
Fixes PR 57955
To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.242.4.1 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.175.4.1 -r1.175.4.2 src/sys/netinet6/raw_ip6.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Mon, 11 Mar 2024 22:22:53 +0000
State-Changed-Why:
fixed and pulled up
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.