Search in sources :

Example 46 with Prefix

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.

the class BaseVrfEntryHandler method programRemoteFib.

// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
public void programRemoteFib(final Uint64 remoteDpnId, final Uint32 vpnId, final VrfEntry vrfEntry, WriteTransaction tx, String rd, List<AdjacencyResult> adjacencyResults, @Nullable List<SubTransaction> subTxns) {
    if (upgradeState.isUpgradeInProgress()) {
        InstanceIdentifier<Interface> absentInterfaceStateIid = getFirstAbsentInterfaceStateIid(adjacencyResults);
        if (absentInterfaceStateIid != null) {
            LOG.info("programRemoteFib: interface state for {} not yet present, waiting...", absentInterfaceStateIid);
            eventCallbacks.onAddOrUpdate(LogicalDatastoreType.OPERATIONAL, absentInterfaceStateIid, (before, after) -> {
                LOG.info("programRemoteFib: waited for and got interface state {}", absentInterfaceStateIid);
                LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, (wtx) -> programRemoteFib(remoteDpnId, vpnId, vrfEntry, TransactionAdapter.toWriteTransaction(wtx), rd, adjacencyResults, null)), LOG, "Failed to program remote FIB {}", absentInterfaceStateIid);
                return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
            }, Duration.of(15, ChronoUnit.MINUTES), (iid) -> {
                LOG.error("programRemoteFib: timed out waiting for {}", absentInterfaceStateIid);
                LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, (wtx) -> programRemoteFib(remoteDpnId, vpnId, vrfEntry, TransactionAdapter.toWriteTransaction(wtx), rd, adjacencyResults, null)), LOG, "Failed to program timed-out remote FIB {}", absentInterfaceStateIid);
            });
            return;
        }
    }
    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(), true, vpnId, vrfEntry.getDestPrefix());
        if (egressActions.isEmpty()) {
            LOG.error("Failed to retrieve egress action for prefix {} route-paths {} interface {}. " + "Aborting remote FIB entry creation.", vrfEntry.getDestPrefix(), new ArrayList<RoutePaths>(vrfEntry.nonnullRoutePaths().values()), egressInterface);
            return;
        }
        actionInfos.addAll(egressActions);
        instructions.add(new InstructionApplyActions(actionInfos));
    }
    makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, subTxns);
}
Also used : SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) VpnToExtraroutes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnToExtraroutes) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) SubTransactionImpl(org.opendaylight.genius.utils.batching.SubTransactionImpl) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) InetAddress(java.net.InetAddress) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetSourceIp(org.opendaylight.genius.mdsalutil.actions.ActionSetSourceIp) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Vpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.Vpn) Nullable(org.eclipse.jdt.annotation.Nullable) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) Duration(java.time.Duration) Datastore(org.opendaylight.mdsal.binding.util.Datastore) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) UpgradeState(org.opendaylight.serviceutils.upgrade.UpgradeState) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) VpnKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.VpnKey) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) ActionNxLoadInPort(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) List(java.util.List) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) MatchIpv6Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv6Destination) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) TunnelTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) ActionMoveSourceDestinationIp(org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationIp) Optional(java.util.Optional) NWUtil.isIpv4Address(org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address) NonNull(org.eclipse.jdt.annotation.NonNull) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) ActionSetIcmpType(org.opendaylight.genius.mdsalutil.actions.ActionSetIcmpType) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ExtraRoutesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.ExtraRoutesKey) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) TransactionAdapter(org.opendaylight.mdsal.binding.util.TransactionAdapter) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnNexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop) ExtraRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.ExtraRoutes) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) RoutesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.RoutesKey) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) MatchIpProtocol(org.opendaylight.genius.mdsalutil.matches.MatchIpProtocol) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Inet4Address(java.net.Inet4Address) UnknownHostException(java.net.UnknownHostException) ActionMoveSourceDestinationEth(org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationEth) ExecutionException(java.util.concurrent.ExecutionException) Collectors.toList(java.util.stream.Collectors.toList) ChronoUnit(java.time.temporal.ChronoUnit) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) Collections(java.util.Collections) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 47 with Prefix

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.

the class BaseVrfEntryHandler method addTunnelInterfaceActions.

