Search in sources :

Example 11 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class ElanDmacUtils method buildDmacFlowForExternalRemoteMac.

/**
 * Builds a Flow to be programmed in a DPN's DMAC table. This method must be
 * used when the MAC is located in an External Device (TOR). The flow
 * matches on the specified MAC and 1) sends the packet over the CSS-TOR
 * tunnel if SHFlag is not set, or 2) drops it if SHFlag is set (what means
 * the packet came from an external tunnel)
 *
 * @param dpId
 *            DPN whose DMAC table is going to be modified
 * @param extDeviceNodeId
 *            Hwvtep node where the mac is attached to
 * @param elanTag
 *            ElanId to which the MAC is being added to
 * @param vni
 *            the vni
 * @param dstMacAddress
 *            The mac address to be programmed
 * @param displayName
 *            the display name
 * @return the flow
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public Flow buildDmacFlowForExternalRemoteMac(BigInteger dpId, String extDeviceNodeId, long elanTag, Long vni, String dstMacAddress, String displayName) {
    List<MatchInfo> mkMatches = ElanUtils.buildMatchesForElanTagShFlagAndDstMac(elanTag, /* shFlag */
    false, dstMacAddress);
    List<Instruction> mkInstructions = new ArrayList<>();
    try {
        List<Action> actions = elanItmUtils.getExternalTunnelItmEgressAction(dpId, new NodeId(extDeviceNodeId), vni);
        mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
    } catch (Exception e) {
        LOG.error("Could not get Egress Actions for DpId {} externalNode {}", dpId, extDeviceNodeId, e);
    }
    return MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, ElanUtils.getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, extDeviceNodeId, dstMacAddress, elanTag, false), 20, /* prio */
    displayName, 0, /* idleTimeout */
    0, /* hardTimeout */
    ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) ElanException(org.opendaylight.netvirt.elan.ElanException)

Example 12 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class ElanItmUtils method getExternalTunnelItmEgressAction.

/**
 * Builds the list of actions to be taken when sending the packet over an
 * external VxLan tunnel interface, such as stamping the VNI on the VxLAN
 * header, setting the vlanId if it proceeds and output the packet over the
 * right port.
 *
 * @param srcDpnId
 *            Dpn where the tunnelInterface is located
 * @param torNode
 *            NodeId of the ExternalDevice where the packet must be sent to.
 * @param vni
 *            Vni to be stamped on the VxLAN Header.
 * @return the external itm egress action
 */
public List<Action> getExternalTunnelItmEgressAction(BigInteger srcDpnId, NodeId torNode, long vni) {
    List<Action> result = Collections.emptyList();
    GetExternalTunnelInterfaceNameInput input = new GetExternalTunnelInterfaceNameInputBuilder().setDestinationNode(torNode.getValue()).setSourceNode(srcDpnId.toString()).setTunnelType(TunnelTypeVxlan.class).build();
    Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> output = itmRpcService.getExternalTunnelInterfaceName(input);
    try {
        if (output.get().isSuccessful()) {
            GetExternalTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
            String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
            LOG.debug("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
            result = buildTunnelItmEgressActions(tunnelIfaceName, vni);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetExternalTunnelInterfaceNameInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInput) GetExternalTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) ExecutionException(java.util.concurrent.ExecutionException) GetExternalTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInputBuilder)

Example 13 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class ElanItmUtils method getInternalTunnelItmEgressAction.

/**
 * Builds the list of actions to be taken when sending the packet over an internal VxLAN tunnel interface, such
 * as setting the serviceTag/segmentationID on the VNI field of the VxLAN header, setting the vlanId if it proceeds
 * and output the packet over the right port.
 *
 * @param sourceDpnId
 *            Dpn where the tunnelInterface is located
 * @param destinationDpnId
 *            Dpn where the packet must be sent to. It is used here in order
 *            to select the right tunnel interface.
 * @param tunnelKey
 *            Tunnel key to be sent on the VxLAN header.
 * @return the internal itm egress action
 */
public List<Action> getInternalTunnelItmEgressAction(BigInteger sourceDpnId, BigInteger destinationDpnId, long tunnelKey) {
    List<Action> result = Collections.emptyList();
    LOG.trace("In getInternalItmEgressAction Action source {}, destination {}, serviceTag/Vni {}", sourceDpnId, destinationDpnId, tunnelKey);
    Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
    GetTunnelInterfaceNameInput input = new GetTunnelInterfaceNameInputBuilder().setDestinationDpid(destinationDpnId).setSourceDpid(sourceDpnId).setTunnelType(tunType).build();
    Future<RpcResult<GetTunnelInterfaceNameOutput>> output = itmRpcService.getTunnelInterfaceName(input);
    try {
        if (output.get().isSuccessful()) {
            GetTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
            String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
            LOG.info("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
            result = buildTunnelItmEgressActions(tunnelIfaceName, tunnelKey);
        } else {
            LOG.trace("Tunnel interface doesn't exist between srcDpId {} dstDpId {}", sourceDpnId, destinationDpnId);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error in RPC call getTunnelInterfaceName {}", e);
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetTunnelInterfaceNameInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 14 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class BaseVrfEntryHandler method addTunnelInterfaceActions.

protected void addTunnelInterfaceActions(AdjacencyResult adjacencyResult, long vpnId, VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
    Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(nextHopManager.getInterfaceManager(), 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<Long> optionalLabel = FibUtil.getLabelForNextHop(vrfEntry, nextHopIp);
    if (!optionalLabel.isPresent()) {
        LOG.warn("NextHopIp {} not found in vrfEntry {}", nextHopIp, vrfEntry);
        return;
    }
    long label = optionalLabel.get();
    BigInteger tunnelId = null;
    Prefixes prefixInfo = null;
    // revisit
    if (tunnelType.equals(TunnelTypeVxlan.class)) {
        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());
        }
        // 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() != 0) {
                tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
            }
        } else {
            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);
            }
        }
    } else {
        tunnelId = BigInteger.valueOf(label);
    }
    LOG.debug("adding set tunnel id action for label {}", label);
    actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
    addRewriteDstMacAction(vpnId, vrfEntry, prefixInfo, actionInfos);
}
Also used : BigInteger(java.math.BigInteger) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)

