Skip to content

Commit e746f34

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: iscsi: Fix iface sysfs attr detection
A ISCSI_IFACE_PARAM can have the same value as a ISCSI_NET_PARAM so when iscsi_iface_attr_is_visible tries to figure out the type by just checking the value, we can collide and return the wrong type. When we call into the driver we might not match and return that we don't want attr visible in sysfs. The patch fixes this by setting the type when we figure out what the param is. Link: https://lore.kernel.org/r/[email protected] Fixes: 3e0f65b ("[SCSI] iscsi_transport: Additional parameters for network settings") Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 053c16a commit e746f34

File tree

1 file changed

+34
-56
lines changed

1 file changed

+34
-56
lines changed

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -439,39 +439,10 @@ static umode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
439439
struct device *dev = container_of(kobj, struct device, kobj);
440440
struct iscsi_iface *iface = iscsi_dev_to_iface(dev);
441441
struct iscsi_transport *t = iface->transport;
442-
int param;
443-
int param_type;
442+
int param = -1;
444443

445444
if (attr == &dev_attr_iface_enabled.attr)
446445
param = ISCSI_NET_PARAM_IFACE_ENABLE;
447-
else if (attr == &dev_attr_iface_vlan_id.attr)
448-
param = ISCSI_NET_PARAM_VLAN_ID;
449-
else if (attr == &dev_attr_iface_vlan_priority.attr)
450-
param = ISCSI_NET_PARAM_VLAN_PRIORITY;
451-
else if (attr == &dev_attr_iface_vlan_enabled.attr)
452-
param = ISCSI_NET_PARAM_VLAN_ENABLED;
453-
else if (attr == &dev_attr_iface_mtu.attr)
454-
param = ISCSI_NET_PARAM_MTU;
455-
else if (attr == &dev_attr_iface_port.attr)
456-
param = ISCSI_NET_PARAM_PORT;
457-
else if (attr == &dev_attr_iface_ipaddress_state.attr)
458-
param = ISCSI_NET_PARAM_IPADDR_STATE;
459-
else if (attr == &dev_attr_iface_delayed_ack_en.attr)
460-
param = ISCSI_NET_PARAM_DELAYED_ACK_EN;
461-
else if (attr == &dev_attr_iface_tcp_nagle_disable.attr)
462-
param = ISCSI_NET_PARAM_TCP_NAGLE_DISABLE;
463-
else if (attr == &dev_attr_iface_tcp_wsf_disable.attr)
464-
param = ISCSI_NET_PARAM_TCP_WSF_DISABLE;
465-
else if (attr == &dev_attr_iface_tcp_wsf.attr)
466-
param = ISCSI_NET_PARAM_TCP_WSF;
467-
else if (attr == &dev_attr_iface_tcp_timer_scale.attr)
468-
param = ISCSI_NET_PARAM_TCP_TIMER_SCALE;
469-
else if (attr == &dev_attr_iface_tcp_timestamp_en.attr)
470-
param = ISCSI_NET_PARAM_TCP_TIMESTAMP_EN;
471-
else if (attr == &dev_attr_iface_cache_id.attr)
472-
param = ISCSI_NET_PARAM_CACHE_ID;
473-
else if (attr == &dev_attr_iface_redirect_en.attr)
474-
param = ISCSI_NET_PARAM_REDIRECT_EN;
475446
else if (attr == &dev_attr_iface_def_taskmgmt_tmo.attr)
476447
param = ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO;
477448
else if (attr == &dev_attr_iface_header_digest.attr)
@@ -508,6 +479,38 @@ static umode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
508479
param = ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN;
509480
else if (attr == &dev_attr_iface_initiator_name.attr)
510481
param = ISCSI_IFACE_PARAM_INITIATOR_NAME;
482+
483+
if (param != -1)
484+
return t->attr_is_visible(ISCSI_IFACE_PARAM, param);
485+
486+
if (attr == &dev_attr_iface_vlan_id.attr)
487+
param = ISCSI_NET_PARAM_VLAN_ID;
488+
else if (attr == &dev_attr_iface_vlan_priority.attr)
489+
param = ISCSI_NET_PARAM_VLAN_PRIORITY;
490+
else if (attr == &dev_attr_iface_vlan_enabled.attr)
491+
param = ISCSI_NET_PARAM_VLAN_ENABLED;
492+
else if (attr == &dev_attr_iface_mtu.attr)
493+
param = ISCSI_NET_PARAM_MTU;
494+
else if (attr == &dev_attr_iface_port.attr)
495+
param = ISCSI_NET_PARAM_PORT;
496+
else if (attr == &dev_attr_iface_ipaddress_state.attr)
497+
param = ISCSI_NET_PARAM_IPADDR_STATE;
498+
else if (attr == &dev_attr_iface_delayed_ack_en.attr)
499+
param = ISCSI_NET_PARAM_DELAYED_ACK_EN;
500+
else if (attr == &dev_attr_iface_tcp_nagle_disable.attr)
501+
param = ISCSI_NET_PARAM_TCP_NAGLE_DISABLE;
502+
else if (attr == &dev_attr_iface_tcp_wsf_disable.attr)
503+
param = ISCSI_NET_PARAM_TCP_WSF_DISABLE;
504+
else if (attr == &dev_attr_iface_tcp_wsf.attr)
505+
param = ISCSI_NET_PARAM_TCP_WSF;
506+
else if (attr == &dev_attr_iface_tcp_timer_scale.attr)
507+
param = ISCSI_NET_PARAM_TCP_TIMER_SCALE;
508+
else if (attr == &dev_attr_iface_tcp_timestamp_en.attr)
509+
param = ISCSI_NET_PARAM_TCP_TIMESTAMP_EN;
510+
else if (attr == &dev_attr_iface_cache_id.attr)
511+
param = ISCSI_NET_PARAM_CACHE_ID;
512+
else if (attr == &dev_attr_iface_redirect_en.attr)
513+
param = ISCSI_NET_PARAM_REDIRECT_EN;
511514
else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
512515
if (attr == &dev_attr_ipv4_iface_ipaddress.attr)
513516
param = ISCSI_NET_PARAM_IPV4_ADDR;
@@ -598,32 +601,7 @@ static umode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
598601
return 0;
599602
}
600603

