netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kristian Evensen <kristian.evensen@gmail.com>
To: Network Development <netdev@vger.kernel.org>
Subject: Overlapping networks can only be added in a certain order
Date: Wed, 22 Jan 2020 21:14:04 +0100	[thread overview]
Message-ID: <CAKfDRXgkU9apv+544cd=u_RWP_3htDSarsv4XqmxW9W0n2KiqQ@mail.gmail.com> (raw)

Hello,

I have a machine that is connected to two separate networks (on two
separate interfaces), but the network addresses overlap. The first
network (lets call it N1) gives me an address in 10.5.101.248/29,
while the other (N2) in 10.5.101.248/30. If routing is successfully
configured or not, depends on the order in which the networks are
configured.

If N1 is configured first, then routing is successfully configured for
both networks. If N2 is configured first, then the configuration of N1
fails. The routes for each network are placed in separate tables, and
I know that the configuration of one network is done before the other
is configured.

The machine where I initially observed this behavior runs kernel 4.14,
but I was able to replicate on a machine running 5.0 using the
commands below. Things start going wrong when I configure N2 before
N1, and set the address for N1. The address is set on the device, but
there is no route added to the main routing table. Instrumenting the
kernel shows that the error happens in fib_valid_prefsrc().

I also checked that routing works correctly when N1 is configured
first, and it does. I used ping and bound the process to the interface
I wanted to check, capturing packets showed that the correct interface
was used

Thanks in advance for any help.

BR,
Kristian

Commands for replicating issue:

#Set up networking. test1 matches N1, test2 N2
ip link add test1 type dummy
ip link add test2 type dummy
ip link set dev test1 up
ip link set dev test2 up

#Configure N1 before N2, works fine
ip addr add 10.5.101.251/29 dev test1
ip ro del 10.5.101.248/29 dev test1 src 10.5.101.251
ip ro add 10.5.101.248/29 dev test1 src 10.5.101.251 table 1
ip ro add default via 10.5.101.252 dev test1 src 10.5.101.251 table 1

ip addr add 10.5.101.250/30 dev test2
ip ro del 10.5.101.248/30 dev test2 src 10.5.101.250
ip ro add 10.5.101.248/30 dev test2 src 10.5.101.250 table 4

#Clean up
ip addr flush dev test1
ip addr flush dev test2

#Configure N2 before N1, failes
ip addr add 10.5.101.250/30 dev test2
ip ro del 10.5.101.248/30 dev test2 src 10.5.101.250
ip ro add 10.5.101.248/30 dev test2 src 10.5.101.250 table 4
ip ro add default via 10.5.101.249 dev test2 src 10.5.101.250 table 4

ip addr add 10.5.101.251/29 dev test1
ip ro del 10.5.101.248/29 dev test1 src 10.5.101.251
ip ro add 10.5.101.248/29 dev test1 src 10.5.101.251 table 1
ip ro add default via 10.5.101.252 dev test1 src 10.5.101.251 table 1

                 reply	other threads:[~2020-01-22 20:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAKfDRXgkU9apv+544cd=u_RWP_3htDSarsv4XqmxW9W0n2KiqQ@mail.gmail.com' \
    --to=kristian.evensen@gmail.com \
    --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 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).