protected void addTunnelInterfaceActions(AdjacencyResult adjacencyResult, Uint32 vpnId, VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
    Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(nextHopManager.getItmManager(), adjacencyResult.getInterfaceName());
    if (tunnelType == null) {
        LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
        return;
    }
    // TODO - For now have added routePath into adjacencyResult so that we know for which
    // routePath this result is built for. If this is not possible construct a map which does
    // the same.
    String nextHopIp = adjacencyResult.getNextHopIp();
    java.util.Optional<Uint32> optionalLabel = FibUtil.getLabelForNextHop(vrfEntry, nextHopIp);
    if (!optionalLabel.isPresent()) {
        LOG.warn("NextHopIp {} not found in vrfEntry {}", nextHopIp, vrfEntry);
        return;
    }
    Uint32 label = optionalLabel.get();
    Uint64 tunnelId = null;
    Prefixes prefixInfo = null;
    // revisit
    if (tunnelType.equals(TunnelTypeVxlan.class)) {
        if (FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
            prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
            // For extra route, the prefixInfo is fetched from the primary adjacency
            if (prefixInfo == null) {
                prefixInfo = fibUtil.getPrefixToInterface(vpnId, adjacencyResult.getPrefix());
            }
        } else {
            // Imported Route. Get Prefix Info from parent RD
            VpnInstanceOpDataEntry parentVpn = fibUtil.getVpnInstance(vrfEntry.getParentVpnRd());
            prefixInfo = fibUtil.getPrefixToInterface(parentVpn.getVpnId(), adjacencyResult.getPrefix());
        }
        // Internet VPN VNI will be used as tun_id for NAT use-cases
        if (Prefixes.PrefixCue.Nat.equals(prefixInfo.getPrefixCue())) {
            if (vrfEntry.getL3vni() != null && vrfEntry.getL3vni().toJava() != 0) {
                tunnelId = Uint64.valueOf(vrfEntry.getL3vni().longValue());
            }
        } else {
            if (FibUtil.isVxlanNetwork(prefixInfo.getNetworkType())) {
                tunnelId = Uint64.valueOf(prefixInfo.getSegmentationId().longValue());
            } else {
                LOG.warn("Network is not of type VXLAN for prefix {}." + "Going with default Lport Tag.", prefixInfo.toString());
                tunnelId = Uint64.valueOf(label.longValue());
            }
        }
    } else {
        tunnelId = Uint64.valueOf(label.longValue());
    }
    LOG.debug("adding set tunnel id action for label {}", label);
    actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
    addRewriteDstMacAction(vpnId, vrfEntry, prefixInfo, actionInfos);
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 48 with Prefix

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.

the class BaseVrfEntryHandler method addRewriteDstMacAction.

protected void addRewriteDstMacAction(Uint32 vpnId, VrfEntry vrfEntry, @Nullable Prefixes prefixInfo, List<ActionInfo> actionInfos) {
    if (vrfEntry.getMac() != null) {
        actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(), new MacAddress(vrfEntry.getMac())));
        return;
    }
    if (prefixInfo == null) {
        prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
        // Checking PrefixtoInterface again as it is populated later in some cases
        if (prefixInfo == null) {
            LOG.debug("No prefix info found for prefix {}", vrfEntry.getDestPrefix());
            return;
        }
    }
    if (prefixInfo.getPrefixCue() == Prefixes.PrefixCue.Nat) {
        /* natprefix prefix-to-interface will not hold vpninterface at all. Also such natprefixes
             * tend to use remote-flows without destMac filled. Hence just return here.
             */
        return;
    }
    String ipPrefix = prefixInfo.getIpAddress();
    String ifName = prefixInfo.getVpnInterfaceName();
    if (ifName == null) {
        LOG.debug("Failed to get VPN interface for prefix {}", ipPrefix);
        return;
    }
    String vpnName = fibUtil.getVpnNameFromId(vpnId);
    if (vpnName == null) {
        LOG.debug("Failed to get VPN name for vpnId {}", vpnId);
        return;
    }
    String macAddress = null;
    if (vrfEntry.getParentVpnRd() != null) {
        // Handling iRT/eRT use-case for missing destination mac address in Remote FIB flow
        Optional<VpnInstanceOpDataEntry> vpnInstance = fibUtil.getVpnInstanceOpData(vrfEntry.getParentVpnRd());
        if (vpnInstance.isPresent()) {
            macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnInstance.get().getVpnInstanceName(), ipPrefix);
        } else {
            LOG.warn("VpnInstance missing for Parent Rd {} value for prefix {}", vrfEntry.getParentVpnRd(), vrfEntry.getDestPrefix());
        }
    } else {
        macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, ipPrefix);
    }
    if (macAddress == null) {
        LOG.warn("No MAC address found for VPN interface {} prefix {}", ifName, ipPrefix);
        return;
    }
    actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(), new MacAddress(macAddress)));
}
Also used : ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 49 with Prefix

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.

