Re: [RESEND PATCH 1/1]cxgb3i: Fix a login over vlan issue

2010-01-04 Thread David Miller
From: Rakesh Ranjan rak...@chelsio.com
Date: Sun, 27 Dec 2009 12:41:58 +0530 (IST)

 From: Rakesh Ranjan rak...@chelsio.com
 Date: Sun, 27 Dec 2009 12:33:08 +0530
 Fix a target login issue, when parent interface is vlan and we are using 
 cxgb3i sepecific
 private ip address in '/etc/iscsi/ifaces/' iface file.
 
 Acked-by: Karen Xie k...@chelsio.com
 Signed-off-by: Rakesh Ranjan rak...@chelsio.com

Applied.

--

You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.




[RESEND PATCH 1/1]cxgb3i: Fix a login over vlan issue

2009-12-26 Thread Rakesh Ranjan
From: Rakesh Ranjan rak...@chelsio.com
Date: Sun, 27 Dec 2009 12:33:08 +0530
Fix a target login issue, when parent interface is vlan and we are using cxgb3i 
sepecific
private ip address in '/etc/iscsi/ifaces/' iface file.

Acked-by: Karen Xie k...@chelsio.com
Signed-off-by: Rakesh Ranjan rak...@chelsio.com
---
 drivers/scsi/cxgb3i/cxgb3i_offload.c |   34 +-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c 
