Search in sources :

Example 76 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface in project netvirt by opendaylight.

the class ElanUtils method setupTermDmacFlows.

/**
 * Installs a Flow in INTERNAL_TUNNEL_TABLE of the affected DPN that sends
 * the packet through the specified interface if the tunnel_id matches the
 * interface's lportTag.
 *
 * @param interfaceInfo
 *            the interface info
 * @param mdsalApiManager
 *            the mdsal API manager
 * @param writeFlowGroupTx
 *            the writeFLowGroup tx
 */
public void setupTermDmacFlows(InterfaceInfo interfaceInfo, IMdsalApiManager mdsalApiManager, WriteTransaction writeFlowGroupTx) {
    BigInteger dpId = interfaceInfo.getDpId();
    int lportTag = interfaceInfo.getInterfaceTag();
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, getIntTunnelTableFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE, lportTag), 5, String.format("%s:%d", "ITM Flow Entry ", lportTag), 0, 0, ITMConstants.COOKIE_ITM.add(BigInteger.valueOf(lportTag)), getTunnelIdMatchForFilterEqualsLPortTag(lportTag), getInstructionsInPortForOutGroup(interfaceInfo.getInterfaceName()));
    mdsalApiManager.addFlowToTx(dpId, flow, writeFlowGroupTx);
    LOG.debug("Terminating service table flow entry created on dpn:{} for logical Interface port:{}", dpId, interfaceInfo.getPortName());
}
Also used : BigInteger(java.math.BigInteger) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 77 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface in project netvirt by opendaylight.

the class ElanUtils method installEtreeLocalDmacFlow.

private void installEtreeLocalDmacFlow(long elanTag, BigInteger dpId, String ifName, String macAddress, ElanInstance elanInfo, long ifTag, WriteTransaction writeFlowGroupTx) {
    EtreeInterface etreeInterface = elanInterfaceCache.getEtreeInterface(ifName).orNull();
    if (etreeInterface != null && etreeInterface.getEtreeInterfaceType() == EtreeInterfaceType.Root) {
        EtreeLeafTagName etreeTagName = elanEtreeUtils.getEtreeLeafTagByElanTag(elanTag);
        if (etreeTagName == null) {
            LOG.warn("Interface {} seems like it belongs to Etree but etreeTagName from elanTag {} is null", ifName, elanTag);
        } else {
            Flow flowEntity = buildLocalDmacFlowEntry(etreeTagName.getEtreeLeafTag().getValue(), dpId, ifName, macAddress, elanInfo, ifTag);
            mdsalManager.addFlowToTx(dpId, flowEntity, writeFlowGroupTx);
        }
    }
}
Also used : EtreeInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface) EtreeLeafTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 78 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface in project netvirt by opendaylight.

the class VrfEntryListener method deleteLocalFibEntry.

public List<BigInteger> deleteLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
    List<BigInteger> returnLocalDpnId = new ArrayList<>();
    Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
    String vpnName = fibUtil.getVpnNameFromId(vpnId);
    boolean isExtraroute = false;
    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;
        }
        // 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, rd, vrfEntry.getDestPrefix());
        if (extraRouteOptional.isPresent()) {
            isExtraroute = true;
            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;
            }
            localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
            if (localNextHopInfo != null) {
                String localNextHopIP = localNextHopInfo.getIpAddress();
                BigInteger dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, isExtraroute, vpnId);
                if (!dpnId.equals(BigInteger.ZERO)) {
                    LOG.trace("Deleting ECMP group for prefix {}, dpn {}", vrfEntry.getDestPrefix(), dpnId);
                    nextHopManager.setupLoadBalancingNextHop(vpnId, dpnId, vrfEntry.getDestPrefix(), /*listBucketInfo*/
                    Collections.emptyList(), /*remove*/
                    false);
                    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<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
            if (optionalLabel.isPresent()) {
                Long 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());
                    BigInteger dpnId = checkDeleteLocalFibEntry(prefixBuilder.build(), nextHopAddressList.get(0), vpnId, rd, vrfEntry, isExtraroute, lri.getParentVpnid());
                    if (!dpnId.equals(BigInteger.ZERO)) {
                        returnLocalDpnId.add(dpnId);
                    }
                }
            }
        }
    } else {
        LOG.debug("Obtained prefix to interface for rd {} prefix {}", rd, vrfEntry.getDestPrefix());
        String localNextHopIP = localNextHopInfo.getIpAddress();
        BigInteger dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP, vpnId, rd, vrfEntry, isExtraroute, vpnId);
        if (!dpnId.equals(BigInteger.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) BigInteger(java.math.BigInteger)

Example 79 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface in project netvirt by opendaylight.

the class ExpectedObjects method newInterfaceConfig.

public static Interface newInterfaceConfig(final String interfaceName, final String parentName) {
    InterfaceBuilder _interfaceBuilder = new InterfaceBuilder();
    final Procedure1<InterfaceBuilder> _function = (InterfaceBuilder it) -> {
        it.setDescription(interfaceName);
        it.setName(interfaceName);
        it.setType(L2vlan.class);
        ParentRefsBuilder _parentRefsBuilder = new ParentRefsBuilder();
        final Procedure1<ParentRefsBuilder> _function_1 = (ParentRefsBuilder it_1) -> {
            it_1.setParentInterface(parentName);
        };
        ParentRefs _doubleGreaterThan = XtendBuilderExtensions.<ParentRefs, ParentRefsBuilder>operator_doubleGreaterThan(_parentRefsBuilder, _function_1);
        it.addAugmentation(ParentRefs.class, _doubleGreaterThan);
        IfL2vlanBuilder _ifL2vlanBuilder = new IfL2vlanBuilder();
        final Procedure1<IfL2vlanBuilder> _function_2 = (IfL2vlanBuilder it_1) -> {
            it_1.setL2vlanMode(IfL2vlan.L2vlanMode.Trunk);
            VlanId _vlanId = new VlanId(Integer.valueOf(0));
            it_1.setVlanId(_vlanId);
        };
        IfL2vlan _doubleGreaterThan_1 = XtendBuilderExtensions.<IfL2vlan, IfL2vlanBuilder>operator_doubleGreaterThan(_ifL2vlanBuilder, _function_2);
        it.addAugmentation(IfL2vlan.class, _doubleGreaterThan_1);
    };
    return XtendBuilderExtensions.<Interface, InterfaceBuilder>operator_doubleGreaterThan(_interfaceBuilder, _function);
}
Also used : IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 80 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface 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

BigInteger (java.math.BigInteger)131 ArrayList (java.util.ArrayList)117 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)69 ExecutionException (java.util.concurrent.ExecutionException)64 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)56 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)52 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)47 List (java.util.List)45 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)44 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)40 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)39 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)39 Logger (org.slf4j.Logger)39 LoggerFactory (org.slf4j.LoggerFactory)39 Collections (java.util.Collections)38 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)34 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)33 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)33 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)32