mirror of
https://github.com/torvalds/linux.git
synced 2024-12-22 02:52:56 +00:00
Merge branch 'net-y2038-safe-socket-timestamps'
Deepa Dinamani says: ==================== net: y2038-safe socket timestamps The series introduces new socket timestamps that are y2038 safe. The time data types used for the existing socket timestamp options: SO_TIMESTAMP, SO_TIMESTAMPNS and SO_TIMESTAMPING are not y2038 safe. The series introduces SO_TIMESTAMP_NEW, SO_TIMESTAMPNS_NEW and SO_TIMESTAMPING_NEW to replace these. These new timestamps can be used on all architectures. The alternative considered was to extend the sys_setsockopt() by using the flags. We did not receive any strong opinions about either of the approaches. Hence, this was chosen, as glibc folks preferred this. The series does not deal with updating the internal kernel socket calls like rxrpc to make them y2038 safe. This will be dealt with separately. Note that the timestamps behavior already does not match the man page specific behavior: SIOCGSTAMP This ioctl should only be used if the socket option SO_TIMESTAMP is not set on the socket. Otherwise, it returns the timestamp of the last packet that was received while SO_TIMESTAMP was not set, or it fails if no such packet has been received, (i.e., ioctl(2) returns -1 with errno set to ENOENT). The recommendation is to update the man page to remove the above statement. The overview of the socket timestamp series is as below: 1. Delete asm specific socket.h when possible. 2. Support SO/SCM_TIMESTAMP* options only in userspace. 3. Rename current SO/SCM_TIMESTAMP* to SO/SCM_TIMESTAMP*_OLD. 3. Alter socket options so that SOCK_RCVTSTAMPNS does not rely on SOCK_RCVTSTAMP. 4. Introduce y2038 safe types for socket timestamp. 5. Introduce new y2038 safe socket options SO/SCM_TIMESTAMP*_NEW. 6. Intorduce new y2038 safe socket timeout options. Changes since v4: * Fixed the typo in calling sock_get_timeout() Changes since v3: * Rebased onto net-next and fixups as per review comments * Merged the socket timeout series * Integrated Arnd's patch to simplify compat handling of timeout syscalls Changes since v2: * Removed extra functions to reduce diff churn as per code review Changes since v1: * Dropped the change to disentangle sock flags * Renamed sock_timeval to __kernel_sock_timeval * Updated a few comments * Added documentation changes ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
a98dc6aee7
@ -6,11 +6,21 @@ The interfaces for receiving network packages timestamps are:
|
||||
* SO_TIMESTAMP
|
||||
Generates a timestamp for each incoming packet in (not necessarily
|
||||
monotonic) system time. Reports the timestamp via recvmsg() in a
|
||||
control message as struct timeval (usec resolution).
|
||||
control message in usec resolution.
|
||||
SO_TIMESTAMP is defined as SO_TIMESTAMP_NEW or SO_TIMESTAMP_OLD
|
||||
based on the architecture type and time_t representation of libc.
|
||||
Control message format is in struct __kernel_old_timeval for
|
||||
SO_TIMESTAMP_OLD and in struct __kernel_sock_timeval for
|
||||
SO_TIMESTAMP_NEW options respectively.
|
||||
|
||||
* SO_TIMESTAMPNS
|
||||
Same timestamping mechanism as SO_TIMESTAMP, but reports the
|
||||
timestamp as struct timespec (nsec resolution).
|
||||
timestamp as struct timespec in nsec resolution.
|
||||
SO_TIMESTAMPNS is defined as SO_TIMESTAMPNS_NEW or SO_TIMESTAMPNS_OLD
|
||||
based on the architecture type and time_t representation of libc.
|
||||
Control message format is in struct timespec for SO_TIMESTAMPNS_OLD
|
||||
and in struct __kernel_timespec for SO_TIMESTAMPNS_NEW options
|
||||
respectively.
|
||||
|
||||
* IP_MULTICAST_LOOP + SO_TIMESTAMP[NS]
|
||||
Only for multicast:approximate transmit timestamp obtained by
|
||||
@ -22,7 +32,7 @@ The interfaces for receiving network packages timestamps are:
|
||||
timestamps for stream sockets.
|
||||
|
||||
|
||||
1.1 SO_TIMESTAMP:
|
||||
1.1 SO_TIMESTAMP (also SO_TIMESTAMP_OLD and SO_TIMESTAMP_NEW):
|
||||
|
||||
This socket option enables timestamping of datagrams on the reception
|
||||
path. Because the destination socket, if any, is not known early in
|
||||
@ -31,15 +41,25 @@ same is true for all early receive timestamp options.
|
||||
|
||||
For interface details, see `man 7 socket`.
|
||||
|
||||
Always use SO_TIMESTAMP_NEW timestamp to always get timestamp in
|
||||
struct __kernel_sock_timeval format.
|
||||
|
||||
1.2 SO_TIMESTAMPNS:
|
||||
SO_TIMESTAMP_OLD returns incorrect timestamps after the year 2038
|
||||
on 32 bit machines.
|
||||
|
||||
1.2 SO_TIMESTAMPNS (also SO_TIMESTAMPNS_OLD and SO_TIMESTAMPNS_NEW):
|
||||
|
||||
This option is identical to SO_TIMESTAMP except for the returned data type.
|
||||
Its struct timespec allows for higher resolution (ns) timestamps than the
|
||||
timeval of SO_TIMESTAMP (ms).
|
||||
|
||||
Always use SO_TIMESTAMPNS_NEW timestamp to always get timestamp in
|
||||
struct __kernel_timespec format.
|
||||
|
||||
1.3 SO_TIMESTAMPING:
|
||||
SO_TIMESTAMPNS_OLD returns incorrect timestamps after the year 2038
|
||||
on 32 bit machines.
|
||||
|
||||
1.3 SO_TIMESTAMPING (also SO_TIMESTAMPING_OLD and SO_TIMESTAMPING_NEW):
|
||||
|
||||
Supports multiple types of timestamp requests. As a result, this
|
||||
socket option takes a bitmap of flags, not a boolean. In
|
||||
@ -323,10 +343,23 @@ SO_TIMESTAMP and SO_TIMESTAMPNS records can be retrieved.
|
||||
These timestamps are returned in a control message with cmsg_level
|
||||
SOL_SOCKET, cmsg_type SCM_TIMESTAMPING, and payload of type
|
||||
|
||||
For SO_TIMESTAMPING_OLD:
|
||||
|
||||
struct scm_timestamping {
|
||||
struct timespec ts[3];
|
||||
};
|
||||
|
||||
For SO_TIMESTAMPING_NEW:
|
||||
|
||||
struct scm_timestamping64 {
|
||||
struct __kernel_timespec ts[3];
|
||||
|
||||
Always use SO_TIMESTAMPING_NEW timestamp to always get timestamp in
|
||||
struct scm_timestamping64 format.
|
||||
|
||||
SO_TIMESTAMPING_OLD returns incorrect timestamps after the year 2038
|
||||
on 32 bit machines.
|
||||
|
||||
The structure can return up to three timestamps. This is a legacy
|
||||
feature. At least one field is non-zero at any time. Most timestamps
|
||||
are passed in ts[0]. Hardware timestamps are passed in ts[2].
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define _UAPI_ASM_SOCKET_H
|
||||
|
||||
#include <asm/sockios.h>
|
||||
#include <asm/bitsperlong.h>
|
||||
|
||||
/* For setsockopt(2) */
|
||||
/*
|
||||
@ -30,8 +31,8 @@
|
||||
#define SO_RCVBUFFORCE 0x100b
|
||||
#define SO_RCVLOWAT 0x1010
|
||||
#define SO_SNDLOWAT 0x1011
|
||||
#define SO_RCVTIMEO 0x1012
|
||||
#define SO_SNDTIMEO 0x1013
|
||||
#define SO_RCVTIMEO_OLD 0x1012
|
||||
#define SO_SNDTIMEO_OLD 0x1013
|
||||
#define SO_ACCEPTCONN 0x1014
|
||||
#define SO_PROTOCOL 0x1028
|
||||
#define SO_DOMAIN 0x1029
|
||||
@ -51,13 +52,9 @@
|
||||
#define SO_GET_FILTER SO_ATTACH_FILTER
|
||||
|
||||
#define SO_PEERNAME 28
|
||||
#define SO_TIMESTAMP 29
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
|
||||
#define SO_PEERSEC 30
|
||||
#define SO_PASSSEC 34
|
||||
#define SO_TIMESTAMPNS 35
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
|
||||
/* Security levels - as per NRL IPv6 - don't actually do anything */
|
||||
#define SO_SECURITY_AUTHENTICATION 19
|
||||
@ -66,9 +63,6 @@
|
||||
|
||||
#define SO_MARK 36
|
||||
|
||||
#define SO_TIMESTAMPING 37
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#define SO_RXQ_OVFL 40
|
||||
|
||||
#define SO_WIFI_STATUS 41
|
||||
@ -117,4 +111,39 @@
|
||||
|
||||
#define SO_BINDTOIFINDEX 62
|
||||
|
||||
#define SO_TIMESTAMP_OLD 29
|
||||
#define SO_TIMESTAMPNS_OLD 35
|
||||
#define SO_TIMESTAMPING_OLD 37
|
||||
|
||||
#define SO_TIMESTAMP_NEW 63
|
||||
#define SO_TIMESTAMPNS_NEW 64
|
||||
#define SO_TIMESTAMPING_NEW 65
|
||||
|
||||
#define SO_RCVTIMEO_NEW 66
|
||||
#define SO_SNDTIMEO_NEW 67
|
||||
|
||||
#if !defined(__KERNEL__)
|
||||
|
||||
#if __BITS_PER_LONG == 64
|
||||
#define SO_TIMESTAMP SO_TIMESTAMP_OLD
|
||||
#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
|
||||
#define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
|
||||
|
||||
#define SO_RCVTIMEO SO_RCVTIMEO_OLD
|
||||
#define SO_SNDTIMEO SO_SNDTIMEO_OLD
|
||||
#else
|
||||
#define SO_TIMESTAMP (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMP_OLD : SO_TIMESTAMP_NEW)
|
||||
#define SO_TIMESTAMPNS (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPNS_OLD : SO_TIMESTAMPNS_NEW)
|
||||
#define SO_TIMESTAMPING (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPING_OLD : SO_TIMESTAMPING_NEW)
|
||||
|
||||
#define SO_RCVTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_RCVTIMEO_OLD : SO_RCVTIMEO_NEW)
|
||||
#define SO_SNDTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_SNDTIMEO_OLD : SO_SNDTIMEO_NEW)
|
||||
#endif
|
||||
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _UAPI_ASM_SOCKET_H */
|
||||
|
@ -2,3 +2,4 @@ include include/uapi/asm-generic/Kbuild.asm
|
||||
|
||||
generated-y += unistd_64.h
|
||||
generic-y += kvm_para.h
|
||||
generic-y += socket.h
|
||||
|
@ -1,122 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _ASM_IA64_SOCKET_H
|
||||
#define _ASM_IA64_SOCKET_H
|
||||
|
||||
/*
|
||||
* Socket related defines.
|
||||
*
|
||||
* Based on <asm-i386/socket.h>.
|
||||
*
|
||||
* Modified 1998-2000
|
||||
* David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
|
||||
*/
|
||||
|
||||
#include <asm/sockios.h>
|
||||
|
||||
/* For setsockopt(2) */
|
||||
#define SOL_SOCKET 1
|
||||
|
||||
#define SO_DEBUG 1
|
||||
#define SO_REUSEADDR 2
|
||||
#define SO_TYPE 3
|
||||
#define SO_ERROR 4
|
||||
#define SO_DONTROUTE 5
|
||||
#define SO_BROADCAST 6
|
||||
#define SO_SNDBUF 7
|
||||
#define SO_RCVBUF 8
|
||||
#define SO_SNDBUFFORCE 32
|
||||
#define SO_RCVBUFFORCE 33
|
||||
#define SO_KEEPALIVE 9
|
||||
#define SO_OOBINLINE 10
|
||||
#define SO_NO_CHECK 11
|
||||
#define SO_PRIORITY 12
|
||||
#define SO_LINGER 13
|
||||
#define SO_BSDCOMPAT 14
|
||||
#define SO_REUSEPORT 15
|
||||
#define SO_PASSCRED 16
|
||||
#define SO_PEERCRED 17
|
||||
#define SO_RCVLOWAT 18
|
||||
#define SO_SNDLOWAT 19
|
||||
#define SO_RCVTIMEO 20
|
||||
#define SO_SNDTIMEO 21
|
||||
|
||||
/* Security levels - as per NRL IPv6 - don't actually do anything */
|
||||
#define SO_SECURITY_AUTHENTICATION 22
|
||||
#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
|
||||
#define SO_SECURITY_ENCRYPTION_NETWORK 24
|
||||
|
||||
#define SO_BINDTODEVICE 25
|
||||
|
||||
/* Socket filtering */
|
||||
#define SO_ATTACH_FILTER 26
|
||||
#define SO_DETACH_FILTER 27
|
||||
#define SO_GET_FILTER SO_ATTACH_FILTER
|
||||
|
||||
#define SO_PEERNAME 28
|
||||
#define SO_TIMESTAMP 29
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
|
||||
#define SO_ACCEPTCONN 30
|
||||
|
||||
#define SO_PEERSEC 31
|
||||
#define SO_PASSSEC 34
|
||||
#define SO_TIMESTAMPNS 35
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
|
||||
#define SO_MARK 36
|
||||
|
||||
#define SO_TIMESTAMPING 37
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#define SO_PROTOCOL 38
|
||||
#define SO_DOMAIN 39
|
||||
|
||||
#define SO_RXQ_OVFL 40
|
||||
|
||||
#define SO_WIFI_STATUS 41
|
||||
#define SCM_WIFI_STATUS SO_WIFI_STATUS
|
||||
#define SO_PEEK_OFF 42
|
||||
|
||||
/* Instruct lower device to use last 4-bytes of skb data as FCS */
|
||||
#define SO_NOFCS 43
|
||||
|
||||
#define SO_LOCK_FILTER 44
|
||||
|
||||
#define SO_SELECT_ERR_QUEUE 45
|
||||
|
||||
#define SO_BUSY_POLL 46
|
||||
|
||||
#define SO_MAX_PACING_RATE 47
|
||||
|
||||
#define SO_BPF_EXTENSIONS 48
|
||||
|
||||
#define SO_INCOMING_CPU 49
|
||||
|
||||
#define SO_ATTACH_BPF 50
|
||||
#define SO_DETACH_BPF SO_DETACH_FILTER
|
||||
|
||||
#define SO_ATTACH_REUSEPORT_CBPF 51
|
||||
#define SO_ATTACH_REUSEPORT_EBPF 52
|
||||
|
||||
#define SO_CNX_ADVICE 53
|
||||
|
||||
#define SCM_TIMESTAMPING_OPT_STATS 54
|
||||
|
||||
#define SO_MEMINFO 55
|
||||
|
||||
#define SO_INCOMING_NAPI_ID 56
|
||||
|
||||
#define SO_COOKIE 57
|
||||
|
||||
#define SCM_TIMESTAMPING_PKTINFO 58
|
||||
|
||||
#define SO_PEERGROUPS 59
|
||||
|
||||
#define SO_ZEROCOPY 60
|
||||
|
||||
#define SO_TXTIME 61
|
||||
#define SCM_TXTIME SO_TXTIME
|
||||
|
||||
#define SO_BINDTOIFINDEX 62
|
||||
|
||||
#endif /* _ASM_IA64_SOCKET_H */
|
@ -11,6 +11,7 @@
|
||||
#define _UAPI_ASM_SOCKET_H
|
||||
|
||||
#include <asm/sockios.h>
|
||||
#include <asm/bitsperlong.h>
|
||||
|
||||
/*
|
||||
* For setsockopt(2)
|
||||
@ -38,8 +39,8 @@
|
||||
#define SO_RCVBUF 0x1002 /* Receive buffer. */
|
||||
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
|
||||
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
|
||||
#define SO_SNDTIMEO 0x1005 /* send timeout */
|
||||
#define SO_RCVTIMEO 0x1006 /* receive timeout */
|
||||
#define SO_SNDTIMEO_OLD 0x1005 /* send timeout */
|
||||
#define SO_RCVTIMEO_OLD 0x1006 /* receive timeout */
|
||||
#define SO_ACCEPTCONN 0x1009
|
||||
#define SO_PROTOCOL 0x1028 /* protocol type */
|
||||
#define SO_DOMAIN 0x1029 /* domain/socket family */
|
||||
@ -65,21 +66,14 @@
|
||||
#define SO_GET_FILTER SO_ATTACH_FILTER
|
||||
|
||||
#define SO_PEERNAME 28
|
||||
#define SO_TIMESTAMP 29
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
|
||||
#define SO_PEERSEC 30
|
||||
#define SO_SNDBUFFORCE 31
|
||||
#define SO_RCVBUFFORCE 33
|
||||
#define SO_PASSSEC 34
|
||||
#define SO_TIMESTAMPNS 35
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
|
||||
#define SO_MARK 36
|
||||
|
||||
#define SO_TIMESTAMPING 37
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#define SO_RXQ_OVFL 40
|
||||
|
||||
#define SO_WIFI_STATUS 41
|
||||
@ -128,4 +122,39 @@
|
||||
|
||||
#define SO_BINDTOIFINDEX 62
|
||||
|
||||
#define SO_TIMESTAMP_OLD 29
|
||||
#define SO_TIMESTAMPNS_OLD 35
|
||||
#define SO_TIMESTAMPING_OLD 37
|
||||
|
||||
#define SO_TIMESTAMP_NEW 63
|
||||
#define SO_TIMESTAMPNS_NEW 64
|
||||
#define SO_TIMESTAMPING_NEW 65
|
||||
|
||||
#define SO_RCVTIMEO_NEW 66
|
||||
#define SO_SNDTIMEO_NEW 67
|
||||
|
||||
#if !defined(__KERNEL__)
|
||||
|
||||
#if __BITS_PER_LONG == 64
|
||||
#define SO_TIMESTAMP SO_TIMESTAMP_OLD
|
||||
#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
|
||||
#define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
|
||||
|
||||
#define SO_RCVTIMEO SO_RCVTIMEO_OLD
|
||||
#define SO_SNDTIMEO SO_SNDTIMEO_OLD
|
||||
#else
|
||||
#define SO_TIMESTAMP (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMP_OLD : SO_TIMESTAMP_NEW)
|
||||
#define SO_TIMESTAMPNS (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPNS_OLD : SO_TIMESTAMPNS_NEW)
|
||||
#define SO_TIMESTAMPING (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPING_OLD : SO_TIMESTAMPING_NEW)
|
||||
|
||||
#define SO_RCVTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_RCVTIMEO_OLD : SO_RCVTIMEO_NEW)
|
||||
#define SO_SNDTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_SNDTIMEO_OLD : SO_SNDTIMEO_NEW)
|
||||
#endif
|
||||
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _UAPI_ASM_SOCKET_H */
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define _UAPI_ASM_SOCKET_H
|
||||
|
||||
#include <asm/sockios.h>
|
||||
#include <asm/bitsperlong.h>
|
||||
|
||||
/* For setsockopt(2) */
|
||||
#define SOL_SOCKET 0xffff
|
||||
@ -21,8 +22,8 @@
|
||||
#define SO_RCVBUFFORCE 0x100b
|
||||
#define SO_SNDLOWAT 0x1003
|
||||
#define SO_RCVLOWAT 0x1004
|
||||
#define SO_SNDTIMEO 0x1005
|
||||
#define SO_RCVTIMEO 0x1006
|
||||
#define SO_SNDTIMEO_OLD 0x1005
|
||||
#define SO_RCVTIMEO_OLD 0x1006
|
||||
#define SO_ERROR 0x1007
|
||||
#define SO_TYPE 0x1008
|
||||
#define SO_PROTOCOL 0x1028
|
||||
@ -34,10 +35,6 @@
|
||||
#define SO_BSDCOMPAT 0x400e
|
||||
#define SO_PASSCRED 0x4010
|
||||
#define SO_PEERCRED 0x4011
|
||||
#define SO_TIMESTAMP 0x4012
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
#define SO_TIMESTAMPNS 0x4013
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
|
||||
/* Security levels - as per NRL IPv6 - don't actually do anything */
|
||||
#define SO_SECURITY_AUTHENTICATION 0x4016
|
||||
@ -58,9 +55,6 @@
|
||||
|
||||
#define SO_MARK 0x401f
|
||||
|
||||
#define SO_TIMESTAMPING 0x4020
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#define SO_RXQ_OVFL 0x4021
|
||||
|
||||
#define SO_WIFI_STATUS 0x4022
|
||||
@ -109,4 +103,38 @@
|
||||
|
||||
#define SO_BINDTOIFINDEX 0x4037
|
||||
|
||||
#define SO_TIMESTAMP_OLD 0x4012
|
||||
#define SO_TIMESTAMPNS_OLD 0x4013
|
||||
#define SO_TIMESTAMPING_OLD 0x4020
|
||||
|
||||
#define SO_TIMESTAMP_NEW 0x4038
|
||||
#define SO_TIMESTAMPNS_NEW 0x4039
|
||||
#define SO_TIMESTAMPING_NEW 0x403A
|
||||
|
||||
#define SO_RCVTIMEO_NEW 0x4040
|
||||
#define SO_SNDTIMEO_NEW 0x4041
|
||||
|
||||
#if !defined(__KERNEL__)
|
||||
|
||||
#if __BITS_PER_LONG == 64
|
||||
#define SO_TIMESTAMP SO_TIMESTAMP_OLD
|
||||
#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
|
||||
#define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
|
||||
#define SO_RCVTIMEO SO_RCVTIMEO_OLD
|
||||
#define SO_SNDTIMEO SO_SNDTIMEO_OLD
|
||||
#else
|
||||
#define SO_TIMESTAMP (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMP_OLD : SO_TIMESTAMP_NEW)
|
||||
#define SO_TIMESTAMPNS (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPNS_OLD : SO_TIMESTAMPNS_NEW)
|
||||
#define SO_TIMESTAMPING (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPING_OLD : SO_TIMESTAMPING_NEW)
|
||||
|
||||
#define SO_RCVTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_RCVTIMEO_OLD : SO_RCVTIMEO_NEW)
|
||||
#define SO_SNDTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_SNDTIMEO_OLD : SO_SNDTIMEO_NEW)
|
||||
#endif
|
||||
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _UAPI_ASM_SOCKET_H */
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
#define SO_RCVLOWAT 16
|
||||
#define SO_SNDLOWAT 17
|
||||
#define SO_RCVTIMEO 18
|
||||
#define SO_SNDTIMEO 19
|
||||
#define SO_RCVTIMEO_OLD 18
|
||||
#define SO_SNDTIMEO_OLD 19
|
||||
#define SO_PASSCRED 20
|
||||
#define SO_PEERCRED 21
|
||||
|
||||
|
@ -3,3 +3,4 @@ include include/uapi/asm-generic/Kbuild.asm
|
||||
|
||||
generated-y += unistd_32.h
|
||||
generated-y += unistd_64.h
|
||||
generic-y += socket.h
|
||||
|
@ -1,119 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/*
|
||||
* S390 version
|
||||
*
|
||||
* Derived from "include/asm-i386/socket.h"
|
||||
*/
|
||||
|
||||
#ifndef _ASM_SOCKET_H
|
||||
#define _ASM_SOCKET_H
|
||||
|
||||
#include <asm/sockios.h>
|
||||
|
||||
/* For setsockopt(2) */
|
||||
#define SOL_SOCKET 1
|
||||
|
||||
#define SO_DEBUG 1
|
||||
#define SO_REUSEADDR 2
|
||||
#define SO_TYPE 3
|
||||
#define SO_ERROR 4
|
||||
#define SO_DONTROUTE 5
|
||||
#define SO_BROADCAST 6
|
||||
#define SO_SNDBUF 7
|
||||
#define SO_RCVBUF 8
|
||||
#define SO_SNDBUFFORCE 32
|
||||
#define SO_RCVBUFFORCE 33
|
||||
#define SO_KEEPALIVE 9
|
||||
#define SO_OOBINLINE 10
|
||||
#define SO_NO_CHECK 11
|
||||
#define SO_PRIORITY 12
|
||||
#define SO_LINGER 13
|
||||
#define SO_BSDCOMPAT 14
|
||||
#define SO_REUSEPORT 15
|
||||
#define SO_PASSCRED 16
|
||||
#define SO_PEERCRED 17
|
||||
#define SO_RCVLOWAT 18
|
||||
#define SO_SNDLOWAT 19
|
||||
#define SO_RCVTIMEO 20
|
||||
#define SO_SNDTIMEO 21
|
||||
|
||||
/* Security levels - as per NRL IPv6 - don't actually do anything */
|
||||
#define SO_SECURITY_AUTHENTICATION 22
|
||||
#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
|
||||
#define SO_SECURITY_ENCRYPTION_NETWORK 24
|
||||
|
||||
#define SO_BINDTODEVICE 25
|
||||
|
||||
/* Socket filtering */
|
||||
#define SO_ATTACH_FILTER 26
|
||||
#define SO_DETACH_FILTER 27
|
||||
#define SO_GET_FILTER SO_ATTACH_FILTER
|
||||
|
||||
#define SO_PEERNAME 28
|
||||
#define SO_TIMESTAMP 29
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
|
||||
#define SO_ACCEPTCONN 30
|
||||
|
||||
#define SO_PEERSEC 31
|
||||
#define SO_PASSSEC 34
|
||||
#define SO_TIMESTAMPNS 35
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
|
||||
#define SO_MARK 36
|
||||
|
||||
#define SO_TIMESTAMPING 37
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#define SO_PROTOCOL 38
|
||||
#define SO_DOMAIN 39
|
||||
|
||||
#define SO_RXQ_OVFL 40
|
||||
|
||||
#define SO_WIFI_STATUS 41
|
||||
#define SCM_WIFI_STATUS SO_WIFI_STATUS
|
||||
#define SO_PEEK_OFF 42
|
||||
|
||||
/* Instruct lower device to use last 4-bytes of skb data as FCS */
|
||||
#define SO_NOFCS 43
|
||||
|
||||
#define SO_LOCK_FILTER 44
|
||||
|
||||
#define SO_SELECT_ERR_QUEUE 45
|
||||
|
||||
#define SO_BUSY_POLL 46
|
||||
|
||||
#define SO_MAX_PACING_RATE 47
|
||||
|
||||
#define SO_BPF_EXTENSIONS 48
|
||||
|
||||
#define SO_INCOMING_CPU 49
|
||||
|
||||
#define SO_ATTACH_BPF 50
|
||||
#define SO_DETACH_BPF SO_DETACH_FILTER
|
||||
|
||||
#define SO_ATTACH_REUSEPORT_CBPF 51
|
||||
#define SO_ATTACH_REUSEPORT_EBPF 52
|
||||
|
||||
#define SO_CNX_ADVICE 53
|
||||
|
||||
#define SCM_TIMESTAMPING_OPT_STATS 54
|
||||
|
||||
#define SO_MEMINFO 55
|
||||
|
||||
#define SO_INCOMING_NAPI_ID 56
|
||||
|
||||
#define SO_COOKIE 57
|
||||
|
||||
#define SCM_TIMESTAMPING_PKTINFO 58
|
||||
|
||||
#define SO_PEERGROUPS 59
|
||||
|
||||
#define SO_ZEROCOPY 60
|
||||
|
||||
#define SO_TXTIME 61
|
||||
#define SCM_TXTIME SO_TXTIME
|
||||
|
||||
#define SO_BINDTOIFINDEX 62
|
||||
|
||||
#endif /* _ASM_SOCKET_H */
|
@ -19,6 +19,16 @@ typedef unsigned short __kernel_old_gid_t;
|
||||
typedef int __kernel_suseconds_t;
|
||||
#define __kernel_suseconds_t __kernel_suseconds_t
|
||||
|
||||
typedef long __kernel_long_t;
|
||||
typedef unsigned long __kernel_ulong_t;
|
||||
#define __kernel_long_t __kernel_long_t
|
||||
|
||||
struct __kernel_old_timeval {
|
||||
__kernel_long_t tv_sec;
|
||||
__kernel_suseconds_t tv_usec;
|
||||
};
|
||||
#define __kernel_old_timeval __kernel_old_timeval
|
||||
|
||||
#else
|
||||
/* sparc 32 bit */
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define _ASM_SOCKET_H
|
||||
|
||||
#include <asm/sockios.h>
|
||||
#include <asm/bitsperlong.h>
|
||||
|
||||
/* For setsockopt(2) */
|
||||
#define SOL_SOCKET 0xffff
|
||||
@ -20,8 +21,8 @@
|
||||
#define SO_BSDCOMPAT 0x0400
|
||||
#define SO_RCVLOWAT 0x0800
|
||||
#define SO_SNDLOWAT 0x1000
|
||||
#define SO_RCVTIMEO 0x2000
|
||||
#define SO_SNDTIMEO 0x4000
|
||||
#define SO_RCVTIMEO_OLD 0x2000
|
||||
#define SO_SNDTIMEO_OLD 0x4000
|
||||
#define SO_ACCEPTCONN 0x8000
|
||||
|
||||
#define SO_SNDBUF 0x1001
|
||||
@ -33,7 +34,6 @@
|
||||
#define SO_PROTOCOL 0x1028
|
||||
#define SO_DOMAIN 0x1029
|
||||
|
||||
|
||||
/* Linux specific, keep the same. */
|
||||
#define SO_NO_CHECK 0x000b
|
||||
#define SO_PRIORITY 0x000c
|
||||
@ -45,19 +45,12 @@
|
||||
#define SO_GET_FILTER SO_ATTACH_FILTER
|
||||
|
||||
#define SO_PEERNAME 0x001c
|
||||
#define SO_TIMESTAMP 0x001d
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
|
||||
#define SO_PEERSEC 0x001e
|
||||
#define SO_PASSSEC 0x001f
|
||||
#define SO_TIMESTAMPNS 0x0021
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
|
||||
#define SO_MARK 0x0022
|
||||
|
||||
#define SO_TIMESTAMPING 0x0023
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#define SO_RXQ_OVFL 0x0024
|
||||
|
||||
#define SO_WIFI_STATUS 0x0025
|
||||
@ -111,4 +104,40 @@
|
||||
#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
|
||||
#define SO_SECURITY_ENCRYPTION_NETWORK 0x5004
|
||||
|
||||
#define SO_TIMESTAMP_OLD 0x001d
|
||||
#define SO_TIMESTAMPNS_OLD 0x0021
|
||||
#define SO_TIMESTAMPING_OLD 0x0023
|
||||
|
||||
#define SO_TIMESTAMP_NEW 0x0041
|
||||
#define SO_TIMESTAMPNS_NEW 0x0042
|
||||
#define SO_TIMESTAMPING_NEW 0x0043
|
||||
|
||||
#define SO_RCVTIMEO_NEW 0x0044
|
||||
#define SO_SNDTIMEO_NEW 0x0045
|
||||
|
||||
#if !defined(__KERNEL__)
|
||||
|
||||
|
||||
#if __BITS_PER_LONG == 64
|
||||
#define SO_TIMESTAMP SO_TIMESTAMP_OLD
|
||||
#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
|
||||
#define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
|
||||
|
||||
#define SO_RCVTIMEO SO_RCVTIMEO_OLD
|
||||
#define SO_SNDTIMEO SO_SNDTIMEO_OLD
|
||||
#else
|
||||
#define SO_TIMESTAMP (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMP_OLD : SO_TIMESTAMP_NEW)
|
||||
#define SO_TIMESTAMPNS (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPNS_OLD : SO_TIMESTAMPNS_NEW)
|
||||
#define SO_TIMESTAMPING (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPING_OLD : SO_TIMESTAMPING_NEW)
|
||||
|
||||
#define SO_RCVTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_RCVTIMEO_OLD : SO_RCVTIMEO_NEW)
|
||||
#define SO_SNDTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_SNDTIMEO_OLD : SO_SNDTIMEO_NEW)
|
||||
#endif
|
||||
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _ASM_SOCKET_H */
|
||||
|
@ -3,3 +3,4 @@ include include/uapi/asm-generic/Kbuild.asm
|
||||
generated-y += unistd_32.h
|
||||
generated-y += unistd_64.h
|
||||
generated-y += unistd_x32.h
|
||||
generic-y += socket.h
|
||||
|
@ -1 +0,0 @@
|
||||
#include <asm-generic/socket.h>
|
@ -25,6 +25,7 @@ generic-y += percpu.h
|
||||
generic-y += preempt.h
|
||||
generic-y += rwsem.h
|
||||
generic-y += sections.h
|
||||
generic-y += socket.h
|
||||
generic-y += topology.h
|
||||
generic-y += trace_clock.h
|
||||
generic-y += vga.h
|
||||
|
@ -2,3 +2,4 @@ include include/uapi/asm-generic/Kbuild.asm
|
||||
|
||||
generated-y += unistd_32.h
|
||||
generic-y += kvm_para.h
|
||||
generic-y += socket.h
|
||||
|
@ -1,124 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/*
|
||||
* include/asm-xtensa/socket.h
|
||||
*
|
||||
* Copied from i386.
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef _XTENSA_SOCKET_H
|
||||
#define _XTENSA_SOCKET_H
|
||||
|
||||
#include <asm/sockios.h>
|
||||
|
||||
/* For setsockoptions(2) */
|
||||
#define SOL_SOCKET 1
|
||||
|
||||
#define SO_DEBUG 1
|
||||
#define SO_REUSEADDR 2
|
||||
#define SO_TYPE 3
|
||||
#define SO_ERROR 4
|
||||
#define SO_DONTROUTE 5
|
||||
#define SO_BROADCAST 6
|
||||
#define SO_SNDBUF 7
|
||||
#define SO_RCVBUF 8
|
||||
#define SO_SNDBUFFORCE 32
|
||||
#define SO_RCVBUFFORCE 33
|
||||
#define SO_KEEPALIVE 9
|
||||
#define SO_OOBINLINE 10
|
||||
#define SO_NO_CHECK 11
|
||||
#define SO_PRIORITY 12
|
||||
#define SO_LINGER 13
|
||||
#define SO_BSDCOMPAT 14
|
||||
#define SO_REUSEPORT 15
|
||||
#define SO_PASSCRED 16
|
||||
#define SO_PEERCRED 17
|
||||
#define SO_RCVLOWAT 18
|
||||
#define SO_SNDLOWAT 19
|
||||
#define SO_RCVTIMEO 20
|
||||
#define SO_SNDTIMEO 21
|
||||
|
||||
/* Security levels - as per NRL IPv6 - don't actually do anything */
|
||||
|
||||
#define SO_SECURITY_AUTHENTICATION 22
|
||||
#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
|
||||
#define SO_SECURITY_ENCRYPTION_NETWORK 24
|
||||
|
||||
#define SO_BINDTODEVICE 25
|
||||
|
||||
/* Socket filtering */
|
||||
|
||||
#define SO_ATTACH_FILTER 26
|
||||
#define SO_DETACH_FILTER 27
|
||||
#define SO_GET_FILTER SO_ATTACH_FILTER
|
||||
|
||||
#define SO_PEERNAME 28
|
||||
#define SO_TIMESTAMP 29
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
|
||||
#define SO_ACCEPTCONN 30
|
||||
#define SO_PEERSEC 31
|
||||
#define SO_PASSSEC 34
|
||||
#define SO_TIMESTAMPNS 35
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
|
||||
#define SO_MARK 36
|
||||
|
||||
#define SO_TIMESTAMPING 37
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#define SO_PROTOCOL 38
|
||||
#define SO_DOMAIN 39
|
||||
|
||||
#define SO_RXQ_OVFL 40
|
||||
|
||||
#define SO_WIFI_STATUS 41
|
||||
#define SCM_WIFI_STATUS SO_WIFI_STATUS
|
||||
#define SO_PEEK_OFF 42
|
||||
|
||||
/* Instruct lower device to use last 4-bytes of skb data as FCS */
|
||||
#define SO_NOFCS 43
|
||||
|
||||
#define SO_LOCK_FILTER 44
|
||||
|
||||
#define SO_SELECT_ERR_QUEUE 45
|
||||
|
||||
#define SO_BUSY_POLL 46
|
||||
|
||||
#define SO_MAX_PACING_RATE 47
|
||||
|
||||
#define SO_BPF_EXTENSIONS 48
|
||||
|
||||
#define SO_INCOMING_CPU 49
|
||||
|
||||
#define SO_ATTACH_BPF 50
|
||||
#define SO_DETACH_BPF SO_DETACH_FILTER
|
||||
|
||||
#define SO_ATTACH_REUSEPORT_CBPF 51
|
||||
#define SO_ATTACH_REUSEPORT_EBPF 52
|
||||
|
||||
#define SO_CNX_ADVICE 53
|
||||
|
||||
#define SCM_TIMESTAMPING_OPT_STATS 54
|
||||
|
||||
#define SO_MEMINFO 55
|
||||
|
||||
#define SO_INCOMING_NAPI_ID 56
|
||||
|
||||
#define SO_COOKIE 57
|
||||
|
||||
#define SCM_TIMESTAMPING_PKTINFO 58
|
||||
|
||||
#define SO_PEERGROUPS 59
|
||||
|
||||
#define SO_ZEROCOPY 60
|
||||
|
||||
#define SO_TXTIME 61
|
||||
#define SCM_TXTIME SO_TXTIME
|
||||
|
||||
#define SO_BINDTOIFINDEX 62
|
||||
|
||||
#endif /* _XTENSA_SOCKET_H */
|
@ -103,7 +103,7 @@ mISDN_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
|
||||
static inline void
|
||||
mISDN_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct __kernel_old_timeval tv;
|
||||
|
||||
if (_pms(sk)->cmask & MISDN_TIME_STAMP) {
|
||||
skb_get_timestamp(skb, &tv);
|
||||
|
@ -1089,12 +1089,12 @@ static void sctp_connect_to_sock(struct connection *con)
|
||||
* since O_NONBLOCK argument in connect() function does not work here,
|
||||
* then, we should restore the default value of this attribute.
|
||||
*/
|
||||
kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,
|
||||
kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_OLD, (char *)&tv,
|
||||
sizeof(tv));
|
||||
result = sock->ops->connect(sock, (struct sockaddr *)&daddr, addr_len,
|
||||
0);
|
||||
memset(&tv, 0, sizeof(tv));
|
||||
kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv,
|
||||
kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_OLD, (char *)&tv,
|
||||
sizeof(tv));
|
||||
|
||||
if (result == -EINPROGRESS)
|
||||
|
@ -3486,16 +3486,25 @@ static inline ktime_t skb_get_ktime(const struct sk_buff *skb)
|
||||
/**
|
||||
* skb_get_timestamp - get timestamp from a skb
|
||||
* @skb: skb to get stamp from
|
||||
* @stamp: pointer to struct timeval to store stamp in
|
||||
* @stamp: pointer to struct __kernel_old_timeval to store stamp in
|
||||
*
|
||||
* Timestamps are stored in the skb as offsets to a base timestamp.
|
||||
* This function converts the offset back to a struct timeval and stores
|
||||
* it in stamp.
|
||||
*/
|
||||
static inline void skb_get_timestamp(const struct sk_buff *skb,
|
||||
struct timeval *stamp)
|
||||
struct __kernel_old_timeval *stamp)
|
||||
{
|
||||
*stamp = ktime_to_timeval(skb->tstamp);
|
||||
*stamp = ns_to_kernel_old_timeval(skb->tstamp);
|
||||
}
|
||||
|
||||
static inline void skb_get_new_timestamp(const struct sk_buff *skb,
|
||||
struct __kernel_sock_timeval *stamp)
|
||||
{
|
||||
struct timespec64 ts = ktime_to_timespec64(skb->tstamp);
|
||||
|
||||
stamp->tv_sec = ts.tv_sec;
|
||||
stamp->tv_usec = ts.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
static inline void skb_get_timestampns(const struct sk_buff *skb,
|
||||
@ -3504,6 +3513,15 @@ static inline void skb_get_timestampns(const struct sk_buff *skb,
|
||||
*stamp = ktime_to_timespec(skb->tstamp);
|
||||
}
|
||||
|
||||
static inline void skb_get_new_timestampns(const struct sk_buff *skb,
|
||||
struct __kernel_timespec *stamp)
|
||||
{
|
||||
struct timespec64 ts = ktime_to_timespec64(skb->tstamp);
|
||||
|
||||
stamp->tv_sec = ts.tv_sec;
|
||||
stamp->tv_nsec = ts.tv_nsec;
|
||||
}
|
||||
|
||||
static inline void __net_timestamp(struct sk_buff *skb)
|
||||
{
|
||||
skb->tstamp = ktime_get_real();
|
||||
|
@ -349,9 +349,17 @@ struct ucred {
|
||||
extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr_storage *kaddr);
|
||||
extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
|
||||
|
||||
struct timespec64;
|
||||
struct __kernel_timespec;
|
||||
struct old_timespec32;
|
||||
|
||||
struct scm_timestamping_internal {
|
||||
struct timespec64 ts[3];
|
||||
};
|
||||
|
||||
extern void put_cmsg_scm_timestamping64(struct msghdr *msg, struct scm_timestamping_internal *tss);
|
||||
extern void put_cmsg_scm_timestamping(struct msghdr *msg, struct scm_timestamping_internal *tss);
|
||||
|
||||
/* The __sys_...msg variants allow MSG_CMSG_COMPAT iff
|
||||
* forbid_cmsg_compat==false
|
||||
*/
|
||||
|
@ -805,6 +805,7 @@ enum sock_flags {
|
||||
SOCK_RCU_FREE, /* wait rcu grace period in sk_destruct() */
|
||||
SOCK_TXTIME,
|
||||
SOCK_XDP, /* XDP is attached */
|
||||
SOCK_TSTAMP_NEW, /* Indicates 64 bit timestamps always */
|
||||
};
|
||||
|
||||
#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define __ASM_GENERIC_SOCKET_H
|
||||
|
||||
#include <asm/sockios.h>
|
||||
#include <asm/bitsperlong.h>
|
||||
|
||||
/* For setsockopt(2) */
|
||||
#define SOL_SOCKET 1
|
||||
@ -29,8 +30,8 @@
|
||||
#define SO_PEERCRED 17
|
||||
#define SO_RCVLOWAT 18
|
||||
#define SO_SNDLOWAT 19
|
||||
#define SO_RCVTIMEO 20
|
||||
#define SO_SNDTIMEO 21
|
||||
#define SO_RCVTIMEO_OLD 20
|
||||
#define SO_SNDTIMEO_OLD 21
|
||||
#endif
|
||||
|
||||
/* Security levels - as per NRL IPv6 - don't actually do anything */
|
||||
@ -46,21 +47,14 @@
|
||||
#define SO_GET_FILTER SO_ATTACH_FILTER
|
||||
|
||||
#define SO_PEERNAME 28
|
||||
#define SO_TIMESTAMP 29
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
|
||||
#define SO_ACCEPTCONN 30
|
||||
|
||||
#define SO_PEERSEC 31
|
||||
#define SO_PASSSEC 34
|
||||
#define SO_TIMESTAMPNS 35
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
|
||||
#define SO_MARK 36
|
||||
|
||||
#define SO_TIMESTAMPING 37
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#define SO_PROTOCOL 38
|
||||
#define SO_DOMAIN 39
|
||||
|
||||
@ -112,4 +106,40 @@
|
||||
|
||||
#define SO_BINDTOIFINDEX 62
|
||||
|
||||
#define SO_TIMESTAMP_OLD 29
|
||||
#define SO_TIMESTAMPNS_OLD 35
|
||||
#define SO_TIMESTAMPING_OLD 37
|
||||
|
||||
#define SO_TIMESTAMP_NEW 63
|
||||
#define SO_TIMESTAMPNS_NEW 64
|
||||
#define SO_TIMESTAMPING_NEW 65
|
||||
|
||||
#define SO_RCVTIMEO_NEW 66
|
||||
#define SO_SNDTIMEO_NEW 67
|
||||
|
||||
#if !defined(__KERNEL__)
|
||||
|
||||
#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))
|
||||
/* on 64-bit and x32, avoid the ?: operator */
|
||||
#define SO_TIMESTAMP SO_TIMESTAMP_OLD
|
||||
#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
|
||||
#define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
|
||||
|
||||
#define SO_RCVTIMEO SO_RCVTIMEO_OLD
|
||||
#define SO_SNDTIMEO SO_SNDTIMEO_OLD
|
||||
#else
|
||||
#define SO_TIMESTAMP (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMP_OLD : SO_TIMESTAMP_NEW)
|
||||
#define SO_TIMESTAMPNS (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPNS_OLD : SO_TIMESTAMPNS_NEW)
|
||||
#define SO_TIMESTAMPING (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPING_OLD : SO_TIMESTAMPING_NEW)
|
||||
|
||||
#define SO_RCVTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_RCVTIMEO_OLD : SO_RCVTIMEO_NEW)
|
||||
#define SO_SNDTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_SNDTIMEO_OLD : SO_SNDTIMEO_NEW)
|
||||
#endif
|
||||
|
||||
#define SCM_TIMESTAMP SO_TIMESTAMP
|
||||
#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
|
||||
#define SCM_TIMESTAMPING SO_TIMESTAMPING
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __ASM_GENERIC_SOCKET_H */
|
||||
|
@ -41,6 +41,10 @@ struct scm_timestamping {
|
||||
struct timespec ts[3];
|
||||
};
|
||||
|
||||
struct scm_timestamping64 {
|
||||
struct __kernel_timespec ts[3];
|
||||
};
|
||||
|
||||
/* The type of scm_timestamping, passed in sock_extended_err ee_info.
|
||||
* This defines the type of ts[0]. For SCM_TSTAMP_SND only, if ts[0]
|
||||
* is zero, then this is a hardware timestamp and recorded in ts[2].
|
||||
|
@ -63,10 +63,17 @@ struct __kernel_itimerspec {
|
||||
* here, this is probably because it is not y2038 safe and needs to
|
||||
* be changed to use another interface.
|
||||
*/
|
||||
#ifndef __kernel_old_timeval
|
||||
struct __kernel_old_timeval {
|
||||
__kernel_long_t tv_sec;
|
||||
__kernel_long_t tv_usec;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct __kernel_sock_timeval {
|
||||
__s64 tv_sec;
|
||||
__s64 tv_usec;
|
||||
};
|
||||
|
||||
/*
|
||||
* The IDs of the various system clocks (for POSIX.1b interval timers):
|
||||
|
@ -1383,9 +1383,9 @@ static void hci_sock_cmsg(struct sock *sk, struct msghdr *msg,
|
||||
|
||||
if (mask & HCI_CMSG_TSTAMP) {
|
||||
#ifdef CONFIG_COMPAT
|
||||
struct compat_timeval ctv;
|
||||
struct old_timeval32 ctv;
|
||||
#endif
|
||||
struct timeval tv;
|
||||
struct __kernel_old_timeval tv;
|
||||
void *data;
|
||||
int len;
|
||||
|
||||
|
78
net/compat.c
78
net/compat.c
@ -209,8 +209,8 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
|
||||
{
|
||||
struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
|
||||
struct compat_cmsghdr cmhdr;
|
||||
struct compat_timeval ctv;
|
||||
struct compat_timespec cts[3];
|
||||
struct old_timeval32 ctv;
|
||||
struct old_timespec32 cts[3];
|
||||
int cmlen;
|
||||
|
||||
if (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) {
|
||||
@ -219,16 +219,16 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
|
||||
}
|
||||
|
||||
if (!COMPAT_USE_64BIT_TIME) {
|
||||
if (level == SOL_SOCKET && type == SCM_TIMESTAMP) {
|
||||
struct timeval *tv = (struct timeval *)data;
|
||||
if (level == SOL_SOCKET && type == SO_TIMESTAMP_OLD) {
|
||||
struct __kernel_old_timeval *tv = (struct __kernel_old_timeval *)data;
|
||||
ctv.tv_sec = tv->tv_sec;
|
||||
ctv.tv_usec = tv->tv_usec;
|
||||
data = &ctv;
|
||||
len = sizeof(ctv);
|
||||
}
|
||||
if (level == SOL_SOCKET &&
|
||||
(type == SCM_TIMESTAMPNS || type == SCM_TIMESTAMPING)) {
|
||||
int count = type == SCM_TIMESTAMPNS ? 1 : 3;
|
||||
(type == SO_TIMESTAMPNS_OLD || type == SO_TIMESTAMPING_OLD)) {
|
||||
int count = type == SO_TIMESTAMPNS_OLD ? 1 : 3;
|
||||
int i;
|
||||
struct timespec *ts = (struct timespec *)data;
|
||||
for (i = 0; i < count; i++) {
|
||||
@ -348,28 +348,6 @@ static int do_set_attach_filter(struct socket *sock, int level, int optname,
|
||||
sizeof(struct sock_fprog));
|
||||
}
|
||||
|
||||
static int do_set_sock_timeout(struct socket *sock, int level,
|
||||
int optname, char __user *optval, unsigned int optlen)
|
||||
{
|
||||
struct compat_timeval __user *up = (struct compat_timeval __user *)optval;
|
||||
struct timeval ktime;
|
||||
mm_segment_t old_fs;
|
||||
int err;
|
||||
|
||||
if (optlen < sizeof(*up))
|
||||
return -EINVAL;
|
||||
if (!access_ok(up, sizeof(*up)) ||
|
||||
__get_user(ktime.tv_sec, &up->tv_sec) ||
|
||||
__get_user(ktime.tv_usec, &up->tv_usec))
|
||||
return -EFAULT;
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
|
||||
set_fs(old_fs);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int compat_sock_setsockopt(struct socket *sock, int level, int optname,
|
||||
char __user *optval, unsigned int optlen)
|
||||
{
|
||||
@ -377,10 +355,6 @@ static int compat_sock_setsockopt(struct socket *sock, int level, int optname,
|
||||
optname == SO_ATTACH_REUSEPORT_CBPF)
|
||||
return do_set_attach_filter(sock, level, optname,
|
||||
optval, optlen);
|
||||
if (!COMPAT_USE_64BIT_TIME &&
|
||||
(optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
|
||||
return do_set_sock_timeout(sock, level, optname, optval, optlen);
|
||||
|
||||
return sock_setsockopt(sock, level, optname, optval, optlen);
|
||||
}
|
||||
|
||||
@ -417,44 +391,6 @@ COMPAT_SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname,
|
||||
return __compat_sys_setsockopt(fd, level, optname, optval, optlen);
|
||||
}
|
||||
|
||||
static int do_get_sock_timeout(struct socket *sock, int level, int optname,
|
||||
char __user *optval, int __user *optlen)
|
||||
{
|
||||
struct compat_timeval __user *up;
|
||||
struct timeval ktime;
|
||||
mm_segment_t old_fs;
|
||||
int len, err;
|
||||
|
||||
up = (struct compat_timeval __user *) optval;
|
||||
if (get_user(len, optlen))
|
||||
return -EFAULT;
|
||||
if (len < sizeof(*up))
|
||||
return -EINVAL;
|
||||
len = sizeof(ktime);
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
|
||||
set_fs(old_fs);
|
||||
|
||||
if (!err) {
|
||||
if (put_user(sizeof(*up), optlen) ||
|
||||
!access_ok(up, sizeof(*up)) ||
|
||||
__put_user(ktime.tv_sec, &up->tv_sec) ||
|
||||
__put_user(ktime.tv_usec, &up->tv_usec))
|
||||
err = -EFAULT;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static int compat_sock_getsockopt(struct socket *sock, int level, int optname,
|
||||
char __user *optval, int __user *optlen)
|
||||
{
|
||||
if (!COMPAT_USE_64BIT_TIME &&
|
||||
(optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
|
||||
return do_get_sock_timeout(sock, level, optname, optval, optlen);
|
||||
return sock_getsockopt(sock, level, optname, optval, optlen);
|
||||
}
|
||||
|
||||
int compat_sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
|
||||
{
|
||||
struct compat_timeval __user *ctv;
|
||||
@ -527,7 +463,7 @@ static int __compat_sys_getsockopt(int fd, int level, int optname,
|
||||
}
|
||||
|
||||
if (level == SOL_SOCKET)
|
||||
err = compat_sock_getsockopt(sock, level,
|
||||
err = sock_getsockopt(sock, level,
|
||||
optname, optval, optlen);
|
||||
else if (sock->ops->compat_getsockopt)
|
||||
err = sock->ops->compat_getsockopt(sock, level,
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <linux/pid.h>
|
||||
#include <linux/nsproxy.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/errqueue.h>
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
@ -252,6 +253,32 @@ out:
|
||||
}
|
||||
EXPORT_SYMBOL(put_cmsg);
|
||||
|
||||
void put_cmsg_scm_timestamping64(struct msghdr *msg, struct scm_timestamping_internal *tss_internal)
|
||||
{
|
||||
struct scm_timestamping64 tss;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tss.ts); i++) {
|
||||
tss.ts[i].tv_sec = tss_internal->ts[i].tv_sec;
|
||||
tss.ts[i].tv_nsec = tss_internal->ts[i].tv_nsec;
|
||||
}
|
||||
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPING_NEW, sizeof(tss), &tss);
|
||||
}
|
||||
EXPORT_SYMBOL(put_cmsg_scm_timestamping64);
|
||||
|
||||
void put_cmsg_scm_timestamping(struct msghdr *msg, struct scm_timestamping_internal *tss_internal)
|
||||
{
|
||||
struct scm_timestamping tss;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tss.ts); i++)
|
||||
tss.ts[i] = timespec64_to_timespec(tss_internal->ts[i]);
|
||||
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPING_OLD, sizeof(tss), &tss);
|
||||
}
|
||||
EXPORT_SYMBOL(put_cmsg_scm_timestamping);
|
||||
|
||||
void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
|
||||
{
|
||||
struct cmsghdr __user *cm
|
||||
|
151
net/core/sock.c
151
net/core/sock.c
@ -335,14 +335,68 @@ int __sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
|
||||
}
|
||||
EXPORT_SYMBOL(__sk_backlog_rcv);
|
||||
|
||||
static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen)
|
||||
static int sock_get_timeout(long timeo, void *optval, bool old_timeval)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct __kernel_sock_timeval tv;
|
||||
int size;
|
||||
|
||||
if (optlen < sizeof(tv))
|
||||
return -EINVAL;
|
||||
if (copy_from_user(&tv, optval, sizeof(tv)))
|
||||
return -EFAULT;
|
||||
if (timeo == MAX_SCHEDULE_TIMEOUT) {
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
} else {
|
||||
tv.tv_sec = timeo / HZ;
|
||||
tv.tv_usec = ((timeo % HZ) * USEC_PER_SEC) / HZ;
|
||||
}
|
||||
|
||||
if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
|
||||
struct old_timeval32 tv32 = { tv.tv_sec, tv.tv_usec };
|
||||
*(struct old_timeval32 *)optval = tv32;
|
||||
return sizeof(tv32);
|
||||
}
|
||||
|
||||
if (old_timeval) {
|
||||
struct __kernel_old_timeval old_tv;
|
||||
old_tv.tv_sec = tv.tv_sec;
|
||||
old_tv.tv_usec = tv.tv_usec;
|
||||
*(struct __kernel_old_timeval *)optval = old_tv;
|
||||
size = sizeof(old_tv);
|
||||
} else {
|
||||
*(struct __kernel_sock_timeval *)optval = tv;
|
||||
size = sizeof(tv);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool old_timeval)
|
||||
{
|
||||
struct __kernel_sock_timeval tv;
|
||||
|
||||
if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
|
||||
struct old_timeval32 tv32;
|
||||
|
||||
if (optlen < sizeof(tv32))
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_from_user(&tv32, optval, sizeof(tv32)))
|
||||
return -EFAULT;
|
||||
tv.tv_sec = tv32.tv_sec;
|
||||
tv.tv_usec = tv32.tv_usec;
|
||||
} else if (old_timeval) {
|
||||
struct __kernel_old_timeval old_tv;
|
||||
|
||||
if (optlen < sizeof(old_tv))
|
||||
return -EINVAL;
|
||||
if (copy_from_user(&old_tv, optval, sizeof(old_tv)))
|
||||
return -EFAULT;
|
||||
tv.tv_sec = old_tv.tv_sec;
|
||||
tv.tv_usec = old_tv.tv_usec;
|
||||
} else {
|
||||
if (optlen < sizeof(tv))
|
||||
return -EINVAL;
|
||||
if (copy_from_user(&tv, optval, sizeof(tv)))
|
||||
return -EFAULT;
|
||||
}
|
||||
if (tv.tv_usec < 0 || tv.tv_usec >= USEC_PER_SEC)
|
||||
return -EDOM;
|
||||
|
||||
@ -360,8 +414,8 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen)
|
||||
*timeo_p = MAX_SCHEDULE_TIMEOUT;
|
||||
if (tv.tv_sec == 0 && tv.tv_usec == 0)
|
||||
return 0;
|
||||
if (tv.tv_sec < (MAX_SCHEDULE_TIMEOUT/HZ - 1))
|
||||
*timeo_p = tv.tv_sec * HZ + DIV_ROUND_UP(tv.tv_usec, USEC_PER_SEC / HZ);
|
||||
if (tv.tv_sec < (MAX_SCHEDULE_TIMEOUT / HZ - 1))
|
||||
*timeo_p = tv.tv_sec * HZ + DIV_ROUND_UP((unsigned long)tv.tv_usec, USEC_PER_SEC / HZ);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -833,10 +887,17 @@ set_rcvbuf:
|
||||
clear_bit(SOCK_PASSCRED, &sock->flags);
|
||||
break;
|
||||
|
||||
case SO_TIMESTAMP:
|
||||
case SO_TIMESTAMPNS:
|
||||
case SO_TIMESTAMP_OLD:
|
||||
case SO_TIMESTAMP_NEW:
|
||||
case SO_TIMESTAMPNS_OLD:
|
||||
case SO_TIMESTAMPNS_NEW:
|
||||
if (valbool) {
|
||||
if (optname == SO_TIMESTAMP)
|
||||
if (optname == SO_TIMESTAMP_NEW || optname == SO_TIMESTAMPNS_NEW)
|
||||
sock_set_flag(sk, SOCK_TSTAMP_NEW);
|
||||
else
|
||||
sock_reset_flag(sk, SOCK_TSTAMP_NEW);
|
||||
|
||||
if (optname == SO_TIMESTAMP_OLD || optname == SO_TIMESTAMP_NEW)
|
||||
sock_reset_flag(sk, SOCK_RCVTSTAMPNS);
|
||||
else
|
||||
sock_set_flag(sk, SOCK_RCVTSTAMPNS);
|
||||
@ -845,10 +906,13 @@ set_rcvbuf:
|
||||
} else {
|
||||
sock_reset_flag(sk, SOCK_RCVTSTAMP);
|
||||
sock_reset_flag(sk, SOCK_RCVTSTAMPNS);
|
||||
sock_reset_flag(sk, SOCK_TSTAMP_NEW);
|
||||
}
|
||||
break;
|
||||
|
||||
case SO_TIMESTAMPING:
|
||||
case SO_TIMESTAMPING_NEW:
|
||||
sock_set_flag(sk, SOCK_TSTAMP_NEW);
|
||||
case SO_TIMESTAMPING_OLD:
|
||||
if (val & ~SOF_TIMESTAMPING_MASK) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
@ -879,9 +943,13 @@ set_rcvbuf:
|
||||
if (val & SOF_TIMESTAMPING_RX_SOFTWARE)
|
||||
sock_enable_timestamp(sk,
|
||||
SOCK_TIMESTAMPING_RX_SOFTWARE);
|
||||
else
|
||||
else {
|
||||
if (optname == SO_TIMESTAMPING_NEW)
|
||||
sock_reset_flag(sk, SOCK_TSTAMP_NEW);
|
||||
|
||||
sock_disable_timestamp(sk,
|
||||
(1UL << SOCK_TIMESTAMPING_RX_SOFTWARE));
|
||||
}
|
||||
break;
|
||||
|
||||
case SO_RCVLOWAT:
|
||||
@ -893,12 +961,14 @@ set_rcvbuf:
|
||||
sk->sk_rcvlowat = val ? : 1;
|
||||
break;
|
||||
|
||||
case SO_RCVTIMEO:
|
||||
ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen);
|
||||
case SO_RCVTIMEO_OLD:
|
||||
case SO_RCVTIMEO_NEW:
|
||||
ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen, optname == SO_RCVTIMEO_OLD);
|
||||
break;
|
||||
|
||||
case SO_SNDTIMEO:
|
||||
ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen);
|
||||
case SO_SNDTIMEO_OLD:
|
||||
case SO_SNDTIMEO_NEW:
|
||||
ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen, optname == SO_SNDTIMEO_OLD);
|
||||
break;
|
||||
|
||||
case SO_ATTACH_FILTER:
|
||||
@ -1121,7 +1191,9 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
|
||||
int val;
|
||||
u64 val64;
|
||||
struct linger ling;
|
||||
struct timeval tm;
|
||||
struct old_timeval32 tm32;
|
||||
struct __kernel_old_timeval tm;
|
||||
struct __kernel_sock_timeval stm;
|
||||
struct sock_txtime txtime;
|
||||
} v;
|
||||
|
||||
@ -1208,39 +1280,36 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
|
||||
sock_warn_obsolete_bsdism("getsockopt");
|
||||
break;
|
||||
|
||||
case SO_TIMESTAMP:
|
||||
case SO_TIMESTAMP_OLD:
|
||||
v.val = sock_flag(sk, SOCK_RCVTSTAMP) &&
|
||||
!sock_flag(sk, SOCK_TSTAMP_NEW) &&
|
||||
!sock_flag(sk, SOCK_RCVTSTAMPNS);
|
||||
break;
|
||||
|
||||
case SO_TIMESTAMPNS:
|
||||
v.val = sock_flag(sk, SOCK_RCVTSTAMPNS);
|
||||
case SO_TIMESTAMPNS_OLD:
|
||||
v.val = sock_flag(sk, SOCK_RCVTSTAMPNS) && !sock_flag(sk, SOCK_TSTAMP_NEW);
|
||||
break;
|
||||
|
||||
case SO_TIMESTAMPING:
|
||||
case SO_TIMESTAMP_NEW:
|
||||
v.val = sock_flag(sk, SOCK_RCVTSTAMP) && sock_flag(sk, SOCK_TSTAMP_NEW);
|
||||
break;
|
||||
|
||||
case SO_TIMESTAMPNS_NEW:
|
||||
v.val = sock_flag(sk, SOCK_RCVTSTAMPNS) && sock_flag(sk, SOCK_TSTAMP_NEW);
|
||||
break;
|
||||
|
||||
case SO_TIMESTAMPING_OLD:
|
||||
v.val = sk->sk_tsflags;
|
||||
break;
|
||||
|
||||
case SO_RCVTIMEO:
|
||||
lv = sizeof(struct timeval);
|
||||
if (sk->sk_rcvtimeo == MAX_SCHEDULE_TIMEOUT) {
|
||||
v.tm.tv_sec = 0;
|
||||
v.tm.tv_usec = 0;
|
||||
} else {
|
||||
v.tm.tv_sec = sk->sk_rcvtimeo / HZ;
|
||||
v.tm.tv_usec = ((sk->sk_rcvtimeo % HZ) * USEC_PER_SEC) / HZ;
|
||||
}
|
||||
case SO_RCVTIMEO_OLD:
|
||||
case SO_RCVTIMEO_NEW:
|
||||
lv = sock_get_timeout(sk->sk_rcvtimeo, &v, SO_RCVTIMEO_OLD == optname);
|
||||
break;
|
||||
|
||||
case SO_SNDTIMEO:
|
||||
lv = sizeof(struct timeval);
|
||||
if (sk->sk_sndtimeo == MAX_SCHEDULE_TIMEOUT) {
|
||||
v.tm.tv_sec = 0;
|
||||
v.tm.tv_usec = 0;
|
||||
} else {
|
||||
v.tm.tv_sec = sk->sk_sndtimeo / HZ;
|
||||
v.tm.tv_usec = ((sk->sk_sndtimeo % HZ) * USEC_PER_SEC) / HZ;
|
||||
}
|
||||
case SO_SNDTIMEO_OLD:
|
||||
case SO_SNDTIMEO_NEW:
|
||||
lv = sock_get_timeout(sk->sk_sndtimeo, &v, SO_SNDTIMEO_OLD == optname);
|
||||
break;
|
||||
|
||||
case SO_RCVLOWAT:
|
||||
@ -2147,7 +2216,7 @@ int __sock_cmsg_send(struct sock *sk, struct msghdr *msg, struct cmsghdr *cmsg,
|
||||
return -EINVAL;
|
||||
sockc->mark = *(u32 *)CMSG_DATA(cmsg);
|
||||
break;
|
||||
case SO_TIMESTAMPING:
|
||||
case SO_TIMESTAMPING_OLD:
|
||||
if (cmsg->cmsg_len != CMSG_LEN(sizeof(u32)))
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -1844,57 +1844,78 @@ out:
|
||||
#endif
|
||||
|
||||
static void tcp_update_recv_tstamps(struct sk_buff *skb,
|
||||
struct scm_timestamping *tss)
|
||||
struct scm_timestamping_internal *tss)
|
||||
{
|
||||
if (skb->tstamp)
|
||||
tss->ts[0] = ktime_to_timespec(skb->tstamp);
|
||||
tss->ts[0] = ktime_to_timespec64(skb->tstamp);
|
||||
else
|
||||
tss->ts[0] = (struct timespec) {0};
|
||||
tss->ts[0] = (struct timespec64) {0};
|
||||
|
||||
if (skb_hwtstamps(skb)->hwtstamp)
|
||||
tss->ts[2] = ktime_to_timespec(skb_hwtstamps(skb)->hwtstamp);
|
||||
tss->ts[2] = ktime_to_timespec64(skb_hwtstamps(skb)->hwtstamp);
|
||||
else
|
||||
tss->ts[2] = (struct timespec) {0};
|
||||
tss->ts[2] = (struct timespec64) {0};
|
||||
}
|
||||
|
||||
/* Similar to __sock_recv_timestamp, but does not require an skb */
|
||||
static void tcp_recv_timestamp(struct msghdr *msg, const struct sock *sk,
|
||||
struct scm_timestamping *tss)
|
||||
struct scm_timestamping_internal *tss)
|
||||
{
|
||||
struct timeval tv;
|
||||
int new_tstamp = sock_flag(sk, SOCK_TSTAMP_NEW);
|
||||
bool has_timestamping = false;
|
||||
|
||||
if (tss->ts[0].tv_sec || tss->ts[0].tv_nsec) {
|
||||
if (sock_flag(sk, SOCK_RCVTSTAMP)) {
|
||||
if (sock_flag(sk, SOCK_RCVTSTAMPNS)) {
|
||||
put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMPNS,
|
||||
sizeof(tss->ts[0]), &tss->ts[0]);
|
||||
} else {
|
||||
tv.tv_sec = tss->ts[0].tv_sec;
|
||||
tv.tv_usec = tss->ts[0].tv_nsec / 1000;
|
||||
if (new_tstamp) {
|
||||
struct __kernel_timespec kts = {tss->ts[0].tv_sec, tss->ts[0].tv_nsec};
|
||||
|
||||
put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMP,
|
||||
sizeof(tv), &tv);
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_NEW,
|
||||
sizeof(kts), &kts);
|
||||
} else {
|
||||
struct timespec ts_old = timespec64_to_timespec(tss->ts[0]);
|
||||
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_OLD,
|
||||
sizeof(ts_old), &ts_old);
|
||||
}
|
||||
} else {
|
||||
if (new_tstamp) {
|
||||
struct __kernel_sock_timeval stv;
|
||||
|
||||
stv.tv_sec = tss->ts[0].tv_sec;
|
||||
stv.tv_usec = tss->ts[0].tv_nsec / 1000;
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_NEW,
|
||||
sizeof(stv), &stv);
|
||||
} else {
|
||||
struct __kernel_old_timeval tv;
|
||||
|
||||
tv.tv_sec = tss->ts[0].tv_sec;
|
||||
tv.tv_usec = tss->ts[0].tv_nsec / 1000;
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD,
|
||||
sizeof(tv), &tv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sk->sk_tsflags & SOF_TIMESTAMPING_SOFTWARE)
|
||||
has_timestamping = true;
|
||||
else
|
||||
tss->ts[0] = (struct timespec) {0};
|
||||
tss->ts[0] = (struct timespec64) {0};
|
||||
}
|
||||
|
||||
if (tss->ts[2].tv_sec || tss->ts[2].tv_nsec) {
|
||||
if (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE)
|
||||
has_timestamping = true;
|
||||
else
|
||||
tss->ts[2] = (struct timespec) {0};
|
||||
tss->ts[2] = (struct timespec64) {0};
|
||||
}
|
||||
|
||||
if (has_timestamping) {
|
||||
tss->ts[1] = (struct timespec) {0};
|
||||
put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMPING,
|
||||
sizeof(*tss), tss);
|
||||
tss->ts[1] = (struct timespec64) {0};
|
||||
if (sock_flag(sk, SOCK_TSTAMP_NEW))
|
||||
put_cmsg_scm_timestamping64(msg, tss);
|
||||
else
|
||||
put_cmsg_scm_timestamping(msg, tss);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1935,7 +1956,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
|
||||
long timeo;
|
||||
struct sk_buff *skb, *last;
|
||||
u32 urg_hole = 0;
|
||||
struct scm_timestamping tss;
|
||||
struct scm_timestamping_internal tss;
|
||||
bool has_tss = false;
|
||||
bool has_cmsg;
|
||||
|
||||
|
@ -348,7 +348,7 @@ static int rds_set_transport(struct rds_sock *rs, char __user *optval,
|
||||
}
|
||||
|
||||
static int rds_enable_recvtstamp(struct sock *sk, char __user *optval,
|
||||
int optlen)
|
||||
int optlen, int optname)
|
||||
{
|
||||
int val, valbool;
|
||||
|
||||
@ -360,6 +360,9 @@ static int rds_enable_recvtstamp(struct sock *sk, char __user *optval,
|
||||
|
||||
valbool = val ? 1 : 0;
|
||||
|
||||
if (optname == SO_TIMESTAMP_NEW)
|
||||
sock_set_flag(sk, SOCK_TSTAMP_NEW);
|
||||
|
||||
if (valbool)
|
||||
sock_set_flag(sk, SOCK_RCVTSTAMP);
|
||||
else
|
||||
@ -430,9 +433,10 @@ static int rds_setsockopt(struct socket *sock, int level, int optname,
|
||||
ret = rds_set_transport(rs, optval, optlen);
|
||||
release_sock(sock->sk);
|
||||
break;
|
||||
case SO_TIMESTAMP:
|
||||
case SO_TIMESTAMP_OLD:
|
||||
case SO_TIMESTAMP_NEW:
|
||||
lock_sock(sock->sk);
|
||||
ret = rds_enable_recvtstamp(sock->sk, optval, optlen);
|
||||
ret = rds_enable_recvtstamp(sock->sk, optval, optlen, optname);
|
||||
release_sock(sock->sk);
|
||||
break;
|
||||
case SO_RDS_MSG_RXPATH_LATENCY:
|
||||
|
@ -549,9 +549,21 @@ static int rds_cmsg_recv(struct rds_incoming *inc, struct msghdr *msg,
|
||||
|
||||
if ((inc->i_rx_tstamp != 0) &&
|
||||
sock_flag(rds_rs_to_sk(rs), SOCK_RCVTSTAMP)) {
|
||||
struct timeval tv = ktime_to_timeval(inc->i_rx_tstamp);
|
||||
ret = put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMP,
|
||||
sizeof(tv), &tv);
|
||||
struct __kernel_old_timeval tv = ns_to_kernel_old_timeval(inc->i_rx_tstamp);
|
||||
|
||||
if (!sock_flag(rds_rs_to_sk(rs), SOCK_TSTAMP_NEW)) {
|
||||
ret = put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD,
|
||||
sizeof(tv), &tv);
|
||||
} else {
|
||||
struct __kernel_sock_timeval sk_tv;
|
||||
|
||||
sk_tv.tv_sec = tv.tv_sec;
|
||||
sk_tv.tv_usec = tv.tv_usec;
|
||||
|
||||
ret = put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_NEW,
|
||||
sizeof(sk_tv), &sk_tv);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
|
||||
|
||||
/* We want receive timestamps. */
|
||||
opt = 1;
|
||||
ret = kernel_setsockopt(local->socket, SOL_SOCKET, SO_TIMESTAMPNS,
|
||||
ret = kernel_setsockopt(local->socket, SOL_SOCKET, SO_TIMESTAMPNS_OLD,
|
||||
(char *)&opt, sizeof(opt));
|
||||
if (ret < 0) {
|
||||
_debug("setsockopt failed");
|
||||
|
@ -291,7 +291,8 @@ static void smc_copy_sock_settings(struct sock *nsk, struct sock *osk,
|
||||
(1UL << SOCK_RXQ_OVFL) | \
|
||||
(1UL << SOCK_WIFI_STATUS) | \
|
||||
(1UL << SOCK_NOFCS) | \
|
||||
(1UL << SOCK_FILTER_LOCKED))
|
||||
(1UL << SOCK_FILTER_LOCKED) | \
|
||||
(1UL << SOCK_TSTAMP_NEW))
|
||||
/* copy only relevant settings and flags of SOL_SOCKET level from smc to
|
||||
* clc socket (since smc is not called for these options from net/core)
|
||||
*/
|
||||
|
50
net/socket.c
50
net/socket.c
@ -669,7 +669,7 @@ static bool skb_is_err_queue(const struct sk_buff *skb)
|
||||
* before the software timestamp is received, a hardware TX timestamp may be
|
||||
* returned only if there is no software TX timestamp. Ignore false software
|
||||
* timestamps, which may be made in the __sock_recv_timestamp() call when the
|
||||
* option SO_TIMESTAMP(NS) is enabled on the socket, even when the skb has a
|
||||
* option SO_TIMESTAMP_OLD(NS) is enabled on the socket, even when the skb has a
|
||||
* hardware timestamp.
|
||||
*/
|
||||
static bool skb_is_swtx_tstamp(const struct sk_buff *skb, int false_tstamp)
|
||||
@ -705,7 +705,9 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP);
|
||||
struct scm_timestamping tss;
|
||||
int new_tstamp = sock_flag(sk, SOCK_TSTAMP_NEW);
|
||||
struct scm_timestamping_internal tss;
|
||||
|
||||
int empty = 1, false_tstamp = 0;
|
||||
struct skb_shared_hwtstamps *shhwtstamps =
|
||||
skb_hwtstamps(skb);
|
||||
@ -719,34 +721,54 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
|
||||
|
||||
if (need_software_tstamp) {
|
||||
if (!sock_flag(sk, SOCK_RCVTSTAMPNS)) {
|
||||
struct timeval tv;
|
||||
skb_get_timestamp(skb, &tv);
|
||||
put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMP,
|
||||
sizeof(tv), &tv);
|
||||
if (new_tstamp) {
|
||||
struct __kernel_sock_timeval tv;
|
||||
|
||||
skb_get_new_timestamp(skb, &tv);
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_NEW,
|
||||
sizeof(tv), &tv);
|
||||
} else {
|
||||
struct __kernel_old_timeval tv;
|
||||
|
||||
skb_get_timestamp(skb, &tv);
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD,
|
||||
sizeof(tv), &tv);
|
||||
}
|
||||
} else {
|
||||
struct timespec ts;
|
||||
skb_get_timestampns(skb, &ts);
|
||||
put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMPNS,
|
||||
sizeof(ts), &ts);
|
||||
if (new_tstamp) {
|
||||
struct __kernel_timespec ts;
|
||||
|
||||
skb_get_new_timestampns(skb, &ts);
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_NEW,
|
||||
sizeof(ts), &ts);
|
||||
} else {
|
||||
struct timespec ts;
|
||||
|
||||
skb_get_timestampns(skb, &ts);
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_OLD,
|
||||
sizeof(ts), &ts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memset(&tss, 0, sizeof(tss));
|
||||
if ((sk->sk_tsflags & SOF_TIMESTAMPING_SOFTWARE) &&
|
||||
ktime_to_timespec_cond(skb->tstamp, tss.ts + 0))
|
||||
ktime_to_timespec64_cond(skb->tstamp, tss.ts + 0))
|
||||
empty = 0;
|
||||
if (shhwtstamps &&
|
||||
(sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
|
||||
!skb_is_swtx_tstamp(skb, false_tstamp) &&
|
||||
ktime_to_timespec_cond(shhwtstamps->hwtstamp, tss.ts + 2)) {
|
||||
ktime_to_timespec64_cond(shhwtstamps->hwtstamp, tss.ts + 2)) {
|
||||
empty = 0;
|
||||
if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) &&
|
||||
!skb_is_err_queue(skb))
|
||||
put_ts_pktinfo(msg, skb);
|
||||
}
|
||||
if (!empty) {
|
||||
put_cmsg(msg, SOL_SOCKET,
|
||||
SCM_TIMESTAMPING, sizeof(tss), &tss);
|
||||
if (sock_flag(sk, SOCK_TSTAMP_NEW))
|
||||
put_cmsg_scm_timestamping64(msg, &tss);
|
||||
else
|
||||
put_cmsg_scm_timestamping(msg, &tss);
|
||||
|
||||
if (skb_is_err_queue(skb) && skb->len &&
|
||||
SKB_EXT_ERR(skb)->opt_stats)
|
||||
|
@ -1439,7 +1439,7 @@ static int vsock_stream_setsockopt(struct socket *sock,
|
||||
break;
|
||||
|
||||
case SO_VM_SOCKETS_CONNECT_TIMEOUT: {
|
||||
struct timeval tv;
|
||||
struct __kernel_old_timeval tv;
|
||||
COPY_IN(tv);
|
||||
if (tv.tv_sec >= 0 && tv.tv_usec < USEC_PER_SEC &&
|
||||
tv.tv_sec < (MAX_SCHEDULE_TIMEOUT / HZ - 1)) {
|
||||
@ -1517,7 +1517,7 @@ static int vsock_stream_getsockopt(struct socket *sock,
|
||||
break;
|
||||
|
||||
case SO_VM_SOCKETS_CONNECT_TIMEOUT: {
|
||||
struct timeval tv;
|
||||
struct __kernel_old_timeval tv;
|
||||
tv.tv_sec = vsk->connect_timeout / HZ;
|
||||
tv.tv_usec =
|
||||
(vsk->connect_timeout -
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
|
Loading…
Reference in New Issue
Block a user