Search in sources :

Example 21 with Paths

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths in project netvirt by opendaylight.

the class NexthopManager method getBucketsForRemoteNexthop.

private List<BucketInfo> getBucketsForRemoteNexthop(Long vpnId, BigInteger dpnId, VrfEntry vrfEntry, String rd, List<Routes> vpnExtraRoutes) {
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    Map<String, List<ActionInfo>> egressActionMap = new HashMap<>();
    vpnExtraRoutes.forEach(vpnExtraRoute -> vpnExtraRoute.getNexthopIpList().forEach(nextHopIp -> {
        String nextHopPrefixIp;
        if (isIpv4Address(nextHopIp)) {
            nextHopPrefixIp = nextHopIp + NwConstants.IPV4PREFIX;
        } else {
            nextHopPrefixIp = nextHopIp + NwConstants.IPV6PREFIX;
        }
        List<String> tepIpAddresses = fibUtil.getNextHopAddresses(rd, nextHopPrefixIp);
        if (tepIpAddresses.isEmpty()) {
            return;
        }
        // There would be only one nexthop address for a VM ip which would be the tep Ip
        String tepIp = tepIpAddresses.get(0);
        AdjacencyResult adjacencyResult = getRemoteNextHopPointer(dpnId, vpnId, vrfEntry.getDestPrefix(), tepIp);
        if (adjacencyResult == null) {
            return;
        }
        String egressInterface = adjacencyResult.getInterfaceName();
        if (!FibUtil.isTunnelInterface(adjacencyResult)) {
            return;
        }
        Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(interfaceManager, egressInterface);
        Interface ifState = fibUtil.getInterfaceStateFromOperDS(egressInterface);
        if (ifState == null || ifState.getOperStatus() != OperStatus.Up) {
            LOG.trace("Tunnel not up {}", egressInterface);
            return;
        }
        if (!TunnelTypeVxlan.class.equals(tunnelType)) {
            return;
        }
        Long label = FibUtil.getLabelFromRoutePaths(vrfEntry).get();
        Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, nextHopPrefixIp);
        BigInteger tunnelId;
        if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId, rd)) {
            java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
            if (!optionalVni.isPresent()) {
                LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp, vrfEntry, prefixInfo.getSubnetId());
                return;
            }
            tunnelId = BigInteger.valueOf(optionalVni.get());
        } else {
            tunnelId = BigInteger.valueOf(label);
        }
        List<ActionInfo> actionInfos = new ArrayList<>();
        actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
        String ifName = prefixInfo.getVpnInterfaceName();
        String vpnName = fibUtil.getVpnNameFromId(vpnId);
        if (vpnName == null) {
            return;
        }
        String macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, nextHopPrefixIp);
        actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(), new MacAddress(macAddress)));
        List<ActionInfo> egressActions;
        if (egressActionMap.containsKey(egressInterface)) {
            egressActions = egressActionMap.get(egressInterface);
        } else {
            egressActions = getEgressActionsForInterface(egressInterface, actionInfos.size());
            egressActionMap.put(egressInterface, egressActions);
        }
        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);
        }
        actionInfos.addAll(egressActions);
        BucketInfo bucket = new BucketInfo(actionInfos);
        bucket.setWeight(1);
        listBucketInfo.add(bucket);
    }));
    LOG.trace("LOCAL: listbucket {}, rd {}, dpnId {}, routes {}", listBucketInfo, rd, dpnId, vpnExtraRoutes);
    return listBucketInfo;
}
Also used : ActionOutput(org.opendaylight.genius.mdsalutil.actions.ActionOutput) NxActionResubmitRpcAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) GetInternalOrExternalInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutput) Future(java.util.concurrent.Future) NxActionRegLoadNodesNodeTableFlowApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCase) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Optional(com.google.common.base.Optional) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) Map(java.util.Map) TunnelTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre) SegmentTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeVlan) BigInteger(java.math.BigInteger) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) StateTunnelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey) ReleaseIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) SegmentTypeFlat(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeFlat) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder) GroupRef(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) SalGroupService(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService) ActionSetFieldVlanVid(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid) ConfTransportTypeL3vpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.ConfTransportTypeL3vpn) NWUtil.isIpv4Address(org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) PushVlanActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) ArrayList(java.util.ArrayList) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) ConfTransportTypeL3vpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.ConfTransportTypeL3vpnBuilder) NxRegLoad(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) VpnNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthops) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) ExecutionException(java.util.concurrent.ExecutionException) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) AddGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) VpnNexthopKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthopKey) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Preconditions(com.google.common.base.Preconditions) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes) Tunnel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel) SegmentTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeBase) InterfaceType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType) LoggerFactory(org.slf4j.LoggerFactory) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) GetInternalOrExternalInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameInputBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PreDestroy(javax.annotation.PreDestroy) NxmNxReg6(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6) Locale(java.util.Locale) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre) TunnelsState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelsState) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) ActionPushMpls(org.opendaylight.genius.mdsalutil.actions.ActionPushMpls) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) ActionPushVlan(org.opendaylight.genius.mdsalutil.actions.ActionPushVlan) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) List(java.util.List) Nexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.l3vpn.lb.nexthops.Nexthops) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) TunnelTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase) ActionRegMove(org.opendaylight.genius.mdsalutil.actions.ActionRegMove) DpnLbNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpid.l3vpn.lb.nexthops.DpnLbNexthops) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) VpnNexthopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthopBuilder) HashMap(java.util.HashMap) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) L3nexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.L3nexthop) Inject(javax.inject.Inject) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) VpnNexthopsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthopsKey) ActionRegLoad(org.opendaylight.genius.mdsalutil.actions.ActionRegLoad) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnNexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop) SetFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) Logger(org.slf4j.Logger) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) ReleaseIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder) GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) L3VPNTransportTypes(org.opendaylight.netvirt.fibmanager.api.L3VPNTransportTypes) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) ITMConstants(org.opendaylight.genius.itm.globals.ITMConstants) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) Collections(java.util.Collections) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) Optional(com.google.common.base.Optional) HashMap(java.util.HashMap) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) TunnelTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) BigInteger(java.math.BigInteger) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 22 with Paths

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths in project netvirt by opendaylight.

