Fix for missing DHCP flow for SR-IOV VMs 68/83368/3
authorAnkit Jain <ankit.j.jain@ericsson.com>
Wed, 26 Sep 2018 05:57:44 +0000 (11:27 +0530)
committerAmitesh Soni <amitesh.soni@ericsson.com>
Wed, 4 Sep 2019 11:26:21 +0000 (11:26 +0000)
There is a race condition between NodeListener and
InterfaceListener. It was observed that when new node
got connected, both (NodeListener and InterfaceListener)
events were not handled as tunnel state was unknown.
Hence selection of the designated didn't happen and
DHCP flow was not programmed for SR-IOV VMs.

Fix is made to handle only the InterfaceListener event,
since when node gets connected/disconnected,
we get interface event as well.

Change-Id: I65758220a8d63ad1e91ae38f8895cc10861173ec
Signed-off-by: Ankit Jain <ankit.j.jain@ericsson.com>
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpInterfaceEventListener.java
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/NodeListener.java
dhcpservice/impl/src/main/java/org/opendaylight/netvirt/dhcpservice/jobs/DhcpInterfaceUpdateJob.java

index 6ea0e94a6f386131a7a355262c6fc8e2ad54974b..1f5253d4827f5831fc4f40f71f20aa0a35de180f 100644 (file)
@@ -103,12 +103,6 @@ public class DhcpInterfaceEventListener
             LOG.trace("Interface operstatus is same orig {} updated {}", original, update);
             return;
         }
-
-        if (original.getOperStatus().equals(OperStatus.Unknown) || update.getOperStatus().equals(OperStatus.Unknown)) {
-            LOG.trace("New/old interface state is unknown not handling orig {} updated {}", original, update);
-            return;
-        }
-
         List<String> ofportIds = update.getLowerLayerIf();
         if (ofportIds == null || ofportIds.isEmpty()) {
             return;
@@ -116,8 +110,12 @@ public class DhcpInterfaceEventListener
         NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
         BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
         String interfaceName = update.getName();
+        OperStatus updatedOperStatus = update.getOperStatus();
+        if (original.getOperStatus().equals(OperStatus.Up) && updatedOperStatus.equals(OperStatus.Unknown)) {
+            updatedOperStatus = OperStatus.Down;
+        }
         DhcpInterfaceUpdateJob job = new DhcpInterfaceUpdateJob(dhcpExternalTunnelManager, dataBroker,
-                interfaceName, dpnId, update.getOperStatus(), interfaceManager);
+                interfaceName, dpnId, updatedOperStatus, interfaceManager);
         jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
     }
 
index 7b1c07321eb12a2f2965c22663f6daf03b2831de..5445a083bbce249b9e85bcef3f3cae37d5bc470b 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.netvirt.dhcpservice;
 
 import java.math.BigInteger;
-import java.util.List;
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
@@ -19,9 +18,7 @@ import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
 import org.opendaylight.genius.infra.Datastore;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
-import org.opendaylight.netvirt.dhcpservice.api.DhcpMConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
@@ -57,10 +54,6 @@ public class NodeListener extends AsyncDataTreeChangeListenerBase<Node, NodeList
 
     @Override
     protected void remove(InstanceIdentifier<Node> identifier, Node del) {
-        NodeId nodeId = del.getId();
-        BigInteger dpnId = MDSALUtil.getDpnIdFromNodeName(nodeId);
-        List<BigInteger> listOfDpns = DhcpServiceUtils.getListOfDpns(broker);
-        dhcpExternalTunnelManager.handleDesignatedDpnDown(dpnId, listOfDpns);
     }
 
     @Override
@@ -80,8 +73,6 @@ public class NodeListener extends AsyncDataTreeChangeListenerBase<Node, NodeList
         ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION,
             tx -> dhcpManager.setupDefaultDhcpFlows(tx, dpId)), LOG, "Error handling node addition for {}", add);
         dhcpExternalTunnelManager.installDhcpDropActionOnDpn(dpId);
-        List<BigInteger> listOfDpns = DhcpServiceUtils.getListOfDpns(broker);
-        dhcpExternalTunnelManager.handleDesignatedDpnDown(DhcpMConstants.INVALID_DPID, listOfDpns);
     }
 
     @Override
index 82957b8c99c5daa5f1a677e37e42a3a56237a171..c647c2f5344ce34cd789bc0ef1b4d7f91e441c01 100644 (file)
@@ -15,7 +15,6 @@ import java.util.concurrent.Callable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.netvirt.dhcpservice.DhcpExternalTunnelManager;
-import org.opendaylight.netvirt.dhcpservice.DhcpServiceUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus;
@@ -56,13 +55,10 @@ public class DhcpInterfaceUpdateJob implements Callable<List<ListenableFuture<Vo
             IfTunnel tunnelInterface = iface.augmentation(IfTunnel.class);
             if (tunnelInterface != null && !tunnelInterface.isInternal()) {
                 IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
-                List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
-                if (dpns.contains(dpnId)) {
-                    if (operStatus == OperStatus.Down) {
-                        return dhcpExternalTunnelManager.handleTunnelStateDown(tunnelIp, dpnId);
-                    } else if (operStatus == OperStatus.Up) {
-                        return dhcpExternalTunnelManager.handleTunnelStateUp(tunnelIp, dpnId);
-                    }
+                if (operStatus == OperStatus.Down) {
+                    return dhcpExternalTunnelManager.handleTunnelStateDown(tunnelIp, dpnId);
+                } else if (operStatus == OperStatus.Up) {
+                    return dhcpExternalTunnelManager.handleTunnelStateUp(tunnelIp, dpnId);
                 }
             }
         }