Support for multiple route paths
[netvirt.git] / vpnservice / vpnmanager / vpnmanager-impl / src / main / java / org / opendaylight / netvirt / vpnmanager / TunnelInterfaceStateListener.java
index 5616bf297ebcb3a02e74acc2c0e5a456ebd5fe58..d0de55018b9fcd220163fc0935b26ed073ae45d1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright © 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -237,8 +237,8 @@ public class TunnelInterfaceStateListener extends AsyncDataTreeChangeListenerBas
              */
             Iterator<String> interfacelistIter = srcDpninterfacelist.iterator();
             String intfName = null;
-            List<Uuid> subnetList = new ArrayList<Uuid>();
-            Map<Long, String> vpnIdRdMap = new HashMap<Long, String>();
+            List<Uuid> subnetList = new ArrayList<>();
+            Map<Long, String> vpnIdRdMap = new HashMap<>();
 
             while (interfacelistIter.hasNext()) {
                 intfName = interfacelistIter.next();
@@ -266,7 +266,6 @@ public class TunnelInterfaceStateListener extends AsyncDataTreeChangeListenerBas
                             subnetList.add(subnetId);
                         }
                     }
-
                     //Populate the map for VpnId-to-Rd
                     long vpnId = VpnUtil.getVpnId(dataBroker, vpnInterface.getVpnInstanceName());
                     rd = VpnUtil.getVpnRd(dataBroker, vpnInterface.getVpnInstanceName());
@@ -294,14 +293,15 @@ public class TunnelInterfaceStateListener extends AsyncDataTreeChangeListenerBas
                             vpnInterface);
                         for (Adjacency adj : adjList) {
                             prefix = adj.getIpAddress();
+                            long label = adj.getLabel();
                             if ((tunnelAction == TunnelAction.TUNNEL_EP_ADD)
                                 && (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue())) {
-                                fibManager.manageRemoteRouteOnDPN(true, srcDpnId, vpnId, rd, prefix, destTepIp);
+                                fibManager.manageRemoteRouteOnDPN(true, srcDpnId, vpnId, rd, prefix, destTepIp, label);
                             }
 
                             if ((tunnelAction == TunnelAction.TUNNEL_EP_DELETE)
                                 && (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue())) {
-                                fibManager.manageRemoteRouteOnDPN(false, srcDpnId, vpnId, rd, prefix, destTepIp);
+                                fibManager.manageRemoteRouteOnDPN(false, srcDpnId, vpnId, rd, prefix, destTepIp, label);
                             }
                         }
                     }
@@ -309,9 +309,7 @@ public class TunnelInterfaceStateListener extends AsyncDataTreeChangeListenerBas
             }
 
             //Iterate over the VpnId-to-Rd map.
-            Iterator<Map.Entry<Long, String>> entries = vpnIdRdMap.entrySet().iterator();
-            while (entries.hasNext()) {
-                Map.Entry<Long, String> entry = entries.next();
+            for (Map.Entry<Long, String> entry : vpnIdRdMap.entrySet()) {
                 Long vpnId = entry.getKey();
                 rd = entry.getValue();
                 if ((tunnelAction == TunnelAction.TUNNEL_EP_ADD)