aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2007-03-18 20:33:16 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:24:04 -0400
commitae40eb1ef30ab4120bd3c8b7e3da99ee53d27a23 (patch)
treeb5ae288b3c27d13bde9648c41d7db3cfe1884bc2
parentcb69cc52364690d7789940c480b3a9490784b680 (diff)
[NET]: Introduce SIOCGSTAMPNS ioctl to get timestamps with nanosec resolution
Now network timestamps use ktime_t infrastructure, we can add a new ioctl() SIOCGSTAMPNS command to get timestamps in 'struct timespec'. User programs can thus access to nanosecond resolution. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> CC: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--fs/compat_ioctl.c18
-rw-r--r--include/asm-alpha/sockios.h3
-rw-r--r--include/asm-arm/sockios.h3
-rw-r--r--include/asm-arm26/sockios.h3
-rw-r--r--include/asm-avr32/sockios.h3
-rw-r--r--include/asm-cris/sockios.h3
-rw-r--r--include/asm-frv/sockios.h3
-rw-r--r--include/asm-h8300/sockios.h3
-rw-r--r--include/asm-i386/sockios.h3
-rw-r--r--include/asm-ia64/sockios.h3
-rw-r--r--include/asm-m32r/sockios.h3
-rw-r--r--include/asm-m68k/sockios.h3
-rw-r--r--include/asm-mips/sockios.h3
-rw-r--r--include/asm-parisc/sockios.h3
-rw-r--r--include/asm-powerpc/sockios.h3
-rw-r--r--include/asm-s390/sockios.h3
-rw-r--r--include/asm-sh/sockios.h3
-rw-r--r--include/asm-sh64/sockios.h3
-rw-r--r--include/asm-sparc/sockios.h3
-rw-r--r--include/asm-sparc64/sockios.h3
-rw-r--r--include/asm-v850/sockios.h3
-rw-r--r--include/asm-x86_64/sockios.h3
-rw-r--r--include/asm-xtensa/sockios.h3
-rw-r--r--include/net/compat.h1
-rw-r--r--include/net/sock.h1
-rw-r--r--net/appletalk/ddp.c3
-rw-r--r--net/atm/ioctl.c3
-rw-r--r--net/ax25/af_ax25.c4
-rw-r--r--net/compat.c24
-rw-r--r--net/core/sock.c16
-rw-r--r--net/econet/af_econet.c3
-rw-r--r--net/ipv4/af_inet.c3
-rw-r--r--net/ipv6/af_inet6.c3
-rw-r--r--net/netrom/af_netrom.c6
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/rose/af_rose.c3
-rw-r--r--net/x25/af_x25.c12
37 files changed, 146 insertions, 22 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 8b1c5d8bf4ef..c68b055fa26e 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -266,6 +266,23 @@ static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
266 return err; 266 return err;
267} 267}
268 268
269static int do_siocgstampns(unsigned int fd, unsigned int cmd, unsigned long arg)
270{
271 struct compat_timespec __user *up = compat_ptr(arg);
272 struct timespec kts;
273 mm_segment_t old_fs = get_fs();
274 int err;
275
276 set_fs(KERNEL_DS);
277 err = sys_ioctl(fd, cmd, (unsigned long)&kts);
278 set_fs(old_fs);
279 if (!err) {
280 err = put_user(kts.tv_sec, &up->tv_sec);
281 err |= __put_user(kts.tv_nsec, &up->tv_nsec);
282 }
283 return err;
284}
285
269struct ifmap32 { 286struct ifmap32 {
270 compat_ulong_t mem_start; 287 compat_ulong_t mem_start;
271 compat_ulong_t mem_end; 288 compat_ulong_t mem_end;
@@ -2437,6 +2454,7 @@ HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc)
2437/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */ 2454/* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
2438HANDLE_IOCTL(SIOCRTMSG, ret_einval) 2455HANDLE_IOCTL(SIOCRTMSG, ret_einval)
2439HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp) 2456HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
2457HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns)
2440#endif 2458#endif
2441#ifdef CONFIG_BLOCK 2459#ifdef CONFIG_BLOCK
2442HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo) 2460HANDLE_IOCTL(HDIO_GETGEO, hdio_getgeo)
diff --git a/include/asm-alpha/sockios.h b/include/asm-alpha/sockios.h
index e4961a740e5f..7932c7ab4a4d 100644
--- a/include/asm-alpha/sockios.h
+++ b/include/asm-alpha/sockios.h
@@ -10,6 +10,7 @@
10#define SIOCSPGRP _IOW('s', 8, pid_t) 10#define SIOCSPGRP _IOW('s', 8, pid_t)
11#define SIOCGPGRP _IOR('s', 9, pid_t) 11#define SIOCGPGRP _IOR('s', 9, pid_t)
12 12
13#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */ 13#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
14#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
14 15
15#endif /* _ASM_ALPHA_SOCKIOS_H */ 16#endif /* _ASM_ALPHA_SOCKIOS_H */
diff --git a/include/asm-arm/sockios.h b/include/asm-arm/sockios.h
index 77c34087d513..a2588a2512df 100644
--- a/include/asm-arm/sockios.h
+++ b/include/asm-arm/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif 13#endif
diff --git a/include/asm-arm26/sockios.h b/include/asm-arm26/sockios.h
index 77c34087d513..a2588a2512df 100644
--- a/include/asm-arm26/sockios.h
+++ b/include/asm-arm26/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif 13#endif
diff --git a/include/asm-avr32/sockios.h b/include/asm-avr32/sockios.h
index 84f3d65b3b3b..0802d742f97d 100644
--- a/include/asm-avr32/sockios.h
+++ b/include/asm-avr32/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif /* __ASM_AVR32_SOCKIOS_H */ 13#endif /* __ASM_AVR32_SOCKIOS_H */
diff --git a/include/asm-cris/sockios.h b/include/asm-cris/sockios.h
index 6c4012f0b29f..cfe7bfecf599 100644
--- a/include/asm-cris/sockios.h
+++ b/include/asm-cris/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif 13#endif
diff --git a/include/asm-frv/sockios.h b/include/asm-frv/sockios.h
index 8a6e4b2074b7..5dbdd13e6de3 100644
--- a/include/asm-frv/sockios.h
+++ b/include/asm-frv/sockios.h
@@ -7,7 +7,8 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif /* _ASM_SOCKIOS__ */ 13#endif /* _ASM_SOCKIOS__ */
13 14
diff --git a/include/asm-h8300/sockios.h b/include/asm-h8300/sockios.h
index d005d9594cc6..e9c7ec810c23 100644
--- a/include/asm-h8300/sockios.h
+++ b/include/asm-h8300/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif /* __ARCH_H8300_SOCKIOS__ */ 13#endif /* __ARCH_H8300_SOCKIOS__ */
diff --git a/include/asm-i386/sockios.h b/include/asm-i386/sockios.h
index 6b747f8e228b..ff528c7d255c 100644
--- a/include/asm-i386/sockios.h
+++ b/include/asm-i386/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif 13#endif
diff --git a/include/asm-ia64/sockios.h b/include/asm-ia64/sockios.h
index cf94857c8a54..15c92468ad38 100644
--- a/include/asm-ia64/sockios.h
+++ b/include/asm-ia64/sockios.h
@@ -14,6 +14,7 @@
14#define FIOGETOWN 0x8903 14#define FIOGETOWN 0x8903
15#define SIOCGPGRP 0x8904 15#define SIOCGPGRP 0x8904
16#define SIOCATMARK 0x8905 16#define SIOCATMARK 0x8905
17#define SIOCGSTAMP 0x8906 /* Get stamp */ 17#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
18#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
18 19
19#endif /* _ASM_IA64_SOCKIOS_H */ 20#endif /* _ASM_IA64_SOCKIOS_H */
diff --git a/include/asm-m32r/sockios.h b/include/asm-m32r/sockios.h
index f89962e231fe..6c1fb9b43bdb 100644
--- a/include/asm-m32r/sockios.h
+++ b/include/asm-m32r/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif /* _ASM_M32R_SOCKIOS_H */ 13#endif /* _ASM_M32R_SOCKIOS_H */
diff --git a/include/asm-m68k/sockios.h b/include/asm-m68k/sockios.h
index 9b9ed973c24e..c04a23943cb7 100644
--- a/include/asm-m68k/sockios.h
+++ b/include/asm-m68k/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif /* __ARCH_M68K_SOCKIOS__ */ 13#endif /* __ARCH_M68K_SOCKIOS__ */
diff --git a/include/asm-mips/sockios.h b/include/asm-mips/sockios.h
index 87a50bf039ed..ed1a5f78d22f 100644
--- a/include/asm-mips/sockios.h
+++ b/include/asm-mips/sockios.h
@@ -20,6 +20,7 @@
20#define SIOCSPGRP _IOW('s', 8, pid_t) 20#define SIOCSPGRP _IOW('s', 8, pid_t)
21#define SIOCGPGRP _IOR('s', 9, pid_t) 21#define SIOCGPGRP _IOR('s', 9, pid_t)
22 22
23#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */ 23#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
24#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
24 25
25#endif /* _ASM_SOCKIOS_H */ 26#endif /* _ASM_SOCKIOS_H */
diff --git a/include/asm-parisc/sockios.h b/include/asm-parisc/sockios.h
index aace49629949..dabfbc7483f6 100644
--- a/include/asm-parisc/sockios.h
+++ b/include/asm-parisc/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif 13#endif
diff --git a/include/asm-powerpc/sockios.h b/include/asm-powerpc/sockios.h
index 590078d8ed28..55cef7675a31 100644
--- a/include/asm-powerpc/sockios.h
+++ b/include/asm-powerpc/sockios.h
@@ -14,6 +14,7 @@
14#define FIOGETOWN 0x8903 14#define FIOGETOWN 0x8903
15#define SIOCGPGRP 0x8904 15#define SIOCGPGRP 0x8904
16#define SIOCATMARK 0x8905 16#define SIOCATMARK 0x8905
17#define SIOCGSTAMP 0x8906 /* Get stamp */ 17#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
18#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
18 19
19#endif /* _ASM_POWERPC_SOCKIOS_H */ 20#endif /* _ASM_POWERPC_SOCKIOS_H */
diff --git a/include/asm-s390/sockios.h b/include/asm-s390/sockios.h
index 412aeb4dd6ce..f4fc16c7da59 100644
--- a/include/asm-s390/sockios.h
+++ b/include/asm-s390/sockios.h
@@ -15,6 +15,7 @@
15#define FIOGETOWN 0x8903 15#define FIOGETOWN 0x8903
16#define SIOCGPGRP 0x8904 16#define SIOCGPGRP 0x8904
17#define SIOCATMARK 0x8905 17#define SIOCATMARK 0x8905
18#define SIOCGSTAMP 0x8906 /* Get stamp */ 18#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
19#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
19 20
20#endif 21#endif
diff --git a/include/asm-sh/sockios.h b/include/asm-sh/sockios.h
index 08a71df8a8be..cf8b96b1f9ab 100644
--- a/include/asm-sh/sockios.h
+++ b/include/asm-sh/sockios.h
@@ -9,5 +9,6 @@
9#define SIOCSPGRP _IOW('s', 8, pid_t) 9#define SIOCSPGRP _IOW('s', 8, pid_t)
10#define SIOCGPGRP _IOR('s', 9, pid_t) 10#define SIOCGPGRP _IOR('s', 9, pid_t)
11 11
12#define SIOCGSTAMP _IOR('s', 100, struct timeval) /* Get stamp - linux-specific */ 12#define SIOCGSTAMP _IOR('s', 100, struct timeval) /* Get stamp (timeval) */
13#define SIOCGSTAMPNS _IOR('s', 101, struct timespec) /* Get stamp (timespec) */
13#endif /* __ASM_SH_SOCKIOS_H */ 14#endif /* __ASM_SH_SOCKIOS_H */
diff --git a/include/asm-sh64/sockios.h b/include/asm-sh64/sockios.h
index 1ae23ae82977..419e76f12f41 100644
--- a/include/asm-sh64/sockios.h
+++ b/include/asm-sh64/sockios.h
@@ -20,5 +20,6 @@
20#define SIOCSPGRP _IOW('s', 8, pid_t) 20#define SIOCSPGRP _IOW('s', 8, pid_t)
21#define SIOCGPGRP _IOR('s', 9, pid_t) 21#define SIOCGPGRP _IOR('s', 9, pid_t)
22 22
23#define SIOCGSTAMP _IOR('s', 100, struct timeval) /* Get stamp - linux-specific */ 23#define SIOCGSTAMP _IOR('s', 100, struct timeval) /* Get stamp (timeval) */
24#define SIOCGSTAMPNS _IOR('s', 101, struct timespec) /* Get stamp (timespec) */
24#endif /* __ASM_SH64_SOCKIOS_H */ 25#endif /* __ASM_SH64_SOCKIOS_H */
diff --git a/include/asm-sparc/sockios.h b/include/asm-sparc/sockios.h
index 0c01b597b06f..990ea746486b 100644
--- a/include/asm-sparc/sockios.h
+++ b/include/asm-sparc/sockios.h
@@ -7,7 +7,8 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif /* !(_ASM_SPARC_SOCKIOS_H) */ 13#endif /* !(_ASM_SPARC_SOCKIOS_H) */
13 14
diff --git a/include/asm-sparc64/sockios.h b/include/asm-sparc64/sockios.h
index 6735bab4f39d..c7d9900638d0 100644
--- a/include/asm-sparc64/sockios.h
+++ b/include/asm-sparc64/sockios.h
@@ -7,7 +7,8 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif /* !(_ASM_SPARC64_SOCKIOS_H) */ 13#endif /* !(_ASM_SPARC64_SOCKIOS_H) */
13 14
diff --git a/include/asm-v850/sockios.h b/include/asm-v850/sockios.h
index cf4874c2fd8a..823e106e6cd0 100644
--- a/include/asm-v850/sockios.h
+++ b/include/asm-v850/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif /* __V850_SOCKIOS_H__ */ 13#endif /* __V850_SOCKIOS_H__ */
diff --git a/include/asm-x86_64/sockios.h b/include/asm-x86_64/sockios.h
index 2eefd10d4f48..d726ba2513e3 100644
--- a/include/asm-x86_64/sockios.h
+++ b/include/asm-x86_64/sockios.h
@@ -7,6 +7,7 @@
7#define FIOGETOWN 0x8903 7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904 8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905 9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */ 10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
11 12
12#endif 13#endif
diff --git a/include/asm-xtensa/sockios.h b/include/asm-xtensa/sockios.h
index 20d2ba10ecd1..efe0af379f01 100644
--- a/include/asm-xtensa/sockios.h
+++ b/include/asm-xtensa/sockios.h
@@ -25,6 +25,7 @@
25#define SIOCSPGRP _IOW('s', 8, pid_t) 25#define SIOCSPGRP _IOW('s', 8, pid_t)
26#define SIOCGPGRP _IOR('s', 9, pid_t) 26#define SIOCGPGRP _IOR('s', 9, pid_t)
27 27
28#define SIOCGSTAMP 0x8906 /* Get stamp - linux-specific */ 28#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
29#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
29 30
30#endif /* _XTENSA_SOCKIOS_H */ 31#endif /* _XTENSA_SOCKIOS_H */
diff --git a/include/net/compat.h b/include/net/compat.h
index 9859b60280d5..406db242f73a 100644
--- a/include/net/compat.h
+++ b/include/net/compat.h
@@ -25,6 +25,7 @@ struct compat_cmsghdr {
25}; 25};
26 26
27extern int compat_sock_get_timestamp(struct sock *, struct timeval __user *); 27extern int compat_sock_get_timestamp(struct sock *, struct timeval __user *);
28extern int compat_sock_get_timestampns(struct sock *, struct timespec __user *);
28 29
29#else /* defined(CONFIG_COMPAT) */ 30#else /* defined(CONFIG_COMPAT) */
30#define compat_msghdr msghdr /* to avoid compiler warnings */ 31#define compat_msghdr msghdr /* to avoid compiler warnings */
diff --git a/include/net/sock.h b/include/net/sock.h
index 2974bacc8850..d093e49fdc85 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1329,6 +1329,7 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e
1329 1329
1330extern void sock_enable_timestamp(struct sock *sk); 1330extern void sock_enable_timestamp(struct sock *sk);
1331extern int sock_get_timestamp(struct sock *, struct timeval __user *); 1331extern int sock_get_timestamp(struct sock *, struct timeval __user *);
1332extern int sock_get_timestampns(struct sock *, struct timespec __user *);
1332 1333
1333/* 1334/*
1334 * Enable debug/info messages 1335 * Enable debug/info messages
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index c8b7dc2c3257..32b82705b685 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1771,6 +1771,9 @@ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1771 case SIOCGSTAMP: 1771 case SIOCGSTAMP:
1772 rc = sock_get_timestamp(sk, argp); 1772 rc = sock_get_timestamp(sk, argp);
1773 break; 1773 break;
1774 case SIOCGSTAMPNS:
1775 rc = sock_get_timestampns(sk, argp);
1776 break;
1774 /* Routing */ 1777 /* Routing */
1775 case SIOCADDRT: 1778 case SIOCADDRT:
1776 case SIOCDELRT: 1779 case SIOCDELRT:
diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c
index 8ccee4591f65..7afd8e7754fd 100644
--- a/net/atm/ioctl.c
+++ b/net/atm/ioctl.c
@@ -82,6 +82,9 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
82 case SIOCGSTAMP: /* borrowed from IP */ 82 case SIOCGSTAMP: /* borrowed from IP */
83 error = sock_get_timestamp(sk, argp); 83 error = sock_get_timestamp(sk, argp);
84 goto done; 84 goto done;
85 case SIOCGSTAMPNS: /* borrowed from IP */
86 error = sock_get_timestampns(sk, argp);
87 goto done;
85 case ATM_SETSC: 88 case ATM_SETSC:
86 printk(KERN_WARNING "ATM_SETSC is obsolete\n"); 89 printk(KERN_WARNING "ATM_SETSC is obsolete\n");
87 error = 0; 90 error = 0;
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 1c07c6a50eb8..62605dc5a2c8 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -1711,6 +1711,10 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1711 res = sock_get_timestamp(sk, argp); 1711 res = sock_get_timestamp(sk, argp);
1712 break; 1712 break;
1713 1713
1714 case SIOCGSTAMPNS:
1715 res = sock_get_timestampns(sk, argp);
1716 break;
1717
1714 case SIOCAX25ADDUID: /* Add a uid to the uid/call map table */ 1718 case SIOCAX25ADDUID: /* Add a uid to the uid/call map table */
1715 case SIOCAX25DELUID: /* Delete a uid from the uid/call map table */ 1719 case SIOCAX25DELUID: /* Delete a uid from the uid/call map table */
1716 case SIOCAX25GETUID: { 1720 case SIOCAX25GETUID: {
diff --git a/net/compat.c b/net/compat.c
index 17c2710b2b93..2fc6d9bb622b 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -564,6 +564,30 @@ int compat_sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
564} 564}
565EXPORT_SYMBOL(compat_sock_get_timestamp); 565EXPORT_SYMBOL(compat_sock_get_timestamp);
566 566
567int compat_sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp)
568{
569 struct compat_timespec __user *ctv =
570 (struct compat_timespec __user*) userstamp;
571 int err = -ENOENT;
572 struct timespec ts;
573
574 if (!sock_flag(sk, SOCK_TIMESTAMP))
575 sock_enable_timestamp(sk);
576 ts = ktime_to_timespec(sk->sk_stamp);
577 if (ts.tv_sec == -1)
578 return err;
579 if (ts.tv_sec == 0) {
580 sk->sk_stamp = ktime_get_real();
581 ts = ktime_to_timespec(sk->sk_stamp);
582 }
583 err = 0;
584 if (put_user(ts.tv_sec, &ctv->tv_sec) ||
585 put_user(ts.tv_nsec, &ctv->tv_nsec))
586 err = -EFAULT;
587 return err;
588}
589EXPORT_SYMBOL(compat_sock_get_timestampns);
590
567asmlinkage long compat_sys_getsockopt(int fd, int level, int optname, 591asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
568 char __user *optval, int __user *optlen) 592 char __user *optval, int __user *optlen)
569{ 593{
diff --git a/net/core/sock.c b/net/core/sock.c
index 6ddb3664b993..cb48fa0e1249 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1567,6 +1567,22 @@ int sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
1567} 1567}
1568EXPORT_SYMBOL(sock_get_timestamp); 1568EXPORT_SYMBOL(sock_get_timestamp);
1569 1569
1570int sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp)
1571{
1572 struct timespec ts;
1573 if (!sock_flag(sk, SOCK_TIMESTAMP))
1574 sock_enable_timestamp(sk);
1575 ts = ktime_to_timespec(sk->sk_stamp);
1576 if (ts.tv_sec == -1)
1577 return -ENOENT;
1578 if (ts.tv_sec == 0) {
1579 sk->sk_stamp = ktime_get_real();
1580 ts = ktime_to_timespec(sk->sk_stamp);
1581 }
1582 return copy_to_user(userstamp, &ts, sizeof(ts)) ? -EFAULT : 0;
1583}
1584EXPORT_SYMBOL(sock_get_timestampns);
1585
1570void sock_enable_timestamp(struct sock *sk) 1586void sock_enable_timestamp(struct sock *sk)
1571{ 1587{
1572 if (!sock_flag(sk, SOCK_TIMESTAMP)) { 1588 if (!sock_flag(sk, SOCK_TIMESTAMP)) {
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c
index f573eddc6034..487f879f5a19 100644
--- a/net/econet/af_econet.c
+++ b/net/econet/af_econet.c
@@ -727,6 +727,9 @@ static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg
727 case SIOCGSTAMP: 727 case SIOCGSTAMP:
728 return sock_get_timestamp(sk, argp); 728 return sock_get_timestamp(sk, argp);
729 729
730 case SIOCGSTAMPNS:
731 return sock_get_timestampns(sk, argp);
732
730 case SIOCSIFADDR: 733 case SIOCSIFADDR:
731 case SIOCGIFADDR: 734 case SIOCGIFADDR:
732 return ec_dev_ioctl(sock, cmd, argp); 735 return ec_dev_ioctl(sock, cmd, argp);
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index cf358c84c440..df41856fc603 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -755,6 +755,9 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
755 case SIOCGSTAMP: 755 case SIOCGSTAMP:
756 err = sock_get_timestamp(sk, (struct timeval __user *)arg); 756 err = sock_get_timestamp(sk, (struct timeval __user *)arg);
757 break; 757 break;
758 case SIOCGSTAMPNS:
759 err = sock_get_timestampns(sk, (struct timespec __user *)arg);
760 break;
758 case SIOCADDRT: 761 case SIOCADDRT:
759 case SIOCDELRT: 762 case SIOCDELRT:
760 case SIOCRTMSG: 763 case SIOCRTMSG:
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index fed3758181e1..2ff070417955 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -443,6 +443,9 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
443 case SIOCGSTAMP: 443 case SIOCGSTAMP:
444 return sock_get_timestamp(sk, (struct timeval __user *)arg); 444 return sock_get_timestamp(sk, (struct timeval __user *)arg);
445 445
446 case SIOCGSTAMPNS:
447 return sock_get_timestampns(sk, (struct timespec __user *)arg);
448
446 case SIOCADDRT: 449 case SIOCADDRT:
447 case SIOCDELRT: 450 case SIOCDELRT:
448 451
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index bf9837dd95c4..a54e7ef2568a 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -1209,6 +1209,12 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1209 release_sock(sk); 1209 release_sock(sk);
1210 return ret; 1210 return ret;
1211 1211
1212 case SIOCGSTAMPNS:
1213 lock_sock(sk);
1214 ret = sock_get_timestampns(sk, argp);
1215 release_sock(sk);
1216 return ret;
1217
1212 case SIOCGIFADDR: 1218 case SIOCGIFADDR:
1213 case SIOCSIFADDR: 1219 case SIOCSIFADDR:
1214 case SIOCGIFDSTADDR: 1220 case SIOCGIFDSTADDR:
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index f9866a8456a1..6f8c72d2413b 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1545,6 +1545,8 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
1545 } 1545 }
1546 case SIOCGSTAMP: 1546 case SIOCGSTAMP:
1547 return sock_get_timestamp(sk, (struct timeval __user *)arg); 1547 return sock_get_timestamp(sk, (struct timeval __user *)arg);
1548 case SIOCGSTAMPNS:
1549 return sock_get_timestampns(sk, (struct timespec __user *)arg);
1548 1550
1549#ifdef CONFIG_INET 1551#ifdef CONFIG_INET
1550 case SIOCADDRT: 1552 case SIOCADDRT:
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index f92d5310847b..f64be9369ef7 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1296,6 +1296,9 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1296 case SIOCGSTAMP: 1296 case SIOCGSTAMP:
1297 return sock_get_timestamp(sk, (struct timeval __user *) argp); 1297 return sock_get_timestamp(sk, (struct timeval __user *) argp);
1298 1298
1299 case SIOCGSTAMPNS:
1300 return sock_get_timestampns(sk, (struct timespec __user *) argp);
1301
1299 case SIOCGIFADDR: 1302 case SIOCGIFADDR:
1300 case SIOCSIFADDR: 1303 case SIOCSIFADDR:
1301 case SIOCGIFDSTADDR: 1304 case SIOCGIFDSTADDR:
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index e62ba41b05c5..a19884315622 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1280,6 +1280,12 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1280 rc = sock_get_timestamp(sk, 1280 rc = sock_get_timestamp(sk,
1281 (struct timeval __user *)argp); 1281 (struct timeval __user *)argp);
1282 break; 1282 break;
1283 case SIOCGSTAMPNS:
1284 rc = -EINVAL;
1285 if (sk)
1286 rc = sock_get_timestampns(sk,
1287 (struct timespec __user *)argp);
1288 break;
1283 case SIOCGIFADDR: 1289 case SIOCGIFADDR:
1284 case SIOCSIFADDR: 1290 case SIOCSIFADDR:
1285 case SIOCGIFDSTADDR: 1291 case SIOCGIFDSTADDR:
@@ -1521,6 +1527,12 @@ static int compat_x25_ioctl(struct socket *sock, unsigned int cmd,
1521 rc = compat_sock_get_timestamp(sk, 1527 rc = compat_sock_get_timestamp(sk,
1522 (struct timeval __user*)argp); 1528 (struct timeval __user*)argp);
1523 break; 1529 break;
1530 case SIOCGSTAMPNS:
1531 rc = -EINVAL;
1532 if (sk)
1533 rc = compat_sock_get_timestampns(sk,
1534 (struct timespec __user*)argp);
1535 break;
1524 case SIOCGIFADDR: 1536 case SIOCGIFADDR:
1525 case SIOCSIFADDR: 1537 case SIOCSIFADDR:
1526 case SIOCGIFDSTADDR: 1538 case SIOCGIFDSTADDR: