scsi: libcxgbi: update route finding logic
authorVarun Prakash <varun@chelsio.com>
Sun, 14 Apr 2019 14:53:31 +0000 (20:23 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 16 Apr 2019 02:14:20 +0000 (22:14 -0400)
To support vlan and bridge devices first find route using ifindex 0, if
route is not found through net device associated with input scsi host then
find route using ifindex of net device.

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/cxgbi/libcxgbi.c

index d7abc7e9ec9429d2677d6b47a3e580cc8bf65799..8b915d4ed98dcffdb41bfa8d4ded91cd526bac6a 100644 (file)
@@ -2562,13 +2562,9 @@ struct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *shost,
                        pr_info("shost 0x%p, priv NULL.\n", shost);
                        goto err_out;
                }
-
-               rtnl_lock();
-               if (!vlan_uses_dev(hba->ndev))
-                       ifindex = hba->ndev->ifindex;
-               rtnl_unlock();
        }
 
+check_route:
        if (dst_addr->sa_family == AF_INET) {
                csk = cxgbi_check_route(dst_addr, ifindex);
 #if IS_ENABLED(CONFIG_IPV6)
@@ -2589,6 +2585,13 @@ struct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *shost,
        if (!hba)
                hba = csk->cdev->hbas[csk->port_id];
        else if (hba != csk->cdev->hbas[csk->port_id]) {
+               if (ifindex != hba->ndev->ifindex) {
+                       cxgbi_sock_put(csk);
+                       cxgbi_sock_closed(csk);
+                       ifindex = hba->ndev->ifindex;
+                       goto check_route;
+               }
+
                pr_info("Could not connect through requested host %u"
                        "hba 0x%p != 0x%p (%u).\n",
                        shost->host_no, hba,