b/drivers/scsi/cxgb3i/cxgb3i_offload.c
index c1d5be4..4b8a513 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
@@ -1440,6 +1440,10 @@ void cxgb3i_c3cn_release(struct s3_conn *c3cn)
 static int is_cxgb3_dev(struct net_device *dev)
 {
struct cxgb3i_sdev_data *cdata;
+   struct net_device *ndev = dev;
+
+   if (dev-priv_flags  IFF_802_1Q_VLAN)
+   ndev = vlan_dev_real_dev(dev);
 
write_lock(cdata_rwlock);
list_for_each_entry(cdata, cdata_list, list) {
@@ -1447,7 +1451,7 @@ static int is_cxgb3_dev(struct net_device *dev)
int i;
 
for (i = 0; i  ports-nports; i++)
-   if (dev == ports-lldevs[i]) {
+   if (ndev == ports-lldevs[i]) {
write_unlock(cdata_rwlock);
return 1;
}
@@ -1566,6 +1570,26 @@ out_err:
return -1;
 }
 
+/* *
+ * cxgb3i_find_dev - find the interface associated with the given address
+ * @ipaddr: ip address
+ */
+static struct net_device *
+cxgb3i_find_dev(struct net_device *dev, __be32 ipaddr)
+{
+   struct flowi fl;
+   int err;
+   struct rtable *rt;
+
+   memset(fl, 0, sizeof(fl));
+   fl.nl_u.ip4_u.daddr = ipaddr;
+
+   err = ip_route_output_key(dev ? dev_net(dev) : init_net, rt, fl);
+   if (!err)
+   return (rt-u.dst)-dev;
+
+   return NULL;
+}
 
 /**
  * cxgb3i_c3cn_connect - initiates an iscsi tcp connection to a given address
@@ -1581,6 +1605,7 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
s3_conn *c3cn,
struct cxgb3i_sdev_data *cdata;
struct t3cdev *cdev;
__be32 sipv4;
+   struct net_device *dstdev;
int err;
 
c3cn_conn_debug(c3cn 0x%p, dev 0x%p.\n, c3cn, dev);
@@ -1591,6 +1616,13 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
s3_conn *c3cn,
c3cn-daddr.sin_port = usin-sin_port;
c3cn-daddr.sin_addr.s_addr = usin-sin_addr.s_addr;
 
+   dstdev = cxgb3i_find_dev(dev, usin-sin_addr.s_addr);
+   if (!dstdev || !is_cxgb3_dev(dstdev))
+   return -ENETUNREACH;
+
+   if (dstdev-priv_flags  IFF_802_1Q_VLAN)
+   dev = dstdev;
+
rt = find_route(dev, c3cn-saddr.sin_addr.s_addr,
c3cn-daddr.sin_addr.s_addr,
c3cn-saddr.sin_port,
-- 
1.6.0.6

--

You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.




[RESEND PATCH 1/1]cxgb3i: Fix a login over vlan issue

2009-12-14 Thread Rakesh Ranjan
From: Rakesh Ranjan rak...@chelsio.com

Fix a target login issue, when parent interface is vlan and we are using cxgb3i 
sepecific
private ip address in '/etc/iscsi/ifaces/' iface file.

Acked-by: Karen Xie k...@chelsio.com
Signed-off-by: Rakesh Ranjan rak...@chelsio.com
---
 drivers/scsi/cxgb3i/cxgb3i_offload.c |   34 +-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c 
b/drivers/scsi/cxgb3i/cxgb3i_offload.c
index 26ffdcd..15a00e8 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
@@ -1440,6 +1440,10 @@ void cxgb3i_c3cn_release(struct s3_conn *c3cn)
 static int is_cxgb3_dev(struct net_device *dev)
 {
struct cxgb3i_sdev_data *cdata;
+   struct net_device *ndev = dev;
+
+   if (dev-priv_flags  IFF_802_1Q_VLAN)
+   ndev = vlan_dev_real_dev(dev);
 
write_lock(cdata_rwlock);
list_for_each_entry(cdata, cdata_list, list) {
@@ -1447,7 +1451,7 @@ static int is_cxgb3_dev(struct net_device *dev)
int i;
 
for (i = 0; i  ports-nports; i++)
-   if (dev == ports-lldevs[i]) {
+   if (ndev == ports-lldevs[i]) {
write_unlock(cdata_rwlock);
return 1;
}
@@ -1566,6 +1570,26 @@ out_err:
return -EINVAL;
 }
 
+/**
+ * cxgb3i_find_dev - find the interface associated with the given address
+ * @ipaddr: ip address
+ */
+static struct net_device *
+cxgb3i_find_dev(struct net_device *dev, __be32 ipaddr)
+{
+   struct flowi fl;
+   int err;
+   struct rtable *rt;
+
+   memset(fl, 0, sizeof(fl));
+   fl.nl_u.ip4_u.daddr = ipaddr;
+
+   err = ip_route_output_key(dev ? dev_net(dev) : init_net, rt, fl);
+   if (!err)
+   return (rt-u.dst)-dev;
+
+   return NULL;
+}
 
 /**
  * cxgb3i_c3cn_connect - initiates an iscsi tcp connection to a given address
@@ -1581,6 +1605,7 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
s3_conn *c3cn,
struct cxgb3i_sdev_data *cdata;
struct t3cdev *cdev;
__be32 sipv4;
+   struct net_device *dstdev;
int err;
 
c3cn_conn_debug(c3cn 0x%p, dev 0x%p.\n, c3cn, dev);
@@ -1591,6 +1616,13 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
s3_conn *c3cn,
c3cn-daddr.sin_port = usin-sin_port;
c3cn-daddr.sin_addr.s_addr = usin-sin_addr.s_addr;
 
+   dstdev = cxgb3i_find_dev(dev, usin-sin_addr.s_addr);
+   if (!dstdev || !is_cxgb3_dev(dstdev))
+   return -ENETUNREACH;
+
+   if (dstdev-priv_flags  IFF_802_1Q_VLAN)
+   dev = dstdev;
+
rt = find_route(dev, c3cn-saddr.sin_addr.s_addr,
c3cn-daddr.sin_addr.s_addr,
c3cn-saddr.sin_port,
-- 
1.6.0.6


--

You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.




Re: [PATCH 1/1] cxgb3i: Fix a login over vlan issue

2009-12-10 Thread Rakesh Ranjan
Patrick McHardy wrote:
 k...@chelsio.com wrote:
 [PATCH 1/1] cxgb3i: Fix a login over vlan issue

 From: Karen Xie k...@chelsio.com

 Fix a login over vlan issue, when parent interface is vlan and we are using

 cxgb3i sepecific private ip address in '/etc/iscsi/ifaces/' iface file.

 +/**
 + * cxgb3i_find_dev - find the interface associated with the given address
 + * @ipaddr: ip address
 + */
 +static struct net_device *cxgb3i_find_dev(__be32 ipaddr)
 +{
 +struct flowi fl;
 +int err;
 +struct rtable *rt;
 +
 +memset(fl, 0, sizeof(fl));
 +fl.nl_u.ip4_u.daddr = ipaddr;
 +
 +err = ip_route_output_key(init_net, rt, fl);
 +if (!err)
 +return (rt-u.dst)-dev;
 +
 +return NULL;
 +}
 
 This probably shouldn't be using init_net but the current namespace.

Hi Patrick,

Thanks for review, will fix that and send another path shortly.

Regards
Rakesh Ranjan




signature.asc
Description: OpenPGP digital signature


[PATCH 1/1] cxgb3i: Fix a login over vlan issue

2009-12-09 Thread kxie
[PATCH 1/1] cxgb3i: Fix a login over vlan issue

From: Karen Xie k...@chelsio.com

Fix a login over vlan issue, when parent interface is vlan and we are using

cxgb3i sepecific private ip address in '/etc/iscsi/ifaces/' iface file.

Acked-by: Karen Xie k...@chelsio.com
Signed-off-by: Rakesh Ranjan rak...@chelsio.com
---

 drivers/scsi/cxgb3i/cxgb3i_offload.c |   33 -
 1 files changed, 32 insertions(+), 1 deletions(-)


diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c 
b/drivers/scsi/cxgb3i/cxgb3i_offload.c
index 26ffdcd..1aef364 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
@@ -1440,6 +1440,10 @@ void cxgb3i_c3cn_release(struct s3_conn *c3cn)
 static int is_cxgb3_dev(struct net_device *dev)
 {
struct cxgb3i_sdev_data *cdata;
+   struct net_device *ndev = dev;
+
+   if (dev-priv_flags  IFF_802_1Q_VLAN)
+   ndev = vlan_dev_real_dev(dev);
 
write_lock(cdata_rwlock);
list_for_each_entry(cdata, cdata_list, list) {
@@ -1447,7 +1451,7 @@ static int is_cxgb3_dev(struct net_device *dev)
int i;
 
for (i = 0; i  ports-nports; i++)
-   if (dev == ports-lldevs[i]) {
+   if (ndev == ports-lldevs[i]) {
write_unlock(cdata_rwlock);
return 1;
}
@@ -1566,6 +1570,25 @@ out_err:
return -EINVAL;
 }
 
+/**
+ * cxgb3i_find_dev - find the interface associated with the given address
+ * @ipaddr: ip address
+ */
+static struct net_device *cxgb3i_find_dev(__be32 ipaddr)
+{
+   struct flowi fl;
+   int err;
+   struct rtable *rt;
+
+   memset(fl, 0, sizeof(fl));
+   fl.nl_u.ip4_u.daddr = ipaddr;
+
+   err = ip_route_output_key(init_net, rt, fl);
+   if (!err)
+   return (rt-u.dst)-dev;
+
+   return NULL;
+}
 
 /**
  * cxgb3i_c3cn_connect - initiates an iscsi tcp connection to a given address
@@ -1581,6 +1604,7 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
s3_conn *c3cn,
struct cxgb3i_sdev_data *cdata;
struct t3cdev *cdev;
__be32 sipv4;
+   struct net_device *dstdev;
int err;
 
c3cn_conn_debug(c3cn 0x%p, dev 0x%p.\n, c3cn, dev);
@@ -1591,6 +1615,13 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
s3_conn *c3cn,
c3cn-daddr.sin_port = usin-sin_port;
c3cn-daddr.sin_addr.s_addr = usin-sin_addr.s_addr;
 
+   dstdev = cxgb3i_find_dev(usin-sin_addr.s_addr);
+   if (!dstdev || !is_cxgb3_dev(dstdev))
+   return -ENETUNREACH;
+
+   if (dstdev-priv_flags  IFF_802_1Q_VLAN)
+   dev = dstdev;
+
rt = find_route(dev, c3cn-saddr.sin_addr.s_addr,
c3cn-daddr.sin_addr.s_addr,
c3cn-saddr.sin_port,

--

You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.




RE: [PATCH 1/1] cxgb3i: Fix a login over vlan issue

2009-12-09 Thread Karen Xie

Hi, thanks, Mike.

It looks like the original patch somehow did not make into the linux-scsi list 
at all for some reason: tried to search for it but could not find it.

We are re-submitting it just to make sure.

Best regards,
Karen

-Original Message-
From: Mike Christie [mailto:micha...@cs.wisc.edu]
Sent: Mon 12/7/2009 8:34 AM
To: open-iscsi@googlegroups.com
Cc: james.bottom...@hansenpartnership.com; da...@davemloft.net; Steve Wise; 
Karen Xie; linux-s...@vger.kernel.org; linux-ker...@vger.kernel.org; 
net...@vger.kernel.org; Rakesh Ranjan
Subject: Re: [PATCH 1/1] cxgb3i: Fix a login over vlan issue
 
Rakesh Ranjan wrote:
 Fix a login over vlan issue, when parent interface is vlan and we are using 
 cxgb3i sepecific
 private ip address in '/etc/iscsi/ifaces/' iface file.
 
 Acked-by: Karen Xie k...@chelsio.com
 Signed-off-by: Rakesh Ranjan rak...@chelsio.com
 ---
  drivers/scsi/cxgb3i/cxgb3i_offload.c |   34 
 +-
  1 files changed, 33 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c 
 b/drivers/scsi/cxgb3i/cxgb3i_offload.c
 index c1d5be4..66d52e4 100644
 --- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
 +++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
 @@ -1440,6 +1440,10 @@ void cxgb3i_c3cn_release(struct s3_conn *c3cn)
  static int is_cxgb3_dev(struct net_device *dev)
  {
   struct cxgb3i_sdev_data *cdata;
 + struct net_device *ndev = dev;
 +
 + if (dev-priv_flags  IFF_802_1Q_VLAN)
 + ndev = vlan_dev_real_dev(dev);
  
   write_lock(cdata_rwlock);
   list_for_each_entry(cdata, cdata_list, list) {
 @@ -1447,7 +1451,7 @@ static int is_cxgb3_dev(struct net_device *dev)
   int i;
  
   for (i = 0; i  ports-nports; i++)
 - if (dev == ports-lldevs[i]) {
 + if (ndev == ports-lldevs[i]) {
   write_unlock(cdata_rwlock);
   return 1;
   }
 @@ -1566,6 +1570,26 @@ out_err:
   return -1;
  }
  
 +/**
 + * cxgb3i_find_dev - find the interface associated with the given address
 + * @ipaddr: ip address
 + */
 +static struct net_device *
 +cxgb3i_find_dev(__be32 ipaddr)
 +{
 + struct flowi fl;
 + int err;
 + struct rtable *rt;
 +
 + memset(fl, 0, sizeof(fl));
 + fl.nl_u.ip4_u.daddr = ipaddr;
 +
 + err = ip_route_output_key(init_net, rt, fl);
 + if (!err)
 + return (rt-u.dst)-dev;
 +
 + return NULL;
 +}
  
  /**
   * cxgb3i_c3cn_connect - initiates an iscsi tcp connection to a given address
 @@ -1581,6 +1605,7 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
 s3_conn *c3cn,
   struct cxgb3i_sdev_data *cdata;
   struct t3cdev *cdev;
   __be32 sipv4;
 + struct net_device *dstdev;
   int err;
  
   c3cn_conn_debug(c3cn 0x%p, dev 0x%p.\n, c3cn, dev);
 @@ -1591,6 +1616,13 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
 s3_conn *c3cn,
   c3cn-daddr.sin_port = usin-sin_port;
   c3cn-daddr.sin_addr.s_addr = usin-sin_addr.s_addr;
  
 + dstdev = cxgb3i_find_dev(usin-sin_addr.s_addr);
 + if (!dstdev || !is_cxgb3_dev(dstdev))
 + return -ENETUNREACH;
 +
 + if (dstdev-priv_flags  IFF_802_1Q_VLAN)
 + dev = dstdev;
 +
   rt = find_route(dev, c3cn-saddr.sin_addr.s_addr,
   c3cn-daddr.sin_addr.s_addr,
   c3cn-saddr.sin_port,


Looks sane. I am not a expert on the networks apis being used though.


--

You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.




Re: [PATCH 1/1] cxgb3i: Fix a login over vlan issue

2009-12-07 Thread Mike Christie
Rakesh Ranjan wrote:
 Fix a login over vlan issue, when parent interface is vlan and we are using 
 cxgb3i sepecific
 private ip address in '/etc/iscsi/ifaces/' iface file.
 
 Acked-by: Karen Xie k...@chelsio.com
 Signed-off-by: Rakesh Ranjan rak...@chelsio.com
 ---
  drivers/scsi/cxgb3i/cxgb3i_offload.c |   34 
 +-
  1 files changed, 33 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c 
 b/drivers/scsi/cxgb3i/cxgb3i_offload.c
 index c1d5be4..66d52e4 100644
 --- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
 +++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
 @@ -1440,6 +1440,10 @@ void cxgb3i_c3cn_release(struct s3_conn *c3cn)
  static int is_cxgb3_dev(struct net_device *dev)
  {
   struct cxgb3i_sdev_data *cdata;
 + struct net_device *ndev = dev;
 +
 + if (dev-priv_flags  IFF_802_1Q_VLAN)
 + ndev = vlan_dev_real_dev(dev);
  
   write_lock(cdata_rwlock);
   list_for_each_entry(cdata, cdata_list, list) {
 @@ -1447,7 +1451,7 @@ static int is_cxgb3_dev(struct net_device *dev)
   int i;
  
   for (i = 0; i  ports-nports; i++)
 - if (dev == ports-lldevs[i]) {
 + if (ndev == ports-lldevs[i]) {
   write_unlock(cdata_rwlock);
   return 1;
   }
 @@ -1566,6 +1570,26 @@ out_err:
   return -1;
  }
  
 +/**
 + * cxgb3i_find_dev - find the interface associated with the given address
 + * @ipaddr: ip address
 + */
 +static struct net_device *
 +cxgb3i_find_dev(__be32 ipaddr)
 +{
 + struct flowi fl;
 + int err;
 + struct rtable *rt;
 +
 + memset(fl, 0, sizeof(fl));
 + fl.nl_u.ip4_u.daddr = ipaddr;
 +
 + err = ip_route_output_key(init_net, rt, fl);
 + if (!err)
 + return (rt-u.dst)-dev;
 +
 + return NULL;
 +}
  
  /**
   * cxgb3i_c3cn_connect - initiates an iscsi tcp connection to a given address
 @@ -1581,6 +1605,7 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
 s3_conn *c3cn,
   struct cxgb3i_sdev_data *cdata;
   struct t3cdev *cdev;
   __be32 sipv4;
 + struct net_device *dstdev;
   int err;
  
   c3cn_conn_debug(c3cn 0x%p, dev 0x%p.\n, c3cn, dev);
 @@ -1591,6 +1616,13 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
 s3_conn *c3cn,
   c3cn-daddr.sin_port = usin-sin_port;
   c3cn-daddr.sin_addr.s_addr = usin-sin_addr.s_addr;
  
 + dstdev = cxgb3i_find_dev(usin-sin_addr.s_addr);
 + if (!dstdev || !is_cxgb3_dev(dstdev))
 + return -ENETUNREACH;
 +
 + if (dstdev-priv_flags  IFF_802_1Q_VLAN)
 + dev = dstdev;
 +
   rt = find_route(dev, c3cn-saddr.sin_addr.s_addr,
   c3cn-daddr.sin_addr.s_addr,
   c3cn-saddr.sin_port,


Looks sane. I am not a expert on the networks apis being used though.

--

You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.




[PATCH 1/1] cxgb3i: Fix a login over vlan issue

2009-12-04 Thread Rakesh Ranjan
Fix a login over vlan issue, when parent interface is vlan and we are using 
cxgb3i sepecific
private ip address in '/etc/iscsi/ifaces/' iface file.

Acked-by: Karen Xie k...@chelsio.com
Signed-off-by: Rakesh Ranjan rak...@chelsio.com
---
 drivers/scsi/cxgb3i/cxgb3i_offload.c |   34 +-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c 
b/drivers/scsi/cxgb3i/cxgb3i_offload.c
index c1d5be4..66d52e4 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
@@ -1440,6 +1440,10 @@ void cxgb3i_c3cn_release(struct s3_conn *c3cn)
 static int is_cxgb3_dev(struct net_device *dev)
 {
struct cxgb3i_sdev_data *cdata;
+   struct net_device *ndev = dev;
+
+   if (dev-priv_flags  IFF_802_1Q_VLAN)
+   ndev = vlan_dev_real_dev(dev);
 
write_lock(cdata_rwlock);
list_for_each_entry(cdata, cdata_list, list) {
@@ -1447,7 +1451,7 @@ static int is_cxgb3_dev(struct net_device *dev)
int i;
 
for (i = 0; i  ports-nports; i++)
-   if (dev == ports-lldevs[i]) {
+   if (ndev == ports-lldevs[i]) {
write_unlock(cdata_rwlock);
return 1;
}
@@ -1566,6 +1570,26 @@ out_err:
return -1;
 }
 
+/**
+ * cxgb3i_find_dev - find the interface associated with the given address
+ * @ipaddr: ip address
+ */
+static struct net_device *
+cxgb3i_find_dev(__be32 ipaddr)
+{
+   struct flowi fl;
+   int err;
+   struct rtable *rt;
+
+   memset(fl, 0, sizeof(fl));
+   fl.nl_u.ip4_u.daddr = ipaddr;
+
+   err = ip_route_output_key(init_net, rt, fl);
+   if (!err)
+   return (rt-u.dst)-dev;
+
+   return NULL;
+}
 
 /**
  * cxgb3i_c3cn_connect - initiates an iscsi tcp connection to a given address
@@ -1581,6 +1605,7 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
s3_conn *c3cn,
struct cxgb3i_sdev_data *cdata;
struct t3cdev *cdev;
__be32 sipv4;
+   struct net_device *dstdev;
int err;
 
c3cn_conn_debug(c3cn 0x%p, dev 0x%p.\n, c3cn, dev);
@@ -1591,6 +1616,13 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct 
s3_conn *c3cn,
c3cn-daddr.sin_port = usin-sin_port;
c3cn-daddr.sin_addr.s_addr = usin-sin_addr.s_addr;
 
+   dstdev = cxgb3i_find_dev(usin-sin_addr.s_addr);
+   if (!dstdev || !is_cxgb3_dev(dstdev))
+   return -ENETUNREACH;
+
+   if (dstdev-priv_flags  IFF_802_1Q_VLAN)
+   dev = dstdev;
+
rt = find_route(dev, c3cn-saddr.sin_addr.s_addr,
c3cn-daddr.sin_addr.s_addr,
c3cn-saddr.sin_port,
-- 
1.6.0.6

--

You received this message because you are subscribed to the Google Groups 
open-iscsi group.
To post to this group, send email to open-is...@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.