diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-03-26 01:14:49 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:24:21 -0400 |
commit | 92f37fd2ee805aa77925c1e64fd56088b46094fc (patch) | |
tree | 8251c38b83ab362116dac89d94412ce229b42831 /include | |
parent | c7a3c5da35055e2fa97ed4f0da3eec4bd0ef4c38 (diff) |
[NET]: Adding SO_TIMESTAMPNS / SCM_TIMESTAMPNS support
Now that network timestamps use ktime_t infrastructure, we can add a new
SOL_SOCKET sockopt SO_TIMESTAMPNS.
This command is similar to SO_TIMESTAMP, but permits transmission of
a 'timespec struct' instead of a 'timeval struct' control message.
(nanosecond resolution instead of microsecond)
Control message is labelled SCM_TIMESTAMPNS instead of SCM_TIMESTAMP
A socket cannot mix SO_TIMESTAMP and SO_TIMESTAMPNS : the two modes are
mutually exclusive.
sock_recv_timestamp() became too big to be fully inlined so I added a
__sock_recv_timestamp() helper function.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
CC: linux-arch@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-alpha/socket.h | 2 | ||||
-rw-r--r-- | include/asm-arm/socket.h | 2 | ||||
-rw-r--r-- | include/asm-arm26/socket.h | 2 | ||||
-rw-r--r-- | include/asm-avr32/socket.h | 2 | ||||
-rw-r--r-- | include/asm-cris/socket.h | 2 | ||||
-rw-r--r-- | include/asm-frv/socket.h | 2 | ||||
-rw-r--r-- | include/asm-h8300/socket.h | 2 | ||||
-rw-r--r-- | include/asm-i386/socket.h | 2 | ||||
-rw-r--r-- | include/asm-ia64/socket.h | 2 | ||||
-rw-r--r-- | include/asm-m32r/socket.h | 2 | ||||
-rw-r--r-- | include/asm-m68k/socket.h | 2 | ||||
-rw-r--r-- | include/asm-mips/socket.h | 2 | ||||
-rw-r--r-- | include/asm-parisc/socket.h | 2 | ||||
-rw-r--r-- | include/asm-powerpc/socket.h | 2 | ||||
-rw-r--r-- | include/asm-s390/socket.h | 2 | ||||
-rw-r--r-- | include/asm-sh/socket.h | 2 | ||||
-rw-r--r-- | include/asm-sparc/socket.h | 2 | ||||
-rw-r--r-- | include/asm-sparc64/socket.h | 2 | ||||
-rw-r--r-- | include/asm-v850/socket.h | 2 | ||||
-rw-r--r-- | include/asm-x86_64/socket.h | 2 | ||||
-rw-r--r-- | include/asm-xtensa/socket.h | 2 | ||||
-rw-r--r-- | include/net/sock.h | 17 |
22 files changed, 49 insertions, 10 deletions
diff --git a/include/asm-alpha/socket.h b/include/asm-alpha/socket.h index d22ab97ea72e..1fede7f92860 100644 --- a/include/asm-alpha/socket.h +++ b/include/asm-alpha/socket.h | |||
@@ -52,6 +52,8 @@ | |||
52 | 52 | ||
53 | #define SO_PEERSEC 30 | 53 | #define SO_PEERSEC 30 |
54 | #define SO_PASSSEC 34 | 54 | #define SO_PASSSEC 34 |
55 | #define SO_TIMESTAMPNS 35 | ||
56 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
55 | 57 | ||
56 | /* Security levels - as per NRL IPv6 - don't actually do anything */ | 58 | /* Security levels - as per NRL IPv6 - don't actually do anything */ |
57 | #define SO_SECURITY_AUTHENTICATION 19 | 59 | #define SO_SECURITY_AUTHENTICATION 19 |
diff --git a/include/asm-arm/socket.h b/include/asm-arm/socket.h index 19f7df702b06..65a1a64bf934 100644 --- a/include/asm-arm/socket.h +++ b/include/asm-arm/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* _ASM_SOCKET_H */ | 55 | #endif /* _ASM_SOCKET_H */ |
diff --git a/include/asm-arm26/socket.h b/include/asm-arm26/socket.h index 19f7df702b06..65a1a64bf934 100644 --- a/include/asm-arm26/socket.h +++ b/include/asm-arm26/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* _ASM_SOCKET_H */ | 55 | #endif /* _ASM_SOCKET_H */ |
diff --git a/include/asm-avr32/socket.h b/include/asm-avr32/socket.h index 543229de8173..a0d0507a5034 100644 --- a/include/asm-avr32/socket.h +++ b/include/asm-avr32/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* __ASM_AVR32_SOCKET_H */ | 55 | #endif /* __ASM_AVR32_SOCKET_H */ |
diff --git a/include/asm-cris/socket.h b/include/asm-cris/socket.h index 01cfdf1d6d33..5b18dfdf1748 100644 --- a/include/asm-cris/socket.h +++ b/include/asm-cris/socket.h | |||
@@ -51,6 +51,8 @@ | |||
51 | 51 | ||
52 | #define SO_PEERSEC 31 | 52 | #define SO_PEERSEC 31 |
53 | #define SO_PASSSEC 34 | 53 | #define SO_PASSSEC 34 |
54 | #define SO_TIMESTAMPNS 35 | ||
55 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
54 | 56 | ||
55 | #endif /* _ASM_SOCKET_H */ | 57 | #endif /* _ASM_SOCKET_H */ |
56 | 58 | ||
diff --git a/include/asm-frv/socket.h b/include/asm-frv/socket.h index 31db18fc871f..a823befd11dd 100644 --- a/include/asm-frv/socket.h +++ b/include/asm-frv/socket.h | |||
@@ -49,6 +49,8 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* _ASM_SOCKET_H */ | 55 | #endif /* _ASM_SOCKET_H */ |
54 | 56 | ||
diff --git a/include/asm-h8300/socket.h b/include/asm-h8300/socket.h index ebc830fee0d0..39911d8c9684 100644 --- a/include/asm-h8300/socket.h +++ b/include/asm-h8300/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* _ASM_SOCKET_H */ | 55 | #endif /* _ASM_SOCKET_H */ |
diff --git a/include/asm-i386/socket.h b/include/asm-i386/socket.h index 5755d57c4e95..99ca648b94c5 100644 --- a/include/asm-i386/socket.h +++ b/include/asm-i386/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* _ASM_SOCKET_H */ | 55 | #endif /* _ASM_SOCKET_H */ |
diff --git a/include/asm-ia64/socket.h b/include/asm-ia64/socket.h index d638ef3d50c3..9e42ce43cfbe 100644 --- a/include/asm-ia64/socket.h +++ b/include/asm-ia64/socket.h | |||
@@ -58,5 +58,7 @@ | |||
58 | 58 | ||
59 | #define SO_PEERSEC 31 | 59 | #define SO_PEERSEC 31 |
60 | #define SO_PASSSEC 34 | 60 | #define SO_PASSSEC 34 |
61 | #define SO_TIMESTAMPNS 35 | ||
62 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
61 | 63 | ||
62 | #endif /* _ASM_IA64_SOCKET_H */ | 64 | #endif /* _ASM_IA64_SOCKET_H */ |
diff --git a/include/asm-m32r/socket.h b/include/asm-m32r/socket.h index acdf748fcdc8..793d5d30c850 100644 --- a/include/asm-m32r/socket.h +++ b/include/asm-m32r/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* _ASM_M32R_SOCKET_H */ | 55 | #endif /* _ASM_M32R_SOCKET_H */ |
diff --git a/include/asm-m68k/socket.h b/include/asm-m68k/socket.h index a5966ec005ae..6d21b90863ad 100644 --- a/include/asm-m68k/socket.h +++ b/include/asm-m68k/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* _ASM_SOCKET_H */ | 55 | #endif /* _ASM_SOCKET_H */ |
diff --git a/include/asm-mips/socket.h b/include/asm-mips/socket.h index 36ebe4e186a7..95945689b1c6 100644 --- a/include/asm-mips/socket.h +++ b/include/asm-mips/socket.h | |||
@@ -70,6 +70,8 @@ To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */ | |||
70 | #define SO_SNDBUFFORCE 31 | 70 | #define SO_SNDBUFFORCE 31 |
71 | #define SO_RCVBUFFORCE 33 | 71 | #define SO_RCVBUFFORCE 33 |
72 | #define SO_PASSSEC 34 | 72 | #define SO_PASSSEC 34 |
73 | #define SO_TIMESTAMPNS 35 | ||
74 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
73 | 75 | ||
74 | #ifdef __KERNEL__ | 76 | #ifdef __KERNEL__ |
75 | 77 | ||
diff --git a/include/asm-parisc/socket.h b/include/asm-parisc/socket.h index ce2eae1708b5..99e868f6a8f5 100644 --- a/include/asm-parisc/socket.h +++ b/include/asm-parisc/socket.h | |||
@@ -33,6 +33,8 @@ | |||
33 | #define SO_PEERCRED 0x4011 | 33 | #define SO_PEERCRED 0x4011 |
34 | #define SO_TIMESTAMP 0x4012 | 34 | #define SO_TIMESTAMP 0x4012 |
35 | #define SCM_TIMESTAMP SO_TIMESTAMP | 35 | #define SCM_TIMESTAMP SO_TIMESTAMP |
36 | #define SO_TIMESTAMPNS 0x4013 | ||
37 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
36 | 38 | ||
37 | /* Security levels - as per NRL IPv6 - don't actually do anything */ | 39 | /* Security levels - as per NRL IPv6 - don't actually do anything */ |
38 | #define SO_SECURITY_AUTHENTICATION 0x4016 | 40 | #define SO_SECURITY_AUTHENTICATION 0x4016 |
diff --git a/include/asm-powerpc/socket.h b/include/asm-powerpc/socket.h index c8b1da50e72d..403e9fde2eb5 100644 --- a/include/asm-powerpc/socket.h +++ b/include/asm-powerpc/socket.h | |||
@@ -56,5 +56,7 @@ | |||
56 | 56 | ||
57 | #define SO_PEERSEC 31 | 57 | #define SO_PEERSEC 31 |
58 | #define SO_PASSSEC 34 | 58 | #define SO_PASSSEC 34 |
59 | #define SO_TIMESTAMPNS 35 | ||
60 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
59 | 61 | ||
60 | #endif /* _ASM_POWERPC_SOCKET_H */ | 62 | #endif /* _ASM_POWERPC_SOCKET_H */ |
diff --git a/include/asm-s390/socket.h b/include/asm-s390/socket.h index 1778a49a74c5..1161ebe3dec9 100644 --- a/include/asm-s390/socket.h +++ b/include/asm-s390/socket.h | |||
@@ -57,5 +57,7 @@ | |||
57 | 57 | ||
58 | #define SO_PEERSEC 31 | 58 | #define SO_PEERSEC 31 |
59 | #define SO_PASSSEC 34 | 59 | #define SO_PASSSEC 34 |
60 | #define SO_TIMESTAMPNS 35 | ||
61 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
60 | 62 | ||
61 | #endif /* _ASM_SOCKET_H */ | 63 | #endif /* _ASM_SOCKET_H */ |
diff --git a/include/asm-sh/socket.h b/include/asm-sh/socket.h index ca70362eb563..c48d6fc9da38 100644 --- a/include/asm-sh/socket.h +++ b/include/asm-sh/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* __ASM_SH_SOCKET_H */ | 55 | #endif /* __ASM_SH_SOCKET_H */ |
diff --git a/include/asm-sparc/socket.h b/include/asm-sparc/socket.h index f6c4e5baf3f7..7c1423997cf0 100644 --- a/include/asm-sparc/socket.h +++ b/include/asm-sparc/socket.h | |||
@@ -49,6 +49,8 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 0x001e | 50 | #define SO_PEERSEC 0x001e |
51 | #define SO_PASSSEC 0x001f | 51 | #define SO_PASSSEC 0x001f |
52 | #define SO_TIMESTAMPNS 0x0021 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | /* Security levels - as per NRL IPv6 - don't actually do anything */ | 55 | /* Security levels - as per NRL IPv6 - don't actually do anything */ |
54 | #define SO_SECURITY_AUTHENTICATION 0x5001 | 56 | #define SO_SECURITY_AUTHENTICATION 0x5001 |
diff --git a/include/asm-sparc64/socket.h b/include/asm-sparc64/socket.h index 754d46a50af3..986441dcb8f0 100644 --- a/include/asm-sparc64/socket.h +++ b/include/asm-sparc64/socket.h | |||
@@ -49,6 +49,8 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 0x001e | 50 | #define SO_PEERSEC 0x001e |
51 | #define SO_PASSSEC 0x001f | 51 | #define SO_PASSSEC 0x001f |
52 | #define SO_TIMESTAMPNS 0x0021 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | /* Security levels - as per NRL IPv6 - don't actually do anything */ | 55 | /* Security levels - as per NRL IPv6 - don't actually do anything */ |
54 | #define SO_SECURITY_AUTHENTICATION 0x5001 | 56 | #define SO_SECURITY_AUTHENTICATION 0x5001 |
diff --git a/include/asm-v850/socket.h b/include/asm-v850/socket.h index 0dfe55ac2ef2..a4c2493b025f 100644 --- a/include/asm-v850/socket.h +++ b/include/asm-v850/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* __V850_SOCKET_H__ */ | 55 | #endif /* __V850_SOCKET_H__ */ |
diff --git a/include/asm-x86_64/socket.h b/include/asm-x86_64/socket.h index b46702607933..90af60cf3c0e 100644 --- a/include/asm-x86_64/socket.h +++ b/include/asm-x86_64/socket.h | |||
@@ -49,5 +49,7 @@ | |||
49 | 49 | ||
50 | #define SO_PEERSEC 31 | 50 | #define SO_PEERSEC 31 |
51 | #define SO_PASSSEC 34 | 51 | #define SO_PASSSEC 34 |
52 | #define SO_TIMESTAMPNS 35 | ||
53 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
52 | 54 | ||
53 | #endif /* _ASM_SOCKET_H */ | 55 | #endif /* _ASM_SOCKET_H */ |
diff --git a/include/asm-xtensa/socket.h b/include/asm-xtensa/socket.h index 971d231be60e..1f5aeacb9da2 100644 --- a/include/asm-xtensa/socket.h +++ b/include/asm-xtensa/socket.h | |||
@@ -60,5 +60,7 @@ | |||
60 | #define SO_ACCEPTCONN 30 | 60 | #define SO_ACCEPTCONN 30 |
61 | #define SO_PEERSEC 31 | 61 | #define SO_PEERSEC 31 |
62 | #define SO_PASSSEC 34 | 62 | #define SO_PASSSEC 34 |
63 | #define SO_TIMESTAMPNS 35 | ||
64 | #define SCM_TIMESTAMPNS SO_TIMESTAMPNS | ||
63 | 65 | ||
64 | #endif /* _XTENSA_SOCKET_H */ | 66 | #endif /* _XTENSA_SOCKET_H */ |
diff --git a/include/net/sock.h b/include/net/sock.h index 51246579592e..390c04700590 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -390,6 +390,7 @@ enum sock_flags { | |||
390 | SOCK_USE_WRITE_QUEUE, /* whether to call sk->sk_write_space in sock_wfree */ | 390 | SOCK_USE_WRITE_QUEUE, /* whether to call sk->sk_write_space in sock_wfree */ |
391 | SOCK_DBG, /* %SO_DEBUG setting */ | 391 | SOCK_DBG, /* %SO_DEBUG setting */ |
392 | SOCK_RCVTSTAMP, /* %SO_TIMESTAMP setting */ | 392 | SOCK_RCVTSTAMP, /* %SO_TIMESTAMP setting */ |
393 | SOCK_RCVTSTAMPNS, /* %SO_TIMESTAMPNS setting */ | ||
393 | SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */ | 394 | SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */ |
394 | SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ | 395 | SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ |
395 | }; | 396 | }; |
@@ -1283,21 +1284,17 @@ static inline int sock_intr_errno(long timeo) | |||
1283 | return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR; | 1284 | return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR; |
1284 | } | 1285 | } |
1285 | 1286 | ||
1287 | extern void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, | ||
1288 | struct sk_buff *skb); | ||
1289 | |||
1286 | static __inline__ void | 1290 | static __inline__ void |
1287 | sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) | 1291 | sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) |
1288 | { | 1292 | { |
1289 | ktime_t kt = skb->tstamp; | 1293 | ktime_t kt = skb->tstamp; |
1290 | 1294 | ||
1291 | if (sock_flag(sk, SOCK_RCVTSTAMP)) { | 1295 | if (sock_flag(sk, SOCK_RCVTSTAMP)) |
1292 | struct timeval tv; | 1296 | __sock_recv_timestamp(msg, sk, skb); |
1293 | /* Race occurred between timestamp enabling and packet | 1297 | else |
1294 | receiving. Fill in the current time for now. */ | ||
1295 | if (kt.tv64 == 0) | ||
1296 | kt = ktime_get_real(); | ||
1297 | skb->tstamp = kt; | ||
1298 | tv = ktime_to_timeval(kt); | ||
1299 | put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP, sizeof(tv), &tv); | ||
1300 | } else | ||
1301 | sk->sk_stamp = kt; | 1298 | sk->sk_stamp = kt; |
1302 | } | 1299 | } |
1303 | 1300 | ||