Lines Matching refs:rx

76 static int rxrpc_validate_address(struct rxrpc_sock *rx,  in rxrpc_validate_address()  argument
96 if (srx->transport.family != rx->family && in rxrpc_validate_address()
97 srx->transport.family == AF_INET && rx->family != AF_INET6) in rxrpc_validate_address()
133 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); in rxrpc_bind() local
137 _enter("%p,%p,%d", rx, saddr, len); in rxrpc_bind()
139 ret = rxrpc_validate_address(rx, srx, len); in rxrpc_bind()
144 lock_sock(&rx->sk); in rxrpc_bind()
146 switch (rx->sk.sk_state) { in rxrpc_bind()
148 rx->srx = *srx; in rxrpc_bind()
149 local = rxrpc_lookup_local(sock_net(&rx->sk), &rx->srx); in rxrpc_bind()
159 rx->local = local; in rxrpc_bind()
160 rcu_assign_pointer(local->service, rx); in rxrpc_bind()
163 rx->sk.sk_state = RXRPC_SERVER_BOUND; in rxrpc_bind()
165 rx->local = local; in rxrpc_bind()
166 rx->sk.sk_state = RXRPC_CLIENT_BOUND; in rxrpc_bind()
175 if (service_id == rx->srx.srx_service) in rxrpc_bind()
178 srx->srx_service = rx->srx.srx_service; in rxrpc_bind()
179 if (memcmp(srx, &rx->srx, sizeof(*srx)) != 0) in rxrpc_bind()
181 rx->second_service = service_id; in rxrpc_bind()
182 rx->sk.sk_state = RXRPC_SERVER_BOUND2; in rxrpc_bind()
190 release_sock(&rx->sk); in rxrpc_bind()
200 release_sock(&rx->sk); in rxrpc_bind()
212 struct rxrpc_sock *rx = rxrpc_sk(sk); in rxrpc_listen() local
216 _enter("%p,%d", rx, backlog); in rxrpc_listen()
218 lock_sock(&rx->sk); in rxrpc_listen()
220 switch (rx->sk.sk_state) { in rxrpc_listen()
226 ASSERT(rx->local != NULL); in rxrpc_listen()
235 ret = rxrpc_service_prealloc(rx, GFP_KERNEL); in rxrpc_listen()
237 rx->sk.sk_state = RXRPC_SERVER_LISTENING; in rxrpc_listen()
243 rx->sk.sk_state = RXRPC_SERVER_LISTEN_DISABLED; in rxrpc_listen()
245 rxrpc_discard_prealloc(rx); in rxrpc_listen()
255 release_sock(&rx->sk); in rxrpc_listen()
294 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); in rxrpc_kernel_begin_call() local
299 ret = rxrpc_validate_address(rx, srx, sizeof(*srx)); in rxrpc_kernel_begin_call()
303 lock_sock(&rx->sk); in rxrpc_kernel_begin_call()
306 key = rx->key; in rxrpc_kernel_begin_call()
317 cp.local = rx->local; in rxrpc_kernel_begin_call()
319 cp.security_level = rx->min_sec_level; in rxrpc_kernel_begin_call()
323 call = rxrpc_new_client_call(rx, &cp, srx, &p, gfp, debug_id); in rxrpc_kernel_begin_call()
413 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); in rxrpc_kernel_new_call_notification() local
415 rx->notify_new_call = notify_new_call; in rxrpc_kernel_new_call_notification()
416 rx->discard_new_call = discard_new_call; in rxrpc_kernel_new_call_notification()
454 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); in rxrpc_connect() local
457 _enter("%p,%p,%d,%d", rx, addr, addr_len, flags); in rxrpc_connect()
459 ret = rxrpc_validate_address(rx, srx, addr_len); in rxrpc_connect()
465 lock_sock(&rx->sk); in rxrpc_connect()
468 if (test_bit(RXRPC_SOCK_CONNECTED, &rx->flags)) in rxrpc_connect()
471 switch (rx->sk.sk_state) { in rxrpc_connect()
473 rx->sk.sk_state = RXRPC_CLIENT_UNBOUND; in rxrpc_connect()
483 rx->connect_srx = *srx; in rxrpc_connect()
484 set_bit(RXRPC_SOCK_CONNECTED, &rx->flags); in rxrpc_connect()
488 release_sock(&rx->sk); in rxrpc_connect()
504 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); in rxrpc_sendmsg() local
507 _enter(",{%d},,%zu", rx->sk.sk_state, len); in rxrpc_sendmsg()
513 ret = rxrpc_validate_address(rx, m->msg_name, m->msg_namelen); in rxrpc_sendmsg()
520 lock_sock(&rx->sk); in rxrpc_sendmsg()
522 switch (rx->sk.sk_state) { in rxrpc_sendmsg()
525 rx->srx.srx_family = AF_RXRPC; in rxrpc_sendmsg()
526 rx->srx.srx_service = 0; in rxrpc_sendmsg()
527 rx->srx.transport_type = SOCK_DGRAM; in rxrpc_sendmsg()
528 rx->srx.transport.family = rx->family; in rxrpc_sendmsg()
529 switch (rx->family) { in rxrpc_sendmsg()
531 rx->srx.transport_len = sizeof(struct sockaddr_in); in rxrpc_sendmsg()
535 rx->srx.transport_len = sizeof(struct sockaddr_in6); in rxrpc_sendmsg()
542 local = rxrpc_lookup_local(sock_net(sock->sk), &rx->srx); in rxrpc_sendmsg()
548 rx->local = local; in rxrpc_sendmsg()
549 rx->sk.sk_state = RXRPC_CLIENT_BOUND; in rxrpc_sendmsg()
554 test_bit(RXRPC_SOCK_CONNECTED, &rx->flags)) { in rxrpc_sendmsg()
555 m->msg_name = &rx->connect_srx; in rxrpc_sendmsg()
556 m->msg_namelen = sizeof(rx->connect_srx); in rxrpc_sendmsg()
561 ret = rxrpc_do_sendmsg(rx, m, len); in rxrpc_sendmsg()
570 release_sock(&rx->sk); in rxrpc_sendmsg()
595 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); in rxrpc_setsockopt() local
602 lock_sock(&rx->sk); in rxrpc_setsockopt()
612 if (rx->sk.sk_state != RXRPC_UNBOUND) in rxrpc_setsockopt()
614 rx->exclusive = true; in rxrpc_setsockopt()
619 if (rx->key) in rxrpc_setsockopt()
622 if (rx->sk.sk_state != RXRPC_UNBOUND) in rxrpc_setsockopt()
624 ret = rxrpc_request_key(rx, optval, optlen); in rxrpc_setsockopt()
629 if (rx->key) in rxrpc_setsockopt()
632 if (rx->sk.sk_state != RXRPC_UNBOUND) in rxrpc_setsockopt()
634 ret = rxrpc_server_keyring(rx, optval, optlen); in rxrpc_setsockopt()
642 if (rx->sk.sk_state != RXRPC_UNBOUND) in rxrpc_setsockopt()
651 rx->min_sec_level = min_sec_level; in rxrpc_setsockopt()
657 rx->service_upgrade.from != 0) in rxrpc_setsockopt()
660 if (rx->sk.sk_state != RXRPC_SERVER_BOUND2) in rxrpc_setsockopt()
667 if ((service_upgrade[0] != rx->srx.srx_service || in rxrpc_setsockopt()
668 service_upgrade[1] != rx->second_service) && in rxrpc_setsockopt()
669 (service_upgrade[0] != rx->second_service || in rxrpc_setsockopt()
670 service_upgrade[1] != rx->srx.srx_service)) in rxrpc_setsockopt()
672 rx->service_upgrade.from = service_upgrade[0]; in rxrpc_setsockopt()
673 rx->service_upgrade.to = service_upgrade[1]; in rxrpc_setsockopt()
684 release_sock(&rx->sk); in rxrpc_setsockopt()
723 struct rxrpc_sock *rx = rxrpc_sk(sk); in rxrpc_poll() local
731 if (!list_empty(&rx->recvmsg_q)) in rxrpc_poll()
750 struct rxrpc_sock *rx; in rxrpc_create() local
777 rx = rxrpc_sk(sk); in rxrpc_create()
778 rx->family = protocol; in rxrpc_create()
779 rx->calls = RB_ROOT; in rxrpc_create()
781 spin_lock_init(&rx->incoming_lock); in rxrpc_create()
782 INIT_LIST_HEAD(&rx->sock_calls); in rxrpc_create()
783 INIT_LIST_HEAD(&rx->to_be_accepted); in rxrpc_create()
784 INIT_LIST_HEAD(&rx->recvmsg_q); in rxrpc_create()
785 rwlock_init(&rx->recvmsg_lock); in rxrpc_create()
786 rwlock_init(&rx->call_lock); in rxrpc_create()
787 memset(&rx->srx, 0, sizeof(rx->srx)); in rxrpc_create()
789 rxnet = rxrpc_net(sock_net(&rx->sk)); in rxrpc_create()
792 _leave(" = 0 [%p]", rx); in rxrpc_create()
802 struct rxrpc_sock *rx = rxrpc_sk(sk); in rxrpc_shutdown() local
823 rxrpc_discard_prealloc(rx); in rxrpc_shutdown()
853 struct rxrpc_sock *rx = rxrpc_sk(sk); in rxrpc_release_sock() local
870 rx->local->service_closed = true; in rxrpc_release_sock()
878 if (rx->local && rcu_access_pointer(rx->local->service) == rx) { in rxrpc_release_sock()
879 write_lock(&rx->local->services_lock); in rxrpc_release_sock()
880 rcu_assign_pointer(rx->local->service, NULL); in rxrpc_release_sock()
881 write_unlock(&rx->local->services_lock); in rxrpc_release_sock()
885 rxrpc_discard_prealloc(rx); in rxrpc_release_sock()
886 rxrpc_release_calls_on_socket(rx); in rxrpc_release_sock()
890 rxrpc_unuse_local(rx->local); in rxrpc_release_sock()
891 rxrpc_put_local(rx->local); in rxrpc_release_sock()
892 rx->local = NULL; in rxrpc_release_sock()
893 key_put(rx->key); in rxrpc_release_sock()
894 rx->key = NULL; in rxrpc_release_sock()
895 key_put(rx->securities); in rxrpc_release_sock()
896 rx->securities = NULL; in rxrpc_release_sock()