Skip to content

Commit 0fa6ebc

Browse files
Sage WeilAlex Elder
authored andcommitted
libceph: fix protocol feature mismatch failure path
We should not set con->state to CLOSED here; that happens in ceph_fault() in the caller, where it first asserts that the state is not yet CLOSED. Avoids a BUG when the features don't match. Since the fail_protocol() has become a trivial wrapper, replace calls to it with direct calls to reset_connection(). Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Alex Elder <elder@inktank.com>
1 parent 122070a commit 0fa6ebc

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

net/ceph/messenger.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ static void reset_connection(struct ceph_connection *con)
506506
{
507507
/* reset connection, out_queue, msg_ and connect_seq */
508508
/* discard existing out_queue and msg_seq */
509+
dout("reset_connection %p\n", con);
509510
ceph_msg_remove_list(&con->out_queue);
510511
ceph_msg_remove_list(&con->out_sent);
511512

@@ -1506,13 +1507,6 @@ static int process_banner(struct ceph_connection *con)
15061507
return 0;
15071508
}
15081509

1509-
static void fail_protocol(struct ceph_connection *con)
1510-
{
1511-
reset_connection(con);
1512-
WARN_ON(con->state != CON_STATE_NEGOTIATING);
1513-
con->state = CON_STATE_CLOSED;
1514-
}
1515-
15161510
static int process_connect(struct ceph_connection *con)
15171511
{
15181512
u64 sup_feat = con->msgr->supported_features;
@@ -1530,7 +1524,7 @@ static int process_connect(struct ceph_connection *con)
15301524
ceph_pr_addr(&con->peer_addr.in_addr),
15311525
sup_feat, server_feat, server_feat & ~sup_feat);
15321526
con->error_msg = "missing required protocol features";
1533-
fail_protocol(con);
1527+
reset_connection(con);
15341528
return -1;
15351529

15361530
case CEPH_MSGR_TAG_BADPROTOVER:
@@ -1541,7 +1535,7 @@ static int process_connect(struct ceph_connection *con)
15411535
le32_to_cpu(con->out_connect.protocol_version),
15421536
le32_to_cpu(con->in_reply.protocol_version));
15431537
con->error_msg = "protocol version mismatch";
1544-
fail_protocol(con);
1538+
reset_connection(con);
15451539
return -1;
15461540

15471541
case CEPH_MSGR_TAG_BADAUTHORIZER:
@@ -1631,7 +1625,7 @@ static int process_connect(struct ceph_connection *con)
16311625
ceph_pr_addr(&con->peer_addr.in_addr),
16321626
req_feat, server_feat, req_feat & ~server_feat);
16331627
con->error_msg = "missing required protocol features";
1634-
fail_protocol(con);
1628+
reset_connection(con);
16351629
return -1;
16361630
}
16371631

0 commit comments

Comments
 (0)