diff mbox series

[15/27] lnet: do not crash if lnet_sock_getaddr returns error

Message ID 1623625897-17706-16-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to 2.14.52 | expand

Commit Message

James Simmons June 13, 2021, 11:11 p.m. UTC
From: Artem Blagodarenko <artem.blagodarenko@hpe.com>

Some issues with network lead to panic in ksocknal_accept

rc = lnet_sock_getaddr(sock, true, &peer_ip, &peer_port);
LASSERT(rc == 0); /* we succeeded before */

Let's pass this error to the caller.

HPE-bug-id: LUS-9256
WC-bug-id: https://jira.whamcloud.com/browse/LU-13950
Lustre-commit: 48a9ea82eb30bbb ("LU-13950 lnet: do not crash if lnet_sock_getaddr returns error")
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Reviewed-on: https://es-gerrit.dev.cray.com/157753
Reviewed-by: Andriy Skulysh <c17819@cray.com>
Reviewed-by: Alexander Zarochentsev <c17826@cray.com>
Tested-by: Alexander Lezhoev <c17454@cray.com>
Reviewed-by: Chris Horn <hornc@cray.com>
Reviewed-on: https://review.whamcloud.com/39834
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/klnds/socklnd/socklnd.c | 5 ++++-
 net/lnet/lnet/acceptor.c         | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/net/lnet/klnds/socklnd/socklnd.c b/net/lnet/klnds/socklnd/socklnd.c
index 3a667e5..eb8c736 100644
--- a/net/lnet/klnds/socklnd/socklnd.c
+++ b/net/lnet/klnds/socklnd/socklnd.c
@@ -744,7 +744,10 @@  struct ksock_peer_ni *
 	struct sockaddr_storage peer;
 
 	rc = lnet_sock_getaddr(sock, true, &peer);
-	LASSERT(!rc);			/* we succeeded before */
+	if (rc != 0) {
+		CERROR("Can't determine new connection's address\n");
+		return rc;
+	}
 
 	cr = kzalloc(sizeof(*cr), GFP_NOFS);
 	if (!cr) {
diff --git a/net/lnet/lnet/acceptor.c b/net/lnet/lnet/acceptor.c
index b301ffa..3708b89 100644
--- a/net/lnet/lnet/acceptor.c
+++ b/net/lnet/lnet/acceptor.c
@@ -200,7 +200,10 @@  struct socket *
 	LASSERT(sizeof(cr) <= 16);		/* not too big for the stack */
 
 	rc = lnet_sock_getaddr(sock, true, &peer);
-	LASSERT(!rc);				/* we succeeded before */
+	if (rc != 0) {
+		CERROR("Can't determine new connection's address\n");
+		return rc;
+	}
 
 	if (!lnet_accept_magic(magic, LNET_PROTO_ACCEPTOR_MAGIC)) {
 		if (lnet_accept_magic(magic, LNET_PROTO_MAGIC)) {