aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/af_unix.h29
-rw-r--r--net/unix/af_unix.c30
2 files changed, 28 insertions, 31 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 6de1e9e35c73..0864a775de24 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -12,37 +12,8 @@ extern void unix_gc(void);
12 12
13#define UNIX_HASH_SIZE 256 13#define UNIX_HASH_SIZE 256
14 14
15extern struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
16extern spinlock_t unix_table_lock;
17
18extern atomic_t unix_tot_inflight; 15extern atomic_t unix_tot_inflight;
19 16
20static inline struct sock *first_unix_socket(int *i)
21{
22 for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
23 if (!hlist_empty(&unix_socket_table[*i]))
24 return __sk_head(&unix_socket_table[*i]);
25 }
26 return NULL;
27}
28
29static inline struct sock *next_unix_socket(int *i, struct sock *s)
30{
31 struct sock *next = sk_next(s);
32 /* More in this chain? */
33 if (next)
34 return next;
35 /* Look for next non-empty chain. */
36 for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
37 if (!hlist_empty(&unix_socket_table[*i]))
38 return __sk_head(&unix_socket_table[*i]);
39 }
40 return NULL;
41}
42
43#define forall_unix_sockets(i, s) \
44 for (s = first_unix_socket(&(i)); s; s = next_unix_socket(&(i),(s)))
45
46struct unix_address { 17struct unix_address {
47 atomic_t refcnt; 18 atomic_t refcnt;
48 int len; 19 int len;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 65ebccc0a698..a05c34260e70 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -118,14 +118,40 @@
118 118
119int sysctl_unix_max_dgram_qlen __read_mostly = 10; 119int sysctl_unix_max_dgram_qlen __read_mostly = 10;
120 120
121struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; 121static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
122DEFINE_SPINLOCK(unix_table_lock); 122static DEFINE_SPINLOCK(unix_table_lock);
123static atomic_t unix_nr_socks = ATOMIC_INIT(0); 123static atomic_t unix_nr_socks = ATOMIC_INIT(0);
124 124
125#define unix_sockets_unbound (&unix_socket_table[UNIX_HASH_SIZE]) 125#define unix_sockets_unbound (&unix_socket_table[UNIX_HASH_SIZE])
126 126
127#define UNIX_ABSTRACT(sk) (unix_sk(sk)->addr->hash != UNIX_HASH_SIZE) 127#define UNIX_ABSTRACT(sk) (unix_sk(sk)->addr->hash != UNIX_HASH_SIZE)
128 128
129static struct sock *first_unix_socket(int *i)
130{
131 for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
132 if (!hlist_empty(&unix_socket_table[*i]))
133 return __sk_head(&unix_socket_table[*i]);
134 }
135 return NULL;
136}
137
138static struct sock *next_unix_socket(int *i, struct sock *s)
139{
140 struct sock *next = sk_next(s);
141 /* More in this chain? */
142 if (next)
143 return next;
144 /* Look for next non-empty chain. */
145 for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
146 if (!hlist_empty(&unix_socket_table[*i]))
147 return __sk_head(&unix_socket_table[*i]);
148 }
149 return NULL;
150}
151
152#define forall_unix_sockets(i, s) \
153 for (s = first_unix_socket(&(i)); s; s = next_unix_socket(&(i),(s)))
154
129#ifdef CONFIG_SECURITY_NETWORK 155#ifdef CONFIG_SECURITY_NETWORK
130static void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb) 156static void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb)
131{ 157{