[openib-general] Re: [IBAT] interface numbering assumption
James Lentini
jlentini at netapp.com
Fri Sep 23 12:33:18 PDT 2005
On Fri, 23 Sep 2005, Hal Rosenstock wrote:
> > Is there a better way to enumerate all of the network inferaces? I
> > believe that is what this for loop is attempting to accomplish.
>
> Yes. I think that the net_device list from dev_base could be walked
> instead and that would resolve this issue.
Can you help we understand the logic in at.c:resolve_ip()? Here is my
assumption of what this function does:
1) consults the IP routing table for an interface
device using ip_route_output_key
2) if the device does not meet certain criteria, return an error
3) if the device is a loopback device, search for another device
that is an INFINIBAND device and is UP.
4) ...
I've included a small patch below to fix the problem I observed in #3.
It walks the dev_base list as you described.
However I don't understand why the device returned in step #1 isn't
always used as I assumpe this is the interface the routing table says
to use. That makes me think I've misinterpreted the purpose of
ip_route_output_key. What am I missing?
--
Signed-off-by: James Lentini <jlentini at netapp.com>
Index: core/at.c
===================================================================
--- core/at.c (revision 3528)
+++ core/at.c (working copy)
@@ -430,7 +430,7 @@
}
},
};
- int i, r;
+ int r;
DEBUG("dst ip %08x src ip %08x tos %d", dst_ip, src_ip, tos);
@@ -490,13 +490,15 @@
src->gw = rt->rt_gateway;
src->ip = rt->rt_src; /* true source IP address */
- if (ipoib_dev->flags & IFF_LOOPBACK)
- for (i = 1; (ipoib_dev = dev_get_by_index(i)); i++) {
- dev_put(ipoib_dev);
+ if (ipoib_dev->flags & IFF_LOOPBACK) {
+ read_lock(&dev_base_lock);
+ for(ipoib_dev = dev_base; ipoib_dev;
+ ipoib_dev = ipoib_dev->next)
if (ARPHRD_INFINIBAND == ipoib_dev->type &&
(ipoib_dev->flags & IFF_UP))
break;
- }
+ read_unlock(&dev_base_lock);
+ }
if (!ipoib_dev) {
WARN("No device for IB comm <%s:%08x:%08x>",
More information about the general
mailing list