Search in sources :

Example 36 with Routes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project netvirt by opendaylight.

the class NexthopManager method createLocalNextHop.

public long createLocalNextHop(Uint32 vpnId, Uint64 dpnId, String ifName, String primaryIpAddress, String currDestIpPrefix, String gwMacAddress, Uint32 parentVpnId) {
    // For VPN Imported routes, getting VPN Instance name using parentVpnId
    String vpnName = parentVpnId != null ? fibUtil.getVpnNameFromId(parentVpnId) : fibUtil.getVpnNameFromId(vpnId);
    if (vpnName == null) {
        return 0;
    }
    String macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, primaryIpAddress);
    long groupId = createNextHopPointer(getNextHopKey(vpnId, primaryIpAddress));
    if (groupId == 0) {
        LOG.error("Unable to allocate groupId for vpnId {} , IntfName {}, primaryIpAddress {} curIpPrefix {}", vpnId, ifName, primaryIpAddress, currDestIpPrefix);
        return groupId;
    }
    String nextHopLockStr = vpnId + primaryIpAddress;
    String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, currDestIpPrefix);
    jobCoordinator.enqueueJob(jobKey, () -> {
        try {
            if (FibUtil.lockCluster(lockManager, nextHopLockStr, WAIT_TIME_TO_ACQUIRE_LOCK)) {
                VpnNexthop nexthop = getVpnNexthop(vpnId, primaryIpAddress);
                LOG.trace("nexthop: {} retrieved for vpnId {}, prefix {}, ifName {} on dpn {}", nexthop, vpnId, primaryIpAddress, ifName, dpnId);
                if (nexthop == null) {
                    String encMacAddress = macAddress == null ? fibUtil.getMacAddressFromPrefix(ifName, vpnName, primaryIpAddress) : macAddress;
                    List<ActionInfo> listActionInfo = new ArrayList<>();
                    int actionKey = 0;
                    // MAC re-write
                    if (encMacAddress != null) {
                        if (gwMacAddress != null) {
                            LOG.trace("The Local NextHop Group Source Mac {} for VpnInterface {} on VPN {}", gwMacAddress, ifName, vpnId);
                            listActionInfo.add(new ActionSetFieldEthernetSource(actionKey++, new MacAddress(gwMacAddress)));
                        }
                        listActionInfo.add(new ActionSetFieldEthernetDestination(actionKey++, new MacAddress(encMacAddress)));
                    // listActionInfo.add(0, new ActionPopMpls());
                    } else {
                        LOG.error("mac address for new local nexthop group {} is null for vpnId {}, prefix {}, " + "ifName {} on dpn {}", groupId, vpnId, primaryIpAddress, ifName, dpnId);
                    }
                    List<ActionInfo> nhActionInfoList = getEgressActionsForInterface(ifName, actionKey, false, vpnId, currDestIpPrefix);
                    if (nhActionInfoList.isEmpty()) {
                        LOG.error("createLocalNextHop: Skipping, Empty list of egress actions received for " + "interface {} on dpn {} for vpn {} prefix {}", ifName, dpnId, vpnId, currDestIpPrefix);
                    }
                    listActionInfo.addAll(nhActionInfoList);
                    BucketInfo bucket = new BucketInfo(listActionInfo);
                    List<BucketInfo> listBucketInfo = new ArrayList<>();
                    listBucketInfo.add(bucket);
                    GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, primaryIpAddress, GroupTypes.GroupAll, listBucketInfo);
                    LOG.trace("Install LNH Group: id {}, mac address {}, interface {} for prefix {}", groupId, encMacAddress, ifName, primaryIpAddress);
                    // Try to install group directly on the DPN bypassing the FRM, in order to avoid waiting for the
                    // group to get installed before programming the flows
                    installGroupOnDpn(groupId, dpnId, primaryIpAddress, listBucketInfo, getNextHopKey(vpnId, primaryIpAddress), GroupTypes.GroupAll);
                    // install Group
                    mdsalApiManager.syncInstallGroup(groupEntity);
                    // update MD-SAL DS
                    addVpnNexthopToDS(dpnId, vpnId, primaryIpAddress, currDestIpPrefix, groupId);
                } else {
                    // Ignore adding new prefix , if it already exists
                    Map<IpAdjacenciesKey, IpAdjacencies> keyIpAdjacenciesMap = nexthop.getIpAdjacencies();
                    IpAdjacencies prefix = new IpAdjacenciesBuilder().setIpAdjacency(currDestIpPrefix).build();
                    if (keyIpAdjacenciesMap != null && keyIpAdjacenciesMap.values().contains(prefix)) {
                        LOG.trace("Prefix {} is already present in l3nextHop {} ", currDestIpPrefix, nexthop);
                    } else {
                        IpAdjacenciesBuilder ipPrefixesBuilder = new IpAdjacenciesBuilder().withKey(new IpAdjacenciesKey(currDestIpPrefix));
                        LOG.trace("Updating prefix {} to vpnNextHop {} Operational DS", currDestIpPrefix, nexthop);
                        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, getVpnNextHopIpPrefixIdentifier(vpnId, primaryIpAddress, currDestIpPrefix), ipPrefixesBuilder.build());
                    }
                }
            }
        } finally {
            FibUtil.unlockCluster(lockManager, nextHopLockStr);
        }
        return Collections.emptyList();
    });
    return groupId;
}
Also used : IpAdjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.vpnnexthop.IpAdjacencies) IpAdjacenciesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.vpnnexthop.IpAdjacenciesBuilder) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) VpnNexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) IpAdjacenciesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.vpnnexthop.IpAdjacenciesKey) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo)

