Commit 9718475e6908 ("socket: Add SO_TIMESTAMPING_NEW") added the new socket option SO_TIMESTAMPING_NEW. Setting the option is handled in sk_setsockopt(), querying it was not handled in sk_getsockopt(), though. For consistency, implement the missing getsockopt(SO_TIMESTAMPING_NEW). Similar as with SO_TIMESTAMP_{OLD,NEW}, the active timestamping flags are only returned when querying the same SO_TIMESTAMPING_{OLD,NEW} option they were set for. Empty flags are returned with SO_TIMESTAMPING_{NEW,OLD} otherwise. Fixes: 9718475e6908 ("socket: Add SO_TIMESTAMPING_NEW") Signed-off-by: Jörn-Thorben Hinz <jthinz@xxxxxxxxxxxxxxxxxxxx> --- net/core/sock.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 9370fd50aa2c..cfb48244ed12 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1710,9 +1710,14 @@ int sk_getsockopt(struct sock *sk, int level, int optname, break; case SO_TIMESTAMPING_OLD: + case SO_TIMESTAMPING_NEW: lv = sizeof(v.timestamping); - v.timestamping.flags = sk->sk_tsflags; - v.timestamping.bind_phc = sk->sk_bind_phc; + if (optname == (sock_flag(sk, SOCK_TSTAMP_NEW) ? + SO_TIMESTAMPING_NEW : + SO_TIMESTAMPING_OLD)) { + v.timestamping.flags = sk->sk_tsflags; + v.timestamping.bind_phc = sk->sk_bind_phc; + } break; case SO_RCVTIMEO_OLD: -- 2.39.2