1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Client connection-specific management code.
4 * Copyright (C) 2016, 2020 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
7 * Client connections need to be cached for a little while after they've made a
8 * call so as to handle retransmitted DATA packets in case the server didn't
9 * receive the final ACK or terminating ABORT we sent it.
11 * There are flags of relevance to the cache:
13 * (2) DONT_REUSE - The connection should be discarded as soon as possible and
14 * should not be reused. This is set when an exclusive connection is used
15 * or a call ID counter overflows.
17 * The caching state may only be changed if the cache lock is held.
19 * There are two idle client connection expiry durations. If the total number
20 * of connections is below the reap threshold, we use the normal duration; if
21 * it's above, we use the fast duration.
24 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26 #include <linux/slab.h>
27 #include <linux/idr.h>
28 #include <linux/timer.h>
29 #include <linux/sched/signal.h>
31 #include "ar-internal.h"
33 __read_mostly unsigned int rxrpc_reap_client_connections = 900;
34 __read_mostly unsigned long rxrpc_conn_idle_client_expiry = 2 * 60 * HZ;
35 __read_mostly unsigned long rxrpc_conn_idle_client_fast_expiry = 2 * HZ;
37 static void rxrpc_activate_bundle(struct rxrpc_bundle *bundle)
39 atomic_inc(&bundle->active);
43 * Release a connection ID for a client connection.
45 static void rxrpc_put_client_connection_id(struct rxrpc_local *local,
46 struct rxrpc_connection *conn)
48 idr_remove(&local->conn_ids, conn->proto.cid >> RXRPC_CIDSHIFT);
52 * Destroy the client connection ID tree.
54 static void rxrpc_destroy_client_conn_ids(struct rxrpc_local *local)
56 struct rxrpc_connection *conn;
59 if (!idr_is_empty(&local->conn_ids)) {
60 idr_for_each_entry(&local->conn_ids, conn, id) {
61 pr_err("AF_RXRPC: Leaked client conn %p {%d}\n",
62 conn, refcount_read(&conn->ref));
67 idr_destroy(&local->conn_ids);
71 * Allocate a connection bundle.
73 static struct rxrpc_bundle *rxrpc_alloc_bundle(struct rxrpc_call *call,
76 static atomic_t rxrpc_bundle_id;
77 struct rxrpc_bundle *bundle;
79 bundle = kzalloc(sizeof(*bundle), gfp);
81 bundle->local = call->local;
82 bundle->peer = rxrpc_get_peer(call->peer, rxrpc_peer_get_bundle);
83 bundle->key = key_get(call->key);
84 bundle->security = call->security;
85 bundle->exclusive = test_bit(RXRPC_CALL_EXCLUSIVE, &call->flags);
86 bundle->upgrade = test_bit(RXRPC_CALL_UPGRADE, &call->flags);
87 bundle->service_id = call->dest_srx.srx_service;
88 bundle->security_level = call->security_level;
89 bundle->debug_id = atomic_inc_return(&rxrpc_bundle_id);
90 refcount_set(&bundle->ref, 1);
91 atomic_set(&bundle->active, 1);
92 INIT_LIST_HEAD(&bundle->waiting_calls);
93 trace_rxrpc_bundle(bundle->debug_id, 1, rxrpc_bundle_new);
98 struct rxrpc_bundle *rxrpc_get_bundle(struct rxrpc_bundle *bundle,
99 enum rxrpc_bundle_trace why)
103 __refcount_inc(&bundle->ref, &r);
104 trace_rxrpc_bundle(bundle->debug_id, r + 1, why);
108 static void rxrpc_free_bundle(struct rxrpc_bundle *bundle)
110 trace_rxrpc_bundle(bundle->debug_id, refcount_read(&bundle->ref),
112 rxrpc_put_peer(bundle->peer, rxrpc_peer_put_bundle);
113 key_put(bundle->key);
117 void rxrpc_put_bundle(struct rxrpc_bundle *bundle, enum rxrpc_bundle_trace why)
124 id = bundle->debug_id;
125 dead = __refcount_dec_and_test(&bundle->ref, &r);
126 trace_rxrpc_bundle(id, r - 1, why);
128 rxrpc_free_bundle(bundle);
133 * Get rid of outstanding client connection preallocations when a local
134 * endpoint is destroyed.
136 void rxrpc_purge_client_connections(struct rxrpc_local *local)
138 rxrpc_destroy_client_conn_ids(local);
142 * Allocate a client connection.
144 static struct rxrpc_connection *
145 rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle)
147 struct rxrpc_connection *conn;
148 struct rxrpc_local *local = bundle->local;
149 struct rxrpc_net *rxnet = local->rxnet;
154 conn = rxrpc_alloc_connection(rxnet, GFP_ATOMIC | __GFP_NOWARN);
156 return ERR_PTR(-ENOMEM);
158 id = idr_alloc_cyclic(&local->conn_ids, conn, 1, 0x40000000,
159 GFP_ATOMIC | __GFP_NOWARN);
165 refcount_set(&conn->ref, 1);
166 conn->proto.cid = id << RXRPC_CIDSHIFT;
167 conn->proto.epoch = local->rxnet->epoch;
168 conn->out_clientflag = RXRPC_CLIENT_INITIATED;
169 conn->bundle = rxrpc_get_bundle(bundle, rxrpc_bundle_get_client_conn);
170 conn->local = rxrpc_get_local(bundle->local, rxrpc_local_get_client_conn);
171 conn->peer = rxrpc_get_peer(bundle->peer, rxrpc_peer_get_client_conn);
172 conn->key = key_get(bundle->key);
173 conn->security = bundle->security;
174 conn->exclusive = bundle->exclusive;
175 conn->upgrade = bundle->upgrade;
176 conn->orig_service_id = bundle->service_id;
177 conn->security_level = bundle->security_level;
178 conn->state = RXRPC_CONN_CLIENT_UNSECURED;
179 conn->service_id = conn->orig_service_id;
181 if (conn->security == &rxrpc_no_security)
182 conn->state = RXRPC_CONN_CLIENT;
184 atomic_inc(&rxnet->nr_conns);
185 write_lock(&rxnet->conn_lock);
186 list_add_tail(&conn->proc_link, &rxnet->conn_proc_list);
187 write_unlock(&rxnet->conn_lock);
189 rxrpc_see_connection(conn, rxrpc_conn_new_client);
191 atomic_inc(&rxnet->nr_client_conns);
192 trace_rxrpc_client(conn, -1, rxrpc_client_alloc);
197 * Determine if a connection may be reused.
199 static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn)
201 struct rxrpc_net *rxnet;
202 int id_cursor, id, distance, limit;
208 if (test_bit(RXRPC_CONN_DONT_REUSE, &conn->flags))
211 if ((conn->state != RXRPC_CONN_CLIENT_UNSECURED &&
212 conn->state != RXRPC_CONN_CLIENT) ||
213 conn->proto.epoch != rxnet->epoch)
214 goto mark_dont_reuse;
216 /* The IDR tree gets very expensive on memory if the connection IDs are
217 * widely scattered throughout the number space, so we shall want to
218 * kill off connections that, say, have an ID more than about four
219 * times the maximum number of client conns away from the current
220 * allocation point to try and keep the IDs concentrated.
222 id_cursor = idr_get_cursor(&conn->local->conn_ids);
223 id = conn->proto.cid >> RXRPC_CIDSHIFT;
224 distance = id - id_cursor;
226 distance = -distance;
227 limit = max_t(unsigned long, atomic_read(&rxnet->nr_conns) * 4, 1024);
228 if (distance > limit)
229 goto mark_dont_reuse;
234 set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
240 * Look up the conn bundle that matches the connection parameters, adding it if
241 * it doesn't yet exist.
243 int rxrpc_look_up_bundle(struct rxrpc_call *call, gfp_t gfp)
245 struct rxrpc_bundle *bundle, *candidate;
246 struct rxrpc_local *local = call->local;
247 struct rb_node *p, **pp, *parent;
249 bool upgrade = test_bit(RXRPC_CALL_UPGRADE, &call->flags);
251 _enter("{%px,%x,%u,%u}",
252 call->peer, key_serial(call->key), call->security_level,
255 if (test_bit(RXRPC_CALL_EXCLUSIVE, &call->flags)) {
256 call->bundle = rxrpc_alloc_bundle(call, gfp);
257 return call->bundle ? 0 : -ENOMEM;
260 /* First, see if the bundle is already there. */
262 spin_lock(&local->client_bundles_lock);
263 p = local->client_bundles.rb_node;
265 bundle = rb_entry(p, struct rxrpc_bundle, local_node);
267 #define cmp(X, Y) ((long)(X) - (long)(Y))
268 diff = (cmp(bundle->peer, call->peer) ?:
269 cmp(bundle->key, call->key) ?:
270 cmp(bundle->security_level, call->security_level) ?:
271 cmp(bundle->upgrade, upgrade));
280 spin_unlock(&local->client_bundles_lock);
283 /* It wasn't. We need to add one. */
284 candidate = rxrpc_alloc_bundle(call, gfp);
289 spin_lock(&local->client_bundles_lock);
290 pp = &local->client_bundles.rb_node;
294 bundle = rb_entry(parent, struct rxrpc_bundle, local_node);
296 #define cmp(X, Y) ((long)(X) - (long)(Y))
297 diff = (cmp(bundle->peer, call->peer) ?:
298 cmp(bundle->key, call->key) ?:
299 cmp(bundle->security_level, call->security_level) ?:
300 cmp(bundle->upgrade, upgrade));
303 pp = &(*pp)->rb_left;
305 pp = &(*pp)->rb_right;
307 goto found_bundle_free;
310 _debug("new bundle");
311 rb_link_node(&candidate->local_node, parent, pp);
312 rb_insert_color(&candidate->local_node, &local->client_bundles);
313 call->bundle = rxrpc_get_bundle(candidate, rxrpc_bundle_get_client_call);
314 spin_unlock(&local->client_bundles_lock);
315 _leave(" = B=%u [new]", call->bundle->debug_id);
319 rxrpc_free_bundle(candidate);
321 call->bundle = rxrpc_get_bundle(bundle, rxrpc_bundle_get_client_call);
322 rxrpc_activate_bundle(bundle);
323 spin_unlock(&local->client_bundles_lock);
324 _leave(" = B=%u [found]", call->bundle->debug_id);
329 * Allocate a new connection and add it into a bundle.
331 static bool rxrpc_add_conn_to_bundle(struct rxrpc_bundle *bundle,
334 struct rxrpc_connection *conn, *old;
335 unsigned int shift = slot * RXRPC_MAXCALLS;
338 old = bundle->conns[slot];
340 bundle->conns[slot] = NULL;
341 trace_rxrpc_client(old, -1, rxrpc_client_replace);
342 rxrpc_put_connection(old, rxrpc_conn_put_noreuse);
345 conn = rxrpc_alloc_client_connection(bundle);
347 bundle->alloc_error = PTR_ERR(conn);
351 rxrpc_activate_bundle(bundle);
352 conn->bundle_shift = shift;
353 bundle->conns[slot] = conn;
354 for (i = 0; i < RXRPC_MAXCALLS; i++)
355 set_bit(shift + i, &bundle->avail_chans);
360 * Add a connection to a bundle if there are no usable connections or we have
361 * connections waiting for extra capacity.
363 static bool rxrpc_bundle_has_space(struct rxrpc_bundle *bundle)
365 int slot = -1, i, usable;
369 bundle->alloc_error = 0;
371 /* See if there are any usable connections. */
373 for (i = 0; i < ARRAY_SIZE(bundle->conns); i++) {
374 if (rxrpc_may_reuse_conn(bundle->conns[i]))
380 if (!usable && bundle->upgrade)
381 bundle->try_upgrade = true;
386 if (!bundle->avail_chans &&
387 !bundle->try_upgrade &&
388 usable < ARRAY_SIZE(bundle->conns))
395 return slot >= 0 ? rxrpc_add_conn_to_bundle(bundle, slot) : false;
399 * Assign a channel to the call at the front of the queue and wake the call up.
400 * We don't increment the callNumber counter until this number has been exposed
403 static void rxrpc_activate_one_channel(struct rxrpc_connection *conn,
404 unsigned int channel)
406 struct rxrpc_channel *chan = &conn->channels[channel];
407 struct rxrpc_bundle *bundle = conn->bundle;
408 struct rxrpc_call *call = list_entry(bundle->waiting_calls.next,
409 struct rxrpc_call, wait_link);
410 u32 call_id = chan->call_counter + 1;
412 _enter("C=%x,%u", conn->debug_id, channel);
414 list_del_init(&call->wait_link);
416 trace_rxrpc_client(conn, channel, rxrpc_client_chan_activate);
418 /* Cancel the final ACK on the previous call if it hasn't been sent yet
419 * as the DATA packet will implicitly ACK it.
421 clear_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags);
422 clear_bit(conn->bundle_shift + channel, &bundle->avail_chans);
424 rxrpc_see_call(call, rxrpc_call_see_activate_client);
425 call->conn = rxrpc_get_connection(conn, rxrpc_conn_get_activate_call);
426 call->cid = conn->proto.cid | channel;
427 call->call_id = call_id;
428 call->dest_srx.srx_service = conn->service_id;
429 call->cong_ssthresh = call->peer->cong_ssthresh;
430 if (call->cong_cwnd >= call->cong_ssthresh)
431 call->cong_mode = RXRPC_CALL_CONGEST_AVOIDANCE;
433 call->cong_mode = RXRPC_CALL_SLOW_START;
435 chan->call_id = call_id;
436 chan->call_debug_id = call->debug_id;
439 rxrpc_see_call(call, rxrpc_call_see_connected);
440 trace_rxrpc_connect_call(call);
441 call->tx_last_sent = ktime_get_real();
442 rxrpc_start_call_timer(call);
443 rxrpc_set_call_state(call, RXRPC_CALL_CLIENT_SEND_REQUEST);
444 wake_up(&call->waitq);
448 * Remove a connection from the idle list if it's on it.
450 static void rxrpc_unidle_conn(struct rxrpc_connection *conn)
452 if (!list_empty(&conn->cache_link)) {
453 list_del_init(&conn->cache_link);
454 rxrpc_put_connection(conn, rxrpc_conn_put_unidle);
459 * Assign channels and callNumbers to waiting calls.
461 static void rxrpc_activate_channels(struct rxrpc_bundle *bundle)
463 struct rxrpc_connection *conn;
464 unsigned long avail, mask;
465 unsigned int channel, slot;
467 trace_rxrpc_client(NULL, -1, rxrpc_client_activate_chans);
469 if (bundle->try_upgrade)
474 while (!list_empty(&bundle->waiting_calls)) {
475 avail = bundle->avail_chans & mask;
478 channel = __ffs(avail);
479 clear_bit(channel, &bundle->avail_chans);
481 slot = channel / RXRPC_MAXCALLS;
482 conn = bundle->conns[slot];
486 if (bundle->try_upgrade)
487 set_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags);
488 rxrpc_unidle_conn(conn);
490 channel &= (RXRPC_MAXCALLS - 1);
491 conn->act_chans |= 1 << channel;
492 rxrpc_activate_one_channel(conn, channel);
497 * Connect waiting channels (called from the I/O thread).
499 void rxrpc_connect_client_calls(struct rxrpc_local *local)
501 struct rxrpc_call *call;
503 while ((call = list_first_entry_or_null(&local->new_client_calls,
504 struct rxrpc_call, wait_link))
506 struct rxrpc_bundle *bundle = call->bundle;
508 spin_lock(&local->client_call_lock);
509 list_move_tail(&call->wait_link, &bundle->waiting_calls);
510 spin_unlock(&local->client_call_lock);
512 if (rxrpc_bundle_has_space(bundle))
513 rxrpc_activate_channels(bundle);
518 * Note that a call, and thus a connection, is about to be exposed to the
521 void rxrpc_expose_client_call(struct rxrpc_call *call)
523 unsigned int channel = call->cid & RXRPC_CHANNELMASK;
524 struct rxrpc_connection *conn = call->conn;
525 struct rxrpc_channel *chan = &conn->channels[channel];
527 if (!test_and_set_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
528 /* Mark the call ID as being used. If the callNumber counter
529 * exceeds ~2 billion, we kill the connection after its
530 * outstanding calls have finished so that the counter doesn't
533 chan->call_counter++;
534 if (chan->call_counter >= INT_MAX)
535 set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
536 trace_rxrpc_client(conn, channel, rxrpc_client_exposed);
538 spin_lock(&call->peer->lock);
539 hlist_add_head(&call->error_link, &call->peer->error_targets);
540 spin_unlock(&call->peer->lock);
545 * Set the reap timer.
547 static void rxrpc_set_client_reap_timer(struct rxrpc_local *local)
549 if (!local->kill_all_client_conns) {
550 unsigned long now = jiffies;
551 unsigned long reap_at = now + rxrpc_conn_idle_client_expiry;
553 if (local->rxnet->live)
554 timer_reduce(&local->client_conn_reap_timer, reap_at);
559 * Disconnect a client call.
561 void rxrpc_disconnect_client_call(struct rxrpc_bundle *bundle, struct rxrpc_call *call)
563 struct rxrpc_connection *conn;
564 struct rxrpc_channel *chan = NULL;
565 struct rxrpc_local *local = bundle->local;
566 unsigned int channel;
570 _enter("c=%x", call->debug_id);
572 /* Calls that have never actually been assigned a channel can simply be
577 _debug("call is waiting");
578 ASSERTCMP(call->call_id, ==, 0);
579 ASSERT(!test_bit(RXRPC_CALL_EXPOSED, &call->flags));
580 list_del_init(&call->wait_link);
585 channel = cid & RXRPC_CHANNELMASK;
586 chan = &conn->channels[channel];
587 trace_rxrpc_client(conn, channel, rxrpc_client_chan_disconnect);
589 if (WARN_ON(chan->call != call))
592 may_reuse = rxrpc_may_reuse_conn(conn);
594 /* If a client call was exposed to the world, we save the result for
597 * We use a barrier here so that the call number and abort code can be
598 * read without needing to take a lock.
600 * TODO: Make the incoming packet handler check this and handle
601 * terminal retransmission without requiring access to the call.
603 if (test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
604 _debug("exposed %u,%u", call->call_id, call->abort_code);
605 __rxrpc_disconnect_call(conn, call);
607 if (test_and_clear_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags)) {
608 trace_rxrpc_client(conn, channel, rxrpc_client_to_active);
609 bundle->try_upgrade = false;
611 rxrpc_activate_channels(bundle);
615 /* See if we can pass the channel directly to another call. */
616 if (may_reuse && !list_empty(&bundle->waiting_calls)) {
617 trace_rxrpc_client(conn, channel, rxrpc_client_chan_pass);
618 rxrpc_activate_one_channel(conn, channel);
622 /* Schedule the final ACK to be transmitted in a short while so that it
623 * can be skipped if we find a follow-on call. The first DATA packet
624 * of the follow on call will implicitly ACK this call.
626 if (call->completion == RXRPC_CALL_SUCCEEDED &&
627 test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
628 unsigned long final_ack_at = jiffies + 2;
630 WRITE_ONCE(chan->final_ack_at, final_ack_at);
631 smp_wmb(); /* vs rxrpc_process_delayed_final_acks() */
632 set_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags);
633 rxrpc_reduce_conn_timer(conn, final_ack_at);
636 /* Deactivate the channel. */
638 set_bit(conn->bundle_shift + channel, &conn->bundle->avail_chans);
639 conn->act_chans &= ~(1 << channel);
641 /* If no channels remain active, then put the connection on the idle
642 * list for a short while. Give it a ref to stop it going away if it
645 if (!conn->act_chans) {
646 trace_rxrpc_client(conn, channel, rxrpc_client_to_idle);
647 conn->idle_timestamp = jiffies;
649 rxrpc_get_connection(conn, rxrpc_conn_get_idle);
650 list_move_tail(&conn->cache_link, &local->idle_client_conns);
652 rxrpc_set_client_reap_timer(local);
657 * Remove a connection from a bundle.
659 static void rxrpc_unbundle_conn(struct rxrpc_connection *conn)
661 struct rxrpc_bundle *bundle = conn->bundle;
665 _enter("C=%x", conn->debug_id);
667 if (conn->flags & RXRPC_CONN_FINAL_ACK_MASK)
668 rxrpc_process_delayed_final_acks(conn, true);
670 bindex = conn->bundle_shift / RXRPC_MAXCALLS;
671 if (bundle->conns[bindex] == conn) {
672 _debug("clear slot %u", bindex);
673 bundle->conns[bindex] = NULL;
674 for (i = 0; i < RXRPC_MAXCALLS; i++)
675 clear_bit(conn->bundle_shift + i, &bundle->avail_chans);
676 rxrpc_put_client_connection_id(bundle->local, conn);
677 rxrpc_deactivate_bundle(bundle);
678 rxrpc_put_connection(conn, rxrpc_conn_put_unbundle);
683 * Drop the active count on a bundle.
685 void rxrpc_deactivate_bundle(struct rxrpc_bundle *bundle)
687 struct rxrpc_local *local;
688 bool need_put = false;
693 local = bundle->local;
694 if (atomic_dec_and_lock(&bundle->active, &local->client_bundles_lock)) {
695 if (!bundle->exclusive) {
696 _debug("erase bundle");
697 rb_erase(&bundle->local_node, &local->client_bundles);
701 spin_unlock(&local->client_bundles_lock);
703 rxrpc_put_bundle(bundle, rxrpc_bundle_put_discard);
708 * Clean up a dead client connection.
710 void rxrpc_kill_client_conn(struct rxrpc_connection *conn)
712 struct rxrpc_local *local = conn->local;
713 struct rxrpc_net *rxnet = local->rxnet;
715 _enter("C=%x", conn->debug_id);
717 trace_rxrpc_client(conn, -1, rxrpc_client_cleanup);
718 atomic_dec(&rxnet->nr_client_conns);
720 rxrpc_put_client_connection_id(local, conn);
724 * Discard expired client connections from the idle list. Each conn in the
725 * idle list has been exposed and holds an extra ref because of that.
727 * This may be called from conn setup or from a work item so cannot be
728 * considered non-reentrant.
730 void rxrpc_discard_expired_client_conns(struct rxrpc_local *local)
732 struct rxrpc_connection *conn;
733 unsigned long expiry, conn_expires_at, now;
734 unsigned int nr_conns;
738 /* We keep an estimate of what the number of conns ought to be after
739 * we've discarded some so that we don't overdo the discarding.
741 nr_conns = atomic_read(&local->rxnet->nr_client_conns);
744 conn = list_first_entry_or_null(&local->idle_client_conns,
745 struct rxrpc_connection, cache_link);
749 if (!local->kill_all_client_conns) {
750 /* If the number of connections is over the reap limit, we
751 * expedite discard by reducing the expiry timeout. We must,
752 * however, have at least a short grace period to be able to do
753 * final-ACK or ABORT retransmission.
755 expiry = rxrpc_conn_idle_client_expiry;
756 if (nr_conns > rxrpc_reap_client_connections)
757 expiry = rxrpc_conn_idle_client_fast_expiry;
758 if (conn->local->service_closed)
759 expiry = rxrpc_closed_conn_expiry * HZ;
761 conn_expires_at = conn->idle_timestamp + expiry;
763 now = READ_ONCE(jiffies);
764 if (time_after(conn_expires_at, now))
765 goto not_yet_expired;
768 atomic_dec(&conn->active);
769 trace_rxrpc_client(conn, -1, rxrpc_client_discard);
770 list_del_init(&conn->cache_link);
772 rxrpc_unbundle_conn(conn);
773 /* Drop the ->cache_link ref */
774 rxrpc_put_connection(conn, rxrpc_conn_put_discard_idle);
780 /* The connection at the front of the queue hasn't yet expired, so
781 * schedule the work item for that point if we discarded something.
783 * We don't worry if the work item is already scheduled - it can look
784 * after rescheduling itself at a later time. We could cancel it, but
785 * then things get messier.
788 if (!local->kill_all_client_conns)
789 timer_reduce(&local->client_conn_reap_timer, conn_expires_at);
795 * Clean up the client connections on a local endpoint.
797 void rxrpc_clean_up_local_conns(struct rxrpc_local *local)
799 struct rxrpc_connection *conn;
803 local->kill_all_client_conns = true;
805 del_timer_sync(&local->client_conn_reap_timer);
807 while ((conn = list_first_entry_or_null(&local->idle_client_conns,
808 struct rxrpc_connection, cache_link))) {
809 list_del_init(&conn->cache_link);
810 atomic_dec(&conn->active);
811 trace_rxrpc_client(conn, -1, rxrpc_client_discard);
812 rxrpc_unbundle_conn(conn);
813 rxrpc_put_connection(conn, rxrpc_conn_put_local_dead);