Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67c64eb7 authored by Ilya Dryomov's avatar Ilya Dryomov
Browse files

libceph: don't overwrite specific con error msgs



- specific con->error_msg messages (e.g. "protocol version mismatch")
  end up getting overwritten by a catch-all "socket error on read
  / write", introduced in commit 3a140a0d ("libceph: report socket
  read/write error message")
- "bad message sequence # for incoming message" loses to "bad crc" due
  to the fact that -EBADMSG is used for both

Fix it, and tidy up con->error_msg assignments and pr_errs while at it.

Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 1c841a96
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -505,8 +505,6 @@ static int ceph_tcp_connect(struct ceph_connection *con)
		pr_err("connect %s error %d\n",
		       ceph_pr_addr(&con->peer_addr.in_addr), ret);
		sock_release(sock);
		con->error_msg = "connect error";

		return ret;
	}

@@ -2145,12 +2143,10 @@ static int process_connect(struct ceph_connection *con)
		 * to WAIT.  This shouldn't happen if we are the
		 * client.
		 */
		pr_err("process_connect got WAIT as client\n");
		con->error_msg = "protocol error, got WAIT as client";
		return -1;

	default:
		pr_err("connect protocol error, will retry\n");
		con->error_msg = "protocol error, garbage tag during connect";
		return -1;
	}
@@ -2282,8 +2278,7 @@ static int read_partial_message(struct ceph_connection *con)

	crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc));
	if (cpu_to_le32(crc) != con->in_hdr.crc) {
		pr_err("read_partial_message bad hdr "
		       " crc %u != expected %u\n",
		pr_err("read_partial_message bad hdr crc %u != expected %u\n",
		       crc, con->in_hdr.crc);
		return -EBADMSG;
	}
@@ -2313,7 +2308,7 @@ static int read_partial_message(struct ceph_connection *con)
		pr_err("read_partial_message bad seq %lld expected %lld\n",
		       seq, con->in_seq + 1);
		con->error_msg = "bad message sequence # for incoming message";
		return -EBADMSG;
		return -EBADE;
	}

	/* allocate message? */
@@ -2660,6 +2655,8 @@ static int try_read(struct ceph_connection *con)
			switch (ret) {
			case -EBADMSG:
				con->error_msg = "bad crc";
				/* fall through */
			case -EBADE:
				ret = -EIO;
				break;
			case -EIO:
@@ -2838,6 +2835,7 @@ static void con_work(struct work_struct *work)
		if (ret < 0) {
			if (ret == -EAGAIN)
				continue;
			if (!con->error_msg)
				con->error_msg = "socket error on read";
			fault = true;
			break;
@@ -2847,6 +2845,7 @@ static void con_work(struct work_struct *work)
		if (ret < 0) {
			if (ret == -EAGAIN)
				continue;
			if (!con->error_msg)
				con->error_msg = "socket error on write";
			fault = true;
		}
@@ -2869,11 +2868,13 @@ static void con_work(struct work_struct *work)
 */
static void con_fault(struct ceph_connection *con)
{
	pr_warn("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
		ceph_pr_addr(&con->peer_addr.in_addr), con->error_msg);
	dout("fault %p state %lu to peer %s\n",
	     con, con->state, ceph_pr_addr(&con->peer_addr.in_addr));

	pr_warn("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
		ceph_pr_addr(&con->peer_addr.in_addr), con->error_msg);
	con->error_msg = NULL;

	WARN_ON(con->state != CON_STATE_CONNECTING &&
	       con->state != CON_STATE_NEGOTIATING &&
	       con->state != CON_STATE_OPEN);
@@ -3295,8 +3296,8 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
		 */
		if (*skip)
			return 0;
		con->error_msg = "error allocating memory for incoming message";

		con->error_msg = "error allocating memory for incoming message";
		return -ENOMEM;
	}
	memcpy(&con->in_msg->hdr, &con->in_hdr, sizeof(con->in_hdr));