netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sumanth <sumantk2@linux.vnet.ibm.com>
To: netdev@vger.kernel.org
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
Subject: Re: Some clarification regarding rfc3484 (6724) - Rule 8 Prefer smaller scope
Date: Mon, 26 May 2014 00:31:10 +0530	[thread overview]
Message-ID: <53823DF6.1010505@linux.vnet.ibm.com> (raw)
In-Reply-To: <537F4B55.5040305@linux.vnet.ibm.com>

On 05/23/2014 06:51 PM, sumanth wrote:
> I had configured my local interface as follows :
> ifconfig eth0 inet6 add fe80::1/64
> ifconfig eth0 inet6 add fec0::1/10
>
> And /etc/hosts contains :
> fe80::2 server.org
> fec0::2 server.org
>
> The above two interfaces in /etc/hosts are not configured. Just to get
> the result from getaddrinfo().
>
> So according to rfc3484 , link-local has lower scope when compared to
> site-local .
> So i think fe80::2 should be returned first and then later fec0::2
>
> In my fedora ( any kernel ), getaddrinfo() is preferring site-local
> first instead of link-local.
>
> So when looking into the getaddrinfo() glibc implementation ,  when two
> or more addresses are available (code flow):
> 1) create a udp datagram socket
> 2) connect to the destination addresses returned from gaih_inet ( not
> sorted yet ). This was done inorder to get the source address from the
> kernel (using ipv6_get_saddr_eval() we get the preferred source for 
> each destination). Actually doesnt need the destination to be reachable .
>  #netstat | grep -i udp
> udp        0      0 fec0::1:34236               server.org:http      
> ESTABLISHED
>
> 3) getsockname to get the source address and store in result combo array.
>
> So __connect() to site-local becomes successfull . But __connect() to
> link-local is not successfull .
>
> Hence rfc3484_sort() in glibc changes the order and prefers site-local
> first .
>
> i.e /* Rule 1: Avoid unusable destinations.
>      We have the got_source_addr flag set if the destination is
> reachable.  */
>   if (a1->got_source_addr && ! a2->got_source_addr)
>
> a1->got_source_addr is false because connect to link-local failed.
>
> So my questions are :
> 1) Can this be a problem somewhere around ip6_datagram_connect() [
> because connect fails ]
> 2) Can this be a problem with the parsing of glibc getaddrinfo ? [
> something like sin6_scope_id being not set properly ]
> 3) Or this is the expected behaviour or am i missing out something ?
I was testing one of the tahi testcase :

  DstSelectRule8.seq - Destination Address Selection
                       Check Rule 8(Prefer smaller scopee)

  Rule 8: Prefer smaller scope.
    If Scope(DA) < Scope(DB), then prefer DA.


The configuration was done as shown above. . So link-local was expected.
But returned value was site-local.

- So while looking into the ip6_datagram_connect(), inorder for the
connect() call  to succeed for link-local address, it requires the
sk_bound_dev_if field of the sk to be set. So this can  be done using
setsockopt( fd, SOL_SOCKET, SO_BINDTODEVICE, device , strlen(device) +
1) from the application side / library. 

- But however __connect in glibc getaddrinfo() fails in case of
link-local ( when there are more than 2 address ) . But  in
getaddrinfo.c,  if we add a patch such that   setsockopt() is done
before __connect() and __getsockname() if it is a LINKLOCAL address,
then link-local address is returned first and then later site-local (
which is expected as per tahi testcase ).  i.e rfc3484_sort() goes into
Rule 8 of destination address selection ( otherwise it returns from
Rule1 as source address of link-local wont be set itself as connect() fails)

- But rfc4472 mentions that  Link-local addresses should never be
published in DNS (whether in
   forward or reverse tree), because they have only local (to the
   connected link) significance.

- So whether rfc4472 means that we shouldnt specify link-local address
in /etc/hosts as well ?
- Or it is expected to return site-local first ?  [ If i do setsockopt()
in glibc before connect() iff link-local address, then link-local is
returned first ]. So if it is expected to return link-local , then it is
a bug...


Any help/suggestions would be good.
>
> Any suggestions ?
>
>
> Thank you,
> Sumanth K

      reply	other threads:[~2014-05-25 19:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 13:21 Some clarification regarding rfc3484 (6724) - Rule 8 Prefer smaller scope sumanth
2014-05-25 19:01 ` sumanth [this message]

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=53823DF6.1010505@linux.vnet.ibm.com \
    --to=sumantk2@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=raghavendra.kt@linux.vnet.ibm.com \
    --cc=srikar@linux.vnet.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).