Quoting r. Sean Hefty <[EMAIL PROTECTED]>:
> Subject: Re: [PATCH] sdp: replace ip_dev_find withdev_base scan (was Re: 
> ip_dev_find resolution?)
> 
> Michael S. Tsirkin wrote:
> > Right. So lets map 127.0.0.1 to an arbitrary local device for now?
> 
> Sounds good for now.

OK, thats what the patch did. Something along the following lines
would be a good fit for cma, wouldnt it:

> 1. Get rid of ip_dev_find.
> 2. Add support for local addresses such as 127.0.0.1,
>    resolving them to an arbitrary rdma device, while we are at it.
>
> Signed-off-by: Michael S. Tsirkin <[EMAIL PROTECTED]>
 
+static int tryaddrmatch(struct net_device *dev, u32 s_addr, u32 d_addr)
+{
+       struct in_ifaddr **ifap;
+       struct in_ifaddr *ifa;
+       struct in_device *in_dev;
+       int rc = -ENETUNREACH;
+       __be32 addr;
+
+       if (dev->type != ARPHRD_INFINIBAND)
+               return rc;
+
+       in_dev = in_dev_get(dev);
+       if (!in_dev)
+               return rc;
+
+       addr = (ZERONET(s_addr) || LOOPBACK(s_addr)) ? d_addr : s_addr;
+
+       /* Hack to enable using SDP on addresses such as 127.0.0.1 */
+       if (ZERONET(addr) || LOOPBACK(addr)) {
+               rc = (dev->flags & IFF_UP) ? 0 : -ENETUNREACH;
+               goto done;
+       }
+
+       for (ifap = &in_dev->ifa_list; (ifa = *ifap); ifap = &ifa->ifa_next) {
+               if (s_addr == ifa->ifa_address) {
+                       rc = 0;
+                       break; /* found */
+               }
+       }
+
+done:
+       in_dev_put(in_dev);
+       return rc;
+}
+
 

And, after resolving the route:

        if (dev->flags & IFF_LOOPBACK) {
                dev_put(dev);
                read_lock(&dev_base_lock);
+               for (dev = dev_base; dev; dev = dev->next)
+                       if (!tryaddrmatch(dev, rt->rt_src, rt->rt_dst)) {
+                               dev_hold(dev);
+                               break;
+                       }
                read_unlock(&dev_base_lock);
        }
-- 
MST
_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to