the class BaseVrfEntryHandler method resolveAdjacency.

@NonNull
protected List<AdjacencyResult> resolveAdjacency(final Uint64 remoteDpnId, final Uint32 vpnId, final VrfEntry vrfEntry, String rd) {
    List<RoutePaths> routePaths = new ArrayList<RoutePaths>(vrfEntry.nonnullRoutePaths().values());
    FibHelper.sortIpAddress(routePaths);
    List<AdjacencyResult> adjacencyList = new ArrayList<>();
    List<String> prefixIpList;
    LOG.trace("resolveAdjacency called with remotedDpnId {}, vpnId{}, VrfEntry {}", remoteDpnId, vpnId, vrfEntry);
    final Class<? extends TunnelTypeBase> tunnelType;
    try {
        if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
            tunnelType = TunnelTypeVxlan.class;
            List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
            List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker, fibUtil.getVpnNameFromId(vpnId), usedRds, vrfEntry.getDestPrefix());
            if (vpnExtraRoutes.isEmpty()) {
                Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
                /* We don't want to provide an adjacencyList for
                     * (1) an extra-route-prefix or,
                     * (2) for a local route without prefix-to-interface.
                     * Allow only self-imported routes in such cases */
                if (prefixInfo == null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
                    LOG.debug("The prefix {} in rd {} for vpn {} does not have a valid extra-route or" + " prefix-to-interface entry in the data-store", vrfEntry.getDestPrefix(), rd, vpnId);
                    return adjacencyList;
                }
                prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
            } else {
                List<String> prefixIpListLocal = new ArrayList<>();
                vpnExtraRoutes.stream().filter(route -> route.getNexthopIpList() != null).forEach(route -> route.getNexthopIpList().forEach(extraRouteIp -> {
                    String ipPrefix;
                    if (isIpv4Address(extraRouteIp)) {
                        ipPrefix = extraRouteIp + NwConstants.IPV4PREFIX;
                    } else {
                        ipPrefix = extraRouteIp + NwConstants.IPV6PREFIX;
                    }
                    prefixIpListLocal.add(ipPrefix);
                }));
                prefixIpList = prefixIpListLocal;
            }
        } else {
            prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
            if (vrfEntry.getEncapType() == VrfEntry.EncapType.Mplsgre) {
                tunnelType = TunnelTypeMplsOverGre.class;
            } else {
                tunnelType = TunnelTypeVxlan.class;
            }
        }
        for (String prefixIp : prefixIpList) {
            if (routePaths == null || routePaths.isEmpty()) {
                LOG.trace("Processing Destination IP {} without NextHop IP", prefixIp);
                AdjacencyResult adjacencyResult = nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId, prefixIp, null, tunnelType);
                addAdjacencyResultToList(adjacencyList, adjacencyResult);
                continue;
            }
            adjacencyList.addAll(routePaths.stream().map(routePath -> {
                LOG.debug("NextHop IP for destination {} is {}", prefixIp, routePath.getNexthopAddress());
                return nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId, prefixIp, routePath.getNexthopAddress(), tunnelType);
            }).filter(adjacencyResult -> adjacencyResult != null && !adjacencyList.contains(adjacencyResult)).distinct().collect(toList()));
        }
    } catch (NullPointerException e) {
        // FIXME: NPEs should not be caught but rather their root cause should be eliminated
        LOG.trace("Failed to remove adjacency", e);
    }
    return adjacencyList;
}
Also used : SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) VpnToExtraroutes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnToExtraroutes) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) SubTransactionImpl(org.opendaylight.genius.utils.batching.SubTransactionImpl) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) InetAddress(java.net.InetAddress) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetSourceIp(org.opendaylight.genius.mdsalutil.actions.ActionSetSourceIp) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Vpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.Vpn) Nullable(org.eclipse.jdt.annotation.Nullable) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) Duration(java.time.Duration) Datastore(org.opendaylight.mdsal.binding.util.Datastore) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) UpgradeState(org.opendaylight.serviceutils.upgrade.UpgradeState) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) VpnKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.VpnKey) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) ActionNxLoadInPort(org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) List(java.util.List) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) MatchIpv6Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv6Destination) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) TunnelTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) ActionMoveSourceDestinationIp(org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationIp) Optional(java.util.Optional) NWUtil.isIpv4Address(org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address) NonNull(org.eclipse.jdt.annotation.NonNull) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) ActionSetIcmpType(org.opendaylight.genius.mdsalutil.actions.ActionSetIcmpType) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ExtraRoutesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.ExtraRoutesKey) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) TransactionAdapter(org.opendaylight.mdsal.binding.util.TransactionAdapter) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnNexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop) ExtraRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.ExtraRoutes) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) RoutesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.RoutesKey) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) MatchIpProtocol(org.opendaylight.genius.mdsalutil.matches.MatchIpProtocol) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Inet4Address(java.net.Inet4Address) UnknownHostException(java.net.UnknownHostException) ActionMoveSourceDestinationEth(org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationEth) ExecutionException(java.util.concurrent.ExecutionException) Collectors.toList(java.util.stream.Collectors.toList) ChronoUnit(java.time.temporal.ChronoUnit) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) Collections(java.util.Collections) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ArrayList(java.util.ArrayList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) ExtraRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.ExtraRoutes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 50 with Prefix

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method createLocalEvpnFlows.

