Skip to content

Commit

Permalink
libcxgbi : support ipv6 address host_param
Browse files Browse the repository at this point in the history
libcxgbi was always returning an ipv4 address for ISCSI_HOST_PARAM_IPADDRESS,
return appropriate address based on address family

Signed-off-by: Anish Bhatt <anish@chelsio.com>
Signed-off-by: Karen Xie <kxie@chelsio.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Anish Bhatt authored and Christoph Hellwig committed Oct 28, 2014
1 parent b1dd2aa commit dd9ad67
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
42 changes: 37 additions & 5 deletions drivers/scsi/cxgbi/libcxgbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,35 @@ EXPORT_SYMBOL_GPL(cxgbi_hbas_add);
* If the source port is outside our allocation range, the caller is
* responsible for keeping track of their port usage.
*/

static struct cxgbi_sock *find_sock_on_port(struct cxgbi_device *cdev,
unsigned char port_id)
{
struct cxgbi_ports_map *pmap = &cdev->pmap;
unsigned int i;
unsigned int used;

if (!pmap->max_connect || !pmap->used)
return NULL;

spin_lock_bh(&pmap->lock);
used = pmap->used;
for (i = 0; used && i < pmap->max_connect; i++) {
struct cxgbi_sock *csk = pmap->port_csk[i];

if (csk) {
if (csk->port_id == port_id) {
spin_unlock_bh(&pmap->lock);
return csk;
}
used--;
}
}
spin_unlock_bh(&pmap->lock);

return NULL;
}

static int sock_get_port(struct cxgbi_sock *csk)
{
struct cxgbi_device *cdev = csk->cdev;
Expand Down Expand Up @@ -749,6 +778,7 @@ static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr)
csk->daddr6.sin6_addr = daddr6->sin6_addr;
csk->daddr6.sin6_port = daddr6->sin6_port;
csk->daddr6.sin6_family = daddr6->sin6_family;
csk->saddr6.sin6_family = daddr6->sin6_family;
csk->saddr6.sin6_addr = pref_saddr;

neigh_release(n);
Expand Down Expand Up @@ -2647,12 +2677,14 @@ int cxgbi_get_host_param(struct Scsi_Host *shost, enum iscsi_host_param param,
break;
case ISCSI_HOST_PARAM_IPADDRESS:
{
__be32 addr;

addr = cxgbi_get_iscsi_ipv4(chba);
len = sprintf(buf, "%pI4", &addr);
struct cxgbi_sock *csk = find_sock_on_port(chba->cdev,
chba->port_id);
if (csk) {
len = sprintf(buf, "%pIS",
(struct sockaddr *)&csk->saddr);
}
log_debug(1 << CXGBI_DBG_ISCSI,
"hba %s, ipv4 %pI4.\n", chba->ndev->name, &addr);
"hba %s, addr %s.\n", chba->ndev->name, buf);
break;
}
default:
Expand Down
5 changes: 0 additions & 5 deletions drivers/scsi/cxgbi/libcxgbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,6 @@ static inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba *chba, __be32 ipaddr)
chba->ndev->name);
}

static inline __be32 cxgbi_get_iscsi_ipv4(struct cxgbi_hba *chba)
{
return chba->ipv4addr;
}

struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int);
void cxgbi_device_unregister(struct cxgbi_device *);
void cxgbi_device_unregister_all(unsigned int flag);
Expand Down

0 comments on commit dd9ad67

Please sign in to comment.