Search in sources :

Example 71 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class AbstractIpLearnNotificationHandler method validateAndProcessIpLearning.

protected void validateAndProcessIpLearning(String srcInterface, IpAddress srcIP, MacAddress srcMac, IpAddress targetIP, Uint64 metadata) {
    List<Adjacency> adjacencies = vpnUtil.getAdjacenciesForVpnInterfaceFromConfig(srcInterface);
    IpVersionChoice srcIpVersion = VpnUtil.getIpVersionFromString(srcIP.stringValue());
    boolean isSrcIpVersionPartOfVpn = false;
    if (adjacencies != null && !adjacencies.isEmpty()) {
        for (Adjacency adj : adjacencies) {
            IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(adj.getIpAddress());
            // If extra/static route is configured, we should ignore for learning process
            if (NWUtil.isIpAddressInRange(srcIP, ipPrefix)) {
                return;
            }
            IpVersionChoice currentAdjIpVersion = VpnUtil.getIpVersionFromString(adj.getIpAddress());
            if (srcIpVersion.isIpVersionChosen(currentAdjIpVersion)) {
                isSrcIpVersionPartOfVpn = true;
            }
        }
        // If srcIP version is not part of the srcInterface VPN Adjacency, ignore IpLearning process
        if (!isSrcIpVersionPartOfVpn) {
            return;
        }
    }
    LOG.trace("ARP/NA Notification Response Received from interface {} and IP {} having MAC {}, learning MAC", srcInterface, srcIP.stringValue(), srcMac.getValue());
    processIpLearning(srcInterface, srcIP, srcMac, metadata, targetIP);
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 72 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class IpMonitorStopTask method call.

@Override
public List<ListenableFuture<Void>> call() {
    final List<ListenableFuture<Void>> futures = new ArrayList<>();
    java.util.Optional<Uint32> monitorIdOptional = alivenessMonitorUtils.getMonitorIdFromInterface(macEntry);
    if (monitorIdOptional.isPresent()) {
        alivenessMonitorUtils.stopIpMonitoring(monitorIdOptional.get());
    } else {
        LOG.warn("MonitorId not available for IP {} interface {}. IpMonitoring not stopped", macEntry.getIpAddress(), macEntry.getInterfaceName());
    }
    String learntIp = macEntry.getIpAddress().getHostAddress();
    if (this.isRemoveMipAdjAndLearntIp) {
        String vpnName = macEntry.getVpnName();
        LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
        if (vpnVipToPort != null && !Objects.equals(vpnVipToPort.getCreationTime(), macEntry.getCreatedTime())) {
            LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
            return futures;
        }
        vpnUtil.removeLearntVpnVipToPort(macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
        vpnUtil.removeVpnPortFixedIpToPort(dataBroker, macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
        LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> vpnUtil.removeMipAdjacency(macEntry.getVpnName(), macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), tx)), LOG, "ArpMonitorStopTask: Error writing to datastore for Vpn {} IP  {}", macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress());
    } else {
        // Delete only MIP adjacency
        vpnUtil.removeMipAdjacency(macEntry.getInterfaceName(), learntIp);
    }
    return futures;
}
Also used : VpnUtil(org.opendaylight.netvirt.vpnmanager.VpnUtil) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LoggerFactory(org.slf4j.LoggerFactory) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Callable(java.util.concurrent.Callable) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) MacEntry(org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry) Datastore(org.opendaylight.mdsal.binding.util.Datastore) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 73 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class L3vpnOverMplsGrePopulator method createOperationalAdjacency.

@Override
public Adjacency createOperationalAdjacency(L3vpnInput input) {
    Adjacency nextHop = input.getNextHop();
    String nextHopIp = input.getNextHopIp();
    String prefix = VpnUtil.getIpPrefix(nextHop.getIpAddress());
    List<String> adjNextHop = nextHop.getNextHopIpList();
    String rd = input.getRd();
    String primaryRd = input.getPrimaryRd();
    String vpnName = input.getVpnName();
    Uint32 label = vpnUtil.getUniqueId(VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(primaryRd, prefix));
    if (label.longValue() == VpnConstants.INVALID_LABEL) {
        String error = "Unable to fetch label from Id Manager. Bailing out of creation of operational " + "vpn interface adjacency " + prefix + "for vpn " + vpnName;
        throw new NullPointerException(error);
    }
    List<String> nextHopList = adjNextHop != null && !adjNextHop.isEmpty() ? adjNextHop : nextHopIp == null ? Collections.emptyList() : singletonList(nextHopIp);
    return new AdjacencyBuilder(nextHop).setLabel(label).setNextHopIpList(nextHopList).setIpAddress(prefix).setVrfId(rd).withKey(new AdjacencyKey(prefix)).setAdjacencyType(nextHop.getAdjacencyType()).setSubnetGatewayMacAddress(nextHop.getSubnetGatewayMacAddress()).build();
}
Also used : AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder) AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 74 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class L3vpnOverVxlanPopulator method populateFib.

