Search in sources :

Example 1 with ActionPopMpls

use of org.opendaylight.genius.mdsalutil.actions.ActionPopMpls in project netvirt by opendaylight.

the class ExternalRoutersListener method makeLFibTableEntry.

private void makeLFibTableEntry(BigInteger dpId, long serviceId, short tableId, WriteTransaction writeFlowInvTx) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.MPLS_UNICAST);
    matches.add(new MatchMplsLabel(serviceId));
    List<Instruction> instructions = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    actionsInfos.add(new ActionPopMpls());
    Instruction writeInstruction = new InstructionApplyActions(actionsInfos).buildInstruction(0);
    instructions.add(writeInstruction);
    instructions.add(new InstructionGotoTable(tableId).buildInstruction(1));
    // Install the flow entry in L3_LFIB_TABLE
    String flowRef = getFlowRef(dpId, NwConstants.L3_LFIB_TABLE, serviceId, "");
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef, 10, flowRef, 0, 0, COOKIE_VM_LFIB_TABLE, matches, instructions);
    mdsalManager.addFlowToTx(dpId, flowEntity, writeFlowInvTx);
    LOG.debug("makeLFibTableEntry : LFIB Entry for dpID {} : label : {} modified successfully", dpId, serviceId);
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 2 with ActionPopMpls

use of org.opendaylight.genius.mdsalutil.actions.ActionPopMpls in project netvirt by opendaylight.

the class VpnFloatingIpHandler method makeLFibTableEntry.

private void makeLFibTableEntry(BigInteger dpId, long serviceId, String floatingIpPortMacAddress, short tableId, WriteTransaction writeFlowInvTx) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.MPLS_UNICAST);
    matches.add(new MatchMplsLabel(serviceId));
    List<Instruction> instructions = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    actionsInfos.add(new ActionPopMpls());
    actionsInfos.add(new ActionSetFieldEthernetDestination(new MacAddress(floatingIpPortMacAddress)));
    Instruction writeInstruction = new InstructionApplyActions(actionsInfos).buildInstruction(0);
    instructions.add(writeInstruction);
    instructions.add(new InstructionGotoTable(tableId).buildInstruction(1));
    // Install the flow entry in L3_LFIB_TABLE
    String flowRef = getFlowRef(dpId, NwConstants.L3_LFIB_TABLE, serviceId, "");
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_LFIB_TABLE, flowRef, 10, flowRef, 0, 0, NwConstants.COOKIE_VM_LFIB_TABLE, matches, instructions);
    mdsalManager.addFlowToTx(dpId, flowEntity, writeFlowInvTx);
    LOG.debug("makeLFibTableEntry : LFIB Entry for dpID {} : label : {} modified successfully", dpId, serviceId);
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 3 with ActionPopMpls

use of org.opendaylight.genius.mdsalutil.actions.ActionPopMpls in project netvirt by opendaylight.

the class VpnServiceChainUtils method buildLFibVpnPseudoPortFlow.

/**
 * Builds a Flow for the LFIB table that sets the LPortTag of the
 * VpnPseudoPort and sends to LPortDispatcher table.
 * <ul>
 * <li>Matching: eth_type = MPLS, mpls_label = VPN MPLS label
 * <li>Actions: setMetadata LportTag and SI=2, pop MPLS, Go to
 *              LPortDispacherTable
 * </ul>
 *
 * @param dpId  DpnId
 * @param label MPLS label
 * @param nextHop Next Hop IP
 * @param lportTag Pseudo Logical Port tag
 * @return the FlowEntity
 */
public static FlowEntity buildLFibVpnPseudoPortFlow(BigInteger dpId, Long label, String nextHop, int lportTag) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.MPLS_UNICAST);
    matches.add(new MatchMplsLabel(label));
    List<ActionInfo> actionsInfos = Collections.singletonList(new ActionPopMpls());
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionWriteMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(lportTag, ServiceIndex.getIndex(NwConstants.SCF_SERVICE_NAME, NwConstants.SCF_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()));
    instructions.add(new InstructionApplyActions(actionsInfos));
    instructions.add(new InstructionGotoTable(NwConstants.L3_INTERFACE_TABLE));
    String flowRef = getLFibVpnPseudoPortFlowRef(lportTag, label, nextHop);
    return MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_LFIB_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_VM_LFIB_TABLE, matches, instructions);
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 4 with ActionPopMpls

