RE: [PATCH] link-local address fix for rdma_resolve_addr

Sean Hefty
2009-10-21T23:17:01Z

>This patch, as Jason's suggested, moves the function of addr_resolve_local()
>into addr4_resolve_remote()
>and addr6_resolve_remote(). It eliminates the need for addr_resolve_local().

One quick comment, remove '_remote' from function names:
addr4_resolve_remote, addr6_resolve_remote, and addr_resolve_remote

> drivers/infiniband/core/addr.c | 99 +++++++--------------------------------
> 1 files changed, 18 insertions(+), 81 deletions(-)
>
>diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
>index bd07803..f7a5861 100644
>--- a/drivers/infiniband/core/addr.c
>+++ b/drivers/infiniband/core/addr.c
>@@ -233,6 +233,14 @@ static int addr4_resolve_remote(struct sockaddr_in
>*src_in,
> if (ret)
> goto out;
>
>+ if (rt->idev->dev == init_net.loopback_dev){
>+ ret = rdma_translate_ip((struct sockaddr *)dst_in, addr);
>+ if (!ret)
>+ memcpy(addr->dst_dev_addr, addr->src_dev_addr,
>+ MAX_ADDR_LEN);
>+ goto put;
>+ }

This doesn't end up doing the same thing as what resolve_local did. It only
matches up with the 'else if' portion below:

>-static int addr_resolve_local(struct sockaddr *src_in,
>- struct sockaddr *dst_in,
>- struct rdma_dev_addr *addr)
>-{
>- struct net_device *dev;
>- int ret;
>-
>- switch (dst_in->sa_family) {
>- case AF_INET:
>- {
>- __be32 src_ip = ((struct sockaddr_in *)
src_in)->sin_addr.s_addr;
>- __be32 dst_ip = ((struct sockaddr_in *)
dst_in)->sin_addr.s_addr;
>-
>- dev = ip_dev_find(&init_net, dst_ip);
>- if (!dev)
>- return -EADDRNOTAVAIL;
>-
>- if (ipv4_is_zeronet(src_ip)) {
>- src_in->sa_family = dst_in->sa_family;
>- ((struct sockaddr_in *) src_in)->sin_addr.s_addr =
dst_ip;
>- ret = rdma_copy_addr(addr, dev, dev->dev_addr);
>- } else if (ipv4_is_loopback(src_ip)) {
>- ret = rdma_translate_ip(dst_in, addr);
>- if (!ret)
>- memcpy(addr->dst_dev_addr, dev->dev_addr,
>MAX_ADDR_LEN);
>- } else {
>- ret = rdma_translate_ip(src_in, addr);
>- if (!ret)
>- memcpy(addr->dst_dev_addr, dev->dev_addr,
>MAX_ADDR_LEN);
>- }

We need to handle the case where the source address is not given and provide
one. We also need to handle the case where the source address is given, but may
not match the destination address, or even use the same RDMA device.

I didn't look at the ipv6 changes yet.

- Sean