Example 37 with Routes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project netvirt by opendaylight.

the class NexthopManager method getBucketsForLocalNexthop.

private List<BucketInfo> getBucketsForLocalNexthop(Uint32 vpnId, Uint64 dpnId, VrfEntry vrfEntry, Routes routes) {
    @Nullable List<String> nexthopIpList = routes.getNexthopIpList();
    if (LOG.isDebugEnabled()) {
        LOG.debug("NexthopManager.getBucketsForLocalNexthop invoked with vpnId {} dpnId {} " + " vrfEntry.routePaths {}, routes.nexthopList {}", vpnId, dpnId, vrfEntry.getRoutePaths(), nexthopIpList);
    }
    List<BucketInfo> listBucketInfo = new CopyOnWriteArrayList<>();
    if (nexthopIpList != null) {
        nexthopIpList.parallelStream().forEach(nextHopIp -> {
            String localNextHopIP;
            if (isIpv4Address(nextHopIp)) {
                localNextHopIP = nextHopIp + NwConstants.IPV4PREFIX;
            } else {
                localNextHopIP = nextHopIp + NwConstants.IPV6PREFIX;
            }
            Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
            if (localNextHopInfo != null) {
                long groupId = getLocalNextHopGroup(vpnId, localNextHopIP);
                if (groupId == FibConstants.INVALID_GROUP_ID) {
                    LOG.error("Unable to allocate groupId for vpnId {} , prefix {} , interface {}", vpnId, vrfEntry.getDestPrefix(), localNextHopInfo.getVpnInterfaceName());
                    return;
                }
                List<ActionInfo> actionsInfos = Collections.singletonList(new ActionGroup(groupId));
                BucketInfo bucket = new BucketInfo(actionsInfos);
                bucket.setWeight(1);
                listBucketInfo.add(bucket);
            }
        });
    }
    LOG.trace("LOCAL: listbucket {}, vpnId {}, dpnId {}, routes {}", listBucketInfo, vpnId, dpnId, routes);
    return listBucketInfo;
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) Nullable(org.eclipse.jdt.annotation.Nullable) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 38 with Routes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project netvirt by opendaylight.

the class VrfEntryListener method deleteLocalFibEntry.

