lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180315090214.21706-3-honli@redhat.com>
Date:   Thu, 15 Mar 2018 17:02:14 +0800
From:   Honggang LI <honli@...hat.com>
To:     dledford@...hat.com, jgg@...pe.ca, linux-rdma@...r.kernel.org
Cc:     noaos@...lanox.com, linux-kernel@...r.kernel.org, honli@...hat.com
Subject: [PATCH 2/2] IB/core: Set width to 1X for invalid active widths when port is down

From: Honggang Li <honli@...hat.com>

commit f1b65df5a232 ("IB/mlx5: Add support for active_width and
active_speed in RoCE"). Before this patch applied, the mlx5_ib
driver set default active_width and active_speed to IB_WIDTH_4X
and IB_SPEED_QDR.

When the RoCE port is down, the RoCE port did not negotiate the
active width with remote side. The active width is zero. If run
ibstat to require the port status, ibstat will panic as it read
invalid width from sys file.

Signed-off-by: Honggang Li <honli@...hat.com>
---
 drivers/infiniband/core/sysfs.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index cf36ff1f0068..722e4571f4d2 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -240,6 +240,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
 	struct ib_port_attr attr;
 	char *speed = "";
 	int rate;		/* in deci-Gb/sec */
+	int width;
 	ssize_t ret;
 
 	ret = ib_query_port(p->ibdev, p->port_num, &attr);
@@ -278,13 +279,19 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
 		break;
 	}
 
-	rate *= ib_width_enum_to_int(attr.active_width);
-	if (rate < 0)
-		return -EINVAL;
+	width = ib_width_enum_to_int(attr.active_width);
+	if (width < 0) {
+		if (attr.state != IB_PORT_ACTIVE)
+			width = 1; /* default to 1X for invalid widths */
+		else
+			return -EINVAL;
+	}
+
+	rate *= width;
 
 	return sprintf(buf, "%d%s Gb/sec (%dX%s)\n",
 		       rate / 10, rate % 10 ? ".5" : "",
-		       ib_width_enum_to_int(attr.active_width), speed);
+		       width, speed);
 }
 
 static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused,
-- 
2.14.GIT

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