scsi: be2iscsi: Set and return right iface v4/v6 states
authorJitendra Bhivare <jitendra.bhivare@broadcom.com>
Fri, 19 Aug 2016 09:50:01 +0000 (15:20 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 24 Aug 2016 02:42:42 +0000 (22:42 -0400)
ipv4_iface and ipv6_iface fields need to be set to NULL when destroyed.
Before creation these are checked. Use these to report correct states.

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/be2iscsi/be_iscsi.c

index ab696ec29652e9b5290bdf2580f279d6f9311300..eab0f4fdbb31a8ebc5fc1354a356f43083e8b1ec 100644 (file)
@@ -292,10 +292,14 @@ void beiscsi_create_def_ifaces(struct beiscsi_hba *phba)
 
 void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba)
 {
-       if (phba->ipv6_iface)
+       if (phba->ipv6_iface) {
                iscsi_destroy_iface(phba->ipv6_iface);
-       if (phba->ipv4_iface)
+               phba->ipv6_iface = NULL;
+       }
+       if (phba->ipv4_iface) {
                iscsi_destroy_iface(phba->ipv4_iface);
+               phba->ipv4_iface = NULL;
+       }
 }
 
 static int
@@ -406,6 +410,14 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
 
        /* Check the param */
        switch (iface_param->param) {
+       case ISCSI_NET_PARAM_IFACE_ENABLE:
+               if (iface_param->value[0] == ISCSI_IFACE_ENABLE)
+                       ret = beiscsi_create_ipv4_iface(phba);
+               else {
+                       iscsi_destroy_iface(phba->ipv4_iface);
+                       phba->ipv4_iface = NULL;
+               }
+               break;
        case ISCSI_NET_PARAM_IPV4_GW:
                ret = mgmt_set_gateway(phba, iface_param);
                break;
@@ -421,12 +433,6 @@ beiscsi_set_ipv4(struct Scsi_Host *shost,
                                    "BS_%d : Invalid BOOTPROTO: %d\n",
                                    iface_param->value[0]);
                break;
-       case ISCSI_NET_PARAM_IFACE_ENABLE:
-               if (iface_param->value[0] == ISCSI_IFACE_ENABLE)
-                       ret = beiscsi_create_ipv4_iface(phba);
-               else
-                       iscsi_destroy_iface(phba->ipv4_iface);
-               break;
        case ISCSI_NET_PARAM_IPV4_SUBNET:
        case ISCSI_NET_PARAM_IPV4_ADDR:
                ret = beiscsi_set_static_ip(shost, iface_param,
@@ -459,7 +465,7 @@ beiscsi_set_ipv6(struct Scsi_Host *shost,
                        ret = beiscsi_create_ipv6_iface(phba);
                else {
                        iscsi_destroy_iface(phba->ipv6_iface);
-                       ret = 0;
+                       phba->ipv6_iface = NULL;
                }
                break;
        case ISCSI_NET_PARAM_IPV6_ADDR:
@@ -620,7 +626,12 @@ int be2iscsi_iface_get_param(struct iscsi_iface *iface,
                len = be2iscsi_get_if_param(phba, iface, param, buf);
                break;
        case ISCSI_NET_PARAM_IFACE_ENABLE:
-               len = sprintf(buf, "enable\n");
+               if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
+                       len = sprintf(buf, "%s\n",
+                                     phba->ipv4_iface ? "enable" : "disable");
+               else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
+                       len = sprintf(buf, "%s\n",
+                                     phba->ipv6_iface ? "enable" : "disable");
                break;
        case ISCSI_NET_PARAM_IPV4_GW:
                memset(&gateway, 0, sizeof(gateway));