Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/

Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Chenbo Feng <fengc@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Chenbo Feng and committed by
David S. Miller
5daab9db c42cb98c

+34
+2
arch/alpha/include/uapi/asm/socket.h
··· 103 103 104 104 #define SO_INCOMING_NAPI_ID 56 105 105 106 + #define SO_COOKIE 57 107 + 106 108 #endif /* _UAPI_ASM_SOCKET_H */
+2
arch/avr32/include/uapi/asm/socket.h
··· 96 96 97 97 #define SO_INCOMING_NAPI_ID 56 98 98 99 + #define SO_COOKIE 57 100 + 99 101 #endif /* _UAPI__ASM_AVR32_SOCKET_H */
+2
arch/frv/include/uapi/asm/socket.h
··· 96 96 97 97 #define SO_INCOMING_NAPI_ID 56 98 98 99 + #define SO_COOKIE 57 100 + 99 101 #endif /* _ASM_SOCKET_H */ 100 102
+2
arch/ia64/include/uapi/asm/socket.h
··· 105 105 106 106 #define SO_INCOMING_NAPI_ID 56 107 107 108 + #define SO_COOKIE 57 109 + 108 110 #endif /* _ASM_IA64_SOCKET_H */
+2
arch/m32r/include/uapi/asm/socket.h
··· 96 96 97 97 #define SO_INCOMING_NAPI_ID 56 98 98 99 + #define SO_COOKIE 57 100 + 99 101 #endif /* _ASM_M32R_SOCKET_H */
+2
arch/mips/include/uapi/asm/socket.h
··· 114 114 115 115 #define SO_INCOMING_NAPI_ID 56 116 116 117 + #define SO_COOKIE 57 118 + 117 119 #endif /* _UAPI_ASM_SOCKET_H */
+2
arch/mn10300/include/uapi/asm/socket.h
··· 96 96 97 97 #define SO_INCOMING_NAPI_ID 56 98 98 99 + #define SO_COOKIE 57 100 + 99 101 #endif /* _ASM_SOCKET_H */
+2
arch/parisc/include/uapi/asm/socket.h
··· 95 95 96 96 #define SO_INCOMING_NAPI_ID 0x4031 97 97 98 + #define SO_COOKIE 0x4032 99 + 98 100 #endif /* _UAPI_ASM_SOCKET_H */
+2
arch/powerpc/include/uapi/asm/socket.h
··· 103 103 104 104 #define SO_INCOMING_NAPI_ID 56 105 105 106 + #define SO_COOKIE 57 107 + 106 108 #endif /* _ASM_POWERPC_SOCKET_H */
+2
arch/s390/include/uapi/asm/socket.h
··· 102 102 103 103 #define SO_INCOMING_NAPI_ID 56 104 104 105 + #define SO_COOKIE 57 106 + 105 107 #endif /* _ASM_SOCKET_H */
+2
arch/sparc/include/uapi/asm/socket.h
··· 92 92 93 93 #define SO_INCOMING_NAPI_ID 0x003a 94 94 95 + #define SO_COOKIE 0x003b 96 + 95 97 /* Security levels - as per NRL IPv6 - don't actually do anything */ 96 98 #define SO_SECURITY_AUTHENTICATION 0x5001 97 99 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
+2
arch/xtensa/include/uapi/asm/socket.h
··· 107 107 108 108 #define SO_INCOMING_NAPI_ID 56 109 109 110 + #define SO_COOKIE 57 111 + 110 112 #endif /* _XTENSA_SOCKET_H */
+2
include/uapi/asm-generic/socket.h
··· 98 98 99 99 #define SO_INCOMING_NAPI_ID 56 100 100 101 + #define SO_COOKIE 57 102 + 101 103 #endif /* __ASM_GENERIC_SOCKET_H */
+8
net/core/sock.c
··· 1083 1083 1084 1084 union { 1085 1085 int val; 1086 + u64 val64; 1086 1087 struct linger ling; 1087 1088 struct timeval tm; 1088 1089 } v; ··· 1340 1339 1341 1340 break; 1342 1341 #endif 1342 + 1343 + case SO_COOKIE: 1344 + lv = sizeof(u64); 1345 + if (len < lv) 1346 + return -EINVAL; 1347 + v.val64 = sock_gen_cookie(sk); 1348 + break; 1343 1349 1344 1350 default: 1345 1351 /* We implement the SO_SNDLOWAT etc to not be settable