Skip to contentSkip to conversation

fcoe-utils: Fix get_ctlr_num() for large ctlr_* indices

PATCH Applied Andrey Grafin 3 participants 3 messages Sep 18, 2017 – Sep 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fcoe-utils: Fix get_ctlr_num() for large ctlr_* indices

Each creation of a FCoE device increases counter which is used as a suffix in a FCoE device name in sysfs (i.e. /sys/bus/fcoe/devices/ctlr_1). Once this counter reaches the value of two digits (10 and larger), get_ctlr_num() stopped working properly and a command like fcoeadm -i which depends on get_ctlr_num() call doesn't show anything. This patch solves this problem.

---
 lib/sysfs_hba.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sysfs_hba.c +1 -1
index 5cb7fd3fa5d..786215440ba 100644
@@ -606,7 +606,7 @@ static int get_ctlr_num(const char *netdev)
 		if (!ctlr)
 			continue;
 
-		ctlr_num = atoi(&ctlr[strlen(ctlr) - 1]);
+		ctlr_num = atoi(&ctlr[sizeof("ctlr_") - 1]);
 		break;
 	}
 
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Andrey Grafin

Each creation of a FCoE device increases counter which is used as a suffix in a FCoE device name in sysfs (i.e. /sys/bus/fcoe/devices/ctlr_1). Once this counter reaches the value of two digits (10 and larger), get_ctlr_num() stopped working properly and a command like fcoeadm -i which depends on get_ctlr_num() call doesn't show anything. This patch solves this problem.

---
 lib/sysfs_hba.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sysfs_hba.c +0 -0
index 5cb7fd3fa5d..786215440ba 100644

lib/sysfs_hba.c static int get_ctlr_num(const char *netdev) · line 612

Quoted 8 lines
lib/sysfs_hba.c +1 -1
@@ -606,7 +606,7 @@ static int get_ctlr_num(const char *netdev)
 		if (!ctlr)
 			continue;
 
-		ctlr_num = atoi(&ctlr[strlen(ctlr) - 1]);
+		ctlr_num = atoi(&ctlr[sizeof("ctlr_") - 1]);
 		break;
 	}
 

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
#2 lore raw
In reply to Andrey Grafin

Applied, thanks.

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850