All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: Dmitry Butskoy <buc@odusz.so-cdu.ru>
Cc: netdev@vger.kernel.org
Subject: Re: [ROUTE]: FIB_RES_PREFSRC() selects wrong source in some cases
Date: Wed, 23 Apr 2008 10:09:10 +0000	[thread overview]
Message-ID: <20080423100910.GA3994@ff.dom.local> (raw)
In-Reply-To: <480C889B.3060203@odu.neva.ru>

On 21-04-2008 14:29, Dmitry Butskoy wrote:
> Consider an interface with two (or more) IP addresses, connected to a
> LAN segment with two (or more) networks. In such a case the source IP is
> not unique, it should be chosen depending on the destionation IP. Under
> some circumstances this choice is incorrect.
> 
> Consider the example (an interface in two networks, trying to reach
> "scope link" destinations):
> 
>> # ifdown eth0
>> # ip link set up dev eth0
>> # ip addr add 192.168.0.1/24 dev eth0
>> # ip addr add 172.18.0.1/24 dev eth0
>> # ip route show dev eth0
>> 172.18.0.0/24  proto kernel  scope link  src 172.18.0.1
>> 192.168.0.0/24  proto kernel  scope link  src 192.168.0.1
> 
> now we have two routes with preferred src specified
> 
>> # ip route get 192.168.0.2
>> 192.168.0.2 dev eth0  src 192.168.0.1
>>     cache  mtu 1500 advmss 1460 hoplimit 64
>> # ip route get 172.18.0.2
>> 172.18.0.2 dev eth0  src 172.18.0.1
>>     cache  mtu 1500 advmss 1460 hoplimit 64
> 
> Becasue of the preferred src, the actual source IP is chosen right.
> 
> Now let's flush all the routes, and then add them manually.
> (Certainly such a usage is a corner case, but sometimes some admins
> prefer to set all the routes explicitly, rather than implicitly by
> "proto kernel" etc.)
> 
>> # ip route flush dev eth0
>> #
>> # ip route add 192.168.0.0/24 dev eth0
>> # ip route add 172.18.0.0/24 dev eth0
>> # ip route show dev eth0
>> 172.18.0.0/24  scope link
>> 192.168.0.0/24  scope link
> 
> Now the same as above, but no more preferred src...

...So, why it can't be set explicitly too?:

# ip route add 172.18.0.0/24 dev eth0 src 172.18.0.1

...
> is called with "dst == 0", it chose just the first IP seen on the
> interface (i.e. 192.168.0.1 in the example) ...
> 
> 
> Whether it is possible (and applicable) to change the code someway, to
> call inet_select_addr() with the proper destination IP ?
> 
> Actually, it is a long standing issue (at least since 1999), probably
> it is even "feature" now :), but it seems strange that the kernel have
> all the data to make the right choice, but does not any attemptfor it...

IMHO it's a feature - I mean the way of thinking; low level tools
should do just what they are told to do - if it's possible (even let
you shoot your foot...). And chosing the first IP seems to show
problems faster - just for these admins who like it explicit!?

Regards,
Jarek P.

      reply	other threads:[~2008-04-23 10:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-21 12:29 [ROUTE]: FIB_RES_PREFSRC() selects wrong source in some cases Dmitry Butskoy
2008-04-23 10:09 ` Jarek Poplawski [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=20080423100910.GA3994@ff.dom.local \
    --to=jarkao2@gmail.com \
    --cc=buc@odusz.so-cdu.ru \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.