use of org.opendaylight.genius.mdsalutil.actions.ActionPopMpls in project netvirt by opendaylight.

the class VrfEntryListener method checkCreateLocalFibEntry.

private BigInteger checkCreateLocalFibEntry(Prefixes localNextHopInfo, String localNextHopIP, final Long vpnId, final String rd, final VrfEntry vrfEntry, Long parentVpnId, Routes routes, List<Routes> vpnExtraRoutes) {
    String vpnName = fibUtil.getVpnNameFromId(vpnId);
    if (localNextHopInfo != null) {
        long groupId;
        long localGroupId;
        final BigInteger dpnId = localNextHopInfo.getDpnId();
        if (Prefixes.PrefixCue.Nat.equals(localNextHopInfo.getPrefixCue())) {
            LOG.debug("checkCreateLocalFibEntry: NAT Prefix {} with vpnId {} rd {}. Skip local dpn {}" + " FIB processing", vrfEntry.getDestPrefix(), vpnId, rd, dpnId);
            return dpnId;
        }
        if (Prefixes.PrefixCue.PhysNetFunc.equals(localNextHopInfo.getPrefixCue())) {
            LOG.debug("checkCreateLocalFibEntry: PNF Prefix {} with vpnId {} rd {}. Skip local dpn {}" + " FIB processing", vrfEntry.getDestPrefix(), vpnId, rd, dpnId);
            return dpnId;
        }
        String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, vrfEntry.getDestPrefix());
        String interfaceName = localNextHopInfo.getVpnInterfaceName();
        String prefix = vrfEntry.getDestPrefix();
        String gwMacAddress = vrfEntry.getGatewayMacAddress();
        // to avoid loadbalancing the discovered routes
        if (vpnExtraRoutes != null) {
            if (isIpv4Address(routes.getNexthopIpList().get(0))) {
                localNextHopIP = routes.getNexthopIpList().get(0) + NwConstants.IPV4PREFIX;
            } else {
                localNextHopIP = routes.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
            }
            if (vpnExtraRoutes.size() > 1) {
                groupId = nextHopManager.createNextHopGroups(parentVpnId, rd, dpnId, vrfEntry, routes, vpnExtraRoutes);
                localGroupId = nextHopManager.getLocalNextHopGroup(parentVpnId, localNextHopIP);
            } else if (routes.getNexthopIpList().size() > 1) {
                groupId = nextHopManager.createNextHopGroups(parentVpnId, rd, dpnId, vrfEntry, routes, vpnExtraRoutes);
                localGroupId = groupId;
            } else {
                groupId = nextHopManager.getLocalNextHopGroup(parentVpnId, localNextHopIP);
                localGroupId = groupId;
            }
        } else {
            groupId = nextHopManager.createLocalNextHop(parentVpnId, dpnId, interfaceName, localNextHopIP, prefix, gwMacAddress, jobKey);
            localGroupId = groupId;
        }
        if (groupId == FibConstants.INVALID_GROUP_ID) {
            LOG.error("Unable to create Group for local prefix {} on rd {} for vpninterface {} on Node {}", prefix, rd, interfaceName, dpnId.toString());
            return BigInteger.ZERO;
        }
        final List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(Collections.singletonList(new ActionGroup(groupId))));
        final List<InstructionInfo> lfibinstructions = Collections.singletonList(new InstructionApplyActions(Arrays.asList(new ActionPopMpls(), new ActionGroup(groupId))));
        java.util.Optional<Long> optLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
        List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
        jobCoordinator.enqueueJob(jobKey, () -> {
            WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
            baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, null);
            if (!fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(localNextHopInfo.getSubnetId(), vpnName, rd)) {
                optLabel.ifPresent(label -> {
                    if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
                        LOG.debug("Installing LFIB and tunnel table entry on dpn {} for interface {} with label " + "{}, rd {}, prefix {}, nexthop {}", dpnId, localNextHopInfo.getVpnInterfaceName(), optLabel, rd, vrfEntry.getDestPrefix(), nextHopAddressList);
                        makeLFibTableEntry(dpnId, label, lfibinstructions, DEFAULT_FIB_FLOW_PRIORITY, NwConstants.ADD_FLOW, tx);
                        // then it should be pointing to one of the local group in order to avoid looping.
                        if (vrfEntry.getRoutePaths().size() == 1) {
                            makeTunnelTableEntry(dpnId, label, groupId, tx);
                        } else {
                            makeTunnelTableEntry(dpnId, label, localGroupId, tx);
                        }
                    } else {
                        LOG.debug("Route with rd {} prefix {} label {} nexthop {} for vpn {} is an imported " + "route. LFib and Terminating table entries will not be created.", rd, vrfEntry.getDestPrefix(), optLabel, nextHopAddressList, vpnId);
                    }
                });
            }
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            futures.add(tx.submit());
            return futures;
        });
        return dpnId;
    }
    LOG.error("localNextHopInfo received is null for prefix {} on rd {} on vpn {}", vrfEntry.getDestPrefix(), rd, vpnName);
    return BigInteger.ZERO;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 5 with ActionPopMpls

