Merge "creation of tunnel ingress flow and lfib table entries moved to interface...
[vpnservice.git] / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / rpcservice / InterfaceManagerRpcService.java
index fbf86df8b5f0201a35de1505f7a2a28962fde38f..bd2b8b93b36eed42bcb830183b6bd98282a56f29 100644 (file)
@@ -9,42 +9,42 @@
 package org.opendaylight.vpnservice.interfacemgr.rpcservice;
 
 import com.google.common.base.Optional;
+import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
 import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
-import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
-import org.opendaylight.vpnservice.mdsalutil.ActionType;
-import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
-import org.opendaylight.vpnservice.mdsalutil.InstructionType;
+import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
+import org.opendaylight.vpnservice.mdsalutil.*;
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-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;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.InterfaceChildInfo;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.IfIndexesInterfaceMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterfaceKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeMplsOverGre;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.*;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
@@ -59,8 +59,10 @@ import java.util.concurrent.Future;
 public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
     private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerRpcService.class);
     DataBroker dataBroker;
-    public InterfaceManagerRpcService(DataBroker dataBroker) {
+    IMdsalApiManager mdsalMgr;
+    public InterfaceManagerRpcService(DataBroker dataBroker, IMdsalApiManager mdsalMgr) {
         this.dataBroker = dataBroker;
+        this.mdsalMgr = mdsalMgr;
     }
 
     @Override
@@ -92,6 +94,87 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
         return Futures.immediateFuture(rpcResultBuilder.build());
     }
 
+    @Override
+    public Future<RpcResult<Void>> createTerminatingServiceActions(final CreateTerminatingServiceActionsInput input) {
+        final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
+        try{
+            LOG.info("create terminatingServiceAction on DpnId = {} for tunnel-key {}", input.getDpid() , input.getTunnelKey());
+            Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(input.getInterfaceName()),dataBroker);
+            IfTunnel tunnelInfo = interfaceInfo.getAugmentation(IfTunnel.class);
+            if(tunnelInfo != null) {
+                ListenableFuture<Void> installFlowResult = (tunnelInfo.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class)) ?
+                        makeLFIBFlow(input.getDpid(),input.getTunnelKey(), input.getInstruction(), NwConstants.ADD_FLOW) :
+                        makeTerminatingServiceFlow(tunnelInfo, input.getDpid(), input.getTunnelKey(), input.getInstruction(), NwConstants.ADD_FLOW);
+                Futures.addCallback(installFlowResult, new FutureCallback<Void>(){
+
+                    @Override
+                    public void onSuccess(Void aVoid) {
+                        result.set(RpcResultBuilder.<Void>success().build());
+                    }
+
+                    @Override
+                    public void onFailure(Throwable error) {
+                        String msg = String.format("Unable to install terminating service flow for %s", input.getInterfaceName());
+                        LOG.error("create terminating service actions failed. {}. {}", msg, error);
+                        result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
+                    }
+                });
+                result.set(RpcResultBuilder.<Void>success().build());
+            } else {
+                String msg = String.format("Terminating Service Actions cannot be created for a non-tunnel interface %s",input.getInterfaceName());
+                LOG.error(msg);
+                result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg).build());
+            }
+        }catch(Exception e){
+            String msg = String.format("create Terminating Service Actions for %s failed",input.getInterfaceName());
+            LOG.error("create Terminating Service Actions for {} failed due to {}" ,input.getDpid(), e);
+            result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, e.getMessage()).build());
+        }
+        return result;
+    }
+
+    @Override
+    public Future<RpcResult<Void>> removeTerminatingServiceActions(final RemoveTerminatingServiceActionsInput input) {
+        final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
+        try{
+            WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+            LOG.info("remove terminatingServiceAction on DpnId = {} for tunnel-key {}", input.getDpid() , input.getTunnelKey());
+
+            Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(input.getInterfaceName()),dataBroker);
+            IfTunnel tunnelInfo = interfaceInfo.getAugmentation(IfTunnel.class);
+            if(tunnelInfo != null) {
+                ListenableFuture<Void> removeFlowResult = (tunnelInfo.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class)) ?
+                        makeLFIBFlow(input.getDpid(),input.getTunnelKey(), null, NwConstants.DEL_FLOW) :
+                        makeTerminatingServiceFlow(tunnelInfo, input.getDpid(), input.getTunnelKey(), null, NwConstants.DEL_FLOW);
+                Futures.addCallback(removeFlowResult, new FutureCallback<Void>(){
+
+                    @Override
+                    public void onSuccess(Void aVoid) {
+                        result.set(RpcResultBuilder.<Void>success().build());
+                    }
+
+                    @Override
+                    public void onFailure(Throwable error) {
+                        String msg = String.format("Unable to install terminating service flow %s", input.getInterfaceName());
+                        LOG.error("create terminating service actions failed. {}. {}", msg, error);
+                        result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
+                    }
+                });
+                result.set(RpcResultBuilder.<Void>success().build());
+            } else {
+                String msg = String.format("Terminating Service Actions cannot be removed for a non-tunnel interface %s",
+                        input.getInterfaceName());
+                LOG.error(msg);
+                result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg).build());
+            }
+        }catch(Exception e){
+            LOG.error("Remove Terminating Service Actions for {} failed due to {}" ,input.getDpid(), e);
+            String msg = String.format("Remove Terminating Service Actions for %d failed.", input.getDpid());
+            result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, e.getMessage()).build());
+        }
+        return result;
+    }
+
     @Override
     public Future<RpcResult<GetEndpointIpForDpnOutput>> getEndpointIpForDpn(GetEndpointIpForDpnInput input) {
         RpcResultBuilder<GetEndpointIpForDpnOutput> rpcResultBuilder;
@@ -135,6 +218,24 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
         return Futures.immediateFuture(rpcResultBuilder.build());
     }
 
