Skip to content

Commit 07feaeb

Browse files
ebiedermDavid S. Miller
authored andcommitted
[NET]: Add a network namespace parameter to struct sock
Sockets need to get a reference to their network namespace, or possibly a simple hold if someone registers on the network namespace notifier and will free the sockets when the namespace is going to be destroyed. Signed-off-by: Eric W. Biederman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4a1c537 commit 07feaeb

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

include/net/inet_timewait_sock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct inet_timewait_sock {
115115
#define tw_refcnt __tw_common.skc_refcnt
116116
#define tw_hash __tw_common.skc_hash
117117
#define tw_prot __tw_common.skc_prot
118+
#define tw_net __tw_common.skc_net
118119
volatile unsigned char tw_substate;
119120
/* 3 bits hole, try to pack */
120121
unsigned char tw_rcv_wscale;

include/net/sock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct proto;
105105
* @skc_refcnt: reference count
106106
* @skc_hash: hash value used with various protocol lookup tables
107107
* @skc_prot: protocol handlers inside a network family
108+
* @skc_net: reference to the network namespace of this socket
108109
*
109110
* This is the minimal network layer representation of sockets, the header
110111
* for struct sock and struct inet_timewait_sock.
@@ -119,6 +120,7 @@ struct sock_common {
119120
atomic_t skc_refcnt;
120121
unsigned int skc_hash;
121122
struct proto *skc_prot;
123+
struct net *skc_net;
122124
};
123125

124126
/**
@@ -195,6 +197,7 @@ struct sock {
195197
#define sk_refcnt __sk_common.skc_refcnt
196198
#define sk_hash __sk_common.skc_hash
197199
#define sk_prot __sk_common.skc_prot
200+
#define sk_net __sk_common.skc_net
198201
unsigned char sk_shutdown : 2,
199202
sk_no_check : 2,
200203
sk_userlocks : 4;

0 commit comments

Comments
 (0)