LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2.6.25] RDMA/cxgb3: Fail loopback connections.
@ 2008-02-12 22:09 Steve Wise
  2008-02-13  0:26 ` [ofa-general] " Roland Dreier
  0 siblings, 1 reply; 9+ messages in thread
From: Steve Wise @ 2008-02-12 22:09 UTC (permalink / raw)
  To: rdreier; +Cc: netdev, linux-kernel, general


RDMA/cxgb3: Fail loopback connections.

The cxgb3 HW and driver don't support loopback RDMA connections.  So fail
any connection attempt where the destination address is local.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
---

 drivers/infiniband/hw/cxgb3/iwch_cm.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index e9a08fa..5d82723 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -1784,6 +1784,17 @@ err:
 	return err;
 }
 
+static void is_loopback_dst(struct iw_cm_id *cm_id)
+{
+	struct net_device *dev;
+	
+	dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
+	if (!dev)
+		return 0;
+	dev_put(dev);
+	return 1;
+}
+
 int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 {
 	int err = 0;
@@ -1791,6 +1802,11 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 	struct iwch_ep *ep;
 	struct rtable *rt;
 
+	if (is_loopback_dst(cm_id)) {
+		err = -ENOSYS;
+		goto out;
+	}
+
 	ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
 	if (!ep) {
 		printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopback connections.
  2008-02-12 22:09 [PATCH 2.6.25] RDMA/cxgb3: Fail loopback connections Steve Wise
@ 2008-02-13  0:26 ` Roland Dreier
  2008-02-13  1:41   ` Steve Wise
  2008-02-13  9:18   ` [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections Diego Guella
  0 siblings, 2 replies; 9+ messages in thread
From: Roland Dreier @ 2008-02-13  0:26 UTC (permalink / raw)
  To: Steve Wise; +Cc: netdev, linux-kernel, general

applied, although:

 > +static void is_loopback_dst(struct iw_cm_id *cm_id)
 > +{
 > +	struct net_device *dev;
 > +	
 > +	dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
 > +	if (!dev)
 > +		return 0;
 > +	dev_put(dev);
 > +	return 1;
 > +}

is there any way this could trigger when it should, like if I'm trying
to make a connection from one local device to a different local device
(which should work fine)?

 - R.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopback connections.
  2008-02-13  0:26 ` [ofa-general] " Roland Dreier
@ 2008-02-13  1:41   ` Steve Wise
  2008-02-13  9:18   ` [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections Diego Guella
  1 sibling, 0 replies; 9+ messages in thread
From: Steve Wise @ 2008-02-13  1:41 UTC (permalink / raw)
  To: Roland Dreier; +Cc: netdev, linux-kernel, general

Roland Dreier wrote:
> applied, although:
> 
>  > +static void is_loopback_dst(struct iw_cm_id *cm_id)
>  > +{
>  > +	struct net_device *dev;
>  > +	
>  > +	dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
>  > +	if (!dev)
>  > +		return 0;
>  > +	dev_put(dev);
>  > +	return 1;
>  > +}
> 
> is there any way this could trigger when it should, like if I'm trying
> to make a connection from one local device to a different local device
> (which should work fine)?
> 

As far as I can tell, if the app does a rdma_resolve_addr() on the dst 
addr (which is a local address), then the routing lookup will find the 
local interface with that dst addr, and that device will be used for the 
connect.  IE src and dst devices are the same.

Maybe if the app does an explicit bind to the addr on one device, then 
connects to the addr on the other device.  But that's not gonna work 
either, I think.  I still think it will resolve to one device and that 
device cannot do loopback...


Steve.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections.
  2008-02-13  0:26 ` [ofa-general] " Roland Dreier
  2008-02-13  1:41   ` Steve Wise
@ 2008-02-13  9:18   ` Diego Guella
  2008-02-13 15:46     ` Roland Dreier
  1 sibling, 1 reply; 9+ messages in thread
From: Diego Guella @ 2008-02-13  9:18 UTC (permalink / raw)
  To: Steve Wise, Roland Dreier; +Cc: netdev, linux-kernel, general

One question below


----- Original Message ----- 
From: "Roland Dreier" <rdreier@cisco.com>
To: "Steve Wise" <swise@opengridcomputing.com>
Cc: <netdev@vger.kernel.org>; <linux-kernel@vger.kernel.org>; <general@lists.openfabrics.org>
Sent: Wednesday, February 13, 2008 1:26 AM
Subject: Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections.


> applied, although:
> 
> > +static void is_loopback_dst(struct iw_cm_id *cm_id)
> > +{
> > + struct net_device *dev;
> > + 
> > + dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
> > + if (!dev)
> > + return 0;

how can a static void function return 0?
%)

> > + dev_put(dev);
> > + return 1;

same here



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections.
  2008-02-13  9:18   ` [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections Diego Guella
@ 2008-02-13 15:46     ` Roland Dreier
  2008-02-13 15:47       ` Steve Wise
  2008-02-13 15:49       ` Roland Dreier
  0 siblings, 2 replies; 9+ messages in thread
From: Roland Dreier @ 2008-02-13 15:46 UTC (permalink / raw)
  To: Diego Guella; +Cc: Steve Wise, netdev, linux-kernel, general

  > how can a static void function return 0?

good question... I've fixed the patch in my tree.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections.
  2008-02-13 15:46     ` Roland Dreier
@ 2008-02-13 15:47       ` Steve Wise
  2008-02-13 15:49       ` Roland Dreier
  1 sibling, 0 replies; 9+ messages in thread
From: Steve Wise @ 2008-02-13 15:47 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Diego Guella, netdev, linux-kernel, general

Roland Dreier wrote:
>   > how can a static void function return 0?
> 
> good question... I've fixed the patch in my tree.

oops.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections.
  2008-02-13 15:46     ` Roland Dreier
  2008-02-13 15:47       ` Steve Wise
@ 2008-02-13 15:49       ` Roland Dreier
  2008-02-13 15:51         ` Steve Wise
  1 sibling, 1 reply; 9+ messages in thread
From: Roland Dreier @ 2008-02-13 15:49 UTC (permalink / raw)
  To: Steve Wise; +Cc: netdev, linux-kernel, general

Steve, I had to update the patch adding an include and fixing the
function declaration (as below)... but how much testing have you done
with this??

commit 8704e9a8790cc9e394198663c1c9150c899fb9a2
Author: Steve Wise <swise@opengridcomputing.com>
Date:   Tue Feb 12 16:09:29 2008 -0600

    RDMA/cxgb3: Fail loopback connections
    
    The cxgb3 HW and driver don't support loopback RDMA connections.  So
    fail any connection attempt where the destination address is local.
    
    Signed-off-by: Steve Wise <swise@opengridcomputing.com>
    Signed-off-by: Roland Dreier <rolandd@cisco.com>

diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index e9a08fa..320f2b6 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -35,6 +35,7 @@
 #include <linux/skbuff.h>
 #include <linux/timer.h>
 #include <linux/notifier.h>
+#include <linux/inetdevice.h>
 
 #include <net/neighbour.h>
 #include <net/netevent.h>
@@ -1784,6 +1785,17 @@ err:
 	return err;
 }
 
+static int is_loopback_dst(struct iw_cm_id *cm_id)
+{
+	struct net_device *dev;
+
+	dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
+	if (!dev)
+		return 0;
+	dev_put(dev);
+	return 1;
+}
+
 int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 {
 	int err = 0;
@@ -1791,6 +1803,11 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 	struct iwch_ep *ep;
 	struct rtable *rt;
 
+	if (is_loopback_dst(cm_id)) {
+		err = -ENOSYS;
+		goto out;
+	}
+
 	ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
 	if (!ep) {
 		printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections.
  2008-02-13 15:49       ` Roland Dreier
@ 2008-02-13 15:51         ` Steve Wise
  2008-02-13 16:03           ` Steve Wise
  0 siblings, 1 reply; 9+ messages in thread
From: Steve Wise @ 2008-02-13 15:51 UTC (permalink / raw)
  To: Roland Dreier; +Cc: netdev, linux-kernel, general

Roland Dreier wrote:
> Steve, I had to update the patch adding an include and fixing the
> function declaration (as below)... but how much testing have you done
> with this??
>

Now I understand.  I thought I'd fixed these!  I fixed them locally in 
the test tree on my victim and then tested, but forgot to update my git 
tree.

Sorry for this.

You want me to resubmit?


> commit 8704e9a8790cc9e394198663c1c9150c899fb9a2
> Author: Steve Wise <swise@opengridcomputing.com>
> Date:   Tue Feb 12 16:09:29 2008 -0600
> 
>     RDMA/cxgb3: Fail loopback connections
>     
>     The cxgb3 HW and driver don't support loopback RDMA connections.  So
>     fail any connection attempt where the destination address is local.
>     
>     Signed-off-by: Steve Wise <swise@opengridcomputing.com>
>     Signed-off-by: Roland Dreier <rolandd@cisco.com>
> 
> diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
> index e9a08fa..320f2b6 100644
> --- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
> +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
> @@ -35,6 +35,7 @@
>  #include <linux/skbuff.h>
>  #include <linux/timer.h>
>  #include <linux/notifier.h>
> +#include <linux/inetdevice.h>
>  
>  #include <net/neighbour.h>
>  #include <net/netevent.h>
> @@ -1784,6 +1785,17 @@ err:
>  	return err;
>  }
>  
> +static int is_loopback_dst(struct iw_cm_id *cm_id)
> +{
> +	struct net_device *dev;
> +
> +	dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
> +	if (!dev)
> +		return 0;
> +	dev_put(dev);
> +	return 1;
> +}
> +
>  int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
>  {
>  	int err = 0;
> @@ -1791,6 +1803,11 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
>  	struct iwch_ep *ep;
>  	struct rtable *rt;
>  
> +	if (is_loopback_dst(cm_id)) {
> +		err = -ENOSYS;
> +		goto out;
> +	}
> +
>  	ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
>  	if (!ep) {
>  		printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__);


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections.
  2008-02-13 15:51         ` Steve Wise
@ 2008-02-13 16:03           ` Steve Wise
  0 siblings, 0 replies; 9+ messages in thread
From: Steve Wise @ 2008-02-13 16:03 UTC (permalink / raw)
  To: Roland Dreier; +Cc: netdev, linux-kernel, general

Steve Wise wrote:
> Roland Dreier wrote:
>> Steve, I had to update the patch adding an include and fixing the
>> function declaration (as below)... but how much testing have you done
>> with this??
>>
> 
> Now I understand.  I thought I'd fixed these!  I fixed them locally in 
> the test tree on my victim and then tested, but forgot to update my git 
> tree.
> 
> Sorry for this.
> 
> You want me to resubmit?
> 

BTW: Testing:  I cloned my git tree, resolved the two compile issues 
(void + include), then built and installed the kernel (2.6.25-rc1 + the 
fixed patch).  I then ensured that a connection to the local address 
caused the ENOSYS error.

I just forgot to pull the updated file back into my stg managed git tree.

:(

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-02-13 16:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-12 22:09 [PATCH 2.6.25] RDMA/cxgb3: Fail loopback connections Steve Wise
2008-02-13  0:26 ` [ofa-general] " Roland Dreier
2008-02-13  1:41   ` Steve Wise
2008-02-13  9:18   ` [ofa-general] [PATCH 2.6.25] RDMA/cxgb3: Fail loopbackconnections Diego Guella
2008-02-13 15:46     ` Roland Dreier
2008-02-13 15:47       ` Steve Wise
2008-02-13 15:49       ` Roland Dreier
2008-02-13 15:51         ` Steve Wise
2008-02-13 16:03           ` Steve Wise

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).