Search in sources :

Example 96 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo in project netvirt by opendaylight.

the class VrfEntryListener method installSubnetRouteInFib.

void installSubnetRouteInFib(final BigInteger dpnId, final long elanTag, final String rd, final long vpnId, final VrfEntry vrfEntry, WriteTransaction tx) {
    Boolean wrTxPresent = true;
    if (tx == null) {
        wrTxPresent = false;
        tx = dataBroker.newWriteOnlyTransaction();
    }
    FibUtil.getLabelFromRoutePaths(vrfEntry).ifPresent(label -> {
        List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
        synchronized (label.toString().intern()) {
            LabelRouteInfo lri = getLabelRouteInfo(label);
            if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
                if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
                    Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional = fibUtil.getVpnInstanceOpData(rd);
                    if (vpnInstanceOpDataEntryOptional.isPresent()) {
                        String vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
                        if (!lri.getVpnInstanceList().contains(vpnInstanceName)) {
                            updateVpnReferencesInLri(lri, vpnInstanceName, false);
                        }
                    }
                }
                LOG.debug("SUBNETROUTE: installSubnetRouteInFib: Fetched labelRouteInfo for label {} interface {}" + " and got dpn {}", label, lri.getVpnInterfaceName(), lri.getDpnId());
            }
        }
    });
    final List<InstructionInfo> instructions = new ArrayList<>();
    BigInteger subnetRouteMeta = BigInteger.valueOf(elanTag).shiftLeft(24).or(BigInteger.valueOf(vpnId).shiftLeft(1));
    instructions.add(new InstructionWriteMetadata(subnetRouteMeta, MetaDataUtil.METADATA_MASK_SUBNET_ROUTE));
    instructions.add(new InstructionGotoTable(NwConstants.L3_SUBNET_ROUTE_TABLE));
    baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, null);
    if (vrfEntry.getRoutePaths() != null) {
        for (RoutePaths routePath : vrfEntry.getRoutePaths()) {
            if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
                List<ActionInfo> actionsInfos = new ArrayList<>();
                // reinitialize instructions list for LFIB Table
                final List<InstructionInfo> LFIBinstructions = new ArrayList<>();
                actionsInfos.add(new ActionPopMpls());
                LFIBinstructions.add(new InstructionApplyActions(actionsInfos));
                LFIBinstructions.add(new InstructionWriteMetadata(subnetRouteMeta, MetaDataUtil.METADATA_MASK_SUBNET_ROUTE));
                LFIBinstructions.add(new InstructionGotoTable(NwConstants.L3_SUBNET_ROUTE_TABLE));
                makeLFibTableEntry(dpnId, routePath.getLabel(), LFIBinstructions, DEFAULT_FIB_FLOW_PRIORITY, NwConstants.ADD_FLOW, tx);
            }
        }
    }
    if (!wrTxPresent) {
        tx.submit();
    }
}
Also used : LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) BigInteger(java.math.BigInteger) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 97 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo in project netvirt by opendaylight.

the class BaseVrfEntryHandler method programRemoteFib.

public void programRemoteFib(final BigInteger remoteDpnId, final long vpnId, final VrfEntry vrfEntry, WriteTransaction tx, String rd, List<AdjacencyResult> adjacencyResults, List<SubTransaction> subTxns) {
    List<InstructionInfo> instructions = new ArrayList<>();
    for (AdjacencyResult adjacencyResult : adjacencyResults) {
        List<ActionInfo> actionInfos = new ArrayList<>();
        String egressInterface = adjacencyResult.getInterfaceName();
        if (FibUtil.isTunnelInterface(adjacencyResult)) {
            addTunnelInterfaceActions(adjacencyResult, vpnId, vrfEntry, actionInfos, rd);
        } else {
            addRewriteDstMacAction(vpnId, vrfEntry, null, actionInfos);
        }
        List<ActionInfo> egressActions = nextHopManager.getEgressActionsForInterface(egressInterface, actionInfos.size());
        if (egressActions.isEmpty()) {
            LOG.error("Failed to retrieve egress action for prefix {} route-paths {} interface {}. " + "Aborting remote FIB entry creation.", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), egressInterface);
            return;
        }
        actionInfos.addAll(egressActions);
        instructions.add(new InstructionApplyActions(actionInfos));
    }
    makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, subTxns);
}
Also used : AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 98 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method checkCreateLocalEvpnFlows.

private BigInteger checkCreateLocalEvpnFlows(Prefixes localNextHopInfo, String localNextHopIP, final Long vpnId, final String rd, final VrfEntry vrfEntry) {
    final BigInteger dpnId = localNextHopInfo.getDpnId();
    String jobKey = "FIB-" + vpnId.toString() + "-" + dpnId.toString() + "-" + vrfEntry.getDestPrefix();
    final long groupId = nexthopManager.createLocalNextHop(vpnId, dpnId, localNextHopInfo.getVpnInterfaceName(), localNextHopIP, vrfEntry.getDestPrefix(), vrfEntry.getGatewayMacAddress(), jobKey);
    LOG.debug("LocalNextHopGroup {} created/reused for prefix {} rd {} evi {} route-paths {}", groupId, vrfEntry.getDestPrefix(), rd, vrfEntry.getL3vni(), vrfEntry.getRoutePaths());
    final List<InstructionInfo> instructions = Collections.singletonList(new InstructionApplyActions(Collections.singletonList(new ActionGroup(groupId))));
    jobCoordinator.enqueueJob("FIB-" + vpnId.toString() + "-" + dpnId.toString() + "-" + vrfEntry.getDestPrefix(), () -> {
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, null);
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        futures.add(tx.submit());
        return futures;
    });
    return dpnId;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 99 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo in project netvirt by opendaylight.

the class Ipv6NodeListener method createTableMissEntry.

private void createTableMissEntry(BigInteger dpnId) {
    if (!ipv6ServiceEosHandler.isClusterOwner()) {
        LOG.trace("Not a cluster Owner, skip flow programming.");
        return;
    }
    List<MatchInfo> matches = new ArrayList<>();
    List<InstructionInfo> instructions = new ArrayList<>();
    List<ActionInfo> actionsInfos = new ArrayList<>();
    actionsInfos.add(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
    instructions.add(new InstructionApplyActions(actionsInfos));
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.IPV6_TABLE, "IPv6TableMissFlow", 0, "IPv6 Table Miss Flow", 0, 0, NwConstants.COOKIE_IPV6_TABLE, matches, instructions);
    mdsalUtil.installFlow(flowEntity);
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 100 with InstructionInfo

use of org.opendaylight.genius.mdsalutil.InstructionInfo in project netvirt by opendaylight.

the class AclServiceOFFlowBuilder method getGotoInstructionInfo.

/**
 * Gets the goto instruction info which specifies goto to the specified
 * table.
 *
 * @param gotoTableId the goto table id
 * @return the goto instruction info
 */
public static List<InstructionInfo> getGotoInstructionInfo(short gotoTableId) {
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionGotoTable(gotoTableId));
    return instructions;
}
Also used : InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList)

Aggregations

InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)120 ArrayList (java.util.ArrayList)113 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)74 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)74 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)63 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)52 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)41 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)34 BigInteger (java.math.BigInteger)33 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)33 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)27 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)17 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)16 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)13 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)12 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)11 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)10 NxCtAction (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction)10 MatchTunnelId (org.opendaylight.genius.mdsalutil.matches.MatchTunnelId)10 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)9