public List<Uint64> deleteLocalFibEntry(Uint32 vpnId, String rd, VrfEntry vrfEntry) {
    List<Uint64> returnLocalDpnId = new ArrayList<>();
    Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
    String vpnName = fibUtil.getVpnNameFromId(vpnId);
    boolean shouldUpdateNonEcmpLocalNextHop = true;
    if (localNextHopInfo == null) {
        List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
        if (usedRds.size() > 1) {
            LOG.error("The extra route prefix {} is still present in some DPNs in vpn {} on rd {}", vrfEntry.getDestPrefix(), vpnName, rd);
            return returnLocalDpnId;
        }
        String vpnRd = !usedRds.isEmpty() ? usedRds.get(0) : rd;
        // Is this fib route an extra route? If yes, get the nexthop which would be an adjacency
        // in the vpn
        Optional<Routes> extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, vpnRd, vrfEntry.getDestPrefix());
        if (extraRouteOptional.isPresent()) {
            Routes extraRoute = extraRouteOptional.get();
            String ipPrefix;
            if (isIpv4Address(extraRoute.getNexthopIpList().get(0))) {
                ipPrefix = extraRoute.getNexthopIpList().get(0) + NwConstants.IPV4PREFIX;
            } else {
                ipPrefix = extraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
            }
            if (extraRoute.getNexthopIpList().size() > 1) {
                shouldUpdateNonEcmpLocalNextHop = false;
            }
            localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
            if (localNextHopInfo != null) {
                String localNextHopIP = localNextHopInfo.getIpAddress();
                Uint64 dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnName, vpnId, rd, vrfEntry, shouldUpdateNonEcmpLocalNextHop);
                if (!dpnId.equals(Uint64.ZERO)) {
                    LOG.trace("Deleting ECMP group for prefix {}, dpn {}", vrfEntry.getDestPrefix(), dpnId);
                    nextHopManager.deleteLoadBalancingNextHop(vpnId, dpnId, vrfEntry.getDestPrefix());
                    returnLocalDpnId.add(dpnId);
                }
            } else {
                LOG.error("localNextHopInfo unavailable while deleting prefix {} with rds {}, primary rd {} in " + "vpn {}", vrfEntry.getDestPrefix(), usedRds, rd, vpnName);
            }
        }
        if (localNextHopInfo == null) {
            /* Imported VRF entry */
            java.util.Optional<Uint32> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
            if (optionalLabel.isPresent()) {
                Uint32 label = optionalLabel.get();
                List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
                LabelRouteInfo lri = getLabelRouteInfo(label);
                if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
                    PrefixesBuilder prefixBuilder = new PrefixesBuilder();
                    prefixBuilder.setDpnId(lri.getDpnId());
                    Uint64 dpnId = checkDeleteLocalFibEntry(prefixBuilder.build(), nextHopAddressList.get(0), vpnName, vpnId, rd, vrfEntry, shouldUpdateNonEcmpLocalNextHop);
                    if (!dpnId.equals(Uint64.ZERO)) {
                        returnLocalDpnId.add(dpnId);
                    }
                }
            }
        }
    } else {
        LOG.debug("Obtained prefix to interface for rd {} prefix {}", rd, vrfEntry.getDestPrefix());
        String localNextHopIP = localNextHopInfo.getIpAddress();
        Uint64 dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnName, vpnId, rd, vrfEntry, shouldUpdateNonEcmpLocalNextHop);
        if (!dpnId.equals(Uint64.ZERO)) {
            returnLocalDpnId.add(dpnId);
        }
    }
    return returnLocalDpnId;
}
Also used : LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 39 with Routes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project netvirt by opendaylight.

the class VrfEntryListener method deleteFibEntries.

