conn_client.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. /* Client connection-specific management code.
  2. *
  3. * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. *
  11. *
  12. * Client connections need to be cached for a little while after they've made a
  13. * call so as to handle retransmitted DATA packets in case the server didn't
  14. * receive the final ACK or terminating ABORT we sent it.
  15. *
  16. * Client connections can be in one of a number of cache states:
  17. *
  18. * (1) INACTIVE - The connection is not held in any list and may not have been
  19. * exposed to the world. If it has been previously exposed, it was
  20. * discarded from the idle list after expiring.
  21. *
  22. * (2) WAITING - The connection is waiting for the number of client conns to
  23. * drop below the maximum capacity. Calls may be in progress upon it from
  24. * when it was active and got culled.
  25. *
  26. * The connection is on the rxrpc_waiting_client_conns list which is kept
  27. * in to-be-granted order. Culled conns with waiters go to the back of
  28. * the queue just like new conns.
  29. *
  30. * (3) ACTIVE - The connection has at least one call in progress upon it, it
  31. * may freely grant available channels to new calls and calls may be
  32. * waiting on it for channels to become available.
  33. *
  34. * The connection is on the rxnet->active_client_conns list which is kept
  35. * in activation order for culling purposes.
  36. *
  37. * rxrpc_nr_active_client_conns is held incremented also.
  38. *
  39. * (4) UPGRADE - As for ACTIVE, but only one call may be in progress and is
  40. * being used to probe for service upgrade.
  41. *
  42. * (5) CULLED - The connection got summarily culled to try and free up
  43. * capacity. Calls currently in progress on the connection are allowed to
  44. * continue, but new calls will have to wait. There can be no waiters in
  45. * this state - the conn would have to go to the WAITING state instead.
  46. *
  47. * (6) IDLE - The connection has no calls in progress upon it and must have
  48. * been exposed to the world (ie. the EXPOSED flag must be set). When it
  49. * expires, the EXPOSED flag is cleared and the connection transitions to
  50. * the INACTIVE state.
  51. *
  52. * The connection is on the rxnet->idle_client_conns list which is kept in
  53. * order of how soon they'll expire.
  54. *
  55. * There are flags of relevance to the cache:
  56. *
  57. * (1) EXPOSED - The connection ID got exposed to the world. If this flag is
  58. * set, an extra ref is added to the connection preventing it from being
  59. * reaped when it has no calls outstanding. This flag is cleared and the
  60. * ref dropped when a conn is discarded from the idle list.
  61. *
  62. * This allows us to move terminal call state retransmission to the
  63. * connection and to discard the call immediately we think it is done
  64. * with. It also give us a chance to reuse the connection.
  65. *
  66. * (2) DONT_REUSE - The connection should be discarded as soon as possible and
  67. * should not be reused. This is set when an exclusive connection is used
  68. * or a call ID counter overflows.
  69. *
  70. * The caching state may only be changed if the cache lock is held.
  71. *
  72. * There are two idle client connection expiry durations. If the total number
  73. * of connections is below the reap threshold, we use the normal duration; if
  74. * it's above, we use the fast duration.
  75. */
  76. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  77. #include <linux/slab.h>
  78. #include <linux/idr.h>
  79. #include <linux/timer.h>
  80. #include <linux/sched/signal.h>
  81. #include "ar-internal.h"
  82. __read_mostly unsigned int rxrpc_max_client_connections = 1000;
  83. __read_mostly unsigned int rxrpc_reap_client_connections = 900;
  84. __read_mostly unsigned long rxrpc_conn_idle_client_expiry = 2 * 60 * HZ;
  85. __read_mostly unsigned long rxrpc_conn_idle_client_fast_expiry = 2 * HZ;
  86. /*
  87. * We use machine-unique IDs for our client connections.
  88. */
  89. DEFINE_IDR(rxrpc_client_conn_ids);
  90. static DEFINE_SPINLOCK(rxrpc_conn_id_lock);
  91. static void rxrpc_cull_active_client_conns(struct rxrpc_net *);
  92. /*
  93. * Get a connection ID and epoch for a client connection from the global pool.
  94. * The connection struct pointer is then recorded in the idr radix tree. The
  95. * epoch doesn't change until the client is rebooted (or, at least, unless the
  96. * module is unloaded).
  97. */
  98. static int rxrpc_get_client_connection_id(struct rxrpc_connection *conn,
  99. gfp_t gfp)
  100. {
  101. struct rxrpc_net *rxnet = conn->params.local->rxnet;
  102. int id;
  103. _enter("");
  104. idr_preload(gfp);
  105. spin_lock(&rxrpc_conn_id_lock);
  106. id = idr_alloc_cyclic(&rxrpc_client_conn_ids, conn,
  107. 1, 0x40000000, GFP_NOWAIT);
  108. if (id < 0)
  109. goto error;
  110. spin_unlock(&rxrpc_conn_id_lock);
  111. idr_preload_end();
  112. conn->proto.epoch = rxnet->epoch;
  113. conn->proto.cid = id << RXRPC_CIDSHIFT;
  114. set_bit(RXRPC_CONN_HAS_IDR, &conn->flags);
  115. _leave(" [CID %x]", conn->proto.cid);
  116. return 0;
  117. error:
  118. spin_unlock(&rxrpc_conn_id_lock);
  119. idr_preload_end();
  120. _leave(" = %d", id);
  121. return id;
  122. }
  123. /*
  124. * Release a connection ID for a client connection from the global pool.
  125. */
  126. static void rxrpc_put_client_connection_id(struct rxrpc_connection *conn)
  127. {
  128. if (test_bit(RXRPC_CONN_HAS_IDR, &conn->flags)) {
  129. spin_lock(&rxrpc_conn_id_lock);
  130. idr_remove(&rxrpc_client_conn_ids,
  131. conn->proto.cid >> RXRPC_CIDSHIFT);
  132. spin_unlock(&rxrpc_conn_id_lock);
  133. }
  134. }
  135. /*
  136. * Destroy the client connection ID tree.
  137. */
  138. void rxrpc_destroy_client_conn_ids(void)
  139. {
  140. struct rxrpc_connection *conn;
  141. int id;
  142. if (!idr_is_empty(&rxrpc_client_conn_ids)) {
  143. idr_for_each_entry(&rxrpc_client_conn_ids, conn, id) {
  144. pr_err("AF_RXRPC: Leaked client conn %p {%d}\n",
  145. conn, atomic_read(&conn->usage));
  146. }
  147. BUG();
  148. }
  149. idr_destroy(&rxrpc_client_conn_ids);
  150. }
  151. /*
  152. * Allocate a client connection.
  153. */
  154. static struct rxrpc_connection *
  155. rxrpc_alloc_client_connection(struct rxrpc_conn_parameters *cp, gfp_t gfp)
  156. {
  157. struct rxrpc_connection *conn;
  158. struct rxrpc_net *rxnet = cp->local->rxnet;
  159. int ret;
  160. _enter("");
  161. conn = rxrpc_alloc_connection(gfp);
  162. if (!conn) {
  163. _leave(" = -ENOMEM");
  164. return ERR_PTR(-ENOMEM);
  165. }
  166. atomic_set(&conn->usage, 1);
  167. if (cp->exclusive)
  168. __set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
  169. if (cp->upgrade)
  170. __set_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags);
  171. conn->params = *cp;
  172. conn->out_clientflag = RXRPC_CLIENT_INITIATED;
  173. conn->state = RXRPC_CONN_CLIENT;
  174. conn->service_id = cp->service_id;
  175. ret = rxrpc_get_client_connection_id(conn, gfp);
  176. if (ret < 0)
  177. goto error_0;
  178. ret = rxrpc_init_client_conn_security(conn);
  179. if (ret < 0)
  180. goto error_1;
  181. ret = conn->security->prime_packet_security(conn);
  182. if (ret < 0)
  183. goto error_2;
  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);
  188. /* We steal the caller's peer ref. */
  189. cp->peer = NULL;
  190. rxrpc_get_local(conn->params.local);
  191. key_get(conn->params.key);
  192. trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_client,
  193. atomic_read(&conn->usage),
  194. __builtin_return_address(0));
  195. trace_rxrpc_client(conn, -1, rxrpc_client_alloc);
  196. _leave(" = %p", conn);
  197. return conn;
  198. error_2:
  199. conn->security->clear(conn);
  200. error_1:
  201. rxrpc_put_client_connection_id(conn);
  202. error_0:
  203. kfree(conn);
  204. _leave(" = %d", ret);
  205. return ERR_PTR(ret);
  206. }
  207. /*
  208. * Determine if a connection may be reused.
  209. */
  210. static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn)
  211. {
  212. struct rxrpc_net *rxnet = conn->params.local->rxnet;
  213. int id_cursor, id, distance, limit;
  214. if (test_bit(RXRPC_CONN_DONT_REUSE, &conn->flags))
  215. goto dont_reuse;
  216. if (conn->proto.epoch != rxnet->epoch)
  217. goto mark_dont_reuse;
  218. /* The IDR tree gets very expensive on memory if the connection IDs are
  219. * widely scattered throughout the number space, so we shall want to
  220. * kill off connections that, say, have an ID more than about four
  221. * times the maximum number of client conns away from the current
  222. * allocation point to try and keep the IDs concentrated.
  223. */
  224. id_cursor = idr_get_cursor(&rxrpc_client_conn_ids);
  225. id = conn->proto.cid >> RXRPC_CIDSHIFT;
  226. distance = id - id_cursor;
  227. if (distance < 0)
  228. distance = -distance;
  229. limit = max(rxrpc_max_client_connections * 4, 1024U);
  230. if (distance > limit)
  231. goto mark_dont_reuse;
  232. return true;
  233. mark_dont_reuse:
  234. set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
  235. dont_reuse:
  236. return false;
  237. }
  238. /*
  239. * Create or find a client connection to use for a call.
  240. *
  241. * If we return with a connection, the call will be on its waiting list. It's
  242. * left to the caller to assign a channel and wake up the call.
  243. */
  244. static int rxrpc_get_client_conn(struct rxrpc_sock *rx,
  245. struct rxrpc_call *call,
  246. struct rxrpc_conn_parameters *cp,
  247. struct sockaddr_rxrpc *srx,
  248. gfp_t gfp)
  249. {
  250. struct rxrpc_connection *conn, *candidate = NULL;
  251. struct rxrpc_local *local = cp->local;
  252. struct rb_node *p, **pp, *parent;
  253. long diff;
  254. int ret = -ENOMEM;
  255. _enter("{%d,%lx},", call->debug_id, call->user_call_ID);
  256. cp->peer = rxrpc_lookup_peer(rx, cp->local, srx, gfp);
  257. if (!cp->peer)
  258. goto error;
  259. call->cong_cwnd = cp->peer->cong_cwnd;
  260. if (call->cong_cwnd >= call->cong_ssthresh)
  261. call->cong_mode = RXRPC_CALL_CONGEST_AVOIDANCE;
  262. else
  263. call->cong_mode = RXRPC_CALL_SLOW_START;
  264. /* If the connection is not meant to be exclusive, search the available
  265. * connections to see if the connection we want to use already exists.
  266. */
  267. if (!cp->exclusive) {
  268. _debug("search 1");
  269. spin_lock(&local->client_conns_lock);
  270. p = local->client_conns.rb_node;
  271. while (p) {
  272. conn = rb_entry(p, struct rxrpc_connection, client_node);
  273. #define cmp(X) ((long)conn->params.X - (long)cp->X)
  274. diff = (cmp(peer) ?:
  275. cmp(key) ?:
  276. cmp(security_level) ?:
  277. cmp(upgrade));
  278. #undef cmp
  279. if (diff < 0) {
  280. p = p->rb_left;
  281. } else if (diff > 0) {
  282. p = p->rb_right;
  283. } else {
  284. if (rxrpc_may_reuse_conn(conn) &&
  285. rxrpc_get_connection_maybe(conn))
  286. goto found_extant_conn;
  287. /* The connection needs replacing. It's better
  288. * to effect that when we have something to
  289. * replace it with so that we don't have to
  290. * rebalance the tree twice.
  291. */
  292. break;
  293. }
  294. }
  295. spin_unlock(&local->client_conns_lock);
  296. }
  297. /* There wasn't a connection yet or we need an exclusive connection.
  298. * We need to create a candidate and then potentially redo the search
  299. * in case we're racing with another thread also trying to connect on a
  300. * shareable connection.
  301. */
  302. _debug("new conn");
  303. candidate = rxrpc_alloc_client_connection(cp, gfp);
  304. if (IS_ERR(candidate)) {
  305. ret = PTR_ERR(candidate);
  306. goto error_peer;
  307. }
  308. /* Add the call to the new connection's waiting list in case we're
  309. * going to have to wait for the connection to come live. It's our
  310. * connection, so we want first dibs on the channel slots. We would
  311. * normally have to take channel_lock but we do this before anyone else
  312. * can see the connection.
  313. */
  314. list_add(&call->chan_wait_link, &candidate->waiting_calls);
  315. if (cp->exclusive) {
  316. call->conn = candidate;
  317. call->security_ix = candidate->security_ix;
  318. call->service_id = candidate->service_id;
  319. _leave(" = 0 [exclusive %d]", candidate->debug_id);
  320. return 0;
  321. }
  322. /* Publish the new connection for userspace to find. We need to redo
  323. * the search before doing this lest we race with someone else adding a
  324. * conflicting instance.
  325. */
  326. _debug("search 2");
  327. spin_lock(&local->client_conns_lock);
  328. pp = &local->client_conns.rb_node;
  329. parent = NULL;
  330. while (*pp) {
  331. parent = *pp;
  332. conn = rb_entry(parent, struct rxrpc_connection, client_node);
  333. #define cmp(X) ((long)conn->params.X - (long)candidate->params.X)
  334. diff = (cmp(peer) ?:
  335. cmp(key) ?:
  336. cmp(security_level) ?:
  337. cmp(upgrade));
  338. #undef cmp
  339. if (diff < 0) {
  340. pp = &(*pp)->rb_left;
  341. } else if (diff > 0) {
  342. pp = &(*pp)->rb_right;
  343. } else {
  344. if (rxrpc_may_reuse_conn(conn) &&
  345. rxrpc_get_connection_maybe(conn))
  346. goto found_extant_conn;
  347. /* The old connection is from an outdated epoch. */
  348. _debug("replace conn");
  349. clear_bit(RXRPC_CONN_IN_CLIENT_CONNS, &conn->flags);
  350. rb_replace_node(&conn->client_node,
  351. &candidate->client_node,
  352. &local->client_conns);
  353. trace_rxrpc_client(conn, -1, rxrpc_client_replace);
  354. goto candidate_published;
  355. }
  356. }
  357. _debug("new conn");
  358. rb_link_node(&candidate->client_node, parent, pp);
  359. rb_insert_color(&candidate->client_node, &local->client_conns);
  360. candidate_published:
  361. set_bit(RXRPC_CONN_IN_CLIENT_CONNS, &candidate->flags);
  362. call->conn = candidate;
  363. call->security_ix = candidate->security_ix;
  364. call->service_id = candidate->service_id;
  365. spin_unlock(&local->client_conns_lock);
  366. _leave(" = 0 [new %d]", candidate->debug_id);
  367. return 0;
  368. /* We come here if we found a suitable connection already in existence.
  369. * Discard any candidate we may have allocated, and try to get a
  370. * channel on this one.
  371. */
  372. found_extant_conn:
  373. _debug("found conn");
  374. spin_unlock(&local->client_conns_lock);
  375. if (candidate) {
  376. trace_rxrpc_client(candidate, -1, rxrpc_client_duplicate);
  377. rxrpc_put_connection(candidate);
  378. candidate = NULL;
  379. }
  380. spin_lock(&conn->channel_lock);
  381. call->conn = conn;
  382. call->security_ix = conn->security_ix;
  383. call->service_id = conn->service_id;
  384. list_add_tail(&call->chan_wait_link, &conn->waiting_calls);
  385. spin_unlock(&conn->channel_lock);
  386. _leave(" = 0 [extant %d]", conn->debug_id);
  387. return 0;
  388. error_peer:
  389. rxrpc_put_peer(cp->peer);
  390. cp->peer = NULL;
  391. error:
  392. _leave(" = %d", ret);
  393. return ret;
  394. }
  395. /*
  396. * Activate a connection.
  397. */
  398. static void rxrpc_activate_conn(struct rxrpc_net *rxnet,
  399. struct rxrpc_connection *conn)
  400. {
  401. if (test_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags)) {
  402. trace_rxrpc_client(conn, -1, rxrpc_client_to_upgrade);
  403. conn->cache_state = RXRPC_CONN_CLIENT_UPGRADE;
  404. } else {
  405. trace_rxrpc_client(conn, -1, rxrpc_client_to_active);
  406. conn->cache_state = RXRPC_CONN_CLIENT_ACTIVE;
  407. }
  408. rxnet->nr_active_client_conns++;
  409. list_move_tail(&conn->cache_link, &rxnet->active_client_conns);
  410. }
  411. /*
  412. * Attempt to animate a connection for a new call.
  413. *
  414. * If it's not exclusive, the connection is in the endpoint tree, and we're in
  415. * the conn's list of those waiting to grab a channel. There is, however, a
  416. * limit on the number of live connections allowed at any one time, so we may
  417. * have to wait for capacity to become available.
  418. *
  419. * Note that a connection on the waiting queue might *also* have active
  420. * channels if it has been culled to make space and then re-requested by a new
  421. * call.
  422. */
  423. static void rxrpc_animate_client_conn(struct rxrpc_net *rxnet,
  424. struct rxrpc_connection *conn)
  425. {
  426. unsigned int nr_conns;
  427. _enter("%d,%d", conn->debug_id, conn->cache_state);
  428. if (conn->cache_state == RXRPC_CONN_CLIENT_ACTIVE ||
  429. conn->cache_state == RXRPC_CONN_CLIENT_UPGRADE)
  430. goto out;
  431. spin_lock(&rxnet->client_conn_cache_lock);
  432. nr_conns = rxnet->nr_client_conns;
  433. if (!test_and_set_bit(RXRPC_CONN_COUNTED, &conn->flags)) {
  434. trace_rxrpc_client(conn, -1, rxrpc_client_count);
  435. rxnet->nr_client_conns = nr_conns + 1;
  436. }
  437. switch (conn->cache_state) {
  438. case RXRPC_CONN_CLIENT_ACTIVE:
  439. case RXRPC_CONN_CLIENT_UPGRADE:
  440. case RXRPC_CONN_CLIENT_WAITING:
  441. break;
  442. case RXRPC_CONN_CLIENT_INACTIVE:
  443. case RXRPC_CONN_CLIENT_CULLED:
  444. case RXRPC_CONN_CLIENT_IDLE:
  445. if (nr_conns >= rxrpc_max_client_connections)
  446. goto wait_for_capacity;
  447. goto activate_conn;
  448. default:
  449. BUG();
  450. }
  451. out_unlock:
  452. spin_unlock(&rxnet->client_conn_cache_lock);
  453. out:
  454. _leave(" [%d]", conn->cache_state);
  455. return;
  456. activate_conn:
  457. _debug("activate");
  458. rxrpc_activate_conn(rxnet, conn);
  459. goto out_unlock;
  460. wait_for_capacity:
  461. _debug("wait");
  462. trace_rxrpc_client(conn, -1, rxrpc_client_to_waiting);
  463. conn->cache_state = RXRPC_CONN_CLIENT_WAITING;
  464. list_move_tail(&conn->cache_link, &rxnet->waiting_client_conns);
  465. goto out_unlock;
  466. }
  467. /*
  468. * Deactivate a channel.
  469. */
  470. static void rxrpc_deactivate_one_channel(struct rxrpc_connection *conn,
  471. unsigned int channel)
  472. {
  473. struct rxrpc_channel *chan = &conn->channels[channel];
  474. rcu_assign_pointer(chan->call, NULL);
  475. conn->active_chans &= ~(1 << channel);
  476. }
  477. /*
  478. * Assign a channel to the call at the front of the queue and wake the call up.
  479. * We don't increment the callNumber counter until this number has been exposed
  480. * to the world.
  481. */
  482. static void rxrpc_activate_one_channel(struct rxrpc_connection *conn,
  483. unsigned int channel)
  484. {
  485. struct rxrpc_channel *chan = &conn->channels[channel];
  486. struct rxrpc_call *call = list_entry(conn->waiting_calls.next,
  487. struct rxrpc_call, chan_wait_link);
  488. u32 call_id = chan->call_counter + 1;
  489. trace_rxrpc_client(conn, channel, rxrpc_client_chan_activate);
  490. /* Cancel the final ACK on the previous call if it hasn't been sent yet
  491. * as the DATA packet will implicitly ACK it.
  492. */
  493. clear_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags);
  494. write_lock_bh(&call->state_lock);
  495. if (!test_bit(RXRPC_CALL_TX_LASTQ, &call->flags))
  496. call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
  497. else
  498. call->state = RXRPC_CALL_CLIENT_AWAIT_REPLY;
  499. write_unlock_bh(&call->state_lock);
  500. rxrpc_see_call(call);
  501. list_del_init(&call->chan_wait_link);
  502. conn->active_chans |= 1 << channel;
  503. call->peer = rxrpc_get_peer(conn->params.peer);
  504. call->cid = conn->proto.cid | channel;
  505. call->call_id = call_id;
  506. trace_rxrpc_connect_call(call);
  507. _net("CONNECT call %08x:%08x as call %d on conn %d",
  508. call->cid, call->call_id, call->debug_id, conn->debug_id);
  509. /* Paired with the read barrier in rxrpc_wait_for_channel(). This
  510. * orders cid and epoch in the connection wrt to call_id without the
  511. * need to take the channel_lock.
  512. *
  513. * We provisionally assign a callNumber at this point, but we don't
  514. * confirm it until the call is about to be exposed.
  515. *
  516. * TODO: Pair with a barrier in the data_ready handler when that looks
  517. * at the call ID through a connection channel.
  518. */
  519. smp_wmb();
  520. chan->call_id = call_id;
  521. chan->call_debug_id = call->debug_id;
  522. rcu_assign_pointer(chan->call, call);
  523. wake_up(&call->waitq);
  524. }
  525. /*
  526. * Assign channels and callNumbers to waiting calls with channel_lock
  527. * held by caller.
  528. */
  529. static void rxrpc_activate_channels_locked(struct rxrpc_connection *conn)
  530. {
  531. u8 avail, mask;
  532. switch (conn->cache_state) {
  533. case RXRPC_CONN_CLIENT_ACTIVE:
  534. mask = RXRPC_ACTIVE_CHANS_MASK;
  535. break;
  536. case RXRPC_CONN_CLIENT_UPGRADE:
  537. mask = 0x01;
  538. break;
  539. default:
  540. return;
  541. }
  542. while (!list_empty(&conn->waiting_calls) &&
  543. (avail = ~conn->active_chans,
  544. avail &= mask,
  545. avail != 0))
  546. rxrpc_activate_one_channel(conn, __ffs(avail));
  547. }
  548. /*
  549. * Assign channels and callNumbers to waiting calls.
  550. */
  551. static void rxrpc_activate_channels(struct rxrpc_connection *conn)
  552. {
  553. _enter("%d", conn->debug_id);
  554. trace_rxrpc_client(conn, -1, rxrpc_client_activate_chans);
  555. if (conn->active_chans == RXRPC_ACTIVE_CHANS_MASK)
  556. return;
  557. spin_lock(&conn->channel_lock);
  558. rxrpc_activate_channels_locked(conn);
  559. spin_unlock(&conn->channel_lock);
  560. _leave("");
  561. }
  562. /*
  563. * Wait for a callNumber and a channel to be granted to a call.
  564. */
  565. static int rxrpc_wait_for_channel(struct rxrpc_call *call, gfp_t gfp)
  566. {
  567. int ret = 0;
  568. _enter("%d", call->debug_id);
  569. if (!call->call_id) {
  570. DECLARE_WAITQUEUE(myself, current);
  571. if (!gfpflags_allow_blocking(gfp)) {
  572. ret = -EAGAIN;
  573. goto out;
  574. }
  575. add_wait_queue_exclusive(&call->waitq, &myself);
  576. for (;;) {
  577. set_current_state(TASK_INTERRUPTIBLE);
  578. if (call->call_id)
  579. break;
  580. if (signal_pending(current)) {
  581. ret = -ERESTARTSYS;
  582. break;
  583. }
  584. schedule();
  585. }
  586. remove_wait_queue(&call->waitq, &myself);
  587. __set_current_state(TASK_RUNNING);
  588. }
  589. /* Paired with the write barrier in rxrpc_activate_one_channel(). */
  590. smp_rmb();
  591. out:
  592. _leave(" = %d", ret);
  593. return ret;
  594. }
  595. /*
  596. * find a connection for a call
  597. * - called in process context with IRQs enabled
  598. */
  599. int rxrpc_connect_call(struct rxrpc_sock *rx,
  600. struct rxrpc_call *call,
  601. struct rxrpc_conn_parameters *cp,
  602. struct sockaddr_rxrpc *srx,
  603. gfp_t gfp)
  604. {
  605. struct rxrpc_net *rxnet = cp->local->rxnet;
  606. int ret;
  607. _enter("{%d,%lx},", call->debug_id, call->user_call_ID);
  608. rxrpc_discard_expired_client_conns(&rxnet->client_conn_reaper);
  609. rxrpc_cull_active_client_conns(rxnet);
  610. ret = rxrpc_get_client_conn(rx, call, cp, srx, gfp);
  611. if (ret < 0)
  612. goto out;
  613. rxrpc_animate_client_conn(rxnet, call->conn);
  614. rxrpc_activate_channels(call->conn);
  615. ret = rxrpc_wait_for_channel(call, gfp);
  616. if (ret < 0) {
  617. trace_rxrpc_client(call->conn, ret, rxrpc_client_chan_wait_failed);
  618. rxrpc_disconnect_client_call(call);
  619. goto out;
  620. }
  621. spin_lock_bh(&call->conn->params.peer->lock);
  622. hlist_add_head_rcu(&call->error_link,
  623. &call->conn->params.peer->error_targets);
  624. spin_unlock_bh(&call->conn->params.peer->lock);
  625. out:
  626. _leave(" = %d", ret);
  627. return ret;
  628. }
  629. /*
  630. * Note that a connection is about to be exposed to the world. Once it is
  631. * exposed, we maintain an extra ref on it that stops it from being summarily
  632. * discarded before it's (a) had a chance to deal with retransmission and (b)
  633. * had a chance at re-use (the per-connection security negotiation is
  634. * expensive).
  635. */
  636. static void rxrpc_expose_client_conn(struct rxrpc_connection *conn,
  637. unsigned int channel)
  638. {
  639. if (!test_and_set_bit(RXRPC_CONN_EXPOSED, &conn->flags)) {
  640. trace_rxrpc_client(conn, channel, rxrpc_client_exposed);
  641. rxrpc_get_connection(conn);
  642. }
  643. }
  644. /*
  645. * Note that a call, and thus a connection, is about to be exposed to the
  646. * world.
  647. */
  648. void rxrpc_expose_client_call(struct rxrpc_call *call)
  649. {
  650. unsigned int channel = call->cid & RXRPC_CHANNELMASK;
  651. struct rxrpc_connection *conn = call->conn;
  652. struct rxrpc_channel *chan = &conn->channels[channel];
  653. if (!test_and_set_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
  654. /* Mark the call ID as being used. If the callNumber counter
  655. * exceeds ~2 billion, we kill the connection after its
  656. * outstanding calls have finished so that the counter doesn't
  657. * wrap.
  658. */
  659. chan->call_counter++;
  660. if (chan->call_counter >= INT_MAX)
  661. set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
  662. rxrpc_expose_client_conn(conn, channel);
  663. }
  664. }
  665. /*
  666. * Set the reap timer.
  667. */
  668. static void rxrpc_set_client_reap_timer(struct rxrpc_net *rxnet)
  669. {
  670. unsigned long now = jiffies;
  671. unsigned long reap_at = now + rxrpc_conn_idle_client_expiry;
  672. if (rxnet->live)
  673. timer_reduce(&rxnet->client_conn_reap_timer, reap_at);
  674. }
  675. /*
  676. * Disconnect a client call.
  677. */
  678. void rxrpc_disconnect_client_call(struct rxrpc_call *call)
  679. {
  680. struct rxrpc_connection *conn = call->conn;
  681. struct rxrpc_channel *chan = NULL;
  682. struct rxrpc_net *rxnet = conn->params.local->rxnet;
  683. unsigned int channel = -1;
  684. u32 cid;
  685. spin_lock(&conn->channel_lock);
  686. set_bit(RXRPC_CALL_DISCONNECTED, &call->flags);
  687. cid = call->cid;
  688. if (cid) {
  689. channel = cid & RXRPC_CHANNELMASK;
  690. chan = &conn->channels[channel];
  691. }
  692. trace_rxrpc_client(conn, channel, rxrpc_client_chan_disconnect);
  693. /* Calls that have never actually been assigned a channel can simply be
  694. * discarded. If the conn didn't get used either, it will follow
  695. * immediately unless someone else grabs it in the meantime.
  696. */
  697. if (!list_empty(&call->chan_wait_link)) {
  698. _debug("call is waiting");
  699. ASSERTCMP(call->call_id, ==, 0);
  700. ASSERT(!test_bit(RXRPC_CALL_EXPOSED, &call->flags));
  701. list_del_init(&call->chan_wait_link);
  702. trace_rxrpc_client(conn, channel, rxrpc_client_chan_unstarted);
  703. /* We must deactivate or idle the connection if it's now
  704. * waiting for nothing.
  705. */
  706. spin_lock(&rxnet->client_conn_cache_lock);
  707. if (conn->cache_state == RXRPC_CONN_CLIENT_WAITING &&
  708. list_empty(&conn->waiting_calls) &&
  709. !conn->active_chans)
  710. goto idle_connection;
  711. goto out;
  712. }
  713. if (rcu_access_pointer(chan->call) != call) {
  714. spin_unlock(&conn->channel_lock);
  715. BUG();
  716. }
  717. /* If a client call was exposed to the world, we save the result for
  718. * retransmission.
  719. *
  720. * We use a barrier here so that the call number and abort code can be
  721. * read without needing to take a lock.
  722. *
  723. * TODO: Make the incoming packet handler check this and handle
  724. * terminal retransmission without requiring access to the call.
  725. */
  726. if (test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
  727. _debug("exposed %u,%u", call->call_id, call->abort_code);
  728. __rxrpc_disconnect_call(conn, call);
  729. }
  730. /* See if we can pass the channel directly to another call. */
  731. if (conn->cache_state == RXRPC_CONN_CLIENT_ACTIVE &&
  732. !list_empty(&conn->waiting_calls)) {
  733. trace_rxrpc_client(conn, channel, rxrpc_client_chan_pass);
  734. rxrpc_activate_one_channel(conn, channel);
  735. goto out_2;
  736. }
  737. /* Schedule the final ACK to be transmitted in a short while so that it
  738. * can be skipped if we find a follow-on call. The first DATA packet
  739. * of the follow on call will implicitly ACK this call.
  740. */
  741. if (call->completion == RXRPC_CALL_SUCCEEDED &&
  742. test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
  743. unsigned long final_ack_at = jiffies + 2;
  744. WRITE_ONCE(chan->final_ack_at, final_ack_at);
  745. smp_wmb(); /* vs rxrpc_process_delayed_final_acks() */
  746. set_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags);
  747. rxrpc_reduce_conn_timer(conn, final_ack_at);
  748. }
  749. /* Things are more complex and we need the cache lock. We might be
  750. * able to simply idle the conn or it might now be lurking on the wait
  751. * list. It might even get moved back to the active list whilst we're
  752. * waiting for the lock.
  753. */
  754. spin_lock(&rxnet->client_conn_cache_lock);
  755. switch (conn->cache_state) {
  756. case RXRPC_CONN_CLIENT_UPGRADE:
  757. /* Deal with termination of a service upgrade probe. */
  758. if (test_bit(RXRPC_CONN_EXPOSED, &conn->flags)) {
  759. clear_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags);
  760. trace_rxrpc_client(conn, channel, rxrpc_client_to_active);
  761. conn->cache_state = RXRPC_CONN_CLIENT_ACTIVE;
  762. rxrpc_activate_channels_locked(conn);
  763. }
  764. /* fall through */
  765. case RXRPC_CONN_CLIENT_ACTIVE:
  766. if (list_empty(&conn->waiting_calls)) {
  767. rxrpc_deactivate_one_channel(conn, channel);
  768. if (!conn->active_chans) {
  769. rxnet->nr_active_client_conns--;
  770. goto idle_connection;
  771. }
  772. goto out;
  773. }
  774. trace_rxrpc_client(conn, channel, rxrpc_client_chan_pass);
  775. rxrpc_activate_one_channel(conn, channel);
  776. goto out;
  777. case RXRPC_CONN_CLIENT_CULLED:
  778. rxrpc_deactivate_one_channel(conn, channel);
  779. ASSERT(list_empty(&conn->waiting_calls));
  780. if (!conn->active_chans)
  781. goto idle_connection;
  782. goto out;
  783. case RXRPC_CONN_CLIENT_WAITING:
  784. rxrpc_deactivate_one_channel(conn, channel);
  785. goto out;
  786. default:
  787. BUG();
  788. }
  789. out:
  790. spin_unlock(&rxnet->client_conn_cache_lock);
  791. out_2:
  792. spin_unlock(&conn->channel_lock);
  793. _leave("");
  794. return;
  795. idle_connection:
  796. /* As no channels remain active, the connection gets deactivated
  797. * immediately or moved to the idle list for a short while.
  798. */
  799. if (test_bit(RXRPC_CONN_EXPOSED, &conn->flags)) {
  800. trace_rxrpc_client(conn, channel, rxrpc_client_to_idle);
  801. conn->idle_timestamp = jiffies;
  802. conn->cache_state = RXRPC_CONN_CLIENT_IDLE;
  803. list_move_tail(&conn->cache_link, &rxnet->idle_client_conns);
  804. if (rxnet->idle_client_conns.next == &conn->cache_link &&
  805. !rxnet->kill_all_client_conns)
  806. rxrpc_set_client_reap_timer(rxnet);
  807. } else {
  808. trace_rxrpc_client(conn, channel, rxrpc_client_to_inactive);
  809. conn->cache_state = RXRPC_CONN_CLIENT_INACTIVE;
  810. list_del_init(&conn->cache_link);
  811. }
  812. goto out;
  813. }
  814. /*
  815. * Clean up a dead client connection.
  816. */
  817. static struct rxrpc_connection *
  818. rxrpc_put_one_client_conn(struct rxrpc_connection *conn)
  819. {
  820. struct rxrpc_connection *next = NULL;
  821. struct rxrpc_local *local = conn->params.local;
  822. struct rxrpc_net *rxnet = local->rxnet;
  823. unsigned int nr_conns;
  824. trace_rxrpc_client(conn, -1, rxrpc_client_cleanup);
  825. if (test_bit(RXRPC_CONN_IN_CLIENT_CONNS, &conn->flags)) {
  826. spin_lock(&local->client_conns_lock);
  827. if (test_and_clear_bit(RXRPC_CONN_IN_CLIENT_CONNS,
  828. &conn->flags))
  829. rb_erase(&conn->client_node, &local->client_conns);
  830. spin_unlock(&local->client_conns_lock);
  831. }
  832. rxrpc_put_client_connection_id(conn);
  833. ASSERTCMP(conn->cache_state, ==, RXRPC_CONN_CLIENT_INACTIVE);
  834. if (test_bit(RXRPC_CONN_COUNTED, &conn->flags)) {
  835. trace_rxrpc_client(conn, -1, rxrpc_client_uncount);
  836. spin_lock(&rxnet->client_conn_cache_lock);
  837. nr_conns = --rxnet->nr_client_conns;
  838. if (nr_conns < rxrpc_max_client_connections &&
  839. !list_empty(&rxnet->waiting_client_conns)) {
  840. next = list_entry(rxnet->waiting_client_conns.next,
  841. struct rxrpc_connection, cache_link);
  842. rxrpc_get_connection(next);
  843. rxrpc_activate_conn(rxnet, next);
  844. }
  845. spin_unlock(&rxnet->client_conn_cache_lock);
  846. }
  847. rxrpc_kill_connection(conn);
  848. if (next)
  849. rxrpc_activate_channels(next);
  850. /* We need to get rid of the temporary ref we took upon next, but we
  851. * can't call rxrpc_put_connection() recursively.
  852. */
  853. return next;
  854. }
  855. /*
  856. * Clean up a dead client connections.
  857. */
  858. void rxrpc_put_client_conn(struct rxrpc_connection *conn)
  859. {
  860. const void *here = __builtin_return_address(0);
  861. unsigned int debug_id = conn->debug_id;
  862. int n;
  863. do {
  864. n = atomic_dec_return(&conn->usage);
  865. trace_rxrpc_conn(debug_id, rxrpc_conn_put_client, n, here);
  866. if (n > 0)
  867. return;
  868. ASSERTCMP(n, >=, 0);
  869. conn = rxrpc_put_one_client_conn(conn);
  870. } while (conn);
  871. }
  872. /*
  873. * Kill the longest-active client connections to make room for new ones.
  874. */
  875. static void rxrpc_cull_active_client_conns(struct rxrpc_net *rxnet)
  876. {
  877. struct rxrpc_connection *conn;
  878. unsigned int nr_conns = rxnet->nr_client_conns;
  879. unsigned int nr_active, limit;
  880. _enter("");
  881. ASSERTCMP(nr_conns, >=, 0);
  882. if (nr_conns < rxrpc_max_client_connections) {
  883. _leave(" [ok]");
  884. return;
  885. }
  886. limit = rxrpc_reap_client_connections;
  887. spin_lock(&rxnet->client_conn_cache_lock);
  888. nr_active = rxnet->nr_active_client_conns;
  889. while (nr_active > limit) {
  890. ASSERT(!list_empty(&rxnet->active_client_conns));
  891. conn = list_entry(rxnet->active_client_conns.next,
  892. struct rxrpc_connection, cache_link);
  893. ASSERTIFCMP(conn->cache_state != RXRPC_CONN_CLIENT_ACTIVE,
  894. conn->cache_state, ==, RXRPC_CONN_CLIENT_UPGRADE);
  895. if (list_empty(&conn->waiting_calls)) {
  896. trace_rxrpc_client(conn, -1, rxrpc_client_to_culled);
  897. conn->cache_state = RXRPC_CONN_CLIENT_CULLED;
  898. list_del_init(&conn->cache_link);
  899. } else {
  900. trace_rxrpc_client(conn, -1, rxrpc_client_to_waiting);
  901. conn->cache_state = RXRPC_CONN_CLIENT_WAITING;
  902. list_move_tail(&conn->cache_link,
  903. &rxnet->waiting_client_conns);
  904. }
  905. nr_active--;
  906. }
  907. rxnet->nr_active_client_conns = nr_active;
  908. spin_unlock(&rxnet->client_conn_cache_lock);
  909. ASSERTCMP(nr_active, >=, 0);
  910. _leave(" [culled]");
  911. }
  912. /*
  913. * Discard expired client connections from the idle list. Each conn in the
  914. * idle list has been exposed and holds an extra ref because of that.
  915. *
  916. * This may be called from conn setup or from a work item so cannot be
  917. * considered non-reentrant.
  918. */
  919. void rxrpc_discard_expired_client_conns(struct work_struct *work)
  920. {
  921. struct rxrpc_connection *conn;
  922. struct rxrpc_net *rxnet =
  923. container_of(work, struct rxrpc_net, client_conn_reaper);
  924. unsigned long expiry, conn_expires_at, now;
  925. unsigned int nr_conns;
  926. _enter("");
  927. if (list_empty(&rxnet->idle_client_conns)) {
  928. _leave(" [empty]");
  929. return;
  930. }
  931. /* Don't double up on the discarding */
  932. if (!spin_trylock(&rxnet->client_conn_discard_lock)) {
  933. _leave(" [already]");
  934. return;
  935. }
  936. /* We keep an estimate of what the number of conns ought to be after
  937. * we've discarded some so that we don't overdo the discarding.
  938. */
  939. nr_conns = rxnet->nr_client_conns;
  940. next:
  941. spin_lock(&rxnet->client_conn_cache_lock);
  942. if (list_empty(&rxnet->idle_client_conns))
  943. goto out;
  944. conn = list_entry(rxnet->idle_client_conns.next,
  945. struct rxrpc_connection, cache_link);
  946. ASSERT(test_bit(RXRPC_CONN_EXPOSED, &conn->flags));
  947. if (!rxnet->kill_all_client_conns) {
  948. /* If the number of connections is over the reap limit, we
  949. * expedite discard by reducing the expiry timeout. We must,
  950. * however, have at least a short grace period to be able to do
  951. * final-ACK or ABORT retransmission.
  952. */
  953. expiry = rxrpc_conn_idle_client_expiry;
  954. if (nr_conns > rxrpc_reap_client_connections)
  955. expiry = rxrpc_conn_idle_client_fast_expiry;
  956. if (conn->params.local->service_closed)
  957. expiry = rxrpc_closed_conn_expiry * HZ;
  958. conn_expires_at = conn->idle_timestamp + expiry;
  959. now = READ_ONCE(jiffies);
  960. if (time_after(conn_expires_at, now))
  961. goto not_yet_expired;
  962. }
  963. trace_rxrpc_client(conn, -1, rxrpc_client_discard);
  964. if (!test_and_clear_bit(RXRPC_CONN_EXPOSED, &conn->flags))
  965. BUG();
  966. conn->cache_state = RXRPC_CONN_CLIENT_INACTIVE;
  967. list_del_init(&conn->cache_link);
  968. spin_unlock(&rxnet->client_conn_cache_lock);
  969. /* When we cleared the EXPOSED flag, we took on responsibility for the
  970. * reference that that had on the usage count. We deal with that here.
  971. * If someone re-sets the flag and re-gets the ref, that's fine.
  972. */
  973. rxrpc_put_connection(conn);
  974. nr_conns--;
  975. goto next;
  976. not_yet_expired:
  977. /* The connection at the front of the queue hasn't yet expired, so
  978. * schedule the work item for that point if we discarded something.
  979. *
  980. * We don't worry if the work item is already scheduled - it can look
  981. * after rescheduling itself at a later time. We could cancel it, but
  982. * then things get messier.
  983. */
  984. _debug("not yet");
  985. if (!rxnet->kill_all_client_conns)
  986. timer_reduce(&rxnet->client_conn_reap_timer,
  987. conn_expires_at);
  988. out:
  989. spin_unlock(&rxnet->client_conn_cache_lock);
  990. spin_unlock(&rxnet->client_conn_discard_lock);
  991. _leave("");
  992. }
  993. /*
  994. * Preemptively destroy all the client connection records rather than waiting
  995. * for them to time out
  996. */
  997. void rxrpc_destroy_all_client_connections(struct rxrpc_net *rxnet)
  998. {
  999. _enter("");
  1000. spin_lock(&rxnet->client_conn_cache_lock);
  1001. rxnet->kill_all_client_conns = true;
  1002. spin_unlock(&rxnet->client_conn_cache_lock);
  1003. del_timer_sync(&rxnet->client_conn_reap_timer);
  1004. if (!rxrpc_queue_work(&rxnet->client_conn_reaper))
  1005. _debug("destroy: queue failed");
  1006. _leave("");
  1007. }
  1008. /*
  1009. * Clean up the client connections on a local endpoint.
  1010. */
  1011. void rxrpc_clean_up_local_conns(struct rxrpc_local *local)
  1012. {
  1013. struct rxrpc_connection *conn, *tmp;
  1014. struct rxrpc_net *rxnet = local->rxnet;
  1015. unsigned int nr_active;
  1016. LIST_HEAD(graveyard);
  1017. _enter("");
  1018. spin_lock(&rxnet->client_conn_cache_lock);
  1019. nr_active = rxnet->nr_active_client_conns;
  1020. list_for_each_entry_safe(conn, tmp, &rxnet->idle_client_conns,
  1021. cache_link) {
  1022. if (conn->params.local == local) {
  1023. ASSERTCMP(conn->cache_state, ==, RXRPC_CONN_CLIENT_IDLE);
  1024. trace_rxrpc_client(conn, -1, rxrpc_client_discard);
  1025. if (!test_and_clear_bit(RXRPC_CONN_EXPOSED, &conn->flags))
  1026. BUG();
  1027. conn->cache_state = RXRPC_CONN_CLIENT_INACTIVE;
  1028. list_move(&conn->cache_link, &graveyard);
  1029. nr_active--;
  1030. }
  1031. }
  1032. rxnet->nr_active_client_conns = nr_active;
  1033. spin_unlock(&rxnet->client_conn_cache_lock);
  1034. ASSERTCMP(nr_active, >=, 0);
  1035. while (!list_empty(&graveyard)) {
  1036. conn = list_entry(graveyard.next,
  1037. struct rxrpc_connection, cache_link);
  1038. list_del_init(&conn->cache_link);
  1039. rxrpc_put_connection(conn);
  1040. }
  1041. _leave(" [culled]");
  1042. }