+    @Override
+    public Future<RpcResult<GetInterfaceTypeOutput>> getInterfaceType(GetInterfaceTypeInput input) {
+        String interfaceName = input.getIntfName();
+        RpcResultBuilder<GetInterfaceTypeOutput> rpcResultBuilder;
+        try {
+            InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
+            Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
+
+            GetInterfaceTypeOutputBuilder output = new GetInterfaceTypeOutputBuilder().setInterfaceType(interfaceInfo.getType());
+            rpcResultBuilder = RpcResultBuilder.success();
+            rpcResultBuilder.withResult(output.build());
+        } catch (Exception e) {
+            LOG.error("Retrieval of interface type for the key {} failed due to {}", interfaceName, e);
+            rpcResultBuilder = RpcResultBuilder.failed();
+        }
+        return Futures.immediateFuture(rpcResultBuilder.build());
+    }
+
     @Override
     public Future<RpcResult<GetEgressActionsForInterfaceOutput>> getEgressActionsForInterface(GetEgressActionsForInterfaceInput input) {
         RpcResultBuilder<GetEgressActionsForInterfaceOutput> rpcResultBuilder;
@@ -151,25 +252,6 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
         return Futures.immediateFuture(rpcResultBuilder.build());
     }
 
-    public static InstanceIdentifier<InterfaceChildEntry> getInterfaceChildEntryIdentifier(InterfaceParentEntryKey parentEntryKey, InterfaceChildEntryKey interfaceChildEntryKey) {
-        InstanceIdentifier.InstanceIdentifierBuilder<InterfaceChildEntry> interfaceChildEntryInstanceIdentifierBuilder =
-                InstanceIdentifier.builder(InterfaceChildInfo.class).child(InterfaceParentEntry.class, parentEntryKey).child(InterfaceChildEntry.class, interfaceChildEntryKey);
-        return interfaceChildEntryInstanceIdentifierBuilder.build();
-    }
-
-    public static InterfaceChildEntry getInterfaceChildEntryFromConfigDS(String interfaceName,
-                                                         DataBroker dataBroker) {
-        InterfaceParentEntryKey parentEntryKey = new InterfaceParentEntryKey(interfaceName);
-        InterfaceChildEntryKey childEntryKey = new InterfaceChildEntryKey(interfaceName);
-        InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryInstanceIdentifier = getInterfaceChildEntryIdentifier(parentEntryKey, childEntryKey);
-        Optional<InterfaceChildEntry> interfaceChildEntryOptional =
-                IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfaceChildEntryInstanceIdentifier, dataBroker);
-        if (!interfaceChildEntryOptional.isPresent()) {
-            return null;
-        }
-        return interfaceChildEntryOptional.get();
-    }
-
     @Override
     public Future<RpcResult<GetPortFromInterfaceOutput>> getPortFromInterface(GetPortFromInterfaceInput input) {
         RpcResultBuilder<GetPortFromInterfaceOutput> rpcResultBuilder;
@@ -196,28 +278,43 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
     }
 
     @Override
