2 * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.vpnservice.interfacemgr.rpcservice;
11 import com.google.common.base.Optional;
12 import com.google.common.util.concurrent.FutureCallback;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import com.google.common.util.concurrent.SettableFuture;
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
18 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
19 import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
20 import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
21 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
22 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
23 import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
24 import org.opendaylight.vpnservice.mdsalutil.ActionType;
25 import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
26 import org.opendaylight.vpnservice.mdsalutil.InstructionType;
27 import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
28 import org.opendaylight.vpnservice.mdsalutil.MatchFieldType;
29 import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
30 import org.opendaylight.vpnservice.mdsalutil.NwConstants;
31 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.IfIndexesInterfaceMap;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterface;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._if.indexes._interface.map.IfIndexInterfaceKey;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryKey;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntry;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeMplsOverGre;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.*;
53 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
54 import org.opendaylight.yangtools.yang.common.RpcError;
55 import org.opendaylight.yangtools.yang.common.RpcResult;
56 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
57 import org.slf4j.Logger;
58 import org.slf4j.LoggerFactory;
60 import java.math.BigInteger;
61 import java.util.ArrayList;
62 import java.util.Arrays;
63 import java.util.List;
64 import java.util.concurrent.Future;
66 public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
67 private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerRpcService.class);
68 DataBroker dataBroker;
69 IMdsalApiManager mdsalMgr;
72 public InterfaceManagerRpcService(DataBroker dataBroker, IMdsalApiManager mdsalMgr) {
73 this.dataBroker = dataBroker;
74 this.mdsalMgr = mdsalMgr;
78 public Future<RpcResult<GetDpidFromInterfaceOutput>> getDpidFromInterface(GetDpidFromInterfaceInput input) {
79 String interfaceName = input.getIntfName();
80 RpcResultBuilder<GetDpidFromInterfaceOutput> rpcResultBuilder;
82 BigInteger dpId = null;
83 InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
84 Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
85 if (Tunnel.class.equals(interfaceInfo.getType())) {
86 ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
87 dpId = parentRefs.getDatapathNodeIdentifier();
89 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
90 InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
91 String lowerLayerIf = ifState.getLowerLayerIf().get(0);
92 NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
93 dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
95 GetDpidFromInterfaceOutputBuilder output = new GetDpidFromInterfaceOutputBuilder().setDpid(
97 rpcResultBuilder = RpcResultBuilder.success();
98 rpcResultBuilder.withResult(output.build());
99 } catch (Exception e) {
100 LOG.error("Retrieval of datapath id for the key {} failed due to {}", interfaceName, e);
101 rpcResultBuilder = RpcResultBuilder.failed();
103 return Futures.immediateFuture(rpcResultBuilder.build());
107 public Future<RpcResult<Void>> createTerminatingServiceActions(final CreateTerminatingServiceActionsInput input) {
108 final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
110 LOG.info("create terminatingServiceAction on DpnId = {} for tunnel-key {}", input.getDpid() , input.getTunnelKey());
111 Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(input.getInterfaceName()),dataBroker);
112 IfTunnel tunnelInfo = interfaceInfo.getAugmentation(IfTunnel.class);
113 if(tunnelInfo != null) {
114 ListenableFuture<Void> installFlowResult = (tunnelInfo.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class)) ?
115 makeLFIBFlow(input.getDpid(),input.getTunnelKey(), input.getInstruction(), NwConstants.ADD_FLOW) :
116 makeTerminatingServiceFlow(tunnelInfo, input.getDpid(), input.getTunnelKey(), input.getInstruction(), NwConstants.ADD_FLOW);
117 Futures.addCallback(installFlowResult, new FutureCallback<Void>(){
120 public void onSuccess(Void aVoid) {
121 result.set(RpcResultBuilder.<Void>success().build());
125 public void onFailure(Throwable error) {
126 String msg = String.format("Unable to install terminating service flow for %s", input.getInterfaceName());
127 LOG.error("create terminating service actions failed. {}. {}", msg, error);
128 result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
131 result.set(RpcResultBuilder.<Void>success().build());
133 String msg = String.format("Terminating Service Actions cannot be created for a non-tunnel interface %s",input.getInterfaceName());
135 result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg).build());
138 String msg = String.format("create Terminating Service Actions for %s failed",input.getInterfaceName());
139 LOG.error("create Terminating Service Actions for {} failed due to {}" ,input.getDpid(), e);
140 result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, e.getMessage()).build());
146 public Future<RpcResult<Void>> removeTerminatingServiceActions(final RemoveTerminatingServiceActionsInput input) {
147 final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
149 WriteTransaction t = dataBroker.newWriteOnlyTransaction();
150 LOG.info("remove terminatingServiceAction on DpnId = {} for tunnel-key {}", input.getDpid() , input.getTunnelKey());
152 Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(input.getInterfaceName()),dataBroker);
153 IfTunnel tunnelInfo = interfaceInfo.getAugmentation(IfTunnel.class);
154 if(tunnelInfo != null) {
155 ListenableFuture<Void> removeFlowResult = (tunnelInfo.getTunnelInterfaceType().isAssignableFrom(TunnelTypeMplsOverGre.class)) ?
156 makeLFIBFlow(input.getDpid(),input.getTunnelKey(), null, NwConstants.DEL_FLOW) :
157 makeTerminatingServiceFlow(tunnelInfo, input.getDpid(), input.getTunnelKey(), null, NwConstants.DEL_FLOW);
158 Futures.addCallback(removeFlowResult, new FutureCallback<Void>(){
161 public void onSuccess(Void aVoid) {
162 result.set(RpcResultBuilder.<Void>success().build());
166 public void onFailure(Throwable error) {
167 String msg = String.format("Unable to install terminating service flow %s", input.getInterfaceName());
168 LOG.error("create terminating service actions failed. {}. {}", msg, error);
169 result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
172 result.set(RpcResultBuilder.<Void>success().build());
174 String msg = String.format("Terminating Service Actions cannot be removed for a non-tunnel interface %s",
175 input.getInterfaceName());
177 result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg).build());
180 LOG.error("Remove Terminating Service Actions for {} failed due to {}" ,input.getDpid(), e);
181 String msg = String.format("Remove Terminating Service Actions for %d failed.", input.getDpid());
182 result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, e.getMessage()).build());
188 public Future<RpcResult<GetEndpointIpForDpnOutput>> getEndpointIpForDpn(GetEndpointIpForDpnInput input) {
189 RpcResultBuilder<GetEndpointIpForDpnOutput> rpcResultBuilder;
191 BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(input.getDpid());
192 InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
193 InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
194 BridgeEntry bridgeEntry =
195 InterfaceMetaUtils.getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier,
197 // local ip of any of the bridge interface entry will be the dpn end point ip
198 BridgeInterfaceEntry bridgeInterfaceEntry = bridgeEntry.getBridgeInterfaceEntry().get(0);
199 InterfaceKey interfaceKey = new InterfaceKey(bridgeInterfaceEntry.getInterfaceName());
200 Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
201 IfTunnel tunnel = interfaceInfo.getAugmentation(IfTunnel.class);
202 GetEndpointIpForDpnOutputBuilder endpointIpForDpnOutput = new GetEndpointIpForDpnOutputBuilder().setLocalIps(Arrays.asList(tunnel.getTunnelSource()));
203 rpcResultBuilder = RpcResultBuilder.success();
204 rpcResultBuilder.withResult(endpointIpForDpnOutput.build());
206 LOG.error("Retrieval of endpoint of for dpn {} failed due to {}" ,input.getDpid(), e);
207 rpcResultBuilder = RpcResultBuilder.failed();
209 return Futures.immediateFuture(rpcResultBuilder.build());
213 public Future<RpcResult<GetEgressInstructionsForInterfaceOutput>> getEgressInstructionsForInterface(GetEgressInstructionsForInterfaceInput input) {
214 RpcResultBuilder<GetEgressInstructionsForInterfaceOutput> rpcResultBuilder;
216 List<InstructionInfo> instructionInfo = new ArrayList<InstructionInfo>();
217 List<ActionInfo> actionInfo = IfmUtil.getEgressActionInfosForInterface(input.getIntfName(),
218 input.getTunnelKey(),
219 0, /* ActionKey starting value */
221 instructionInfo.add(new InstructionInfo(InstructionType.write_actions, actionInfo));
222 GetEgressInstructionsForInterfaceOutputBuilder output = new GetEgressInstructionsForInterfaceOutputBuilder().
223 setInstruction(buildInstructions(instructionInfo));
224 rpcResultBuilder = RpcResultBuilder.success();
225 rpcResultBuilder.withResult(output.build());
227 LOG.error("Retrieval of egress actions for the key {} failed due to {}" ,input.getIntfName(), e);
228 rpcResultBuilder = RpcResultBuilder.failed();
230 return Futures.immediateFuture(rpcResultBuilder.build());
234 public Future<RpcResult<GetInterfaceTypeOutput>> getInterfaceType(GetInterfaceTypeInput input) {
235 String interfaceName = input.getIntfName();
236 RpcResultBuilder<GetInterfaceTypeOutput> rpcResultBuilder;
238 InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
239 Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
241 GetInterfaceTypeOutputBuilder output = new GetInterfaceTypeOutputBuilder().setInterfaceType(interfaceInfo.getType());
242 rpcResultBuilder = RpcResultBuilder.success();
243 rpcResultBuilder.withResult(output.build());
244 } catch (Exception e) {
245 LOG.error("Retrieval of interface type for the key {} failed due to {}", interfaceName, e);
246 rpcResultBuilder = RpcResultBuilder.failed();
248 return Futures.immediateFuture(rpcResultBuilder.build());
252 public Future<RpcResult<GetTunnelTypeOutput>> getTunnelType(GetTunnelTypeInput input) {
253 String interfaceName = input.getIntfName();
254 RpcResultBuilder<GetTunnelTypeOutput> rpcResultBuilder;
256 InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
257 Interface interfaceInfo = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
259 if (Tunnel.class.equals(interfaceInfo.getType())) {
260 IfTunnel tnl = interfaceInfo.getAugmentation(IfTunnel.class);
261 Class <? extends TunnelTypeBase> tun_type = tnl.getTunnelInterfaceType();
262 GetTunnelTypeOutputBuilder output = new GetTunnelTypeOutputBuilder().setTunnelType(tun_type);
263 rpcResultBuilder = RpcResultBuilder.success();
264 rpcResultBuilder.withResult(output.build());
266 LOG.error("Retrieval of interface type for the key {} failed", interfaceName);
267 rpcResultBuilder = RpcResultBuilder.failed();
269 } catch (Exception e) {
270 LOG.error("Retrieval of interface type for the key {} failed due to {}", interfaceName, e);
271 rpcResultBuilder = RpcResultBuilder.failed();
273 return Futures.immediateFuture(rpcResultBuilder.build());
277 public Future<RpcResult<GetEgressActionsForInterfaceOutput>> getEgressActionsForInterface(GetEgressActionsForInterfaceInput input) {
278 RpcResultBuilder<GetEgressActionsForInterfaceOutput> rpcResultBuilder;
280 LOG.debug("Get Egress Action for interface {} with key {}", input.getIntfName(), input.getTunnelKey());
281 List<Action> actionsList = IfmUtil.getEgressActionsForInterface(input.getIntfName(),
282 input.getTunnelKey(),
284 GetEgressActionsForInterfaceOutputBuilder output = new GetEgressActionsForInterfaceOutputBuilder().
285 setAction(actionsList);
286 rpcResultBuilder = RpcResultBuilder.success();
287 rpcResultBuilder.withResult(output.build());
289 LOG.error("Retrieval of egress actions for the key {} failed due to {}" ,input.getIntfName(), e);
290 rpcResultBuilder = RpcResultBuilder.failed();
292 return Futures.immediateFuture(rpcResultBuilder.build());
297 public Future<RpcResult<GetPortFromInterfaceOutput>> getPortFromInterface(GetPortFromInterfaceInput input) {
298 RpcResultBuilder<GetPortFromInterfaceOutput> rpcResultBuilder;
299 String interfaceName = input.getIntfName();
301 BigInteger dpId = null;
303 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
304 InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
305 String lowerLayerIf = ifState.getLowerLayerIf().get(0);
306 NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
307 dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
308 portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
309 // FIXME Assuming portName and interfaceName are same
310 GetPortFromInterfaceOutputBuilder output = new GetPortFromInterfaceOutputBuilder().setDpid(dpId).
311 setPortname(interfaceName).setPortno(Long.valueOf(portNo));
312 rpcResultBuilder = RpcResultBuilder.success();
313 rpcResultBuilder.withResult(output.build());
315 LOG.error("Retrieval of lport tag for the key {} failed due to {}" ,input.getIntfName(), e);
316 rpcResultBuilder = RpcResultBuilder.failed();
318 return Futures.immediateFuture(rpcResultBuilder.build());
322 public Future<RpcResult<GetNodeconnectorIdFromInterfaceOutput>> getNodeconnectorIdFromInterface(GetNodeconnectorIdFromInterfaceInput input) {
323 String interfaceName = input.getIntfName();
324 RpcResultBuilder<GetNodeconnectorIdFromInterfaceOutput> rpcResultBuilder;
326 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
327 InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
328 String lowerLayerIf = ifState.getLowerLayerIf().get(0);
329 NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
331 GetNodeconnectorIdFromInterfaceOutputBuilder output = new GetNodeconnectorIdFromInterfaceOutputBuilder().setNodeconnectorId(nodeConnectorId);
332 rpcResultBuilder = RpcResultBuilder.success();
333 rpcResultBuilder.withResult(output.build());
334 } catch (Exception e) {
335 LOG.error("Retrieval of nodeconnector id for the key {} failed due to {}", interfaceName, e);
336 rpcResultBuilder = RpcResultBuilder.failed();
338 return Futures.immediateFuture(rpcResultBuilder.build());
342 public Future<RpcResult<GetInterfaceFromIfIndexOutput>> getInterfaceFromIfIndex(GetInterfaceFromIfIndexInput input) {
343 Integer ifIndex = input.getIfIndex();
344 RpcResultBuilder<GetInterfaceFromIfIndexOutput> rpcResultBuilder = null;
346 InstanceIdentifier<IfIndexInterface> id = InstanceIdentifier.builder(IfIndexesInterfaceMap.class).child(IfIndexInterface.class, new IfIndexInterfaceKey(ifIndex)).build();
347 Optional<IfIndexInterface> ifIndexesInterface = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
348 if(ifIndexesInterface.isPresent()) {
349 String interfaceName = ifIndexesInterface.get().getInterfaceName();
350 GetInterfaceFromIfIndexOutputBuilder output = new GetInterfaceFromIfIndexOutputBuilder().setInterfaceName(interfaceName);
351 rpcResultBuilder = RpcResultBuilder.success();
352 rpcResultBuilder.withResult(output.build());
354 } catch (Exception e) {
355 LOG.error("Retrieval of interfaceName for the key {} failed due to {}", ifIndex, e);
356 rpcResultBuilder = RpcResultBuilder.failed();
358 return Futures.immediateFuture(rpcResultBuilder.build());
361 protected static List<Instruction> buildInstructions(List<InstructionInfo> listInstructionInfo) {
362 if (listInstructionInfo != null) {
363 List<Instruction> instructions = new ArrayList<Instruction>();
364 int instructionKey = 0;
366 for (InstructionInfo instructionInfo : listInstructionInfo) {
367 instructions.add(instructionInfo.buildInstruction(instructionKey));
376 private ListenableFuture<Void> makeTerminatingServiceFlow(IfTunnel tunnelInfo, BigInteger dpnId, BigInteger tunnelKey, List<Instruction> instruction, int addOrRemove) {
377 List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
378 mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {tunnelKey}));
379 short tableId = tunnelInfo.isInternal() ? NwConstants.INTERNAL_TUNNEL_TABLE :
380 NwConstants.EXTERNAL_TUNNEL_TABLE;
381 final String flowRef = getFlowRef(dpnId,tableId, tunnelKey);
382 Flow terminatingSerFlow = MDSALUtil.buildFlowNew(tableId, flowRef,
383 5, "TST Flow Entry", 0, 0,
384 IfmConstants.TUNNEL_TABLE_COOKIE.add(tunnelKey), mkMatches, instruction);
385 if (addOrRemove == NwConstants.ADD_FLOW) {
386 return mdsalMgr.installFlow(dpnId, terminatingSerFlow);
389 return mdsalMgr.removeFlow(dpnId, terminatingSerFlow);
392 private ListenableFuture<Void> makeLFIBFlow(BigInteger dpnId, BigInteger tunnelKey, List<Instruction> instruction, int addOrRemove) {
393 List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
394 mkMatches.add(new MatchInfo(MatchFieldType.eth_type,
395 new long[]{0x8847L}));
396 mkMatches.add(new MatchInfo(MatchFieldType.mpls_label, new String[]{Long.toString(tunnelKey.longValue())}));
397 // Install the flow entry in L3_LFIB_TABLE
398 String flowRef = getFlowRef(dpnId, NwConstants.L3_LFIB_TABLE, tunnelKey);
400 Flow lfibFlow = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef,
401 IfmConstants.DEFAULT_FLOW_PRIORITY, "LFIB Entry", 0, 0,
402 IfmConstants.COOKIE_VM_LFIB_TABLE, mkMatches, instruction);
403 if (addOrRemove == NwConstants.ADD_FLOW) {
404 return mdsalMgr.installFlow(dpnId, lfibFlow);
406 return mdsalMgr.removeFlow(dpnId, lfibFlow);
409 private String getFlowRef(BigInteger dpnId, short tableId, BigInteger tunnelKey) {
410 return new StringBuffer().append(IfmConstants.TUNNEL_TABLE_FLOWID_PREFIX).append(dpnId).append(NwConstants.FLOWID_SEPARATOR)
411 .append(tableId).append(NwConstants.FLOWID_SEPARATOR).append(tunnelKey).toString();