Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c455d8b authored by Chenbo Feng's avatar Chenbo Feng Committed by ivanmeler
Browse files

BACKPORT [FROMLIST] New getsockopt option to get socket cookie

Cherry-pick from linux net-next branch commit
http://patchwork.ozlabs.org/patch/747590/

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/



Test: Unit test added in kernel/tests

Acked-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarChenbo Feng <fengc@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ff3e275f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -102,4 +102,6 @@
#endif
/* END_OF_KNOX_NPA */

#define SO_COOKIE		57

#endif /* __ASM_GENERIC_SOCKET_H */
+8 −0
Original line number Diff line number Diff line
@@ -1061,6 +1061,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,

	union {
		int val;
		u64 val64;
		struct linger ling;
		struct timeval tm;
	} v;
@@ -1295,6 +1296,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
		v.val = sk->sk_incoming_cpu;
		break;


	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).