use of org.opendaylight.genius.mdsalutil.actions.ActionPopMpls in project netvirt by opendaylight.

the class VrfEntryListener method installInterVpnRouteInLFib.

/*
     * For a given route, it installs a flow in LFIB that sets the lportTag of the other endpoint and sends to
     * LportDispatcher table (via table 80)
     */
private void installInterVpnRouteInLFib(final InterVpnLinkDataComposite interVpnLink, final String vpnName, final VrfEntry vrfEntry) {
    // INTERVPN routes are routes in a Vpn1 that have been leaked to Vpn2. In DC-GW, this Vpn2 route is pointing
    // to a list of DPNs where Vpn2's VpnLink was instantiated. In these DPNs LFIB must be programmed so that the
    // packet is commuted from Vpn2 to Vpn1.
    String interVpnLinkName = interVpnLink.getInterVpnLinkName();
    if (!interVpnLink.isActive()) {
        LOG.warn("InterVpnLink {} is NOT ACTIVE. InterVpnLink flows for prefix={} wont be installed in LFIB", interVpnLinkName, vrfEntry.getDestPrefix());
        return;
    }
    List<BigInteger> targetDpns = interVpnLink.getEndpointDpnsByVpnName(vpnName);
    Optional<Long> optLportTag = interVpnLink.getEndpointLportTagByVpnName(vpnName);
    if (!optLportTag.isPresent()) {
        LOG.warn("Could not retrieve lportTag for VPN {} endpoint in InterVpnLink {}", vpnName, interVpnLinkName);
        return;
    }
    Long lportTag = optLportTag.get();
    Long label = FibUtil.getLabelFromRoutePaths(vrfEntry).orElse(null);
    if (label == null) {
        LOG.error("Could not find label in vrfEntry=[prefix={} routePaths={}]. LFIB entry for InterVpnLink skipped", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths());
        return;
    }
    List<ActionInfo> actionsInfos = Collections.singletonList(new ActionPopMpls());
    List<InstructionInfo> instructions = Arrays.asList(new InstructionApplyActions(actionsInfos), new InstructionWriteMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(lportTag.intValue(), ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()), new InstructionGotoTable(NwConstants.L3_INTERFACE_TABLE));
    List<String> interVpnNextHopList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
    for (BigInteger dpId : targetDpns) {
        LOG.debug("Installing flow: VrfEntry=[prefix={} label={} nexthop={}] dpn {} for InterVpnLink {} in LFIB", vrfEntry.getDestPrefix(), label, interVpnNextHopList, dpId, interVpnLink.getInterVpnLinkName());
        makeLFibTableEntry(dpId, label, instructions, LFIB_INTERVPN_PRIORITY, NwConstants.ADD_FLOW, /*writeTx*/
        null);
    }
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) BigInteger(java.math.BigInteger) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Aggregations

ActionPopMpls (org.opendaylight.genius.mdsalutil.actions.ActionPopMpls)6 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)6 ArrayList (java.util.ArrayList)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)5 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)5 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)4 BigInteger (java.math.BigInteger)3 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)3 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)3 MatchMplsLabel (org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)2 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)1 ActionSetFieldEthernetDestination (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 LabelRouteInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo)1 RoutePaths (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths)1