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

Jason Gunthorpe
2009-10-21T23:46:52Z

On Wed, Oct 21, 2009 at 05:36:39PM -0600, Jason Gunthorpe wrote:

> > >- if (ipv4_is_zeronet(src_ip)) {
>
> Looks like:
> $ ip route get 10.0.0.11
> local 10.0.0.11 dev lo src 10.0.0.11
> cache <local> mtu 16436 advmss 16396 hoplimit 64
>
> trips through the if == loopback and does
> 'rdma_translate_ip(10.0.0.11)'
>
> Same as the old code (little different path, but seems to give the
> same result)

Oops, there is a little woopsie here:

Dave:

+ 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;
+ }
+

The 'goto put' will skip over the source address assignment step.

Maybe move this:

if (!src_ip) {
src_in->sin_family = dst_in->sin_family;
src_in->sin_addr.s_addr = rt->rt_src;
}

Up above your if (rt->idev)

And similarly for v6.

Also add a src_in = rt->rt_src assignment for v6.

I'd also remove the test for 0 address, just do it unconditionally
(IIRC routing table always returns src if src is not 0)

Jason