601-
switch (param) {
602-
case ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO:
603-
case ISCSI_IFACE_PARAM_HDRDGST_EN:
604-
case ISCSI_IFACE_PARAM_DATADGST_EN:
605-
case ISCSI_IFACE_PARAM_IMM_DATA_EN:
606-
case ISCSI_IFACE_PARAM_INITIAL_R2T_EN:
607-
case ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN:
608-
case ISCSI_IFACE_PARAM_PDU_INORDER_EN:
609-
case ISCSI_IFACE_PARAM_ERL:
610-
case ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH:
611-
case ISCSI_IFACE_PARAM_FIRST_BURST:
612-
case ISCSI_IFACE_PARAM_MAX_R2T:
613-
case ISCSI_IFACE_PARAM_MAX_BURST:
614-
case ISCSI_IFACE_PARAM_CHAP_AUTH_EN:
615-
case ISCSI_IFACE_PARAM_BIDI_CHAP_EN:
616-
case ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL:
617-
case ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN:
618-
case ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN:
619-
case ISCSI_IFACE_PARAM_INITIATOR_NAME:
620-
param_type = ISCSI_IFACE_PARAM;
621-
break;
622-
default:
623-
param_type = ISCSI_NET_PARAM;
624-
}
625-
626-
return t->attr_is_visible(param_type, param);
604+
return t->attr_is_visible(ISCSI_NET_PARAM, param);
627605
}
628606

629607
static struct attribute *iscsi_iface_attrs[] = {

0 commit comments

Comments
 (0)