On Mon, Nov 16, 2009 at 04:12:07PM -0800, Sean Hefty wrote:

> +static int cma_check_linklocal(struct rdma_dev_addr *dev_addr,
> +                            struct sockaddr *addr)
> +{
> +     struct sockaddr_in6 *sin6;
> +
> +     if (addr->sa_family != AF_INET6)
> +             return 0;
> +
> +     sin6 = (struct sockaddr_in6 *) addr;
> +     if ((ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) &&
> +         !sin6->sin6_scope_id)
> +                     return -EINVAL;
> +
> +     dev_addr->bound_dev_if = sin6->sin6_scope_id;
> +     return 0;
> +}

There is something missing here to match the TCP sin6_scope_id
semantics..

I think what you have is OK for the non-error cases, but the
rdma_resolve_addr path does need to check that an input sin6_scope_id
is either 0 or matches bound_dev_if and return EINVAL.

My approach was to use this:
static int check_ip6_ll(struct rdma_dev_addr *dev_addr,
                        const struct sockaddr *addr)
{
        const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;

        if (addr->sa_family != AF_INET6)
                return 0;

        if (ipv6_addr_type(&addr6->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
                if (dev_addr->bound_dev_if &&
                    dev_addr->bound_dev_if != addr6->sin6_scope_id)
                        return -EINVAL;
                dev_addr->bound_dev_if = addr6->sin6_scope_id;
                if (!dev_addr->bound_dev_if)
                        return -EINVAL;
        }
        return 0;
}

On all 3 addresess, I copied the algorithm from the TCP stack.

The main missing test from the new version is:
                if (dev_addr->bound_dev_if &&
                    dev_addr->bound_dev_if != addr6->sin6_scope_id)
                        return -EINVAL;

Done on the 2nd src and dest address.

Any thoughts on how to fit that in?

Were you able to check the dst/neighbour stuff at all?

Otherwise it looks great to me, thanks for doing this.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to