public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 9/9] ib/addr: fix ipv6 routing lookup
Date: Mon, 23 Nov 2009 12:48:47 -0700	[thread overview]
Message-ID: <20091123194847.GL6188@obsidianresearch.com> (raw)
In-Reply-To: <2449CF17D7E94FCBA643A743473246A5-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>

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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2009-11-23 19:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-17  0:12 [PATCH 9/9] ib/addr: fix ipv6 routing lookup Sean Hefty
     [not found] ` <2449CF17D7E94FCBA643A743473246A5-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-11-18 16:52   ` [PATCH 9/9 v2] " Sean Hefty
     [not found]     ` <B596269C5991406FA7EA473D383667F8-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-11-19 16:46       ` [PATCH 9/9 v3] " Sean Hefty
2009-11-23 19:48   ` Jason Gunthorpe [this message]
     [not found]     ` <20091123194847.GL6188-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-11-23 22:07       ` [PATCH 9/9] " Sean Hefty
     [not found]         ` <913F7AE25239487A9AF368E608F30A34-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-11-23 22:26           ` Jason Gunthorpe
     [not found]             ` <20091123222652.GM6188-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-11-24  3:43               ` Sean Hefty
     [not found]                 ` <89DF931E4E7549858A9BF7A31912F2F7-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-11-24  6:56                   ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091123194847.GL6188@obsidianresearch.com \
    --to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox