Fix 6693 29/45529/7
authorRavit Peretz <ravit.peretz@hpe.com>
Tue, 13 Sep 2016 10:54:07 +0000 (13:54 +0300)
committerSam Hague <shague@redhat.com>
Mon, 3 Oct 2016 17:40:57 +0000 (17:40 +0000)
-DHCP Server responds to DHCP requests punted from its table(60) only
-DHCP server should not run at all when the controller-dhcp-enabled flag is false

Change-Id: I5e39ba4c7ee982f98ccb5499e902659147881f06
Signed-off-by: Ravit Peretz <ravit.peretz@hpe.com>
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpPktHandler.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/resources/org/opendaylight/blueprint/dhcpservice-impl.xml

index a010357ad7a40b0df4c475ed8e60d21a30ceddc2..4b57b9080b9d178d94edeb283cd1fc04320589fa 100644 (file)
@@ -55,6 +55,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.Pa
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -69,6 +70,7 @@ public class DhcpPktHandler implements PacketProcessingListener {
     private final PacketProcessingService pktService;
     private final DhcpExternalTunnelManager dhcpExternalTunnelManager;
     private final IInterfaceManager interfaceManager;
+    private final DhcpserviceConfig config;
 
     private boolean computeUdpChecksum = true;
 
@@ -77,20 +79,27 @@ public class DhcpPktHandler implements PacketProcessingListener {
                           final DhcpExternalTunnelManager dhcpExternalTunnelManager,
                           final OdlInterfaceRpcService interfaceManagerRpc,
                           final PacketProcessingService pktService,
-                          final IInterfaceManager interfaceManager) {
+                          final IInterfaceManager interfaceManager,
+                          final DhcpserviceConfig config) {
         this.interfaceManagerRpc = interfaceManagerRpc;
         this.pktService = pktService;
         this.dhcpExternalTunnelManager = dhcpExternalTunnelManager;
         this.dataBroker = broker;
         this.dhcpMgr = dhcpManager;
         this.interfaceManager = interfaceManager;
+        this.config = config;
     }
 
     //TODO: Handle this in a separate thread
     @Override
     public void onPacketReceived(PacketReceived packet) {
+        if (!config.isControllerDhcpEnabled()) {
+            return;
+        }
         Class<? extends PacketInReason> pktInReason = packet.getPacketInReason();
-        if (isPktInReasonSendtoCtrl(pktInReason)) {
+        short tableId = packet.getTableId().getValue();
+        if ( (tableId == NwConstants.DHCP_TABLE || tableId == NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL )
+                && isPktInReasonSendtoCtrl(pktInReason)) {
             byte[] inPayload = packet.getPayload();
             Ethernet ethPkt = new Ethernet();
             try {
index 33aada361bda0b367701418b1a262dba97ce5ea2..1d45b85fce1d4d0eb7cec74cc25c71d4ea1b6b6a 100644 (file)
@@ -53,6 +53,7 @@
     <argument ref="odlInterfaceRpcService" />
     <argument ref="packetProcessingService" />
     <argument ref="interfaceManager" />
+    <argument ref="dhcpServiceConfig" />
   </bean>
   <odl:notification-listener ref="dhcpPktHandler" />