|
|
c36ff1 |
From e0eca40388080dabf6598c0d9653ea50ae10c984 Mon Sep 17 00:00:00 2001
|
|
|
c36ff1 |
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
c36ff1 |
Date: Tue, 7 Dec 2021 10:04:43 +0100
|
|
|
c36ff1 |
Subject: [PATCH] cloudinit/net: handle two different routes for the same ip
|
|
|
c36ff1 |
(#1124)
|
|
|
c36ff1 |
|
|
|
c36ff1 |
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
c36ff1 |
RH-MergeRequest: 15: cloudinit/net: handle two different routes for the same ip (#1124)
|
|
|
c36ff1 |
RH-Commit: [1/1] b623a76ccd642e22e8d9c4aebc26f0b0cec8118b (eesposit/cloud-init-centos-)
|
|
|
c36ff1 |
RH-Bugzilla: 2028031
|
|
|
c36ff1 |
RH-Acked-by: Mohamed Gamal Morsy <mmorsy@redhat.com>
|
|
|
c36ff1 |
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
|
|
|
c36ff1 |
|
|
|
c36ff1 |
commit 0e25076b34fa995161b83996e866c0974cee431f
|
|
|
c36ff1 |
Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
c36ff1 |
Date: Mon Dec 6 18:34:26 2021 +0100
|
|
|
c36ff1 |
|
|
|
c36ff1 |
cloudinit/net: handle two different routes for the same ip (#1124)
|
|
|
c36ff1 |
|
|
|
c36ff1 |
If we set a dhcp server side like this:
|
|
|
c36ff1 |
$ cat /var/tmp/cloud-init/cloud-init-dhcp-f0rie5tm/dhcp.leases
|
|
|
c36ff1 |
lease {
|
|
|
c36ff1 |
...
|
|
|
c36ff1 |
option classless-static-routes 31.169.254.169.254 0.0.0.0,31.169.254.169.254
|
|
|
c36ff1 |
10.112.143.127,22.10.112.140 0.0.0.0,0 10.112.140.1;
|
|
|
c36ff1 |
...
|
|
|
c36ff1 |
}
|
|
|
c36ff1 |
cloud-init fails to configure the routes via 'ip route add' because to there are
|
|
|
c36ff1 |
two different routes for 169.254.169.254:
|
|
|
c36ff1 |
|
|
|
c36ff1 |
$ ip -4 route add 192.168.1.1/32 via 0.0.0.0 dev eth0
|
|
|
c36ff1 |
$ ip -4 route add 192.168.1.1/32 via 10.112.140.248 dev eth0
|
|
|
c36ff1 |
|
|
|
c36ff1 |
But NetworkManager can handle such scenario successfully as it uses "ip route append".
|
|
|
c36ff1 |
So change cloud-init to also use "ip route append" to fix the issue:
|
|
|
c36ff1 |
|
|
|
c36ff1 |
$ ip -4 route append 192.168.1.1/32 via 0.0.0.0 dev eth0
|
|
|
c36ff1 |
$ ip -4 route append 192.168.1.1/32 via 10.112.140.248 dev eth0
|
|
|
c36ff1 |
|
|
|
c36ff1 |
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
c36ff1 |
|
|
|
c36ff1 |
RHBZ: #2003231
|
|
|
c36ff1 |
|
|
|
c36ff1 |
Conflicts:
|
|
|
c36ff1 |
cloudinit/net/tests/test_init.py: a mock call in
|
|
|
c36ff1 |
test_ephemeral_ipv4_network_with_rfc3442_static_routes is not
|
|
|
c36ff1 |
present downstream.
|
|
|
c36ff1 |
|
|
|
c36ff1 |
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
c36ff1 |
---
|
|
|
c36ff1 |
cloudinit/net/__init__.py | 2 +-
|
|
|
c36ff1 |
cloudinit/net/tests/test_init.py | 4 ++--
|
|
|
c36ff1 |
2 files changed, 3 insertions(+), 3 deletions(-)
|
|
|
c36ff1 |
|
|
|
c36ff1 |
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
|
|
|
c36ff1 |
index de65e7af..4bdc1bda 100644
|
|
|
c36ff1 |
--- a/cloudinit/net/__init__.py
|
|
|
c36ff1 |
+++ b/cloudinit/net/__init__.py
|
|
|
c36ff1 |
@@ -1076,7 +1076,7 @@ class EphemeralIPv4Network(object):
|
|
|
c36ff1 |
if gateway != "0.0.0.0/0":
|
|
|
c36ff1 |
via_arg = ['via', gateway]
|
|
|
c36ff1 |
subp.subp(
|
|
|
c36ff1 |
- ['ip', '-4', 'route', 'add', net_address] + via_arg +
|
|
|
c36ff1 |
+ ['ip', '-4', 'route', 'append', net_address] + via_arg +
|
|
|
c36ff1 |
['dev', self.interface], capture=True)
|
|
|
c36ff1 |
self.cleanup_cmds.insert(
|
|
|
c36ff1 |
0, ['ip', '-4', 'route', 'del', net_address] + via_arg +
|
|
|
c36ff1 |
diff --git a/cloudinit/net/tests/test_init.py b/cloudinit/net/tests/test_init.py
|
|
|
c36ff1 |
index 0535387a..6754df8d 100644
|
|
|
c36ff1 |
--- a/cloudinit/net/tests/test_init.py
|
|
|
c36ff1 |
+++ b/cloudinit/net/tests/test_init.py
|
|
|
c36ff1 |
@@ -715,10 +715,10 @@ class TestEphemeralIPV4Network(CiTestCase):
|
|
|
c36ff1 |
['ip', '-family', 'inet', 'link', 'set', 'dev', 'eth0', 'up'],
|
|
|
c36ff1 |
capture=True),
|
|
|
c36ff1 |
mock.call(
|
|
|
c36ff1 |
- ['ip', '-4', 'route', 'add', '169.254.169.254/32',
|
|
|
c36ff1 |
+ ['ip', '-4', 'route', 'append', '169.254.169.254/32',
|
|
|
c36ff1 |
'via', '192.168.2.1', 'dev', 'eth0'], capture=True),
|
|
|
c36ff1 |
mock.call(
|
|
|
c36ff1 |
- ['ip', '-4', 'route', 'add', '0.0.0.0/0',
|
|
|
c36ff1 |
+ ['ip', '-4', 'route', 'append', '0.0.0.0/0',
|
|
|
c36ff1 |
'via', '192.168.2.1', 'dev', 'eth0'], capture=True)]
|
|
|
c36ff1 |
expected_teardown_calls = [
|
|
|
c36ff1 |
mock.call(
|
|
|
c36ff1 |
--
|
|
|
c36ff1 |
2.27.0
|
|
|
c36ff1 |
|