Skip to contentSkip to conversation

net: core: fix SO_TIMESTAMP_* option setting

PATCH In review Sergei Trofimovich 2 participants 3 messages Jul 7, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: core: fix SO_TIMESTAMP_* option setting

I noticed the problem as a systemd-timesyncd (and ntpsec) sync failures:

systemd-timesyncd[586]: Timed out waiting for reply from ... systemd-timesyncd[586]: Invalid packet timestamp.

Bisected it down to commit 371087aa476
("sock: expose so_timestamp options for mptcp").

The commit should be a no-op but it accidentally reordered option type and option value:

+void sock_set_timestamp(struct sock *sk, int optname, bool valbool);
...
- __sock_set_timestamps(sk, valbool, true, true);
+ sock_set_timestamp(sk, valbool, optname);

Tested the fix on systemd-timesyncd. The sync failures went away.

CC Paolo Abeni <[email protected]>
CC Florian Westphal <[email protected]>
CC Mat Martineau <[email protected]>
CC David S. Miller <[email protected]>
CC Jakub Kicinski <[email protected]>
CC Eric Dumazet <[email protected]>
---
 net/core/sock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/sock.c +1 -1
index ba1c0f75cd45..060892372ac5 100644
@@ -1068,7 +1068,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 	case SO_TIMESTAMP_NEW:
 	case SO_TIMESTAMPNS_OLD:
 	case SO_TIMESTAMPNS_NEW:
-		sock_set_timestamp(sk, valbool, optname);
+		sock_set_timestamp(sk, optname, valbool);
 		break;
 
 	case SO_TIMESTAMPING_NEW:
Signature · 1 line
2.32.0
#1 lore raw
Quoted 19 lines · Sergei Trofimovich

I noticed the problem as a systemd-timesyncd (and ntpsec) sync failures:

systemd-timesyncd[586]: Timed out waiting for reply from ... systemd-timesyncd[586]: Invalid packet timestamp.

Bisected it down to commit 371087aa476
("sock: expose so_timestamp options for mptcp").

The commit should be a no-op but it accidentally reordered option type and option value:

+void sock_set_timestamp(struct sock *sk, int optname, bool valbool);
...
- __sock_set_timestamps(sk, valbool, true, true);
+ sock_set_timestamp(sk, valbool, optname);

Tested the fix on systemd-timesyncd. The sync failures went away.

Quoted 8 lines
CC Paolo Abeni <[email protected]>
CC Florian Westphal <[email protected]>
CC Mat Martineau <[email protected]>
CC David S. Miller <[email protected]>
CC Jakub Kicinski <[email protected]>
CC Eric Dumazet <[email protected]>

---

I think this has been fixed five days ago in

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=81b4a0cc7565b08cadd0d02bae3434f127d1d72a

#2 lore raw
Quoted 29 lines · On Wed, 7 Jul 2021 14:32:01 +0200 Eric Dumazet <[email protected]> wrote:
Quoted 19 lines · Sergei Trofimovich

I noticed the problem as a systemd-timesyncd (and ntpsec) sync failures:

systemd-timesyncd[586]: Timed out waiting for reply from ... systemd-timesyncd[586]: Invalid packet timestamp.

Bisected it down to commit 371087aa476
("sock: expose so_timestamp options for mptcp").

The commit should be a no-op but it accidentally reordered option type and option value:

+void sock_set_timestamp(struct sock *sk, int optname, bool valbool);
...
- __sock_set_timestamps(sk, valbool, true, true);
+ sock_set_timestamp(sk, valbool, optname);

Tested the fix on systemd-timesyncd. The sync failures went away.

Quoted 8 lines
CC Paolo Abeni <[email protected]>
CC Florian Westphal <[email protected]>
CC Mat Martineau <[email protected]>
CC David S. Miller <[email protected]>
CC Jakub Kicinski <[email protected]>
CC Eric Dumazet <[email protected]>

---

Quoted 3 lines

I think this has been fixed five days ago in

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=81b4a0cc7565b08cadd0d02bae3434f127d1d72a

Aha, looks good! Thank you!

Signature · 1 line
  Sergei