diff options
author | Chenbo Feng <fengc@google.com> | 2017-04-05 19:00:55 -0700 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2022-04-19 00:51:44 +0300 |
commit | 8604eec9796759143f9a5e690f10f118d4260530 (patch) | |
tree | ec93cf82d84db869c73c1e5cd9de38f63bea571a /net/core/sock.c | |
parent | 1a759ab3516beb70fc432a7ebbae99b863d15517 (diff) |
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: Willem de Bruijn <willemb@google.com>
Signed-off-by: Chenbo Feng <fengc@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index c292fca75ee2..7ffd843b2866 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -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). |