-    public Future<RpcResult<GetInterfaceFromPortOutput>> getInterfaceFromPort(GetInterfaceFromPortInput input) {
-        /*RpcResultBuilder<GetInterfaceFromPortOutput> rpcResultBuilder;
+    public Future<RpcResult<GetNodeconnectorIdFromInterfaceOutput>> getNodeconnectorIdFromInterface(GetNodeconnectorIdFromInterfaceInput input) {
+        String interfaceName = input.getIntfName();
+        RpcResultBuilder<GetNodeconnectorIdFromInterfaceOutput> rpcResultBuilder;
         try {
-            Interface interfaceInfo = null;
-            NodeId nodeId = IfmUtil.buildDpnNodeId(input.getDpid());
-            Node node = getNodeFromInventoryOperDS(nodeId, dataBroker);
-            ChildInterfaceNames childInterfaceNames = node.getAugmentation(ChildInterfaceNames.class);
-            for(OfInterfaceRefInfo ofInterfaceRefInfo : childInterfaceNames.getOfInterfaceRefInfo()){
-               interfaceInfo = getInterfaceFromTunnelKey(ofInterfaceRefInfo.getOfIntfName(), input.getInterfaceId(),
-                       input.getInterfaceType());
-            }
-            GetInterfaceFromPortOutputBuilder output = new GetInterfaceFromPortOutputBuilder().
-                    setInterfaceName(interfaceInfo == null ? null : interfaceInfo.getName());
+            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
+                    InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
+            String lowerLayerIf = ifState.getLowerLayerIf().get(0);
+            NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
+
+            GetNodeconnectorIdFromInterfaceOutputBuilder output = new GetNodeconnectorIdFromInterfaceOutputBuilder().setNodeconnectorId(nodeConnectorId);
             rpcResultBuilder = RpcResultBuilder.success();
             rpcResultBuilder.withResult(output.build());
-        }catch(Exception e){
-            LOG.error("Retrieval of interface for the key {} failed due to {}" ,input.getPortno(), e);
+        } catch (Exception e) {
+            LOG.error("Retrieval of nodeconnector id for the key {} failed due to {}", interfaceName, e);
+            rpcResultBuilder = RpcResultBuilder.failed();
+        }
+        return Futures.immediateFuture(rpcResultBuilder.build());
+    }
+
+    @Override
+    public Future<RpcResult<GetInterfaceFromIfIndexOutput>> getInterfaceFromIfIndex(GetInterfaceFromIfIndexInput input) {
+        Integer ifIndex = input.getIfIndex();
+        RpcResultBuilder<GetInterfaceFromIfIndexOutput> rpcResultBuilder = null;
+        try {
+            InstanceIdentifier<IfIndexInterface> id = InstanceIdentifier.builder(IfIndexesInterfaceMap.class).child(IfIndexInterface.class, new IfIndexInterfaceKey(ifIndex)).build();
+            Optional<IfIndexInterface> ifIndexesInterface = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
+            if(ifIndexesInterface.isPresent()) {
+                String interfaceName = ifIndexesInterface.get().getInterfaceName();
+                GetInterfaceFromIfIndexOutputBuilder output = new GetInterfaceFromIfIndexOutputBuilder().setInterfaceName(interfaceName);
+                rpcResultBuilder = RpcResultBuilder.success();
+                rpcResultBuilder.withResult(output.build());
+            }
+        } catch (Exception e) {
+            LOG.error("Retrieval of interfaceName for the key {} failed due to {}", ifIndex, e);
             rpcResultBuilder = RpcResultBuilder.failed();
         }
         return Futures.immediateFuture(rpcResultBuilder.build());
-        */
-        return null;
     }
 
     public List<ActionInfo> getEgressActionInfosForInterface(String interfaceName) {
@@ -271,46 +368,41 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
         return null;
     }
 
