Comment 1 for bug 1398768

Revision history for this message
Miguel Angel Ajo (mangelajo) wrote :

This is a POC patch, which must be updated to check if gateway belongs to
subnet , or if it doesn't:

diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py
index 538527b..5a9f186 100644
--- a/neutron/agent/linux/interface.py
+++ b/neutron/agent/linux/interface.py
@@ -116,15 +116,16 @@ class LinuxInterfaceDriver(object):
                                             namespace=namespace,
                                             ip=ip_cidr)

- if gateway:
- device.route.add_gateway(gateway)
-
         new_onlink_routes = set(s['cidr'] for s in extra_subnets)
+ if gateway:
+ new_onlink_routes.update([gateway])
         existing_onlink_routes = set(device.route.list_onlink_routes())
         for route in new_onlink_routes - existing_onlink_routes:
             device.route.add_onlink_route(route)
         for route in existing_onlink_routes - new_onlink_routes:
             device.route.delete_onlink_route(route)
+ if gateway:
+ device.route.add_gateway(gateway)

     def delete_conntrack_state(self, root_helper, namespace, ip):
         """Delete conntrack state associated with an IP address.