Bug 8376: Fix DHCP for external tunnels 11/57311/1
authorVictor Pickard <vpickard@redhat.com>
Thu, 4 May 2017 16:55:06 +0000 (12:55 -0400)
committerVictor Pickard <vpickard@redhat.com>
Wed, 17 May 2017 20:44:51 +0000 (16:44 -0400)
DHCP for external tunnels does not work with neutron
DHCP server.

ODL is installing rules to punt DHCP packets received
on external tunnels to controller, even when ODL
DHCP is disabled. But, since ODL DHCP is disabled,
no DHCP response is sent by ODL. And, with these
rules installed, neutron dhcp server never sees the
DHCP packet. As a result, VM will not get IP
address.

Do not start listeners that are responsible for
installing DHCP rules to punt DHCP packets to
ODL controller when ODL DHCP is disabled.

Change-Id: Ib0e243a9bca5866e50a5d1cb4c70cd4441dd01e6
Signed-off-by: Victor Pickard <vpickard@redhat.com>
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpDesignatedDpnListener.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpHwvtepListener.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpLogicalSwitchListener.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpNeutronPortListener.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpSubnetListener.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpUCastMacListener.java

index 320f27b107c376ff572c57435418c90084dd8cb3..305b84e4fe60cd792f7c64ab202021adf735532e 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListen
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp.rev160428.DesignatedSwitchesForExternalTunnels;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp.rev160428.designated.switches._for.external.tunnels.DesignatedSwitchForTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -28,16 +29,21 @@ public class DhcpDesignatedDpnListener
 
     private final DhcpExternalTunnelManager dhcpExternalTunnelManager;
     private final DataBroker broker;
+    private final DhcpserviceConfig config;
 
     public DhcpDesignatedDpnListener(final DhcpExternalTunnelManager dhcpExternalTunnelManager,
-                                     final DataBroker broker) {
+                                     final DataBroker broker,
+                                     final DhcpserviceConfig config) {
         super(DesignatedSwitchForTunnel.class, DhcpDesignatedDpnListener.class);
         this.dhcpExternalTunnelManager = dhcpExternalTunnelManager;
         this.broker = broker;
+        this.config = config;
     }
 
     public void init() {
-        registerListener(LogicalDatastoreType.CONFIGURATION, broker);
+        if (config.isControllerDhcpEnabled()) {
+            registerListener(LogicalDatastoreType.CONFIGURATION, broker);
+        }
     }
 
     @Override
index d47a1f21c17ca23393f7e1c97e6520b6710f9845..f4988db9a6f8d2d5edff4216b209803512ea1204 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
@@ -32,15 +33,21 @@ public class DhcpHwvtepListener
     private static final Logger LOG = LoggerFactory.getLogger(DhcpHwvtepListener.class);
     private DhcpExternalTunnelManager dhcpExternalTunnelManager;
     private DataBroker dataBroker;
+    private final DhcpserviceConfig config;
 
-    public DhcpHwvtepListener(DataBroker dataBroker, DhcpExternalTunnelManager dhcpManager) {
+
+    public DhcpHwvtepListener(DataBroker dataBroker, DhcpExternalTunnelManager dhcpManager,
+                              DhcpserviceConfig config) {
         super(Node.class, DhcpHwvtepListener.class);
         this.dhcpExternalTunnelManager = dhcpManager;
         this.dataBroker = dataBroker;
+        this.config = config;
     }
 
     public void init() {
-        registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+        if (config.isControllerDhcpEnabled()) {
+            registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+        }
     }
 
     @Override
@@ -100,4 +107,4 @@ public class DhcpHwvtepListener
     protected DhcpHwvtepListener getDataTreeChangeListener() {
         return DhcpHwvtepListener.this;
     }
-}
\ No newline at end of file
+}
index 31aafa00e5fedf27cd67fb358b318bc3aadf6b20..55c4a9d4db97f62d5731ef9e0f655f0fa617a809 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.utils.L2GatewayCacheUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
@@ -40,15 +41,20 @@ public class DhcpLogicalSwitchListener
 
     private final DataBroker dataBroker;
     private final DhcpExternalTunnelManager dhcpExternalTunnelManager;
+    private final DhcpserviceConfig config;
 
