Changes to NextHopManager 64/20264/1
authorAbhinav Gupta <abhi3123@gmail.com>
Wed, 13 May 2015 14:27:10 +0000 (19:57 +0530)
committerAbhinav Gupta <abhi3123@gmail.com>
Wed, 13 May 2015 14:29:09 +0000 (19:59 +0530)
1. Added removelocalnexthop/removeremotenexthop code
2. Added rpc for removelocalnexthop
3. Pop MPLS action added in createlocalnexthop

Change-Id: I02bed960c01d25c96a4a19c2ae6cbb01201451c7
Signed-off-by: Abhinav Gupta <abhi3123@gmail.com>
nexthopmgr/nexthopmgr-api/src/main/yang/l3nexthop.yang
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/VpnInterfaceChangeListener.java

index 8fdc6902279402ae725752327d9aa4ff166a10f5..3090e70211b1447c2c58349cb7bc68f87fc2c11b 100644 (file)
@@ -43,4 +43,14 @@ module l3nexthop {
                        leaf localDestination {type boolean;}
                }
        }
+
+       rpc removeLocalNextHop {
+               description "remove a local next hop";
+               input {
+                       leaf dpnId {type uint32;}
+                       leaf vpnId { type uint32;}  /* optional */
+                       leaf ipPrefix {type string;}
+                       leaf nexthopIp {type string;}
+               }
+       }
 }
\ No newline at end of file
index ab5b2772b4be21531ae5fe18df8d525712806c46..a8f411c7ddb301a471b71d0bb1da7476daaa921d 100644 (file)
@@ -166,6 +166,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
             // MAC re-write
             if (macAddress != null) {
                listActionInfo.add(0, new ActionInfo(ActionType.set_field_eth_dest, new String[]{macAddress}));
+               listActionInfo.add(new ActionInfo(ActionType.pop_mpls, new String[]{}));
             } else {
                 //FIXME: Log message here.
             }
@@ -336,17 +337,16 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
     }
 
  
-    public void removeLocalNextHop(String vpnName, String ipAddress) {
-
-        long vpnId = getVpnId(vpnName);
+    public void removeLocalNextHop(Long dpId, Long vpnId, String ipAddress) {
 
         VpnNexthop nh = getVpnNexthop(vpnId, ipAddress);
         if (nh != null) {
             // how to inform and remove dependent FIB entries??
             // we need to do it before the group is removed
-            
+            GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
+                    dpId, nh.getEgressPointer(), ipAddress, GroupTypes.GroupIndirect, null);
             // remove Group ...
-            
+            mdsalManager.removeGroup(groupEntity);
             //update MD-SAL DS
             removeVpnNexthopFromDS(vpnId, ipAddress);
         } else {
@@ -363,6 +363,10 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
             // we need to do it before the group is removed
 
             // remove Group ...
+            GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
+                    dpnId, nh.getEgressPointer(), ipAddress, GroupTypes.GroupIndirect, null);
+            // remove Group ...
+            mdsalManager.removeGroup(groupEntity);
             //update MD-SAL DS
             removeTunnelNexthopFromDS(dpnId, ipAddress);
         } else {
@@ -424,4 +428,20 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
         Futures.addCallback(tx.submit(), DEFAULT_CALLBACK);
     }
 
+    @Override
+    public Future<RpcResult<Void>> removeLocalNextHop(RemoveLocalNextHopInput input) {
+        VpnNexthop vpnNextHop = getVpnNexthop(input.getVpnId(), input.getIpPrefix());
+        RpcResultBuilder<Void> rpcResultBuilder;
+        LOG.debug("vpnnexthop is: {}", vpnNextHop);
+        try {
+            removeLocalNextHop(input.getDpnId(),input.getVpnId(), input.getIpPrefix());
+            rpcResultBuilder = RpcResultBuilder.success();
+        }
+        catch(Exception e){
+            LOG.error("Removal of local next hop for vpnNextHop {} failed {}" ,vpnNextHop, e);
+            rpcResultBuilder = RpcResultBuilder.failed();
+        }
+        return Futures.immediateFuture(rpcResultBuilder.build());
+    }
+
 }
index 1245a12ad9da2699894aaa6dcf375946c75342fc..08ccadcfe9b497196b758fe3e948a3c0601c92a8 100644 (file)
@@ -87,15 +87,7 @@ public class VpnInterfaceChangeListener extends AbstractDataChangeListener<Adjac
     @Override
     protected void remove(InstanceIdentifier<Adjacencies> identifier,
             Adjacencies adjs) {
-        InstanceIdentifier<VpnInterface> vpnIfId = identifier.firstIdentifierOf(VpnInterface.class);
-        Optional<VpnInterface> vpnIf = read(LogicalDatastoreType.CONFIGURATION, vpnIfId);
-        VpnInterface vpnIfData = vpnIf.get();
-
-        List<Adjacency> adjList = adjs.getAdjacency();
-        for (Adjacency adjacency : adjList) {
-            nexthopManager.removeLocalNextHop(vpnIfData.getVpnInstanceName(), adjacency.getIpAddress());
-        }
-
+        // nexthop group will be removed after fib entry deletion
     }
 
     @Override