Fix for remoteNextHop 09/20409/1
authorVishal Thapar <vishal.thapar@ericsson.com>
Thu, 14 May 2015 16:48:38 +0000 (22:18 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Thu, 14 May 2015 16:48:38 +0000 (22:18 +0530)
1. Tunnel interfaces need goto:LFIB, not FIB table.
2. Changed asyncwrite to syncwrite in vpninterfacemanager
3. Added Copyright.

Change-Id: Ie0295bbe3e084416d330e5bce7af06adac9cf132
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnConstants.java
vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnInterfaceManager.java
vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnUtil.java

index beb17f352462c4593afe57f129f832cfd8fef23b..3fc28972e9fcb9a332ac54b323bfbc8bbb4dd1c1 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2015 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.vpnservice;
 
 public class VpnConstants {
@@ -5,6 +13,7 @@ public class VpnConstants {
     public static final long VPN_IDPOOL_START = 1L;
     public static final String VPN_IDPOOL_SIZE = "65535";
     public static final short LPORT_INGRESS_TABLE = 0;
+    public static final short LFIB_TABLE = 20;
     public static final short FIB_TABLE = 21;
     public static final short DEFAULT_FLOW_PRIORITY = 10;
     public static final long INVALID_ID = -1;
index fa81708e6e4208cb57d966e446febf58445a1bbd..d3fdb24ba7dfd1bf8867411b1302fddbdea240d7 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.vpnservice;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.L3tunnel;
+
 import java.math.BigInteger;
 import java.util.Collection;
 import java.util.Collections;
@@ -17,12 +19,10 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.FutureCallback;
-
 import org.opendaylight.bgpmanager.api.IBgpManager;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
@@ -195,7 +195,7 @@ public class VpnInterfaceManager extends AbstractDataChangeListener<VpnInterface
             Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(value);
             VpnInterface opInterface = VpnUtil.getVpnInterface(intfName, intf.getVpnInstanceName(), aug);
             InstanceIdentifier<VpnInterface> interfaceId = VpnUtil.getVpnInterfaceIdentifier(intfName);
-            asyncWrite(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface, DEFAULT_CALLBACK);
+            syncWrite(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface, DEFAULT_CALLBACK);
             for (Adjacency nextHop : nextHops) {
                 String key = nextHop.getIpAddress();
                 long label = getUniqueId(key);
@@ -307,6 +307,9 @@ public class VpnInterfaceManager extends AbstractDataChangeListener<VpnInterface
 
         int priority = VpnConstants.DEFAULT_FLOW_PRIORITY;
         short gotoTableId = VpnConstants.FIB_TABLE;
+        if(intf.getType().equals(L3tunnel.class)){
+            gotoTableId = VpnConstants.LFIB_TABLE;
+        }
 
         List<InstructionInfo> mkInstructions = new ArrayList<InstructionInfo>();
         mkInstructions.add(new InstructionInfo(InstructionType.write_metadata, new BigInteger[] {
@@ -455,6 +458,13 @@ public class VpnInterfaceManager extends AbstractDataChangeListener<VpnInterface
         Futures.addCallback(tx.submit(), callback);
     }
 
+    private <T extends DataObject> void syncWrite(LogicalDatastoreType datastoreType,
+                        InstanceIdentifier<T> path, T data, FutureCallback<Void> callback) {
+        WriteTransaction tx = broker.newWriteOnlyTransaction();
+        tx.put(datastoreType, path, data, true);
+        tx.submit();
+    }
+
     synchronized Collection<Long> getDpnsForVpn(long vpnId) {
         Collection<Long> dpnIds = vpnToDpnsDb.get(vpnId);
         if(dpnIds != null) {
index fc70f055b085d4de055b2611ee1deaccdb694adc..fe87901381c713c28b7c7fe990ad2ec7330ac7fe 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2015 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.vpnservice;
 
 import java.util.List;