Lines Matching refs:local
33 struct rxrpc_local *local; in rxrpc_alloc_local() local
35 local = kzalloc(sizeof(struct rxrpc_local), GFP_KERNEL); in rxrpc_alloc_local()
36 if (local) { in rxrpc_alloc_local()
37 INIT_WORK(&local->destroyer, &rxrpc_destroy_local); in rxrpc_alloc_local()
38 INIT_WORK(&local->acceptor, &rxrpc_accept_incoming_calls); in rxrpc_alloc_local()
39 INIT_WORK(&local->rejecter, &rxrpc_reject_packets); in rxrpc_alloc_local()
40 INIT_LIST_HEAD(&local->services); in rxrpc_alloc_local()
41 INIT_LIST_HEAD(&local->link); in rxrpc_alloc_local()
42 init_rwsem(&local->defrag_sem); in rxrpc_alloc_local()
43 skb_queue_head_init(&local->accept_queue); in rxrpc_alloc_local()
44 skb_queue_head_init(&local->reject_queue); in rxrpc_alloc_local()
45 spin_lock_init(&local->lock); in rxrpc_alloc_local()
46 rwlock_init(&local->services_lock); in rxrpc_alloc_local()
47 atomic_set(&local->usage, 1); in rxrpc_alloc_local()
48 local->debug_id = atomic_inc_return(&rxrpc_debug_id); in rxrpc_alloc_local()
49 memcpy(&local->srx, srx, sizeof(*srx)); in rxrpc_alloc_local()
52 _leave(" = %p", local); in rxrpc_alloc_local()
53 return local; in rxrpc_alloc_local()
60 static int rxrpc_create_local(struct rxrpc_local *local) in rxrpc_create_local() argument
65 _enter("%p{%d}", local, local->srx.transport_type); in rxrpc_create_local()
68 ret = sock_create_kern(PF_INET, local->srx.transport_type, IPPROTO_UDP, in rxrpc_create_local()
69 &local->socket); in rxrpc_create_local()
76 if (local->srx.transport_len > sizeof(sa_family_t)) { in rxrpc_create_local()
78 ret = kernel_bind(local->socket, in rxrpc_create_local()
79 (struct sockaddr *) &local->srx.transport, in rxrpc_create_local()
80 local->srx.transport_len); in rxrpc_create_local()
89 ret = kernel_setsockopt(local->socket, SOL_IP, IP_RECVERR, in rxrpc_create_local()
98 ret = kernel_setsockopt(local->socket, SOL_IP, IP_MTU_DISCOVER, in rxrpc_create_local()
106 list_add(&local->link, &rxrpc_locals); in rxrpc_create_local()
110 sock = local->socket->sk; in rxrpc_create_local()
111 sock->sk_user_data = local; in rxrpc_create_local()
118 kernel_sock_shutdown(local->socket, SHUT_RDWR); in rxrpc_create_local()
119 local->socket->sk->sk_user_data = NULL; in rxrpc_create_local()
120 sock_release(local->socket); in rxrpc_create_local()
121 local->socket = NULL; in rxrpc_create_local()
132 struct rxrpc_local *local; in rxrpc_lookup_local() local
146 list_for_each_entry(local, &rxrpc_locals, link) { in rxrpc_lookup_local()
148 local->srx.transport_type, in rxrpc_lookup_local()
149 local->srx.transport.family, in rxrpc_lookup_local()
150 &local->srx.transport.sin.sin_addr, in rxrpc_lookup_local()
151 ntohs(local->srx.transport.sin.sin_port)); in rxrpc_lookup_local()
153 if (local->srx.transport_type != srx->transport_type || in rxrpc_lookup_local()
154 local->srx.transport.family != srx->transport.family) in rxrpc_lookup_local()
159 if (local->srx.transport.sin.sin_port != in rxrpc_lookup_local()
162 if (memcmp(&local->srx.transport.sin.sin_addr, in rxrpc_lookup_local()
176 local = rxrpc_alloc_local(srx); in rxrpc_lookup_local()
177 if (!local) { in rxrpc_lookup_local()
182 ret = rxrpc_create_local(local); in rxrpc_lookup_local()
185 kfree(local); in rxrpc_lookup_local()
193 local->debug_id, in rxrpc_lookup_local()
194 local->srx.transport_type, in rxrpc_lookup_local()
195 local->srx.transport.family, in rxrpc_lookup_local()
196 &local->srx.transport.sin.sin_addr, in rxrpc_lookup_local()
197 ntohs(local->srx.transport.sin.sin_port)); in rxrpc_lookup_local()
199 _leave(" = %p [new]", local); in rxrpc_lookup_local()
200 return local; in rxrpc_lookup_local()
203 rxrpc_get_local(local); in rxrpc_lookup_local()
208 local->debug_id, in rxrpc_lookup_local()
209 local->srx.transport_type, in rxrpc_lookup_local()
210 local->srx.transport.family, in rxrpc_lookup_local()
211 &local->srx.transport.sin.sin_addr, in rxrpc_lookup_local()
212 ntohs(local->srx.transport.sin.sin_port)); in rxrpc_lookup_local()
214 _leave(" = %p [reuse]", local); in rxrpc_lookup_local()
215 return local; in rxrpc_lookup_local()
221 void rxrpc_put_local(struct rxrpc_local *local) in rxrpc_put_local() argument
223 _enter("%p{u=%d}", local, atomic_read(&local->usage)); in rxrpc_put_local()
225 ASSERTCMP(atomic_read(&local->usage), >, 0); in rxrpc_put_local()
230 if (unlikely(atomic_dec_and_test(&local->usage))) { in rxrpc_put_local()
232 rxrpc_queue_work(&local->destroyer); in rxrpc_put_local()
243 struct rxrpc_local *local = in rxrpc_destroy_local() local
246 _enter("%p{%d}", local, atomic_read(&local->usage)); in rxrpc_destroy_local()
251 if (atomic_read(&local->usage) > 0) { in rxrpc_destroy_local()
258 list_del(&local->link); in rxrpc_destroy_local()
259 local->socket->sk->sk_user_data = NULL; in rxrpc_destroy_local()
264 ASSERT(list_empty(&local->services)); in rxrpc_destroy_local()
265 ASSERT(!work_pending(&local->acceptor)); in rxrpc_destroy_local()
266 ASSERT(!work_pending(&local->rejecter)); in rxrpc_destroy_local()
269 rxrpc_purge_queue(&local->accept_queue); in rxrpc_destroy_local()
270 rxrpc_purge_queue(&local->reject_queue); in rxrpc_destroy_local()
271 kernel_sock_shutdown(local->socket, SHUT_RDWR); in rxrpc_destroy_local()
272 sock_release(local->socket); in rxrpc_destroy_local()
276 _net("DESTROY LOCAL %d", local->debug_id); in rxrpc_destroy_local()
277 kfree(local); in rxrpc_destroy_local()