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/
Unified · Split
| @@ -103,4 +103,6 @@ · 102 unmodified lines | |||
| 103 | 103 | ||
| 104 | #define SO_INCOMING_NAPI_ID 56 | 104 | #define SO_INCOMING_NAPI_ID 56 |
| 105 | 105 | ||
| 106 | #define SO_COOKIE 57 | ||
| 107 | |||
| 106 | #endif /* _UAPI_ASM_SOCKET_H */ | 108 | #endif /* _UAPI_ASM_SOCKET_H */ |
| @@ -96,4 +96,6 @@ · 95 unmodified lines | |||
| 96 | 96 | ||
| 97 | #define SO_INCOMING_NAPI_ID 56 | 97 | #define SO_INCOMING_NAPI_ID 56 |
| 98 | 98 | ||
| 99 | #define SO_COOKIE 57 | ||
| 100 | |||
| 99 | #endif /* _UAPI__ASM_AVR32_SOCKET_H */ | 101 | #endif /* _UAPI__ASM_AVR32_SOCKET_H */ |
| @@ -96,5 +96,7 @@ · 95 unmodified lines | |||
| 96 | 96 | ||
| 97 | #define SO_INCOMING_NAPI_ID 56 | 97 | #define SO_INCOMING_NAPI_ID 56 |
| 98 | 98 | ||
| 99 | #define SO_COOKIE 57 | ||
| 100 | |||
| 99 | #endif /* _ASM_SOCKET_H */ | 101 | #endif /* _ASM_SOCKET_H */ |
| 100 | 102 | ||
| @@ -105,4 +105,6 @@ · 104 unmodified lines | |||
| 105 | 105 | ||
| 106 | #define SO_INCOMING_NAPI_ID 56 | 106 | #define SO_INCOMING_NAPI_ID 56 |
| 107 | 107 | ||
| 108 | #define SO_COOKIE 57 | ||
| 109 | |||
| 108 | #endif /* _ASM_IA64_SOCKET_H */ | 110 | #endif /* _ASM_IA64_SOCKET_H */ |
| @@ -96,4 +96,6 @@ · 95 unmodified lines | |||
| 96 | 96 | ||
| 97 | #define SO_INCOMING_NAPI_ID 56 | 97 | #define SO_INCOMING_NAPI_ID 56 |
| 98 | 98 | ||
| 99 | #define SO_COOKIE 57 | ||
| 100 | |||
| 99 | #endif /* _ASM_M32R_SOCKET_H */ | 101 | #endif /* _ASM_M32R_SOCKET_H */ |
| @@ -114,4 +114,6 @@ · 113 unmodified lines | |||
| 114 | 114 | ||
| 115 | #define SO_INCOMING_NAPI_ID 56 | 115 | #define SO_INCOMING_NAPI_ID 56 |
| 116 | 116 | ||
| 117 | #define SO_COOKIE 57 | ||
| 118 | |||
| 117 | #endif /* _UAPI_ASM_SOCKET_H */ | 119 | #endif /* _UAPI_ASM_SOCKET_H */ |
| @@ -96,4 +96,6 @@ · 95 unmodified lines | |||
| 96 | 96 | ||
| 97 | #define SO_INCOMING_NAPI_ID 56 | 97 | #define SO_INCOMING_NAPI_ID 56 |
| 98 | 98 | ||
| 99 | #define SO_COOKIE 57 | ||
| 100 | |||
| 99 | #endif /* _ASM_SOCKET_H */ | 101 | #endif /* _ASM_SOCKET_H */ |
| @@ -95,4 +95,6 @@ · 94 unmodified lines | |||
| 95 | 95 | ||
| 96 | #define SO_INCOMING_NAPI_ID 0x4031 | 96 | #define SO_INCOMING_NAPI_ID 0x4031 |
| 97 | 97 | ||
| 98 | #define SO_COOKIE 0x4032 | ||
| 99 | |||
| 98 | #endif /* _UAPI_ASM_SOCKET_H */ | 100 | #endif /* _UAPI_ASM_SOCKET_H */ |
| @@ -103,4 +103,6 @@ · 102 unmodified lines | |||
| 103 | 103 | ||
| 104 | #define SO_INCOMING_NAPI_ID 56 | 104 | #define SO_INCOMING_NAPI_ID 56 |
| 105 | 105 | ||
| 106 | #define SO_COOKIE 57 | ||
| 107 | |||
| 106 | #endif /* _ASM_POWERPC_SOCKET_H */ | 108 | #endif /* _ASM_POWERPC_SOCKET_H */ |
| @@ -102,4 +102,6 @@ · 101 unmodified lines | |||
| 102 | 102 | ||
| 103 | #define SO_INCOMING_NAPI_ID 56 | 103 | #define SO_INCOMING_NAPI_ID 56 |
| 104 | 104 | ||
| 105 | #define SO_COOKIE 57 | ||
| 106 | |||
| 105 | #endif /* _ASM_SOCKET_H */ | 107 | #endif /* _ASM_SOCKET_H */ |
| @@ -92,6 +92,8 @@ · 91 unmodified lines | |||
| 92 | 92 | ||
| 93 | #define SO_INCOMING_NAPI_ID 0x003a | 93 | #define SO_INCOMING_NAPI_ID 0x003a |
| 94 | 94 | ||
| 95 | #define SO_COOKIE 0x003b | ||
| 96 | |||
| 95 | /* Security levels - as per NRL IPv6 - don't actually do anything */ | 97 | /* Security levels - as per NRL IPv6 - don't actually do anything */ |
| 96 | #define SO_SECURITY_AUTHENTICATION 0x5001 | 98 | #define SO_SECURITY_AUTHENTICATION 0x5001 |
| 97 | #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 | 99 | #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 |
| @@ -107,4 +107,6 @@ · 106 unmodified lines | |||
| 107 | 107 | ||
| 108 | #define SO_INCOMING_NAPI_ID 56 | 108 | #define SO_INCOMING_NAPI_ID 56 |
| 109 | 109 | ||
| 110 | #define SO_COOKIE 57 | ||
| 111 | |||
| 110 | #endif /* _XTENSA_SOCKET_H */ | 112 | #endif /* _XTENSA_SOCKET_H */ |
| @@ -98,4 +98,6 @@ · 97 unmodified lines | |||
| 98 | 98 | ||
| 99 | #define SO_INCOMING_NAPI_ID 56 | 99 | #define SO_INCOMING_NAPI_ID 56 |
| 100 | 100 | ||
| 101 | #define SO_COOKIE 57 | ||
| 102 | |||
| 101 | #endif /* __ASM_GENERIC_SOCKET_H */ | 103 | #endif /* __ASM_GENERIC_SOCKET_H */ |
| @@ -1083,6 +1083,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, · 1082 unmodified lines | |||
| 1083 | 1083 | ||
| 1084 | union { | 1084 | union { |
| 1085 | int val; | 1085 | int val; |
| 1086 | u64 val64; | ||
| 1086 | struct linger ling; | 1087 | struct linger ling; |
| 1087 | struct timeval tm; | 1088 | struct timeval tm; |
| 1088 | } v; | 1089 | } v; |
| @@ -1340,6 +1341,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname, · 251 unmodified lines | |||
| 1340 | break; | 1341 | break; |
| 1341 | #endif | 1342 | #endif |
| 1342 | 1343 | ||
| 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 | |||
| 1343 | default: | 1351 | default: |
| 1344 | /* We implement the SO_SNDLOWAT etc to not be settable | 1352 | /* We implement the SO_SNDLOWAT etc to not be settable |
| 1345 | * (1003.1g 7). | 1353 | * (1003.1g 7). |