the class VrfEntryListener method update.

@Override
// originalRoutePath is a little dicey - safest to keep the checking even if not needed.
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
protected void update(InstanceIdentifier<VrfEntry> identifier, VrfEntry original, VrfEntry update) {
    Preconditions.checkNotNull(update, "VrfEntry should not be null or empty.");
    final String rd = identifier.firstKeyOf(VrfTables.class).getRouteDistinguisher();
    LOG.debug("UPDATE: Updating Fib Entries to rd {} prefix {} route-paths {} origin {} old-origin {}", rd, update.getDestPrefix(), update.getRoutePaths(), update.getOrigin(), original.getOrigin());
    // Handle BGP Routes first
    if (RouteOrigin.value(update.getOrigin()) == RouteOrigin.BGP) {
        bgpRouteVrfEntryHandler.updateFlows(identifier, original, update, rd);
        LOG.info("UPDATE: Updated BGP advertised Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
        return;
    }
    if (RouteOrigin.value(update.getOrigin()) == RouteOrigin.STATIC) {
        List<RoutePaths> originalRoutePath = original.getRoutePaths();
        List<RoutePaths> updateRoutePath = update.getRoutePaths();
        LOG.info("UPDATE: Original route-path {} update route-path {} ", originalRoutePath, updateRoutePath);
        // Updates need to be handled for extraroute even if original vrf entry route path is null or
        // updated vrf entry route path is null. This can happen during tunnel events.
        Optional<VpnInstanceOpDataEntry> optVpnInstance = fibUtil.getVpnInstanceOpData(rd);
        List<String> usedRds = new ArrayList<>();
        if (optVpnInstance.isPresent()) {
            usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, optVpnInstance.get().getVpnId(), update.getDestPrefix());
        }
        // has nexthop , route needs to be created on remote Dpns
        if (originalRoutePath == null || originalRoutePath.isEmpty() && updateRoutePath != null && !updateRoutePath.isEmpty() && usedRds.isEmpty()) {
            // TODO(vivek): Though ugly, Not handling this code now, as each
            // tep add event will invoke flow addition
            LOG.trace("Original VRF entry NH is null for destprefix {}. And the prefix is not an extra route." + " This event is IGNORED here.", update.getDestPrefix());
            return;
        }
        // has nexthop empty'ed out, route needs to be removed from remote Dpns
        if (updateRoutePath == null || updateRoutePath.isEmpty() && originalRoutePath != null && !originalRoutePath.isEmpty() && usedRds.isEmpty()) {
            LOG.trace("Original VRF entry had valid NH for destprefix {}. And the prefix is not an extra route." + "This event is IGNORED here.", update.getDestPrefix());
            return;
        }
        // Update the used rds and vpntoextraroute containers only for the deleted nextHops.
        List<String> nextHopsRemoved = FibHelper.getNextHopListFromRoutePaths(original);
        nextHopsRemoved.removeAll(FibHelper.getNextHopListFromRoutePaths(update));
        WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
        nextHopsRemoved.parallelStream().forEach(nextHopRemoved -> fibUtil.updateUsedRdAndVpnToExtraRoute(writeOperTxn, nextHopRemoved, rd, update.getDestPrefix()));
        CheckedFuture<Void, TransactionCommitFailedException> operFuture = writeOperTxn.submit();
        try {
            operFuture.get();
        } catch (InterruptedException | ExecutionException e) {
            LOG.error("Exception encountered while submitting operational future for update vrfentry {}", update, e);
        }
        createFibEntries(identifier, update);
        LOG.info("UPDATE: Updated static Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
        return;
    }
    // Handle all other routes only on a cluster reboot
    if (original.equals(update)) {
        // Reboot use-case
        createFibEntries(identifier, update);
        LOG.info("UPDATE: Updated Non-static Fib Entry with rd {} prefix {} route-paths {}", rd, update.getDestPrefix(), update.getRoutePaths());
        return;
    }
    LOG.info("UPDATE: Ignoring update for FIB entry with rd {} prefix {} route-origin {} route-paths {}", rd, update.getDestPrefix(), update.getOrigin(), update.getRoutePaths());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) ExecutionException(java.util.concurrent.ExecutionException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 23 with Paths

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths in project netvirt by opendaylight.

the class VrfEntryListener method installIVpnLinkSwitchingFlows.

/*
     * Installs the flows in FIB table that, for a given route, do the switching from one VPN to the other.
     */
private void installIVpnLinkSwitchingFlows(final InterVpnLinkDataComposite interVpnLink, final String vpnUuid, final VrfEntry vrfEntry, long vpnTag) {
    Preconditions.checkNotNull(interVpnLink, "InterVpnLink cannot be null");
    Preconditions.checkArgument(vrfEntry.getRoutePaths() != null && vrfEntry.getRoutePaths().size() == 1);
    String destination = vrfEntry.getDestPrefix();
    String nextHop = vrfEntry.getRoutePaths().get(0).getNexthopAddress();
    String interVpnLinkName = interVpnLink.getInterVpnLinkName();
    // using as metadata the LPortTag associated to that vpn in the inter-vpn-link.
    if (interVpnLink.getState().or(State.Error) != State.Active) {
        LOG.warn("Route to {} with nexthop={} cannot be installed because the interVpnLink {} is not active", destination, nextHop, interVpnLinkName);
        return;
    }
    Optional<Long> optOtherEndpointLportTag = interVpnLink.getOtherEndpointLportTagByVpnName(vpnUuid);
    if (!optOtherEndpointLportTag.isPresent()) {
        LOG.warn("Could not find suitable LportTag for the endpoint opposite to vpn {} in interVpnLink {}", vpnUuid, interVpnLinkName);
        return;
    }
    List<BigInteger> targetDpns = interVpnLink.getEndpointDpnsByVpnName(vpnUuid);
    if (targetDpns.isEmpty()) {
        LOG.warn("Could not find DPNs for endpoint opposite to vpn {} in interVpnLink {}", vpnUuid, interVpnLinkName);
        return;
    }
    String[] values = destination.split("/");
    String destPrefixIpAddress = values[0];
    int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnTag), MetaDataUtil.METADATA_MASK_VRFID));
    matches.add(MatchEthernetType.IPV4);
    if (prefixLength != 0) {
        matches.add(new MatchIpv4Destination(destPrefixIpAddress, Integer.toString(prefixLength)));
    }
    List<Instruction> instructions = Arrays.asList(new InstructionWriteMetadata(MetaDataUtil.getMetaDataForLPortDispatcher(optOtherEndpointLportTag.get().intValue(), ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX)), MetaDataUtil.getMetaDataMaskForLPortDispatcher()).buildInstruction(0), new InstructionGotoTable(NwConstants.L3_INTERFACE_TABLE).buildInstruction(1));
    int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
    String flowRef = getInterVpnFibFlowRef(interVpnLinkName, destination, nextHop);
    Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, COOKIE_VM_FIB_TABLE, matches, instructions);
    LOG.trace("Installing flow in FIB table for vpn {} interVpnLink {} nextHop {} key {}", vpnUuid, interVpnLink.getInterVpnLinkName(), nextHop, flowRef);
    for (BigInteger dpId : targetDpns) {
        LOG.debug("Installing flow: VrfEntry=[prefix={} route-paths={}] dpn {} for InterVpnLink {} in FIB", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), dpId, interVpnLink.getInterVpnLinkName());
        mdsalManager.installFlow(dpId, flowEntity);
    }
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) 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) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) BigInteger(java.math.BigInteger) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)