Example 15 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method createRemoteFibEntry.

private void createRemoteFibEntry(final BigInteger remoteDpnId, final long vpnId, final VrfTablesKey vrfTableKey, final VrfEntry vrfEntry, boolean isNatPrefix, WriteTransaction tx) {
    String rd = vrfTableKey.getRouteDistinguisher();
    List<SubTransaction> subTxns = new ArrayList<>();
    LOG.debug("createremotefibentry: adding route {} for rd {} with transaction {}", vrfEntry.getDestPrefix(), rd, tx);
    List<NexthopManager.AdjacencyResult> tunnelInterfaceList = resolveAdjacency(remoteDpnId, vpnId, vrfEntry, rd);
    if (tunnelInterfaceList.isEmpty()) {
        LOG.error("Could not get interface for route-paths: {} in vpn {}", vrfEntry.getRoutePaths(), rd);
        LOG.warn("Failed to add Route: {} in vpn: {}", vrfEntry.getDestPrefix(), rd);
        return;
    }
    for (NexthopManager.AdjacencyResult adjacencyResult : tunnelInterfaceList) {
        List<ActionInfo> actionInfos = new ArrayList<>();
        BigInteger tunnelId;
        String prefix = adjacencyResult.getPrefix();
        Prefixes prefixInfo = getFibUtil().getPrefixToInterface(vpnId, prefix);
        String interfaceName = prefixInfo.getVpnInterfaceName();
        if (vrfEntry.getOrigin().equals(RouteOrigin.BGP.getValue()) || isNatPrefix) {
            tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
        } else if (elanManager.isOpenStackVniSemanticsEnforced()) {
            tunnelId = BigInteger.valueOf(getFibUtil().getVniForVxlanNetwork(prefixInfo.getSubnetId()).get());
        } else {
            Interface interfaceState = getFibUtil().getInterfaceStateFromOperDS(interfaceName);
            tunnelId = BigInteger.valueOf(interfaceState.getIfIndex());
        }
        LOG.debug("adding set tunnel id action for label {}", tunnelId);
        String macAddress = null;
        String vpnName = getFibUtil().getVpnNameFromId(vpnId);
        if (vpnName == null) {
            LOG.debug("Failed to get VPN name for vpnId {}", vpnId);
            return;
        }
        if (interfaceName != null) {
            macAddress = getFibUtil().getMacAddressFromPrefix(interfaceName, vpnName, prefix);
            actionInfos.add(new ActionSetFieldEthernetDestination(new MacAddress(macAddress)));
        }
        actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
        List<ActionInfo> egressActions = nexthopManager.getEgressActionsForInterface(adjacencyResult.getInterfaceName(), actionInfos.size());
        if (egressActions.isEmpty()) {
            LOG.error("Failed to retrieve egress action for prefix {} route-paths {} interface {}." + " Aborting remote FIB entry creation..", vrfEntry.getDestPrefix(), vrfEntry.getRoutePaths(), adjacencyResult.getInterfaceName());
            return;
        }
        actionInfos.addAll(egressActions);
        List<InstructionInfo> instructions = new ArrayList<>();
        instructions.add(new InstructionApplyActions(actionInfos));
        makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, tx, subTxns);
    }
    LOG.debug("Successfully added FIB entry for prefix {} in rd {}", vrfEntry.getDestPrefix(), rd);
}
Also used : SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) 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) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) BigInteger(java.math.BigInteger) 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)

Aggregations

ArrayList (java.util.ArrayList)61 ExecutionException (java.util.concurrent.ExecutionException)48 BigInteger (java.math.BigInteger)42 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)37 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)28 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)26 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)25 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)25 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)22 List (java.util.List)21 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)21 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)21 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)20 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)18 Logger (org.slf4j.Logger)18 LoggerFactory (org.slf4j.LoggerFactory)18 Inject (javax.inject.Inject)17 Singleton (javax.inject.Singleton)17 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)17