diff options
| author | Anish Bhatt <anish@chelsio.com> | 2014-10-16 18:59:19 -0400 |
|---|---|---|
| committer | Christoph Hellwig <hch@lst.de> | 2014-10-28 04:57:00 -0400 |
| commit | dd9ad67e9bcb71e2efeb5b2f38c9202c013aa74c (patch) | |
| tree | d4d4343e5c1c0d72d533041854096ec7d1caf73c | |
| parent | b1dd2aac4cc0892b82ec60232ed37e3b0af776cc (diff) | |
libcxgbi : support ipv6 address host_param
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>
| -rw-r--r-- | drivers/scsi/cxgbi/libcxgbi.c | 42 | ||||
| -rw-r--r-- | drivers/scsi/cxgbi/libcxgbi.h | 5 |
2 files changed, 37 insertions, 10 deletions
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index 54fa6e0bc1bb..674d498b46ab 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c | |||
| @@ -399,6 +399,35 @@ EXPORT_SYMBOL_GPL(cxgbi_hbas_add); | |||
| 399 | * If the source port is outside our allocation range, the caller is | 399 | * If the source port is outside our allocation range, the caller is |
| 400 | * responsible for keeping track of their port usage. | 400 | * responsible for keeping track of their port usage. |
| 401 | */ | 401 | */ |
| 402 | |||
| 403 | static struct cxgbi_sock *find_sock_on_port(struct cxgbi_device *cdev, | ||
| 404 | unsigned char port_id) | ||
| 405 | { | ||
| 406 | struct cxgbi_ports_map *pmap = &cdev->pmap; | ||
| 407 | unsigned int i; | ||
| 408 | unsigned int used; | ||
| 409 | |||
| 410 | if (!pmap->max_connect || !pmap->used) | ||
| 411 | return NULL; | ||
| 412 | |||
| 413 | spin_lock_bh(&pmap->lock); | ||
| 414 | used = pmap->used; | ||
| 415 | for (i = 0; used && i < pmap->max_connect; i++) { | ||
| 416 | struct cxgbi_sock *csk = pmap->port_csk[i]; | ||
| 417 | |||
| 418 | if (csk) { | ||
| 419 | if (csk->port_id == port_id) { | ||
| 420 | spin_unlock_bh(&pmap->lock); | ||
| 421 | return csk; | ||
| 422 | } | ||
| 423 | used--; | ||
| 424 | } | ||
| 425 | } | ||
| 426 | spin_unlock_bh(&pmap->lock); | ||
| 427 | |||
| 428 | return NULL; | ||
| 429 | } | ||
| 430 | |||
| 402 | static int sock_get_port(struct cxgbi_sock *csk) | 431 | static int sock_get_port(struct cxgbi_sock *csk) |
| 403 | { | 432 | { |
| 404 | struct cxgbi_device *cdev = csk->cdev; | 433 | struct cxgbi_device *cdev = csk->cdev; |
| @@ -749,6 +778,7 @@ static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr) | |||
| 749 | csk->daddr6.sin6_addr = daddr6->sin6_addr; | 778 | csk->daddr6.sin6_addr = daddr6->sin6_addr; |
| 750 | csk->daddr6.sin6_port = daddr6->sin6_port; | 779 | csk->daddr6.sin6_port = daddr6->sin6_port; |
| 751 | csk->daddr6.sin6_family = daddr6->sin6_family; | 780 | csk->daddr6.sin6_family = daddr6->sin6_family; |
| 781 | csk->saddr6.sin6_family = daddr6->sin6_family; | ||
| 752 | csk->saddr6.sin6_addr = pref_saddr; | 782 | csk->saddr6.sin6_addr = pref_saddr; |
| 753 | 783 | ||
| 754 | neigh_release(n); | 784 | neigh_release(n); |
| @@ -2647,12 +2677,14 @@ int cxgbi_get_host_param(struct Scsi_Host *shost, enum iscsi_host_param param, | |||
| 2647 | break; | 2677 | break; |
| 2648 | case ISCSI_HOST_PARAM_IPADDRESS: | 2678 | case ISCSI_HOST_PARAM_IPADDRESS: |
| 2649 | { | 2679 | { |
| 2650 | __be32 addr; | 2680 | struct cxgbi_sock *csk = find_sock_on_port(chba->cdev, |
| 2651 | 2681 | chba->port_id); | |
| 2652 | addr = cxgbi_get_iscsi_ipv4(chba); | 2682 | if (csk) { |
| 2653 | len = sprintf(buf, "%pI4", &addr); | 2683 | len = sprintf(buf, "%pIS", |
| 2684 | (struct sockaddr *)&csk->saddr); | ||
| 2685 | } | ||
| 2654 | log_debug(1 << CXGBI_DBG_ISCSI, | 2686 | log_debug(1 << CXGBI_DBG_ISCSI, |
| 2655 | "hba %s, ipv4 %pI4.\n", chba->ndev->name, &addr); | 2687 | "hba %s, addr %s.\n", chba->ndev->name, buf); |
| 2656 | break; | 2688 | break; |
| 2657 | } | 2689 | } |
| 2658 | default: | 2690 | default: |
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h index 1d98fad6a0ab..2c7cb1c0c453 100644 --- a/drivers/scsi/cxgbi/libcxgbi.h +++ b/drivers/scsi/cxgbi/libcxgbi.h | |||
| @@ -700,11 +700,6 @@ static inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba *chba, __be32 ipaddr) | |||
| 700 | chba->ndev->name); | 700 | chba->ndev->name); |
| 701 | } | 701 | } |
| 702 | 702 | ||
| 703 | static inline __be32 cxgbi_get_iscsi_ipv4(struct cxgbi_hba *chba) | ||
| 704 | { | ||
| 705 | return chba->ipv4addr; | ||
| 706 | } | ||
| 707 | |||
| 708 | struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int); | 703 | struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int); |
| 709 | void cxgbi_device_unregister(struct cxgbi_device *); | 704 | void cxgbi_device_unregister(struct cxgbi_device *); |
| 710 | void cxgbi_device_unregister_all(unsigned int flag); | 705 | void cxgbi_device_unregister_all(unsigned int flag); |