private List<Uint64> createLocalEvpnFlows(Uint32 vpnId, String rd, VrfEntry vrfEntry, Prefixes localNextHopInfo) {
    List<Uint64> returnLocalDpnId = new ArrayList<>();
    String localNextHopIP = vrfEntry.getDestPrefix();
    if (localNextHopInfo == null) {
        // Handle extra routes and imported routes
        Routes extraRoute = getVpnToExtraroute(vpnId, rd, vrfEntry.getDestPrefix());
        if (extraRoute != null && extraRoute.getNexthopIpList() != null) {
            for (String nextHopIp : extraRoute.getNexthopIpList()) {
                LOG.info("NextHop IP for destination {} is {}", vrfEntry.getDestPrefix(), nextHopIp);
                if (nextHopIp != null) {
                    localNextHopInfo = getFibUtil().getPrefixToInterface(vpnId, nextHopIp + "/32");
                    if (localNextHopInfo != null) {
                        localNextHopIP = nextHopIp + "/32";
                        Uint64 dpnId = checkCreateLocalEvpnFlows(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry);
                        returnLocalDpnId.add(dpnId);
                    }
                }
            }
        }
    } else {
        LOG.info("Creating local EVPN flows for prefix {} rd {} route-paths {} evi {}.", vrfEntry.getDestPrefix(), rd, vrfEntry.getRoutePaths(), vrfEntry.getL3vni());
        Uint64 dpnId = checkCreateLocalEvpnFlows(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry);
        returnLocalDpnId.add(dpnId);
    }
    return returnLocalDpnId;
}
Also used : ArrayList(java.util.ArrayList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

ArrayList (java.util.ArrayList)109 ExecutionException (java.util.concurrent.ExecutionException)73 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)67 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)63 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)52 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)52 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)49 Test (org.junit.Test)48 List (java.util.List)46 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)42 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)42 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)39 Logger (org.slf4j.Logger)38 LoggerFactory (org.slf4j.LoggerFactory)38 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)37 BigInteger (java.math.BigInteger)36 Collections (java.util.Collections)36 Inject (javax.inject.Inject)36 Singleton (javax.inject.Singleton)36 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)36