From 1cddfc772b08569953f28a0679818aac75a9c30a Mon Sep 17 00:00:00 2001 From: Deepthi V V Date: Tue, 12 Jan 2016 22:00:48 +0530 Subject: [PATCH] Terminaing service table fix in fibmanager Change-Id: If4f2b2d06534b9243fd9b30ddba43e97a283596e Signed-off-by: Deepthi V V --- .../vpnservice/fibmanager/FibManager.java | 34 ++++++++++++------- .../vpnservice/fibmanager/NexthopManager.java | 4 --- .../vpnservice/mdsalutil/ActionType.java | 20 ++++++++--- .../vpnservice/mdsalutil/MetaDataUtil.java | 1 + 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/FibManager.java b/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/FibManager.java index d3d58420..1db29e16 100644 --- a/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/FibManager.java +++ b/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/FibManager.java @@ -51,7 +51,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instanc import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.overlay.rev150105.TunnelTypeVxlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetTunnelInterfaceNameOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.ItmRpcService; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.fibmanager.rev150330.FibEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.fibmanager.rev150330.fibentries.VrfTables; @@ -86,6 +85,7 @@ public class FibManager extends AbstractDataChangeListener implements private static final short L3_FIB_TABLE = 21; private static final short L3_LFIB_TABLE = 20; + public static final short INTERNAL_TUNNEL_TABLE = 23; private static final short L3_PROTOCOL_TABLE = 36; private static final short L3_INTERFACE_TABLE = 80; public static final short LPORT_DISPATCHER_TABLE = 30; @@ -94,6 +94,7 @@ public class FibManager extends AbstractDataChangeListener implements private static final int DEFAULT_FIB_FLOW_PRIORITY = 10; private static final BigInteger METADATA_MASK_CLEAR = new BigInteger("000000FFFFFFFFFF", 16); private static final BigInteger CLEAR_METADATA = BigInteger.valueOf(0); + public static final BigInteger COOKIE_TUNNEL = new BigInteger("9000000", 16); private static final FutureCallback DEFAULT_CALLBACK = @@ -266,8 +267,7 @@ public class FibManager extends AbstractDataChangeListener implements } public void createTerminatingServiceActions( BigInteger destDpId, int label, List actionsInfos) { - // FIXME -/* List mkMatches = new ArrayList(); + List mkMatches = new ArrayList(); LOG.info("create terminatingServiceAction on DpnId = {} and serviceId = {} and actions = {}", destDpId , label,actionsInfos); @@ -279,18 +279,28 @@ public class FibManager extends AbstractDataChangeListener implements List mkInstructions = new ArrayList(); mkInstructions.add(new InstructionInfo(InstructionType.write_actions, actionsInfos)); - FlowEntity terminatingServiceTableFlowEntity = MDSALUtil.buildFlowEntity(destDpId,ITMConstants.TERMINATING_SERVICE_TABLE, - getFlowRef(destDpId, ITMConstants.TERMINATING_SERVICE_TABLE,label), 5, String.format("%s:%d","TST Flow Entry ",label), - 0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(label)),mkMatches, mkInstructions); + FlowEntity terminatingServiceTableFlowEntity = MDSALUtil.buildFlowEntity(destDpId, INTERNAL_TUNNEL_TABLE, + getFlowRef(destDpId, INTERNAL_TUNNEL_TABLE,label), 5, String.format("%s:%d","TST Flow Entry ",label), + 0, 0, COOKIE_TUNNEL.add(BigInteger.valueOf(label)),mkMatches, mkInstructions); - mdsalManager.installFlow(terminatingServiceTableFlowEntity);*/ + mdsalManager.installFlow(terminatingServiceTableFlowEntity); } private void removeTunnelTableEntry(BigInteger dpId, long label) { - // FIXME - // itmManager.removeTerminatingServiceAction(dpId, (int)label); - - // LOG.debug("Terminating service Entry for dpID {} : label : {} removed successfully {}",dpId, label); + FlowEntity flowEntity; + LOG.info("remove terminatingServiceActions called with DpnId = {} and label = {}", dpId , label); + List mkMatches = new ArrayList(); + // Matching metadata + mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] { + MetaDataUtil.getTunnelIdWithValidVniBitAndVniSet((int)label), + MetaDataUtil.METADA_MASK_TUNNEL_ID })); + flowEntity = MDSALUtil.buildFlowEntity(dpId, + INTERNAL_TUNNEL_TABLE, + getFlowRef(dpId, INTERNAL_TUNNEL_TABLE, (int)label), + 5, String.format("%s:%d","TST Flow Entry ",label), 0, 0, + COOKIE_TUNNEL.add(BigInteger.valueOf(label)), mkMatches, null); + mdsalManager.removeFlow(flowEntity); + LOG.debug("Terminating service Entry for dpID {} : label : {} removed successfully {}",dpId, label); } public BigInteger deleteLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) { @@ -378,7 +388,7 @@ public class FibManager extends AbstractDataChangeListener implements } LOG.debug("adding set tunnel id action for label {}", label); actionInfos.add(new ActionInfo(ActionType.set_field_tunnel_id, new BigInteger[] { - tunnelId, MetaDataUtil.METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID })); + tunnelId})); } /* List actionInfos = resolveAdjacency(localDpnId, remoteDpnId, vpnId, vrfEntry); diff --git a/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/NexthopManager.java b/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/NexthopManager.java index b8a01d13..7866cd24 100644 --- a/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/NexthopManager.java +++ b/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/NexthopManager.java @@ -218,8 +218,6 @@ public class NexthopManager implements AutoCloseable { } protected String getTunnelInterfaceName(BigInteger srcDpId, BigInteger dstDpId) { - // FIXME: Enable during itm integration - try { Future> result = itmManager.getTunnelInterfaceName(new GetTunnelInterfaceNameInputBuilder() .setSourceDpid(srcDpId) @@ -238,8 +236,6 @@ public class NexthopManager implements AutoCloseable { } protected String getExternalTunnelInterfaceName(BigInteger srcDpId, IpAddress dstIp) { - // FIXME: Enable during itm integration - try { Future> result = itmManager.getExternalTunnelInterfaceName(new GetExternalTunnelInterfaceNameInputBuilder() .setSourceDpid(srcDpId) diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionType.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionType.java index b5f1fc80..847284f5 100644 --- a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionType.java +++ b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionType.java @@ -213,11 +213,23 @@ public enum ActionType { @Override public Action buildAction(ActionInfo actionInfo) { BigInteger [] actionValues = actionInfo.getBigActionValues(); - return new ActionBuilder().setAction( + if (actionValues.length == 2) { + return new ActionBuilder().setAction( + new SetFieldCaseBuilder().setSetField( + new SetFieldBuilder() + .setTunnel(new TunnelBuilder().setTunnelId(actionValues[0]) + .setTunnelMask(actionValues[1]).build()).build()) + .build()) + .setKey(new ActionKey(actionInfo.getActionKey())).build(); + } else { + return new ActionBuilder().setAction( new SetFieldCaseBuilder().setSetField( - new SetFieldBuilder().setTunnel(new TunnelBuilder().setTunnelId(actionValues[0]) - .setTunnelMask(actionValues[1]).build()).build()).build()) - .setKey(new ActionKey(actionInfo.getActionKey())).build(); + new SetFieldBuilder() + .setTunnel(new TunnelBuilder().setTunnelId(actionValues[0]) + .build()).build()) + .build()) + .setKey(new ActionKey(actionInfo.getActionKey())).build(); + } } diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataUtil.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataUtil.java index deb8c757..568ad4f4 100644 --- a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataUtil.java +++ b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataUtil.java @@ -17,6 +17,7 @@ public class MetaDataUtil { public static final BigInteger METADATA_MASK_LPORT_WRITE = new BigInteger("00FFFF0000000000", 16); public static final BigInteger METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID = new BigInteger("08000000FFFFFF00", 16); public static final BigInteger METADATA_MASK_LABEL_ITM = new BigInteger("40FFFFFF000000FF", 16); + public static final BigInteger METADA_MASK_TUNNEL_ID = new BigInteger("00000000FFFFFF00", 16); public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex) { return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag)); -- 2.36.6