Search in sources :

Example 21 with ActionGroup

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

the class ExternalRoutersListener method buildSnatFlowEntity.

private FlowEntity buildSnatFlowEntity(BigInteger dpId, String routerName, long routerId, long groupId) {
    LOG.debug("buildSnatFlowEntity : called for dpId {}, routerName {} and groupId {}", dpId, routerName, groupId);
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(routerId), MetaDataUtil.METADATA_MASK_VRFID));
    List<ActionInfo> actionsInfo = new ArrayList<>();
    long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId, routerName);
    actionsInfo.add(new ActionSetFieldTunnelId(BigInteger.valueOf(tunnelId)));
    LOG.debug("buildSnatFlowEntity : Setting the tunnel to the list of action infos {}", actionsInfo);
    actionsInfo.add(new ActionGroup(groupId));
    List<InstructionInfo> instructions = new ArrayList<>();
    instructions.add(new InstructionApplyActions(actionsInfo));
    String flowRef = getFlowRefSnat(dpId, NwConstants.PSNAT_TABLE, routerName);
    FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.PSNAT_TABLE, flowRef, NatConstants.DEFAULT_PSNAT_FLOW_PRIORITY, flowRef, 0, 0, NwConstants.COOKIE_SNAT_TABLE, matches, instructions);
    LOG.debug("buildSnatFlowEntity : Returning SNAT Flow Entity {}", flowEntity);
    return flowEntity;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 22 with ActionGroup

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

the class NexthopManager method getBucketsForLocalNexthop.

private List<BucketInfo> getBucketsForLocalNexthop(Long vpnId, BigInteger dpnId, VrfEntry vrfEntry, Routes routes) {
    List<BucketInfo> listBucketInfo = new CopyOnWriteArrayList<>();
    routes.getNexthopIpList().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) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 23 with ActionGroup

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

the class VrfEntryListener method checkCreateLocalFibEntry.

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

Example 24 with ActionGroup

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

the class VrfEntryListener method makeTunnelTableEntry.

void makeTunnelTableEntry(BigInteger dpId, long label, long groupId, /*String egressInterfaceName*/
WriteTransaction tx) {
    List<ActionInfo> actionsInfos = Collections.singletonList(new ActionGroup(groupId));
    createTerminatingServiceActions(dpId, (int) label, actionsInfos, tx);
    LOG.debug("Terminating service Entry for dpID {} : label : {} egress : {} installed successfully", dpId, label, groupId);
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo)

Example 25 with ActionGroup

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

the class EvpnVrfEntryHandler method checkCreateLocalEvpnFlows.

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

Aggregations

ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)26 ArrayList (java.util.ArrayList)20 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)15 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)13 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)12 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)8 BigInteger (java.math.BigInteger)7 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)7 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)7 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)6 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)5 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 Test (org.junit.Test)3 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 InetAddress (java.net.InetAddress)2