-    public DhcpLogicalSwitchListener(DhcpExternalTunnelManager dhcpManager, DataBroker dataBroker) {
+    public DhcpLogicalSwitchListener(DhcpExternalTunnelManager dhcpManager, DataBroker dataBroker,
+                                     DhcpserviceConfig config) {
         super(LogicalSwitches.class, DhcpLogicalSwitchListener.class);
         this.dhcpExternalTunnelManager = dhcpManager;
         this.dataBroker = dataBroker;
+        this.config = config;
     }
 
     public void init() {
-        registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+        if (config.isControllerDhcpEnabled()) {
+            registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+        }
     }
 
     @Override
@@ -160,4 +166,4 @@ public class DhcpLogicalSwitchListener
     protected DhcpLogicalSwitchListener getDataTreeChangeListener() {
         return DhcpLogicalSwitchListener.this;
     }
-}
\ No newline at end of file
+}
index d6a6e1b05e0f1e0000cd75e7caea3ce0cb7e2b43..94905a4e7cd020204fcac1a9fc4117cfd23b9e9d 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.P
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,15 +30,20 @@ public class DhcpNeutronPortListener
 
     private final DhcpExternalTunnelManager dhcpExternalTunnelManager;
     private final DataBroker broker;
+    private DhcpserviceConfig config;
 
-    public DhcpNeutronPortListener(final DataBroker db, final DhcpExternalTunnelManager dhcpExternalTunnelManager) {
+    public DhcpNeutronPortListener(final DataBroker db, final DhcpExternalTunnelManager dhcpExternalTunnelManager,
+                                   final DhcpserviceConfig config) {
         super(Port.class, DhcpNeutronPortListener.class);
         this.dhcpExternalTunnelManager = dhcpExternalTunnelManager;
         this.broker = db;
+        this.config = config;
     }
 
     public void init() {
-        registerListener(LogicalDatastoreType.CONFIGURATION, broker);
+        if (config.isControllerDhcpEnabled()) {
+            registerListener(LogicalDatastoreType.CONFIGURATION, broker);
+        }
     }
 
     @Override
@@ -139,4 +145,4 @@ public class DhcpNeutronPortListener
     protected DhcpNeutronPortListener getDataTreeChangeListener() {
         return DhcpNeutronPortListener.this;
     }
-}
\ No newline at end of file
+}
index e8b0b29c52ff343a35fa8fa76bdee81ef366a983..b2188244d2846af6403dcfc112536a38c99d7cfe 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.por
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -40,19 +41,22 @@ public class DhcpSubnetListener extends AsyncClusteredDataTreeChangeListenerBase
     private DataBroker dataBroker;
     private DhcpManager dhcpManager;
     private DhcpExternalTunnelManager dhcpExternalTunnelManager;
+    private DhcpserviceConfig config;
     private static final Logger LOG = LoggerFactory.getLogger(DhcpSubnetListener.class);
 
     public DhcpSubnetListener(final DhcpManager dhcpManager, final DhcpExternalTunnelManager
-            dhcpExternalTunnelManager, final DataBroker
-                                      broker) {
+            dhcpExternalTunnelManager, final DataBroker broker, final DhcpserviceConfig config) {
         super(Subnet.class, DhcpSubnetListener.class);
         this.dhcpManager = dhcpManager;
         this.dataBroker = broker;
         this.dhcpExternalTunnelManager = dhcpExternalTunnelManager;
+        this.config = config;
     }
 
     public void init() {
-        registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+        if (config.isControllerDhcpEnabled()) {
+            registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+        }
     }
 
     @Override
index 9e73d5d343b68ce19aec9620d670189c03eccd69..b24274ebb5edc1c1e3c40eab200b07f452d711d3 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
@@ -41,17 +42,21 @@ public class DhcpUCastMacListener
     private final DhcpExternalTunnelManager dhcpExternalTunnelManager;
     private final DhcpManager dhcpManager;
     private final DataBroker broker;
+    private final DhcpserviceConfig config;
 
-    public DhcpUCastMacListener(DhcpManager dhcpManager,DhcpExternalTunnelManager dhcpExtTunnelMgr,
-                                DataBroker dataBroker) {
+    public DhcpUCastMacListener(DhcpManager dhcpManager, DhcpExternalTunnelManager dhcpExtTunnelMgr,
+                                DataBroker dataBroker, DhcpserviceConfig config) {
         super(LocalUcastMacs.class, DhcpUCastMacListener.class);
         this.broker = dataBroker;
         this.dhcpExternalTunnelManager = dhcpExtTunnelMgr;
         this.dhcpManager = dhcpManager;
+        this.config = config;
     }
 
     public void init() {
-        registerListener(LogicalDatastoreType.OPERATIONAL, broker);
+        if (config.isControllerDhcpEnabled()) {
+            registerListener(LogicalDatastoreType.OPERATIONAL, broker);
+        }
     }
 
     @Override
@@ -158,4 +163,4 @@ public class DhcpUCastMacListener
     protected DhcpUCastMacListener getDataTreeChangeListener() {
         return DhcpUCastMacListener.this;
     }
-}
\ No newline at end of file
+}