-    public static Node getNodeFromInventoryOperDS(NodeId nodeId, DataBroker dataBroker) {
-        InstanceIdentifier<Node> nodeIdentifier = InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, new NodeKey(nodeId)).build();
-
-        Optional<Node> nodeOptional = IfmUtil.read(LogicalDatastoreType.OPERATIONAL,
-                nodeIdentifier, dataBroker);
-        if (!nodeOptional.isPresent()) {
-            return null;
+    private ListenableFuture<Void> makeTerminatingServiceFlow(IfTunnel tunnelInfo, BigInteger dpnId, BigInteger tunnelKey, List<Instruction> instruction, int addOrRemove) {
+        List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
+        mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {tunnelKey}));
+        short tableId = tunnelInfo.isInternal() ? IfmConstants.INTERNAL_TUNNEL_TABLE :
+                IfmConstants.EXTERNAL_TUNNEL_TABLE;
+        final String flowRef = getFlowRef(dpnId,tableId, tunnelKey);
+        Flow terminatingSerFlow = MDSALUtil.buildFlowNew(tableId, flowRef,
+                5, "TST Flow Entry", 0, 0,
+                IfmConstants.TUNNEL_TABLE_COOKIE.add(tunnelKey), mkMatches, instruction);
+        if (addOrRemove == NwConstants.ADD_FLOW) {
+            return mdsalMgr.installFlow(dpnId, terminatingSerFlow);
         }
-        return nodeOptional.get();
-    }
 
-    public Interface getInterfaceFromTunnelKey(String interfaceName, BigInteger tunnelKey,
-                                               Class<? extends TunnelTypeBase> ifType){
+        return mdsalMgr.removeFlow(dpnId, terminatingSerFlow);
+    }
 
-        /*Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName), dataBroker);
+    private ListenableFuture<Void> makeLFIBFlow(BigInteger dpnId, BigInteger tunnelKey, List<Instruction> instruction, int addOrRemove) {
+        List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
+        mkMatches.add(new MatchInfo(MatchFieldType.eth_type,
+                new long[]{0x8847L}));
+        mkMatches.add(new MatchInfo(MatchFieldType.mpls_label, new String[]{Long.toString(tunnelKey.longValue())}));
+        // Install the flow entry in L3_LFIB_TABLE
+        String flowRef = getFlowRef(dpnId, IfmConstants.LFIB_TABLE, tunnelKey);
 
-        if(ifType.isAssignableFrom(IfL2vlan.class)){
-            IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
-            LOG.trace("L2Vlan: {}",vlanIface);
-            long vlanVid = (vlanIface == null) ? 0 : vlanIface.getVlanId();
-            if(tunnelKey.intValue() == vlanVid){
-               return interfaceInfo;
-            }
-        }else if(ifType.isAssignableFrom(TunnelTypeBase.class)){
-            IfTunnel ifTunnel = interfaceInfo.getAugmentation(IfTunnel.class);
-            TunnelResources tunnelResources = ifTunnel.getTunnelResources();
-            if(ifType.isAssignableFrom(TunnelTypeGre.class)) {
-                IfGre ifGre = tunnelResources.getAugmentation(IfGre.class);
-                if (ifGre.getGreKey() == tunnelKey) {
-                    return interfaceInfo;
-                }
-            }else if(ifType.isAssignableFrom(TunnelTypeVxlan.class)){
-                IfVxlan ifVxlan = tunnelResources.getAugmentation(IfVxlan.class);
-                if(ifVxlan.getVni() == tunnelKey){
-                    return interfaceInfo;
-                }
-            }
+        Flow lfibFlow = MDSALUtil.buildFlowNew(IfmConstants.LFIB_TABLE, flowRef,
+                IfmConstants.DEFAULT_FLOW_PRIORITY, "LFIB Entry", 0, 0,
+                IfmConstants.COOKIE_VM_LFIB_TABLE, mkMatches, instruction);
+        if (addOrRemove == NwConstants.ADD_FLOW) {
+            return mdsalMgr.installFlow(dpnId, lfibFlow);
         }
-        return null;*/
-        return null;
+        return mdsalMgr.removeFlow(dpnId, lfibFlow);
+    }
+
+    private String getFlowRef(BigInteger dpnId, short tableId, BigInteger tunnelKey) {
+        return new StringBuffer().append(IfmConstants.TUNNEL_TABLE_FLOWID_PREFIX).append(dpnId).append(NwConstants.FLOWID_SEPARATOR)
+                .append(tableId).append(NwConstants.FLOWID_SEPARATOR).append(tunnelKey).toString();
     }
 }
\ No newline at end of file