aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-31 18:51:00 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-31 18:51:00 -0400
commit0d6caa1795090bd22ede96b84daa4600b63eee37 (patch)
tree7b69aa68f7f812bd1a13b0c5e73573a01e671ef8 /net/unix/af_unix.c
parent88c8199b9d2f5ec0a8468a0495ba4c9656846500 (diff)
parent8072f085d79a0a73cc5a0333ffa7f0c5d35f76e0 (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (41 commits) [RTNETLINK]: Fix warning for !CONFIG_KMOD [IPV4] ip_options.c: kmalloc + memset conversion to kzalloc [DECNET]: kmalloc + memset conversion to kzalloc [NET]: ethtool_perm_addr only has one implementation [NET]: ethtool ops are the only way [PPPOE]: Improve hashing function in hash_item(). [XFRM]: State selection update to use inner addresses. [IPSEC]: Ensure that state inner family is set [TCP]: Bidir flow must not disregard SACK blocks for lost marking [TCP]: Fix ratehalving with bidirectional flows [PPPOL2TP]: Add CONFIG_INET Kconfig dependency. [NET]: Page offsets and lengths need to be __u32. [AF_UNIX]: Make code static. [NETFILTER]: Make nf_ct_ipv6_skip_exthdr() static. [PKTGEN]: make get_ipsec_sa() static and non-inline [PPPoE]: move lock_sock() in pppoe_sendmsg() to the right location [PPPoX/E]: return ENOTTY on unknown ioctl requests [IPV6]: ipv6_addr_type() doesn't know about RFC4193 addresses. [NET]: Fix prio_tune() handling of root qdisc. [NET]: Fix sch_api to properly set sch->parent on the root. ...
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c30
1 files changed, 28 insertions, 2 deletions
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{