Skip to content

Commit

Permalink
New getsockopt option to get socket cookie
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Chenbo Feng <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Chenbo Feng authored and davem330 committed Apr 8, 2017
1 parent c42cb98 commit 5daab9d
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/alpha/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _UAPI_ASM_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/avr32/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _UAPI__ASM_AVR32_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/frv/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _ASM_SOCKET_H */

2 changes: 2 additions & 0 deletions arch/ia64/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _ASM_IA64_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/m32r/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _ASM_M32R_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/mips/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _UAPI_ASM_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/mn10300/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _ASM_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/parisc/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,6 @@

#define SO_INCOMING_NAPI_ID 0x4031

#define SO_COOKIE 0x4032

#endif /* _UAPI_ASM_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/powerpc/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _ASM_POWERPC_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/s390/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _ASM_SOCKET_H */
2 changes: 2 additions & 0 deletions arch/sparc/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@

#define SO_INCOMING_NAPI_ID 0x003a

#define SO_COOKIE 0x003b

/* Security levels - as per NRL IPv6 - don't actually do anything */
#define SO_SECURITY_AUTHENTICATION 0x5001
#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
Expand Down
2 changes: 2 additions & 0 deletions arch/xtensa/include/uapi/asm/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* _XTENSA_SOCKET_H */
2 changes: 2 additions & 0 deletions include/uapi/asm-generic/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,6 @@

#define SO_INCOMING_NAPI_ID 56

#define SO_COOKIE 57

#endif /* __ASM_GENERIC_SOCKET_H */
8 changes: 8 additions & 0 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,

union {
int val;
u64 val64;
struct linger ling;
struct timeval tm;
} v;
Expand Down Expand Up @@ -1340,6 +1341,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
break;
#endif

case SO_COOKIE:
lv = sizeof(u64);
if (len < lv)
return -EINVAL;
v.val64 = sock_gen_cookie(sk);
break;

default:
/* We implement the SO_SNDLOWAT etc to not be settable
* (1003.1g 7).
Expand Down

0 comments on commit 5daab9d

Please sign in to comment.