Lines Matching full:conn
51 static int rxrpc_get_client_connection_id(struct rxrpc_connection *conn, in rxrpc_get_client_connection_id() argument
54 struct rxrpc_net *rxnet = conn->params.local->rxnet; in rxrpc_get_client_connection_id()
62 id = idr_alloc_cyclic(&rxrpc_client_conn_ids, conn, in rxrpc_get_client_connection_id()
70 conn->proto.epoch = rxnet->epoch; in rxrpc_get_client_connection_id()
71 conn->proto.cid = id << RXRPC_CIDSHIFT; in rxrpc_get_client_connection_id()
72 set_bit(RXRPC_CONN_HAS_IDR, &conn->flags); in rxrpc_get_client_connection_id()
73 _leave(" [CID %x]", conn->proto.cid); in rxrpc_get_client_connection_id()
86 static void rxrpc_put_client_connection_id(struct rxrpc_connection *conn) in rxrpc_put_client_connection_id() argument
88 if (test_bit(RXRPC_CONN_HAS_IDR, &conn->flags)) { in rxrpc_put_client_connection_id()
91 conn->proto.cid >> RXRPC_CIDSHIFT); in rxrpc_put_client_connection_id()
101 struct rxrpc_connection *conn; in rxrpc_destroy_client_conn_ids() local
105 idr_for_each_entry(&rxrpc_client_conn_ids, conn, id) { in rxrpc_destroy_client_conn_ids()
106 pr_err("AF_RXRPC: Leaked client conn %p {%d}\n", in rxrpc_destroy_client_conn_ids()
107 conn, refcount_read(&conn->ref)); in rxrpc_destroy_client_conn_ids()
166 struct rxrpc_connection *conn; in rxrpc_alloc_client_connection() local
172 conn = rxrpc_alloc_connection(gfp); in rxrpc_alloc_client_connection()
173 if (!conn) { in rxrpc_alloc_client_connection()
178 refcount_set(&conn->ref, 1); in rxrpc_alloc_client_connection()
179 conn->bundle = bundle; in rxrpc_alloc_client_connection()
180 conn->params = bundle->params; in rxrpc_alloc_client_connection()
181 conn->out_clientflag = RXRPC_CLIENT_INITIATED; in rxrpc_alloc_client_connection()
182 conn->state = RXRPC_CONN_CLIENT; in rxrpc_alloc_client_connection()
183 conn->service_id = conn->params.service_id; in rxrpc_alloc_client_connection()
185 ret = rxrpc_get_client_connection_id(conn, gfp); in rxrpc_alloc_client_connection()
189 ret = rxrpc_init_client_conn_security(conn); in rxrpc_alloc_client_connection()
195 list_add_tail(&conn->proc_link, &rxnet->conn_proc_list); in rxrpc_alloc_client_connection()
199 rxrpc_get_peer(conn->params.peer); in rxrpc_alloc_client_connection()
200 rxrpc_get_local(conn->params.local); in rxrpc_alloc_client_connection()
201 key_get(conn->params.key); in rxrpc_alloc_client_connection()
203 trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_client, in rxrpc_alloc_client_connection()
204 refcount_read(&conn->ref), in rxrpc_alloc_client_connection()
208 trace_rxrpc_client(conn, -1, rxrpc_client_alloc); in rxrpc_alloc_client_connection()
209 _leave(" = %p", conn); in rxrpc_alloc_client_connection()
210 return conn; in rxrpc_alloc_client_connection()
213 rxrpc_put_client_connection_id(conn); in rxrpc_alloc_client_connection()
215 kfree(conn); in rxrpc_alloc_client_connection()
223 static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn) in rxrpc_may_reuse_conn() argument
228 if (!conn) in rxrpc_may_reuse_conn()
231 rxnet = conn->params.local->rxnet; in rxrpc_may_reuse_conn()
232 if (test_bit(RXRPC_CONN_DONT_REUSE, &conn->flags)) in rxrpc_may_reuse_conn()
235 if (conn->state != RXRPC_CONN_CLIENT || in rxrpc_may_reuse_conn()
236 conn->proto.epoch != rxnet->epoch) in rxrpc_may_reuse_conn()
246 id = conn->proto.cid >> RXRPC_CIDSHIFT; in rxrpc_may_reuse_conn()
257 set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags); in rxrpc_may_reuse_conn()
263 * Look up the conn bundle that matches the connection parameters, adding it if
513 static void rxrpc_activate_one_channel(struct rxrpc_connection *conn, in rxrpc_activate_one_channel() argument
516 struct rxrpc_channel *chan = &conn->channels[channel]; in rxrpc_activate_one_channel()
517 struct rxrpc_bundle *bundle = conn->bundle; in rxrpc_activate_one_channel()
522 _enter("C=%x,%u", conn->debug_id, channel); in rxrpc_activate_one_channel()
524 trace_rxrpc_client(conn, channel, rxrpc_client_chan_activate); in rxrpc_activate_one_channel()
529 clear_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags); in rxrpc_activate_one_channel()
530 clear_bit(conn->bundle_shift + channel, &bundle->avail_chans); in rxrpc_activate_one_channel()
534 call->peer = rxrpc_get_peer(conn->params.peer); in rxrpc_activate_one_channel()
535 call->conn = rxrpc_get_connection(conn); in rxrpc_activate_one_channel()
536 call->cid = conn->proto.cid | channel; in rxrpc_activate_one_channel()
538 call->security = conn->security; in rxrpc_activate_one_channel()
539 call->security_ix = conn->security_ix; in rxrpc_activate_one_channel()
540 call->service_id = conn->service_id; in rxrpc_activate_one_channel()
543 _net("CONNECT call %08x:%08x as call %d on conn %d", in rxrpc_activate_one_channel()
544 call->cid, call->call_id, call->debug_id, conn->debug_id); in rxrpc_activate_one_channel()
571 static void rxrpc_unidle_conn(struct rxrpc_bundle *bundle, struct rxrpc_connection *conn) in rxrpc_unidle_conn() argument
576 if (!list_empty(&conn->cache_link)) { in rxrpc_unidle_conn()
579 if (!list_empty(&conn->cache_link)) { in rxrpc_unidle_conn()
580 list_del_init(&conn->cache_link); in rxrpc_unidle_conn()
585 rxrpc_put_connection(conn); in rxrpc_unidle_conn()
595 struct rxrpc_connection *conn; in rxrpc_activate_channels_locked() local
612 conn = bundle->conns[slot]; in rxrpc_activate_channels_locked()
613 if (!conn) in rxrpc_activate_channels_locked()
617 set_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags); in rxrpc_activate_channels_locked()
618 rxrpc_unidle_conn(bundle, conn); in rxrpc_activate_channels_locked()
621 conn->act_chans |= 1 << channel; in rxrpc_activate_channels_locked()
622 rxrpc_activate_one_channel(conn, channel); in rxrpc_activate_channels_locked()
749 trace_rxrpc_client(call->conn, ret, rxrpc_client_chan_wait_failed); in rxrpc_connect_call()
762 struct rxrpc_connection *conn = call->conn; in rxrpc_expose_client_call() local
763 struct rxrpc_channel *chan = &conn->channels[channel]; in rxrpc_expose_client_call()
773 set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags); in rxrpc_expose_client_call()
774 trace_rxrpc_client(conn, channel, rxrpc_client_exposed); in rxrpc_expose_client_call()
797 struct rxrpc_connection *conn; in rxrpc_disconnect_client_call() local
812 conn = call->conn; in rxrpc_disconnect_client_call()
813 if (!conn) { in rxrpc_disconnect_client_call()
823 chan = &conn->channels[channel]; in rxrpc_disconnect_client_call()
824 trace_rxrpc_client(conn, channel, rxrpc_client_chan_disconnect); in rxrpc_disconnect_client_call()
831 may_reuse = rxrpc_may_reuse_conn(conn); in rxrpc_disconnect_client_call()
844 __rxrpc_disconnect_call(conn, call); in rxrpc_disconnect_client_call()
846 if (test_and_clear_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags)) { in rxrpc_disconnect_client_call()
847 trace_rxrpc_client(conn, channel, rxrpc_client_to_active); in rxrpc_disconnect_client_call()
857 trace_rxrpc_client(conn, channel, rxrpc_client_chan_pass); in rxrpc_disconnect_client_call()
858 rxrpc_activate_one_channel(conn, channel); in rxrpc_disconnect_client_call()
872 set_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags); in rxrpc_disconnect_client_call()
873 rxrpc_reduce_conn_timer(conn, final_ack_at); in rxrpc_disconnect_client_call()
878 set_bit(conn->bundle_shift + channel, &conn->bundle->avail_chans); in rxrpc_disconnect_client_call()
879 conn->act_chans &= ~(1 << channel); in rxrpc_disconnect_client_call()
885 if (!conn->act_chans) { in rxrpc_disconnect_client_call()
886 trace_rxrpc_client(conn, channel, rxrpc_client_to_idle); in rxrpc_disconnect_client_call()
887 conn->idle_timestamp = jiffies; in rxrpc_disconnect_client_call()
889 rxrpc_get_connection(conn); in rxrpc_disconnect_client_call()
891 list_move_tail(&conn->cache_link, &rxnet->idle_client_conns); in rxrpc_disconnect_client_call()
906 static void rxrpc_unbundle_conn(struct rxrpc_connection *conn) in rxrpc_unbundle_conn() argument
908 struct rxrpc_bundle *bundle = conn->bundle; in rxrpc_unbundle_conn()
913 _enter("C=%x", conn->debug_id); in rxrpc_unbundle_conn()
915 if (conn->flags & RXRPC_CONN_FINAL_ACK_MASK) in rxrpc_unbundle_conn()
916 rxrpc_process_delayed_final_acks(conn, true); in rxrpc_unbundle_conn()
919 bindex = conn->bundle_shift / RXRPC_MAXCALLS; in rxrpc_unbundle_conn()
920 if (bundle->conns[bindex] == conn) { in rxrpc_unbundle_conn()
924 clear_bit(conn->bundle_shift + i, &bundle->avail_chans); in rxrpc_unbundle_conn()
931 rxrpc_put_connection(conn); in rxrpc_unbundle_conn()
959 static void rxrpc_kill_client_conn(struct rxrpc_connection *conn) in rxrpc_kill_client_conn() argument
961 struct rxrpc_local *local = conn->params.local; in rxrpc_kill_client_conn()
964 _enter("C=%x", conn->debug_id); in rxrpc_kill_client_conn()
966 trace_rxrpc_client(conn, -1, rxrpc_client_cleanup); in rxrpc_kill_client_conn()
969 rxrpc_put_client_connection_id(conn); in rxrpc_kill_client_conn()
970 rxrpc_kill_connection(conn); in rxrpc_kill_client_conn()
976 void rxrpc_put_client_conn(struct rxrpc_connection *conn) in rxrpc_put_client_conn() argument
979 unsigned int debug_id = conn->debug_id; in rxrpc_put_client_conn()
983 dead = __refcount_dec_and_test(&conn->ref, &r); in rxrpc_put_client_conn()
986 rxrpc_kill_client_conn(conn); in rxrpc_put_client_conn()
990 * Discard expired client connections from the idle list. Each conn in the
993 * This may be called from conn setup or from a work item so cannot be
998 struct rxrpc_connection *conn; in rxrpc_discard_expired_client_conns() local
1028 conn = list_entry(rxnet->idle_client_conns.next, in rxrpc_discard_expired_client_conns()
1040 if (conn->params.local->service_closed) in rxrpc_discard_expired_client_conns()
1043 conn_expires_at = conn->idle_timestamp + expiry; in rxrpc_discard_expired_client_conns()
1050 trace_rxrpc_client(conn, -1, rxrpc_client_discard); in rxrpc_discard_expired_client_conns()
1051 list_del_init(&conn->cache_link); in rxrpc_discard_expired_client_conns()
1055 rxrpc_unbundle_conn(conn); in rxrpc_discard_expired_client_conns()
1056 rxrpc_put_connection(conn); /* Drop the ->cache_link ref */ in rxrpc_discard_expired_client_conns()
1104 struct rxrpc_connection *conn, *tmp; in rxrpc_clean_up_local_conns() local
1112 list_for_each_entry_safe(conn, tmp, &rxnet->idle_client_conns, in rxrpc_clean_up_local_conns()
1114 if (conn->params.local == local) { in rxrpc_clean_up_local_conns()
1115 trace_rxrpc_client(conn, -1, rxrpc_client_discard); in rxrpc_clean_up_local_conns()
1116 list_move(&conn->cache_link, &graveyard); in rxrpc_clean_up_local_conns()
1123 conn = list_entry(graveyard.next, in rxrpc_clean_up_local_conns()
1125 list_del_init(&conn->cache_link); in rxrpc_clean_up_local_conns()
1126 rxrpc_unbundle_conn(conn); in rxrpc_clean_up_local_conns()
1127 rxrpc_put_connection(conn); in rxrpc_clean_up_local_conns()