aboutsummaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorChenbo Feng <fengc@google.com>2017-04-11 10:37:06 -0700
committerMister Oyster <oysterized@gmail.com>2017-05-23 19:48:06 +0200
commit49104f1ff068f94a6644afd28d6e62315d21784e (patch)
treea2129e471c6dbc4821da6a1ad37508625e86f8aa /include/net
parent40dacaaf5628101771dc5bd45bc47bd0ea7842e5 (diff)
BACKPORT [UPSTREAM] net: add real socket cookies
Cherry-pick from upstream commit 33cf7c90fe2f97afb1cadaa0cfb782cb9d1b9ee2. Introduce a unique per netspace identifier for each socket and it is required by xt_qtaguid module to identify the socket without holding the socket reference count. The change is modified to the minimal impact so that it doesn't change other socket networking behavior. Signed-off-by: mydongistiny <jaysonedson@gmail.com> Signed-off-by: Joe Maples <joe@frap129.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/inet_timewait_sock.h1
-rw-r--r--include/net/net_namespace.h2
-rw-r--r--include/net/sock.h3
3 files changed, 6 insertions, 0 deletions
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index f908dfc06..44975efe4 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -116,6 +116,7 @@ struct inet_timewait_sock {
#define tw_dport __tw_common.skc_dport
#define tw_num __tw_common.skc_num
#define tw_portpair __tw_common.skc_portpair
+#define tw_cookie __tw_common.skc_cookie
int tw_timeout;
volatile unsigned char tw_substate;
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 0faaed2e2..b69e8e8d7 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -54,6 +54,8 @@ struct net {
#endif
spinlock_t rules_mod_lock;
+ atomic64_t cookie_gen;
+
struct list_head list; /* list of network namespaces */
struct list_head cleanup_list; /* namespaces on death row */
struct list_head exit_list; /* Use only net_mutex */
diff --git a/include/net/sock.h b/include/net/sock.h
index 1fa662430..8d3d22ce2 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -192,6 +192,8 @@ struct sock_common {
#ifdef CONFIG_NET_NS
struct net *skc_net;
#endif
+ atomic64_t skc_cookie;
+
/*
* fields between dontcopy_begin/dontcopy_end
* are not copied in sock_copy()
@@ -306,6 +308,7 @@ struct sock {
#define sk_bind_node __sk_common.skc_bind_node
#define sk_prot __sk_common.skc_prot
#define sk_net __sk_common.skc_net
+#define sk_cookie __sk_common.skc_cookie
socket_lock_t sk_lock;
struct sk_buff_head sk_receive_queue;
/*