Search in sources :

Example 6 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.

the class BgpConfigurationManager method deleteExternalFibRoutes.

/*
     * BGP config remove scenario, Need to remove all the
     * external routes from FIB.
     */
public void deleteExternalFibRoutes() {
    totalExternalRoutes = 0;
    totalExternalMacRoutes = 0;
    try {
        InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
        Optional<FibEntries> fibEntries = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
        if (fibEntries.isPresent()) {
            if (fibEntries.get().getVrfTables() == null) {
                LOG.error("deleteExternalFibRoutes::getVrfTables is null");
                return;
            }
            List<VrfTables> staleVrfTables = fibEntries.get().getVrfTables();
            for (VrfTables vrfTable : staleVrfTables) {
                String rd = vrfTable.getRouteDistinguisher();
                if (vrfTable.getVrfEntry() != null) {
                    for (VrfEntry vrfEntry : vrfTable.getVrfEntry()) {
                        if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
                            // route cleanup is only meant for the routes learned through BGP.
                            continue;
                        }
                        totalExternalRoutes++;
                        fibDSWriter.removeFibEntryFromDS(rd, vrfEntry.getDestPrefix());
                    }
                } else if (vrfTable.getMacVrfEntry() != null) {
                    for (MacVrfEntry macEntry : vrfTable.getMacVrfEntry()) {
                        if (RouteOrigin.value(macEntry.getOrigin()) != RouteOrigin.BGP) {
                            // route cleanup is only meant for the routes learned through BGP.
                            continue;
                        }
                        totalExternalMacRoutes++;
                        fibDSWriter.removeMacEntryFromDS(rd, macEntry.getMac());
                    }
                }
            }
        } else {
            LOG.error("deleteExternalFibRoutes:: FIBentries.class is not present");
        }
    } catch (ReadFailedException e) {
        LOG.error("deleteExternalFibRoutes:: error ", e);
    }
    LOG.debug("deleted {} fib entries {} mac entries", totalExternalRoutes, totalExternalMacRoutes);
}
Also used : MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)

Example 7 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.

the class EvpnMacVrfUtils method getElanTagByMacvrfiid.

@Nullable
private Long getElanTagByMacvrfiid(InstanceIdentifier<MacVrfEntry> macVrfEntryIid) {
    String elanName = getElanNameByMacvrfiid(macVrfEntryIid);
    if (elanName == null) {
        LOG.error("getElanTag: elanName is NULL for iid = {}", macVrfEntryIid);
    }
    ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
    if (elanInstance == null) {
        return null;
    }
    Long elanTag = elanInstance.getElanTag();
    if (elanTag == null || elanTag == 0L) {
        elanTag = ElanUtils.retrieveNewElanTag(idManager, elanName);
    }
    return elanTag;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Nullable(javax.annotation.Nullable)

Example 8 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.

the class EvpnMacVrfUtils method addEvpnDmacFlowOnAttach.

public void addEvpnDmacFlowOnAttach(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry, ElanInstance elanInstance) {
    // String elanName = getElanNameByMacvrfiid(instanceIdentifier);
    if (elanInstance == null) {
        LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
        return;
    }
    String elanName = elanInstance.getElanInstanceName();
    List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
    if (checkEvpnAttachedToNet(elanName)) {
        String nexthopIP = getRoutePathNexthopIp(macVrfEntry);
        if (nexthopIP == null) {
            LOG.debug("nexthopIP is null for iid {}", instanceIdentifier);
            return;
        }
        IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
        Long elanTag = elanInstance.getElanTag();
        String dstMacAddress = macVrfEntry.getMac();
        long vni = macVrfEntry.getL2vni();
        jobCoordinator.enqueueJob(dstMacAddress, () -> {
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            dpnInterfaceLists.forEach(dpnInterfaces -> {
                BigInteger dpId = dpnInterfaces.getDpId();
                LOG.info("ADD: Build DMAC flow with dpId {}, nexthopIP {}, elanTag {}," + "vni {}, dstMacAddress {}, elanName {} ", dpId, nexthopIP, elanTag, vni, dstMacAddress, elanName);
                ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
                dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setVni(vni).setDstMacAddress(dstMacAddress).setElanName(elanName);
                Flow flow = elanEvpnFlowUtils.evpnBuildDmacFlowForExternalRemoteMac(dmacFlowBuilder.build());
                futures.add(mdsalManager.installFlow(dpId, flow));
            });
            return futures;
        }, ElanConstants.JOB_MAX_RETRIES);
    }
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ArrayList(java.util.ArrayList) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 9 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.

the class FibDSWriter method removeMacEntryFromDS.

public void removeMacEntryFromDS(String rd, String macAddress) {
    if (StringUtils.isEmpty(rd)) {
        LOG.error("Mac {} not associated with vpn", macAddress);
        return;
    }
    LOG.debug("Removing Mac fib entry with Mac {} from vrf table for rd {}", macAddress, rd);
    InstanceIdentifierBuilder<MacVrfEntry> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(MacVrfEntry.class, new MacVrfEntryKey(macAddress));
    InstanceIdentifier<MacVrfEntry> macEntryId = idBuilder.build();
    bgpUtil.delete(macEntryId);
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) MacVrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)

Example 10 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.

the class FibDSWriter method addMacEntryToDS.

public void addMacEntryToDS(String rd, String macAddress, String prefix, List<String> nextHopList, VrfEntry.EncapType encapType, long l2vni, String gatewayMacAddress, RouteOrigin origin) {
    if (StringUtils.isEmpty(rd)) {
        LOG.error("Mac {} not associated with vpn", macAddress);
        return;
    }
    Preconditions.checkNotNull(nextHopList, "NextHopList can't be null");
    for (String nextHop : nextHopList) {
        if (StringUtils.isEmpty(nextHop)) {
            LOG.error("nextHop list contains null element for macVrf");
            return;
        }
    }
    MacVrfEntryBuilder macEntryBuilder = new MacVrfEntryBuilder().setOrigin(origin.getValue());
    buildVpnEncapSpecificInfo(macEntryBuilder, encapType, l2vni, gatewayMacAddress, nextHopList);
    macEntryBuilder.setMac(macAddress);
    macEntryBuilder.setDestPrefix(prefix);
    InstanceIdentifier<MacVrfEntry> macEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(MacVrfEntry.class, new MacVrfEntryKey(macAddress)).build();
    bgpUtil.update(macEntryId, macEntryBuilder.build());
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) MacVrfEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryBuilder) MacVrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)

Aggregations

MacVrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)6 FibEntries (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries)5 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 BigInteger (java.math.BigInteger)4 ArrayList (java.util.ArrayList)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)4 VrfTables (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)4 MacVrfEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)2 MacVrfEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryBuilder)2 Nullable (javax.annotation.Nullable)1 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)1 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)1 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)1 EvpnRdToNetwork (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork)1 EvpnRdToNetworkKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey)1