Example 24 with Paths

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths in project openflowplugin by opendaylight.

the class StackedOutboundQueueNoBarrier method writeEntries.

@Override
int writeEntries(@Nonnull final Channel channel, final long now) {
    // Local cache
    StackedSegment segment = firstSegment;
    int entries = 0;
    while (channel.isWritable()) {
        final OutboundQueueEntry entry = segment.getEntry(flushOffset);
        if (!entry.isCommitted()) {
            LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + flushOffset, segment, flushOffset);
            break;
        }
        LOG.trace("Queue {} flushing entry at offset {}", this, flushOffset);
        final OfHeader message = entry.takeMessage();
        flushOffset++;
        entries++;
        if (message != null) {
            manager.writeMessage(message, now);
        } else {
            entry.complete(null);
        }
        if (flushOffset >= StackedSegment.SEGMENT_SIZE) {
            /*
                 * Slow path: purge the current segment unless it's the last one.
                 * If it is, we leave it for replacement when a new reservation
                 * is run on it.
                 * This costs us two slow paths, but hey, this should be very rare,
                 * so let's keep things simple.
                 */
            synchronized (unflushedSegments) {
                LOG.debug("Flush offset {} unflushed segments {}", flushOffset, unflushedSegments.size());
                // We may have raced ahead of reservation code and need to allocate a segment
                ensureSegment(segment, flushOffset);
                // Remove the segment, update the firstSegment and reset flushOffset
                final StackedSegment oldSegment = unflushedSegments.remove(0);
                oldSegment.completeAll();
                uncompletedSegments.remove(oldSegment);
                oldSegment.recycle();
                // Reset the first segment and add it to the uncompleted list
                segment = unflushedSegments.get(0);
                uncompletedSegments.add(segment);
                // Update the shutdown offset
                if (shutdownOffset != null) {
                    shutdownOffset -= StackedSegment.SEGMENT_SIZE;
                }
                // Allow reservations back on the fast path by publishing the new first segment
                firstSegment = segment;
                flushOffset = 0;
                LOG.debug("Queue {} flush moved to segment {}", this, segment);
            }
        }
    }
    return entries;
}
Also used : OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)

