History

New getsockopt option to get socket cookie

Introduce a new getsockopt operation to retrieve the socket cookie for a specific socket based on the socket fd. It returns a unique non-decreasing cookie for each socket. Tested: https://android-review.googlesource.com/#/c/358163/

Chenbo Feng committed 9 years ago

Commit 5daab9d1 parent c42cb9814 files · +34 −0Browse files

Unified · Split

14 files
  1. arch/alpha/include/uapi/asm/socket.h +2 −0
  2. arch/avr32/include/uapi/asm/socket.h +2 −0
  3. arch/frv/include/uapi/asm/socket.h +2 −0
  4. arch/ia64/include/uapi/asm/socket.h +2 −0
  5. arch/m32r/include/uapi/asm/socket.h +2 −0
  6. arch/mips/include/uapi/asm/socket.h +2 −0
  7. arch/mn10300/include/uapi/asm/socket.h +2 −0
  8. arch/parisc/include/uapi/asm/socket.h +2 −0
  9. arch/powerpc/include/uapi/asm/socket.h +2 −0
  10. arch/s390/include/uapi/asm/socket.h +2 −0
  11. arch/sparc/include/uapi/asm/socket.h +2 −0
  12. arch/xtensa/include/uapi/asm/socket.h +2 −0
  13. include/uapi/asm-generic/socket.h +2 −0
  14. net/core/sock.c +8 −0
arch/alpha/include/uapi/asm/socket.h+2−0
@@ -103,4 +103,6 @@ · 102 unmodified lines
103103
104104 #define SO_INCOMING_NAPI_ID 56
105105
106+#define SO_COOKIE 57
107+
106108 #endif /* _UAPI_ASM_SOCKET_H */
arch/avr32/include/uapi/asm/socket.h+2−0
@@ -96,4 +96,6 @@ · 95 unmodified lines
9696
9797 #define SO_INCOMING_NAPI_ID 56
9898
99+#define SO_COOKIE 57
100+
99101 #endif /* _UAPI__ASM_AVR32_SOCKET_H */
arch/frv/include/uapi/asm/socket.h+2−0
@@ -96,5 +96,7 @@ · 95 unmodified lines
9696
9797 #define SO_INCOMING_NAPI_ID 56
9898
99+#define SO_COOKIE 57
100+
99101 #endif /* _ASM_SOCKET_H */
100102
arch/ia64/include/uapi/asm/socket.h+2−0
@@ -105,4 +105,6 @@ · 104 unmodified lines
105105
106106 #define SO_INCOMING_NAPI_ID 56
107107
108+#define SO_COOKIE 57
109+
108110 #endif /* _ASM_IA64_SOCKET_H */
arch/m32r/include/uapi/asm/socket.h+2−0
@@ -96,4 +96,6 @@ · 95 unmodified lines
9696
9797 #define SO_INCOMING_NAPI_ID 56
9898
99+#define SO_COOKIE 57
100+
99101 #endif /* _ASM_M32R_SOCKET_H */
arch/mips/include/uapi/asm/socket.h+2−0
@@ -114,4 +114,6 @@ · 113 unmodified lines
114114
115115 #define SO_INCOMING_NAPI_ID 56
116116
117+#define SO_COOKIE 57
118+
117119 #endif /* _UAPI_ASM_SOCKET_H */
arch/mn10300/include/uapi/asm/socket.h+2−0
@@ -96,4 +96,6 @@ · 95 unmodified lines
9696
9797 #define SO_INCOMING_NAPI_ID 56
9898
99+#define SO_COOKIE 57
100+
99101 #endif /* _ASM_SOCKET_H */
arch/parisc/include/uapi/asm/socket.h+2−0
@@ -95,4 +95,6 @@ · 94 unmodified lines
9595
9696 #define SO_INCOMING_NAPI_ID 0x4031
9797
98+#define SO_COOKIE 0x4032
99+
98100 #endif /* _UAPI_ASM_SOCKET_H */
arch/powerpc/include/uapi/asm/socket.h+2−0
@@ -103,4 +103,6 @@ · 102 unmodified lines
103103
104104 #define SO_INCOMING_NAPI_ID 56
105105
106+#define SO_COOKIE 57
107+
106108 #endif /* _ASM_POWERPC_SOCKET_H */
arch/s390/include/uapi/asm/socket.h+2−0
@@ -102,4 +102,6 @@ · 101 unmodified lines
102102
103103 #define SO_INCOMING_NAPI_ID 56
104104
105+#define SO_COOKIE 57
106+
105107 #endif /* _ASM_SOCKET_H */
arch/sparc/include/uapi/asm/socket.h+2−0
@@ -92,6 +92,8 @@ · 91 unmodified lines
9292
9393 #define SO_INCOMING_NAPI_ID 0x003a
9494
95+#define SO_COOKIE 0x003b
96+
9597 /* Security levels - as per NRL IPv6 - don't actually do anything */
9698 #define SO_SECURITY_AUTHENTICATION 0x5001
9799 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
arch/xtensa/include/uapi/asm/socket.h+2−0
@@ -107,4 +107,6 @@ · 106 unmodified lines
107107
108108 #define SO_INCOMING_NAPI_ID 56
109109
110+#define SO_COOKIE 57
111+
110112 #endif /* _XTENSA_SOCKET_H */
include/uapi/asm-generic/socket.h+2−0
@@ -98,4 +98,6 @@ · 97 unmodified lines
9898
9999 #define SO_INCOMING_NAPI_ID 56
100100
101+#define SO_COOKIE 57
102+
101103 #endif /* __ASM_GENERIC_SOCKET_H */
net/core/sock.c+8−0
@@ -1083,6 +1083,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, · 1082 unmodified lines
10831083
10841084 union {
10851085 int val;
1086+ u64 val64;
10861087 struct linger ling;
10871088 struct timeval tm;
10881089 } v;
@@ -1340,6 +1341,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname, · 251 unmodified lines
13401341 break;
13411342 #endif
13421343
1344+ case SO_COOKIE:
1345+ lv = sizeof(u64);
1346+ if (len < lv)
1347+ return -EINVAL;
1348+ v.val64 = sock_gen_cookie(sk);
1349+ break;
1350+
13431351 default:
13441352 /* We implement the SO_SNDLOWAT etc to not be settable
13451353 * (1003.1g 7).

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t