[openib-general][PATCH] local device search with source address wildcard
Tom Tucker
tom at opengridcomputing.com
Fri Nov 4 09:02:41 PST 2005
Sean:
I was looking through ip_resolve_local and it looks to me like
if the source address is 0, it will end up getting set to the
destination IP instead of the IP address of the local interface.
Also if ip_dev_find can't find a local interface with connectivity
to the specified remote peer, shouldn't the error be EHOSTUNREACH?
Finally, if the user specifies a bogus source address, we don't
compare it against the source address configured on the local
interface found in the route. It will probably still fail later,
but in some bizarre fashion.
Here's a patch to show you what I mean. BTW, I think this brings
up another issue: which locally configured IP address do we use if
more than one is configured on the device (aliasing)? This patch
just arbitrarily uses the first one. You could look for a key word
in the ifname for example, i.e. eth0:rnic0 or something.
I only compiled this in my branch and did not test it. It is
just a conversation piece at this point.
Signed-off-by: Tom Tucker <tom at opengridcomputing.com>
Index: addr.c
===================================================================
--- addr.c (revision 3860)
+++ addr.c (working copy)
@@ -216,17 +216,20 @@
struct ib_addr *addr)
{
struct net_device *dev;
+ struct in_device* indev;
u32 src_ip = src_in->sin_addr.s_addr;
u32 dst_ip = dst_in->sin_addr.s_addr;
int ret = 0;
dev = ip_dev_find(dst_ip);
if (!dev)
- return -EADDRNOTAVAIL;
+ return -EHOSTUNREACH;
+ indev = __in_dev_get(dev);
+
if (!src_ip) {
- src_in->sin_family = dst_in->sin_family;
- src_in->sin_addr.s_addr = dst_ip;
+ src_in->sin_family = AF_INET;
+ src_in->sin_addr.s_addr = indev->ifa_list->ifa_address;
addr->sgid = *(union ib_gid *) (dev->dev_addr + 4);
addr->pkey = addr_get_pkey(dev);
} else {
@@ -234,6 +237,11 @@
&addr->sgid, &addr->pkey);
if (ret)
goto out;
+
+ if (src_in->sin_addr.s_addr != indev->ifa_list-
>ifa_address) {
+ ret = -EINVAL;
+ goto out;
+ }
}
addr->dgid = *(union ib_gid *) (dev->dev_addr + 4);
More information about the general
mailing list