Fix Octavia for host host routes

If the subnet attached to an Octavia load balancer had a host route defined
that was actually a host, the load balancer would go into ERROR.
This patch fixes that issue by checking the host route and handling the
netns route additions properly.

Change-Id: I95e8ed377d4ed12aab4ecb2142896b13a9b21079
Story: 2003441
Task: 24637
changes/76/591876/1
Michael Johnson 4 years ago
parent b0210e4312
commit 1f73119b7c
  1. 6
      octavia/amphorae/backends/agent/api_server/templates/plug_port_ethX.conf.j2
  2. 6
      octavia/amphorae/backends/agent/api_server/templates/plug_vip_ethX.conf.j2
  3. 26
      octavia/tests/functional/amphorae/backend/agent/api_server/test_server.py

@ -24,8 +24,14 @@ netmask {{ netmask }}
mtu {{ mtu }}
{%- endif %}
{%- for hr in host_routes %}
{%- if ((hr.network.version == 4 and hr.network.prefixlen == 32) or
(hr.network.version == 6 and hr.network.prefixlen == 128)) %}
up route add -host {{ hr.network }} gw {{ hr.gw }} dev {{ interface }}
down route del -host {{ hr.network }} gw {{ hr.gw }} dev {{ interface }}
{%- else %}
up route add -net {{ hr.network }} gw {{ hr.gw }} dev {{ interface }}
down route del -net {{ hr.network }} gw {{ hr.gw }} dev {{ interface }}
{%- endif %}
{%- endfor %}
post-up /sbin/ip{{ '6' if ipv6 }}tables -t nat -A POSTROUTING -p udp -o {{ interface }} -j MASQUERADE
post-down /sbin/ip{{ '6' if ipv6 }}tables -t nat -D POSTROUTING -p udp -o {{ interface }} -j MASQUERADE

@ -28,8 +28,14 @@ gateway {{ gateway }}
mtu {{ mtu }}
{%- endif %}
{%- for hr in host_routes %}
{%- if ((hr.network.version == 4 and hr.network.prefixlen == 32) or
(hr.network.version == 6 and hr.network.prefixlen == 128)) %}
up route add -host {{ hr.network }} gw {{ hr.gw }} dev {{ interface }}
down route del -host {{ hr.network }} gw {{ hr.gw }} dev {{ interface }}
{%- else %}
up route add -net {{ hr.network }} gw {{ hr.gw }} dev {{ interface }}
down route del -net {{ hr.network }} gw {{ hr.gw }} dev {{ interface }}
{%- endif %}
{%- endfor %}
{%- else %}

@ -1430,7 +1430,7 @@ class TestServerTestCase(base.TestCase):
IP = '192.0.1.5'
MAC = '123'
DEST1 = '198.51.100.0/24'
DEST2 = '203.0.113.0/24'
DEST2 = '203.0.113.1/32'
NEXTHOP = '192.0.2.1'
netns_handle = mock_netns.return_value.__enter__.return_value
@ -1492,9 +1492,9 @@ class TestServerTestCase(base.TestCase):
' dev ' + consts.NETNS_PRIMARY_INTERFACE + '\n'
'down route del -net ' + DEST1 + ' gw ' + NEXTHOP +
' dev ' + consts.NETNS_PRIMARY_INTERFACE + '\n'
'up route add -net ' + DEST2 + ' gw ' + NEXTHOP +
'up route add -host ' + DEST2 + ' gw ' + NEXTHOP +
' dev ' + consts.NETNS_PRIMARY_INTERFACE + '\n'
'down route del -net ' + DEST2 + ' gw ' + NEXTHOP +
'down route del -host ' + DEST2 + ' gw ' + NEXTHOP +
' dev ' + consts.NETNS_PRIMARY_INTERFACE + '\n' +
'post-up /sbin/iptables -t nat -A POSTROUTING -p udp -o ' +
consts.NETNS_PRIMARY_INTERFACE + ' -j MASQUERADE' + '\n' +
@ -1661,7 +1661,7 @@ class TestServerTestCase(base.TestCase):
'mtu': 1450,
'host_routes': [{'destination': '203.0.114.0/24',
'nexthop': '203.0.113.5'},
{'destination': '203.0.115.0/24',
{'destination': '203.0.115.1/32',
'nexthop': '203.0.113.5'}]
}
@ -1727,9 +1727,9 @@ class TestServerTestCase(base.TestCase):
'dev {netns_int}\n'
'down route del -net 203.0.114.0/24 gw 203.0.113.5 '
'dev {netns_int}\n'
'up route add -net 203.0.115.0/24 gw 203.0.113.5 '
'up route add -host 203.0.115.1/32 gw 203.0.113.5 '
'dev {netns_int}\n'
'down route del -net 203.0.115.0/24 gw 203.0.113.5 '
'down route del -host 203.0.115.1/32 gw 203.0.113.5 '
'dev {netns_int}\n'
'\n'
'iface {netns_int}:0 inet static\n'
@ -1750,9 +1750,9 @@ class TestServerTestCase(base.TestCase):
'via 203.0.113.5 dev eth1 onlink table 1\n'
'post-down /sbin/ip route del 203.0.114.0/24 '
'via 203.0.113.5 dev eth1 onlink table 1\n'
'post-up /sbin/ip route add 203.0.115.0/24 '
'post-up /sbin/ip route add 203.0.115.1/32 '
'via 203.0.113.5 dev eth1 onlink table 1\n'
'post-down /sbin/ip route del 203.0.115.0/24 '
'post-down /sbin/ip route del 203.0.115.1/32 '
'via 203.0.113.5 dev eth1 onlink table 1\n'
'post-up /sbin/ip rule add from 203.0.113.2/32 table 1 '
'priority 100\n'
@ -2029,7 +2029,7 @@ class TestServerTestCase(base.TestCase):
'mtu': 1450,
'host_routes': [{'destination': '2001:db9::/32',
'nexthop': '2001:db8::5'},
{'destination': '2001:db9::/32',
{'destination': '2001:db9::1/128',
'nexthop': '2001:db8::5'}]
}
@ -2089,9 +2089,9 @@ class TestServerTestCase(base.TestCase):
'dev {netns_int}\n'
'down route del -net 2001:db9::/32 gw 2001:db8::5 '
'dev {netns_int}\n'
'up route add -net 2001:db9::/32 gw 2001:db8::5 '
'up route add -host 2001:db9::1/128 gw 2001:db8::5 '
'dev {netns_int}\n'
'down route del -net 2001:db9::/32 gw 2001:db8::5 '
'down route del -host 2001:db9::1/128 gw 2001:db8::5 '
'dev {netns_int}\n'
'\n'
'iface {netns_int}:0 inet6 static\n'
@ -2114,9 +2114,9 @@ class TestServerTestCase(base.TestCase):
'2001:db8::5 dev eth1 onlink table 1\n'
'post-down /sbin/ip -6 route del 2001:db9::/32 '
'via 2001:db8::5 dev eth1 onlink table 1\n'
'post-up /sbin/ip -6 route add 2001:db9::/32 via '
'post-up /sbin/ip -6 route add 2001:db9::1/128 via '
'2001:db8::5 dev eth1 onlink table 1\n'
'post-down /sbin/ip -6 route del 2001:db9::/32 '
'post-down /sbin/ip -6 route del 2001:db9::1/128 '
'via 2001:db8::5 dev eth1 onlink table 1\n'
'post-up /sbin/ip -6 rule add from '
'2001:0db8:0000:0000:0000:0000:0000:0002/32 table 1 '

Loading…
Cancel
Save