conn_object.c (0d6bf319bc5aba4535bb46e1b607973688a2248a) | conn_object.c (9d35d880e0e4a3ab32d8c12f9e4d76198aadd42d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* RxRPC virtual connection handler, common bits. 3 * 4 * Copyright (C) 2007, 2016 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.com) 6 */ 7 8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt --- 53 unchanged lines hidden (view full) --- 62 conn = kzalloc(sizeof(struct rxrpc_connection), gfp); 63 if (conn) { 64 INIT_LIST_HEAD(&conn->cache_link); 65 timer_setup(&conn->timer, &rxrpc_connection_timer, 0); 66 INIT_WORK(&conn->processor, rxrpc_process_connection); 67 INIT_WORK(&conn->destructor, rxrpc_clean_up_connection); 68 INIT_LIST_HEAD(&conn->proc_link); 69 INIT_LIST_HEAD(&conn->link); | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* RxRPC virtual connection handler, common bits. 3 * 4 * Copyright (C) 2007, 2016 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.com) 6 */ 7 8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt --- 53 unchanged lines hidden (view full) --- 62 conn = kzalloc(sizeof(struct rxrpc_connection), gfp); 63 if (conn) { 64 INIT_LIST_HEAD(&conn->cache_link); 65 timer_setup(&conn->timer, &rxrpc_connection_timer, 0); 66 INIT_WORK(&conn->processor, rxrpc_process_connection); 67 INIT_WORK(&conn->destructor, rxrpc_clean_up_connection); 68 INIT_LIST_HEAD(&conn->proc_link); 69 INIT_LIST_HEAD(&conn->link); |
70 mutex_init(&conn->security_lock); |
|
70 skb_queue_head_init(&conn->rx_queue); 71 conn->rxnet = rxnet; 72 conn->security = &rxrpc_no_security; 73 spin_lock_init(&conn->state_lock); 74 conn->debug_id = atomic_inc_return(&rxrpc_debug_id); 75 conn->idle_timestamp = jiffies; 76 } 77 --- 74 unchanged lines hidden (view full) --- 152void __rxrpc_disconnect_call(struct rxrpc_connection *conn, 153 struct rxrpc_call *call) 154{ 155 struct rxrpc_channel *chan = 156 &conn->channels[call->cid & RXRPC_CHANNELMASK]; 157 158 _enter("%d,%x", conn->debug_id, call->cid); 159 | 71 skb_queue_head_init(&conn->rx_queue); 72 conn->rxnet = rxnet; 73 conn->security = &rxrpc_no_security; 74 spin_lock_init(&conn->state_lock); 75 conn->debug_id = atomic_inc_return(&rxrpc_debug_id); 76 conn->idle_timestamp = jiffies; 77 } 78 --- 74 unchanged lines hidden (view full) --- 153void __rxrpc_disconnect_call(struct rxrpc_connection *conn, 154 struct rxrpc_call *call) 155{ 156 struct rxrpc_channel *chan = 157 &conn->channels[call->cid & RXRPC_CHANNELMASK]; 158 159 _enter("%d,%x", conn->debug_id, call->cid); 160 |
160 if (rcu_access_pointer(chan->call) == call) { | 161 if (chan->call == call) { |
161 /* Save the result of the call so that we can repeat it if necessary 162 * through the channel, whilst disposing of the actual call record. 163 */ 164 trace_rxrpc_disconnect_call(call); 165 switch (call->completion) { 166 case RXRPC_CALL_SUCCEEDED: 167 chan->last_seq = call->rx_highest_seq; 168 chan->last_type = RXRPC_PACKET_TYPE_ACK; 169 break; 170 case RXRPC_CALL_LOCALLY_ABORTED: 171 chan->last_abort = call->abort_code; 172 chan->last_type = RXRPC_PACKET_TYPE_ABORT; 173 break; 174 default: 175 chan->last_abort = RX_CALL_DEAD; 176 chan->last_type = RXRPC_PACKET_TYPE_ABORT; 177 break; 178 } 179 | 162 /* Save the result of the call so that we can repeat it if necessary 163 * through the channel, whilst disposing of the actual call record. 164 */ 165 trace_rxrpc_disconnect_call(call); 166 switch (call->completion) { 167 case RXRPC_CALL_SUCCEEDED: 168 chan->last_seq = call->rx_highest_seq; 169 chan->last_type = RXRPC_PACKET_TYPE_ACK; 170 break; 171 case RXRPC_CALL_LOCALLY_ABORTED: 172 chan->last_abort = call->abort_code; 173 chan->last_type = RXRPC_PACKET_TYPE_ABORT; 174 break; 175 default: 176 chan->last_abort = RX_CALL_DEAD; 177 chan->last_type = RXRPC_PACKET_TYPE_ABORT; 178 break; 179 } 180 |
180 /* Sync with rxrpc_conn_retransmit(). */ 181 smp_wmb(); | |
182 chan->last_call = chan->call_id; 183 chan->call_id = chan->call_counter; | 181 chan->last_call = chan->call_id; 182 chan->call_id = chan->call_counter; |
184 185 rcu_assign_pointer(chan->call, NULL); | 183 chan->call = NULL; |
186 } 187 188 _leave(""); 189} 190 191/* 192 * Disconnect a call and clear any channel it occupies when that call 193 * terminates. --- 11 unchanged lines hidden (view full) --- 205 spin_lock(&call->peer->lock); 206 hlist_del_init(&call->error_link); 207 spin_unlock(&call->peer->lock); 208 } 209 210 if (rxrpc_is_client_call(call)) { 211 rxrpc_disconnect_client_call(call->bundle, call); 212 } else { | 184 } 185 186 _leave(""); 187} 188 189/* 190 * Disconnect a call and clear any channel it occupies when that call 191 * terminates. --- 11 unchanged lines hidden (view full) --- 203 spin_lock(&call->peer->lock); 204 hlist_del_init(&call->error_link); 205 spin_unlock(&call->peer->lock); 206 } 207 208 if (rxrpc_is_client_call(call)) { 209 rxrpc_disconnect_client_call(call->bundle, call); 210 } else { |
213 spin_lock(&conn->bundle->channel_lock); | |
214 __rxrpc_disconnect_call(conn, call); | 211 __rxrpc_disconnect_call(conn, call); |
215 spin_unlock(&conn->bundle->channel_lock); 216 | |
217 conn->idle_timestamp = jiffies; 218 if (atomic_dec_and_test(&conn->active)) 219 rxrpc_set_service_reap_timer(conn->rxnet, 220 jiffies + rxrpc_connection_expiry); 221 } 222 223 rxrpc_put_call(call, rxrpc_call_put_io_thread); 224} --- 86 unchanged lines hidden (view full) --- 311 * Clean up a dead connection. 312 */ 313static void rxrpc_clean_up_connection(struct work_struct *work) 314{ 315 struct rxrpc_connection *conn = 316 container_of(work, struct rxrpc_connection, destructor); 317 struct rxrpc_net *rxnet = conn->rxnet; 318 | 212 conn->idle_timestamp = jiffies; 213 if (atomic_dec_and_test(&conn->active)) 214 rxrpc_set_service_reap_timer(conn->rxnet, 215 jiffies + rxrpc_connection_expiry); 216 } 217 218 rxrpc_put_call(call, rxrpc_call_put_io_thread); 219} --- 86 unchanged lines hidden (view full) --- 306 * Clean up a dead connection. 307 */ 308static void rxrpc_clean_up_connection(struct work_struct *work) 309{ 310 struct rxrpc_connection *conn = 311 container_of(work, struct rxrpc_connection, destructor); 312 struct rxrpc_net *rxnet = conn->rxnet; 313 |
319 ASSERT(!rcu_access_pointer(conn->channels[0].call) && 320 !rcu_access_pointer(conn->channels[1].call) && 321 !rcu_access_pointer(conn->channels[2].call) && 322 !rcu_access_pointer(conn->channels[3].call)); | 314 ASSERT(!conn->channels[0].call && 315 !conn->channels[1].call && 316 !conn->channels[2].call && 317 !conn->channels[3].call); |
323 ASSERT(list_empty(&conn->cache_link)); 324 325 del_timer_sync(&conn->timer); 326 cancel_work_sync(&conn->processor); /* Processing may restart the timer */ 327 del_timer_sync(&conn->timer); 328 329 write_lock(&rxnet->conn_lock); 330 list_del_init(&conn->proc_link); --- 164 unchanged lines hidden --- | 318 ASSERT(list_empty(&conn->cache_link)); 319 320 del_timer_sync(&conn->timer); 321 cancel_work_sync(&conn->processor); /* Processing may restart the timer */ 322 del_timer_sync(&conn->timer); 323 324 write_lock(&rxnet->conn_lock); 325 list_del_init(&conn->proc_link); --- 164 unchanged lines hidden --- |