Midonet plugin: Fix source NAT
Source NAT rule was being applied on the incorrect port. It was being applied to the Neutron gateway port, not to the MidoNet tenant / provider router link port. Change-Id: Ib818c09adfb6957b7cad4523e5ce1fdffde9590b Closes-Bug: #1261665
This commit is contained in:
parent
c85a888098
commit
da71f604ba
@ -870,14 +870,16 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
if (l3_db.EXTERNAL_GW_INFO in r and
|
||||
r[l3_db.EXTERNAL_GW_INFO] is not None):
|
||||
# Gateway created
|
||||
gw_port = self._get_port(context.elevated(),
|
||||
r["gw_port_id"])
|
||||
gw_ip = gw_port['fixed_ips'][0]['ip_address']
|
||||
gw_port_neutron = self._get_port(
|
||||
context.elevated(), r["gw_port_id"])
|
||||
gw_ip = gw_port_neutron['fixed_ips'][0]['ip_address']
|
||||
|
||||
# First link routers and set up the routes
|
||||
self._set_router_gateway(r["id"],
|
||||
self._get_provider_router(),
|
||||
gw_ip)
|
||||
gw_port_midonet = self.client.get_link_port(
|
||||
self._get_provider_router(), r["id"])
|
||||
|
||||
# Get the NAT chains and add dynamic SNAT rules.
|
||||
chain_names = _nat_chain_names(r["id"])
|
||||
@ -885,7 +887,9 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self.client.add_dynamic_snat(tenant_id,
|
||||
chain_names['pre-routing'],
|
||||
chain_names['post-routing'],
|
||||
gw_ip, gw_port["id"], **props)
|
||||
gw_ip,
|
||||
gw_port_midonet.get_id(),
|
||||
**props)
|
||||
|
||||
self.client.update_router(id, **router_data)
|
||||
|
||||
|
@ -103,6 +103,12 @@ class TestMidonetL3NatTestCase(test_l3_plugin.L3NatDBIntTestCase,
|
||||
self._add_external_gateway_to_router(
|
||||
r['router']['id'],
|
||||
public_sub['subnet']['network_id'])
|
||||
|
||||
# Check that get_link_port was called - if not, Source NAT
|
||||
# will not be set up correctly on the MidoNet side
|
||||
self.assertTrue(
|
||||
self.instance.return_value.get_link_port.called)
|
||||
|
||||
self._router_interface_action('add', r['router']['id'],
|
||||
private_sub['subnet']['id'],
|
||||
None)
|
||||
|
Loading…
Reference in New Issue
Block a user