Example 25 with Paths

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths in project openflowplugin by opendaylight.

the class AbstractStackedOutboundQueue method writeEntries.

/**
 * Write some entries from the queue to the channel. Guaranteed to run
 * in the corresponding EventLoop.
 *
 * @param channel Channel onto which we are writing
 * @param now time stamp
 * @return Number of entries written out
 */
int writeEntries(@Nonnull final Channel channel, final long now) {
    // Local cache
    StackedSegment segment = firstSegment;
    int entries = 0;
    while (channel.isWritable()) {
        final OutboundQueueEntry entry = segment.getEntry(flushOffset);
        if (!entry.isCommitted()) {
            LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + flushOffset, segment, flushOffset);
            break;
        }
        LOG.trace("Queue {} flushing entry at offset {}", this, flushOffset);
        final OfHeader message = entry.takeMessage();
        flushOffset++;
        entries++;
        if (message != null) {
            manager.writeMessage(message, now);
        } else {
            entry.complete(null);
        }
        if (flushOffset >= StackedSegment.SEGMENT_SIZE) {
            /*
                 * Slow path: purge the current segment unless it's the last one.
                 * If it is, we leave it for replacement when a new reservation
                 * is run on it.
                 *
                 * This costs us two slow paths, but hey, this should be very rare,
                 * so let's keep things simple.
                 */
            synchronized (unflushedSegments) {
                LOG.debug("Flush offset {} unflushed segments {}", flushOffset, unflushedSegments.size());
                // We may have raced ahead of reservation code and need to allocate a segment
                ensureSegment(segment, flushOffset);
                // Remove the segment, update the firstSegment and reset flushOffset
                final StackedSegment oldSegment = unflushedSegments.remove(0);
                if (oldSegment.isComplete()) {
                    uncompletedSegments.remove(oldSegment);
                    oldSegment.recycle();
                }
                // Reset the first segment and add it to the uncompleted list
                segment = unflushedSegments.get(0);
                uncompletedSegments.add(segment);
                // Update the shutdown offset
                if (shutdownOffset != null) {
                    shutdownOffset -= StackedSegment.SEGMENT_SIZE;
                }
                // Allow reservations back on the fast path by publishing the new first segment
                firstSegment = segment;
                flushOffset = 0;
                LOG.debug("Queue {} flush moved to segment {}", this, segment);
            }
        }
    }
    return entries;
}
Also used : OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)

Aggregations

ArrayList (java.util.ArrayList)9 Test (org.junit.Test)8 ByteBuf (io.netty.buffer.ByteBuf)5 BigInteger (java.math.BigInteger)5 Paths (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.Paths)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 SuccessCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.SuccessCaseBuilder)4 SuccessBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder)4 PathsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)3 Optional (com.google.common.base.Optional)2 Preconditions (com.google.common.base.Preconditions)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 Collections (java.util.Collections)2 List (java.util.List)2 ExecutionException (java.util.concurrent.ExecutionException)2 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)2 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)2