private void deleteFibEntries(final InstanceIdentifier<VrfEntry> identifier, final VrfEntry vrfEntry) {
    final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
    final String rd = vrfTableKey.getRouteDistinguisher();
    final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(vrfTableKey.getRouteDistinguisher());
    if (vpnInstance == null) {
        LOG.error("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
        return;
    }
    final Map<VpnToDpnListKey, VpnToDpnList> keyVpnToDpnListMap;
    if (vrfEntry.getParentVpnRd() != null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
        // This block MUST BE HIT only for PNF (Physical Network Function) FIB Entries.
        VpnInstanceOpDataEntry parentVpnInstance = fibUtil.getVpnInstance(vrfEntry.getParentVpnRd());
        keyVpnToDpnListMap = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() : vpnInstance.getVpnToDpnList();
        LOG.info("deleteFibEntries: Processing deletion of PNF FIB entry with rd {} prefix {}", vrfEntry.getParentVpnRd(), vrfEntry.getDestPrefix());
    } else {
        keyVpnToDpnListMap = vpnInstance.getVpnToDpnList();
    }
    SubnetRoute subnetRoute = vrfEntry.augmentation(SubnetRoute.class);
    final java.util.Optional<Uint32> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
    String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
    if (subnetRoute != null) {
        long elanTag = subnetRoute.getElantag().toJava();
        LOG.trace("SUBNETROUTE: deleteFibEntries: SubnetRoute augmented vrfentry found for rd {} prefix {}" + " with elantag {}", rd, vrfEntry.getDestPrefix(), elanTag);
        if (keyVpnToDpnListMap != null) {
            jobCoordinator.enqueueJob(FibUtil.getJobKeyForRdPrefix(rd, vrfEntry.getDestPrefix()), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                for (final VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
                    baseVrfEntryHandler.makeConnectedRoute(curDpn.getDpnId(), vpnInstance.getVpnId(), vrfEntry, vrfTableKey.getRouteDistinguisher(), null, NwConstants.DEL_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
                    if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
                        optionalLabel.ifPresent(label -> makeLFibTableEntry(curDpn.getDpnId(), label, null, DEFAULT_FIB_FLOW_PRIORITY, NwConstants.DEL_FLOW, tx));
                    }
                    installSubnetBroadcastAddrDropRule(curDpn.getDpnId(), rd, vpnInstance.getVpnId(), vrfEntry, NwConstants.DEL_FLOW, tx);
                }
            })));
        }
        return;
    }
    final List<Uint64> localDpnIdList = deleteLocalFibEntry(vpnInstance.getVpnId(), vrfTableKey.getRouteDistinguisher(), vrfEntry);
    if (keyVpnToDpnListMap != null) {
        List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
        String jobKey;
        Optional<Routes> extraRouteOptional;
        // Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
        if (usedRds != null && !usedRds.isEmpty()) {
            if (usedRds.size() > 1) {
                LOG.error("The extra route prefix is still present in some DPNs");
                return;
            } else {
                // The first rd is retrieved from usedrds as Only 1 rd would be present as extra route prefix
                // is not present in any other DPN
                extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, usedRds.get(0), vrfEntry.getDestPrefix());
            }
        } else {
            extraRouteOptional = Optional.empty();
        }
        jobCoordinator.enqueueJob(FibUtil.getJobKeyForRdPrefix(rd, vrfEntry.getDestPrefix()), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
            if (localDpnIdList.size() <= 0) {
                for (VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
                    baseVrfEntryHandler.deleteRemoteRoute(Uint64.ZERO, curDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
                }
            } else {
                for (Uint64 localDpnId : localDpnIdList) {
                    for (VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
                        if (!Objects.equals(curDpn.getDpnId(), localDpnId)) {
                            baseVrfEntryHandler.deleteRemoteRoute(localDpnId, curDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
                        }
                    }
                }
            }
            if (extraRouteOptional.isPresent()) {
                // Remove select groups only for extra-routes
                nextHopManager.removeNextHopPointer(nextHopManager.getRemoteSelectGroupKey(vpnInstance.getVpnId(), vrfEntry.getDestPrefix()));
                nextHopManager.removeNextHopPointer(nextHopManager.getLocalSelectGroupKey(vpnInstance.getVpnId(), vrfEntry.getDestPrefix()));
            }
        })), MAX_RETRIES);
    }
    // The flow/group entry has been deleted from config DS; need to clean up associated operational
    // DS entries in VPN Op DS, VpnInstanceOpData and PrefixToInterface to complete deletion
    cleanUpOpDataForFib(vpnInstance.getVpnId(), vrfTableKey.getRouteDistinguisher(), vrfEntry);
}
Also used : SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 40 with Routes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project netvirt by opendaylight.

