aboutsummaryrefslogtreecommitdiffstats
path: root/net/rxrpc/ar-connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/rxrpc/ar-connection.c')
-rw-r--r--net/rxrpc/ar-connection.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
index 01eb33c30571..43cb3e051ece 100644
--- a/net/rxrpc/ar-connection.c
+++ b/net/rxrpc/ar-connection.c
@@ -356,7 +356,7 @@ static int rxrpc_connect_exclusive(struct rxrpc_sock *rx,
356 conn->out_clientflag = RXRPC_CLIENT_INITIATED; 356 conn->out_clientflag = RXRPC_CLIENT_INITIATED;
357 conn->cid = 0; 357 conn->cid = 0;
358 conn->state = RXRPC_CONN_CLIENT; 358 conn->state = RXRPC_CONN_CLIENT;
359 conn->avail_calls = RXRPC_MAXCALLS; 359 conn->avail_calls = RXRPC_MAXCALLS - 1;
360 conn->security_level = rx->min_sec_level; 360 conn->security_level = rx->min_sec_level;
361 conn->key = key_get(rx->key); 361 conn->key = key_get(rx->key);
362 362
@@ -447,6 +447,11 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
447 if (--conn->avail_calls == 0) 447 if (--conn->avail_calls == 0)
448 list_move(&conn->bundle_link, 448 list_move(&conn->bundle_link,
449 &bundle->busy_conns); 449 &bundle->busy_conns);
450 ASSERTCMP(conn->avail_calls, <, RXRPC_MAXCALLS);
451 ASSERT(conn->channels[0] == NULL ||
452 conn->channels[1] == NULL ||
453 conn->channels[2] == NULL ||
454 conn->channels[3] == NULL);
450 atomic_inc(&conn->usage); 455 atomic_inc(&conn->usage);
451 break; 456 break;
452 } 457 }
@@ -456,6 +461,12 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
456 conn = list_entry(bundle->unused_conns.next, 461 conn = list_entry(bundle->unused_conns.next,
457 struct rxrpc_connection, 462 struct rxrpc_connection,
458 bundle_link); 463 bundle_link);
464 ASSERTCMP(conn->avail_calls, ==, RXRPC_MAXCALLS);
465 conn->avail_calls = RXRPC_MAXCALLS - 1;
466 ASSERT(conn->channels[0] == NULL &&
467 conn->channels[1] == NULL &&
468 conn->channels[2] == NULL &&
469 conn->channels[3] == NULL);
459 atomic_inc(&conn->usage); 470 atomic_inc(&conn->usage);
460 list_move(&conn->bundle_link, &bundle->avail_conns); 471 list_move(&conn->bundle_link, &bundle->avail_conns);
461 break; 472 break;
@@ -512,7 +523,7 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
512 candidate->state = RXRPC_CONN_CLIENT; 523 candidate->state = RXRPC_CONN_CLIENT;
513 candidate->avail_calls = RXRPC_MAXCALLS; 524 candidate->avail_calls = RXRPC_MAXCALLS;
514 candidate->security_level = rx->min_sec_level; 525 candidate->security_level = rx->min_sec_level;
515 candidate->key = key_get(rx->key); 526 candidate->key = key_get(bundle->key);
516 527
517 ret = rxrpc_init_client_conn_security(candidate); 528 ret = rxrpc_init_client_conn_security(candidate);
518 if (ret < 0) { 529 if (ret < 0) {
@@ -555,6 +566,10 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
555 for (chan = 0; chan < RXRPC_MAXCALLS; chan++) 566 for (chan = 0; chan < RXRPC_MAXCALLS; chan++)
556 if (!conn->channels[chan]) 567 if (!conn->channels[chan])
557 goto found_channel; 568 goto found_channel;
569 ASSERT(conn->channels[0] == NULL ||
570 conn->channels[1] == NULL ||
571 conn->channels[2] == NULL ||
572 conn->channels[3] == NULL);
558 BUG(); 573 BUG();
559 574
560found_channel: 575found_channel:
@@ -567,6 +582,7 @@ found_channel:
567 _net("CONNECT client on conn %d chan %d as call %x", 582 _net("CONNECT client on conn %d chan %d as call %x",
568 conn->debug_id, chan, ntohl(call->call_id)); 583 conn->debug_id, chan, ntohl(call->call_id));
569 584
585 ASSERTCMP(conn->avail_calls, <, RXRPC_MAXCALLS);
570 spin_unlock(&trans->client_lock); 586 spin_unlock(&trans->client_lock);
571 587
572 rxrpc_add_call_ID_to_conn(conn, call); 588 rxrpc_add_call_ID_to_conn(conn, call);
@@ -778,7 +794,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
778 conn->put_time = xtime.tv_sec; 794 conn->put_time = xtime.tv_sec;
779 if (atomic_dec_and_test(&conn->usage)) { 795 if (atomic_dec_and_test(&conn->usage)) {
780 _debug("zombie"); 796 _debug("zombie");
781 schedule_delayed_work(&rxrpc_connection_reap, 0); 797 rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
782 } 798 }
783 799
784 _leave(""); 800 _leave("");
@@ -862,8 +878,8 @@ void rxrpc_connection_reaper(struct work_struct *work)
862 if (earliest != ULONG_MAX) { 878 if (earliest != ULONG_MAX) {
863 _debug("reschedule reaper %ld", (long) earliest - now); 879 _debug("reschedule reaper %ld", (long) earliest - now);
864 ASSERTCMP(earliest, >, now); 880 ASSERTCMP(earliest, >, now);
865 schedule_delayed_work(&rxrpc_connection_reap, 881 rxrpc_queue_delayed_work(&rxrpc_connection_reap,
866 (earliest - now) * HZ); 882 (earliest - now) * HZ);
867 } 883 }
868 884
869 /* then destroy all those pulled out */ 885 /* then destroy all those pulled out */
@@ -889,7 +905,7 @@ void __exit rxrpc_destroy_all_connections(void)
889 905
890 rxrpc_connection_timeout = 0; 906 rxrpc_connection_timeout = 0;
891 cancel_delayed_work(&rxrpc_connection_reap); 907 cancel_delayed_work(&rxrpc_connection_reap);
892 schedule_delayed_work(&rxrpc_connection_reap, 0); 908 rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
893 909
894 _leave(""); 910 _leave("");
895} 911}