@Override
public void populateFib(L3vpnInput input, TypedWriteTransaction<Configuration> writeConfigTxn) {
    if (input.getRouteOrigin() == RouteOrigin.CONNECTED) {
        LOG.info("populateFib : Found SubnetRoute for subnet {} rd {}", input.getSubnetIp(), input.getPrimaryRd());
        addSubnetRouteFibEntry(input);
        return;
    }
    String rd = input.getRd();
    String primaryRd = input.getPrimaryRd();
    Adjacency nextHop = input.getNextHop();
    LOG.info("populateFib : Found Interface Adjacency with prefix {} rd {}", nextHop.getIpAddress(), primaryRd);
    if (!rd.equalsIgnoreCase(input.getVpnName()) && !rd.equals(input.getNetworkName())) {
        Objects.requireNonNull(input.getRouteOrigin(), "populateFib: RouteOrigin is mandatory");
        addPrefixToBGP(rd, primaryRd, nextHop.getMacAddress(), nextHop.getIpAddress(), input.getNextHopIp(), input.getEncapType(), Uint32.ZERO, /*label*/
        Uint32.valueOf(input.getL3vni()), input.getGatewayMac(), input.getRouteOrigin(), writeConfigTxn);
    } else {
        LOG.error("Internal VPN for L3 Over VxLAN is not supported. Aborting.");
        return;
    }
}
Also used : Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency)

Example 75 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class NeutronvpnNatManager method removeAdjacencyAndLearnedEntriesforExternalSubnet.

private void removeAdjacencyAndLearnedEntriesforExternalSubnet(Uuid extNetId, Uuid extSubnetId) {
    Collection<String> extElanInterfaces = elanService.getExternalElanInterfaces(extNetId.getValue());
    if (extElanInterfaces == null || extElanInterfaces.isEmpty()) {
        LOG.error("No external ports attached to external network {}", extNetId.getValue());
        return;
    }
    for (String infName : extElanInterfaces) {
        InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).child(VpnInterface.class, new VpnInterfaceKey(infName)).build();
        InstanceIdentifier<Adjacencies> adjacenciesIdentifier = vpnIfIdentifier.augmentation(Adjacencies.class);
        try {
            // Looking for existing prefix in MDSAL database
            Optional<Adjacencies> optionalAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacenciesIdentifier);
            if (optionalAdjacencies.isPresent()) {
                Map<AdjacencyKey, Adjacency> keyAdjacencyMap = optionalAdjacencies.get().nonnullAdjacency();
                Iterator<Adjacency> adjacencyIter = keyAdjacencyMap.values().iterator();
                while (adjacencyIter.hasNext()) {
                    Adjacency adjacency = adjacencyIter.next();
                    if (!adjacency.getSubnetId().equals(extSubnetId)) {
                        continue;
                    }
                    InstanceIdentifier<Adjacency> adjacencyIdentifier = adjacenciesIdentifier.child(Adjacency.class, new AdjacencyKey(adjacency.getIpAddress()));
                    SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
                    LOG.trace("Removed Adjacency for fixedIP {} for port {} on external subnet {} ", adjacency.getIpAddress(), infName, extSubnetId);
                    String extNetVpnName = extNetId.getValue();
                    String learnedSrcIp = adjacency.getIpAddress().split("/")[0];
                    InstanceIdentifier<LearntVpnVipToPort> id = NeutronvpnUtils.buildLearntVpnVipToPortIdentifier(extNetVpnName, learnedSrcIp);
                    Optional<LearntVpnVipToPort> optionalLearntVpnVipToPort = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
                    if (optionalLearntVpnVipToPort.isPresent()) {
                        neutronvpnUtils.removeLearntVpnVipToPort(extNetVpnName, learnedSrcIp);
                        LOG.trace("Removed Learnt Entry for fixedIP {} for port {}", adjacency.getIpAddress(), infName);
                    }
                }
            }
        } catch (TransactionCommitFailedException | ExecutionException | InterruptedException e) {
            LOG.error("exception in removeAdjacencyAndLearnedEntriesforExternalSubnet for interface {}", infName, e);
        }
    }
}
Also used : AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) VpnInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterfaceKey) VpnInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.interfaces.VpnInterface) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ArrayList (java.util.ArrayList)38 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency)38 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)32 ExecutionException (java.util.concurrent.ExecutionException)31 AdjacenciesOp (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp)28 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)27 AdjacencyKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey)26 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)25 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)24 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)24 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)20 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)17 Adjacencies (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)14 AdjacencyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder)13 BigInteger (java.math.BigInteger)12 List (java.util.List)12 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)12 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)12 Optional (java.util.Optional)10