the class VrfEntryListener method programRemoteFibWithLoadBalancingGroups.

// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
private void programRemoteFibWithLoadBalancingGroups(final Uint64 remoteDpnId, final Uint32 vpnId, String rd, final VrfEntry vrfEntry, List<Routes> vpnExtraRoutes) {
    // create loadbalancing groups for extra routes only when the extra route is
    // present behind multiple VMs
    // Obtain the local routes for this particular dpn.
    java.util.Optional<Routes> routes = vpnExtraRoutes.stream().filter(route -> {
        Prefixes prefixToInterface = fibUtil.getPrefixToInterface(vpnId, FibUtil.getIpPrefix(route.getNexthopIpList().get(0)));
        if (prefixToInterface == null) {
            return false;
        }
        return remoteDpnId.equals(prefixToInterface.getDpnId());
    }).findFirst();
    long groupId = nextHopManager.createNextHopGroups(vpnId, rd, remoteDpnId, vrfEntry, routes.isPresent() ? routes.get() : null, vpnExtraRoutes);
    if (groupId == FibConstants.INVALID_GROUP_ID) {
        LOG.error("Unable to create Group for local prefix {} on rd {} on Node {}", vrfEntry.getDestPrefix(), rd, remoteDpnId);
        return;
    }
    List<ActionInfo> actionInfos = Collections.singletonList(new ActionGroup(groupId));
    List<InstructionInfo> instructions = Lists.newArrayList(new InstructionApplyActions(actionInfos));
    String jobKey = FibUtil.getCreateRemoteNextHopJobKey(vpnId, remoteDpnId, vrfEntry.getDestPrefix());
    jobCoordinator.enqueueJob(jobKey, () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, txn -> {
        baseVrfEntryHandler.makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, TransactionAdapter.toWriteTransaction(txn), null);
    })));
    LOG.debug("Successfully added FIB entry for prefix {} in vpnId {}", vrfEntry.getDestPrefix(), vpnId);
}
Also used : Arrays(java.util.Arrays) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) InetAddress(java.net.InetAddress) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Map(java.util.Map) Datastore(org.opendaylight.mdsal.binding.util.Datastore) BigInteger(java.math.BigInteger) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) 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) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) TypedReadWriteTransaction(org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction) NWUtil.isIpv4Address(org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address) NonNull(org.eclipse.jdt.annotation.NonNull) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) RoutePathsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePathsKey) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Callable(java.util.concurrent.Callable) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder) Lists(com.google.common.collect.Lists) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) UnknownHostException(java.net.UnknownHostException) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) 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) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) 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) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Nullable(org.eclipse.jdt.annotation.Nullable) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) RetryingManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.RetryingManagedNewTransactionRunner) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) 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) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) Objects(java.util.Objects) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) 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) Optional(java.util.Optional) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) NWUtil(org.opendaylight.genius.mdsalutil.NWUtil) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) TransactionAdapter(org.opendaylight.mdsal.binding.util.TransactionAdapter) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) Inject(javax.inject.Inject) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) Objects.requireNonNull(java.util.Objects.requireNonNull) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) ReentrantLock(java.util.concurrent.locks.ReentrantLock) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Operational(org.opendaylight.mdsal.binding.util.Datastore.Operational) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) Collections(java.util.Collections) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) JvmGlobalLocks(org.opendaylight.genius.utils.JvmGlobalLocks) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Aggregations

Test (org.junit.Test)86 ArrayList (java.util.ArrayList)69 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)61 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)45 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)43 ExecutionException (java.util.concurrent.ExecutionException)41 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)40 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)33 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)31 List (java.util.List)30 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)30 BigInteger (java.math.BigInteger)29 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)27 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)27 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)27 Logger (org.slf4j.Logger)27 LoggerFactory (org.slf4j.LoggerFactory)27 Collections (java.util.Collections)26 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)26 AttributesReach (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach)26