Search in sources :

Example 31 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method updateBestPaths.

@Override
public void updateBestPaths(final RouteEntryDependenciesContainer entryDependencies, final Identifier routeKey, final WriteTransaction tx) {
    final RIBSupport ribSupport = entryDependencies.getRibSupport();
    final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDependencies.getLocRibTableTarget();
    if (this.bestPathRemoved != null) {
        this.bestPathRemoved.forEach(path -> {
            final Identifier newRouteKey = ribSupport.createNewRouteKey(path.getPathId(), routeKey);
            final InstanceIdentifier routeTarget = ribSupport.createRouteIdentifier(locRibTarget, newRouteKey);
            LOG.debug("Delete route from LocRib {}", routeTarget);
            tx.delete(LogicalDatastoreType.OPERATIONAL, routeTarget);
        });
        this.bestPathRemoved = null;
    }
    if (this.removedPaths != null) {
        this.removedPaths.forEach(removedPath -> {
            final Identifier routeKeyAddPath = ribSupport.createNewRouteKey(removedPath.getPathId(), routeKey);
            final Identifier routeKeyNonAddPath = ribSupport.createNewRouteKey(NON_PATH_ID_VALUE, routeKey);
            fillAdjRibsOut(true, null, null, null, routeKeyNonAddPath, routeKeyAddPath, RouterIds.createPeerId(removedPath.getRouteId()), entryDependencies.getLocalTablesKey(), entryDependencies, tx);
        });
        this.removedPaths = null;
    }
    if (this.newBestPathToBeAdvertised != null) {
        this.newBestPathToBeAdvertised.forEach(path -> addPathToDataStore(entryDependencies, path, isFirstBestPath(this.bestPath.indexOf(path)), routeKey, tx));
        this.newBestPathToBeAdvertised = null;
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)

Example 32 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.

the class AddPathAbstractRouteEntry method addPathToDataStore.

private void addPathToDataStore(final RouteEntryDependenciesContainer entryDep, final AddPathBestPath path, final boolean isFirstBestPath, final Identifier routeKey, final WriteTransaction tx) {
    final RIBSupport ribSup = entryDep.getRibSupport();
    final Identifier routeKeyAddPath = ribSup.createNewRouteKey(path.getPathId(), routeKey);
    final Identifier routeKeyAddNonPath = ribSup.createNewRouteKey(NON_PATH_ID_VALUE, routeKey);
    final Route routeAddPath = createRoute(ribSup, routeKeyAddPath, path.getPathId(), path);
    final Route routeNonAddPath = createRoute(ribSup, routeKeyAddNonPath, NON_PATH_ID_VALUE, path);
    final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDep.getLocRibTableTarget();
    final InstanceIdentifier routeTarget = ribSup.createRouteIdentifier(locRibTarget, routeKeyAddPath);
    LOG.debug("Write route to LocRib {}", routeAddPath);
    tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, routeAddPath);
    fillAdjRibsOut(isFirstBestPath, path.getAttributes(), routeNonAddPath, routeAddPath, routeKeyAddNonPath, routeKeyAddPath, path.getPeerId(), entryDep.getLocalTablesKey(), entryDep, tx);
}
Also used : InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 33 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.

the class GracefulCapabilityHandler method serializeTables.

private void serializeTables(final List<Tables> tables, final ByteBuf bytes) {
    if (tables == null) {
        return;
    }
    for (final Tables t : tables) {
        final Class<? extends AddressFamily> afi = t.getAfi();
        final Integer afival = this.afiReg.numberForClass(afi);
        Preconditions.checkArgument(afival != null, "Unhandled address family " + afi);
        bytes.writeShort(afival);
        final Class<? extends SubsequentAddressFamily> safi = t.getSafi();
        final Integer safival = this.safiReg.numberForClass(safi);
        Preconditions.checkArgument(safival != null, "Unhandled subsequent address family " + safi);
        bytes.writeByte(safival);
        if (t.getAfiFlags() != null && t.getAfiFlags().isForwardingState()) {
            bytes.writeByte(AFI_FLAG_FORWARDING_STATE);
        } else {
            bytes.writeZero(1);
        }
    }
}
Also used : Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables)

Example 34 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project netvirt by opendaylight.

the class InterVpnLinkListener method removeVpnLinkEndpointFlows.

// We're catching Exception here to continue deleting as much as possible
// TODO Rework this so it's done in one transaction
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeVpnLinkEndpointFlows(InterVpnLink del, String vpnUuid, String rd, List<BigInteger> dpns, int otherEndpointLportTag, String otherEndpointIpAddr, List<VrfEntry> vrfEntries, final boolean isVpnFirstEndPoint) {
    String interVpnLinkName = del.getName();
    LOG.debug("Removing endpoint flows for vpn {}.  InterVpnLink={}.  OtherEndpointLportTag={}", vpnUuid, interVpnLinkName, otherEndpointLportTag);
    if (dpns == null) {
        LOG.debug("VPN {} endpoint is not instantiated in any DPN for InterVpnLink {}", vpnUuid, interVpnLinkName);
        return;
    }
    for (BigInteger dpnId : dpns) {
        try {
            // Removing flow from LportDispatcher table
            String flowRef = InterVpnLinkUtil.getLportDispatcherFlowRef(interVpnLinkName, otherEndpointLportTag);
            FlowKey flowKey = new FlowKey(new FlowId(flowRef));
            Flow flow = new FlowBuilder().setKey(flowKey).setId(new FlowId(flowRef)).setTableId(NwConstants.LPORT_DISPATCHER_TABLE).setFlowName(flowRef).build();
            mdsalManager.removeFlow(dpnId, flow);
            // Also remove the 'fake' iface from the VpnToDpn map
            InterVpnLinkUtil.removeIVpnLinkIfaceFromVpnFootprint(vpnFootprintService, vpnUuid, rd, dpnId);
        } catch (Exception e) {
            // Whatever happens it should not stop it from trying to remove as much as possible
            LOG.warn("Error while removing InterVpnLink {} Endpoint flows on dpn {}. Reason: ", interVpnLinkName, dpnId, e);
        }
    }
    // Removing flow from FIB and LFIB tables
    LOG.trace("Removing flow in FIB and LFIB tables for vpn {} interVpnLink {} otherEndpointIpAddr {}", vpnUuid, interVpnLinkName, otherEndpointIpAddr);
    cleanUpInterVPNRoutes(interVpnLinkName, vrfEntries, isVpnFirstEndPoint);
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) BigInteger(java.math.BigInteger) ExecutionException(java.util.concurrent.ExecutionException) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 35 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project netvirt by opendaylight.

the class ExternalRoutersListener method handleEnableSnat.

public void handleEnableSnat(Routers routers, long routerId, BigInteger primarySwitchId, long bgpVpnId, WriteTransaction writeFlowInvTx) {
    String routerName = routers.getRouterName();
    LOG.info("handleEnableSnat : Handling SNAT for router {}", routerName);
    naptManager.initialiseExternalCounter(routers, routerId);
    subnetRegisterMapping(routers, routerId);
    LOG.debug("handleEnableSnat:About to create and install outbound miss entry in Primary Switch {} for router {}", primarySwitchId, routerName);
    ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, routers.getNetworkId());
    if (extNwProvType == null) {
        LOG.error("handleEnableSnat : External Network Provider Type missing");
        return;
    }
    if (bgpVpnId != NatConstants.INVALID_ID) {
        installFlowsWithUpdatedVpnId(primarySwitchId, routerName, bgpVpnId, routerId, false, writeFlowInvTx, extNwProvType);
    } else {
        // write metadata and punt
        installOutboundMissEntry(routerName, routerId, primarySwitchId, writeFlowInvTx);
        // Now install entries in SNAT tables to point to Primary for each router
        List<BigInteger> switches = naptSwitchSelector.getDpnsForVpn(routerName);
        for (BigInteger dpnId : switches) {
            // Handle switches and NAPT switches separately
            if (!dpnId.equals(primarySwitchId)) {
                LOG.debug("handleEnableSnat : Handle Ordinary switch");
                handleSwitches(dpnId, routerName, routerId, primarySwitchId);
            } else {
                LOG.debug("handleEnableSnat : Handle NAPT switch");
                handlePrimaryNaptSwitch(dpnId, routerName, routerId, writeFlowInvTx);
            }
        }
    }
    Collection<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerId);
    if (externalIps.isEmpty()) {
        LOG.error("handleEnableSnat : Internal External mapping not found for router {}", routerName);
        return;
    } else {
        for (String externalIpAddrPrefix : externalIps) {
            LOG.debug("handleEnableSnat : Calling handleSnatReverseTraffic for primarySwitchId {}, " + "routerName {} and externalIpAddPrefix {}", primarySwitchId, routerName, externalIpAddrPrefix);
            handleSnatReverseTraffic(primarySwitchId, routers, routerId, routerName, externalIpAddrPrefix, writeFlowInvTx);
        }
    }
    LOG.debug("handleEnableSnat : Exit");
}
Also used : ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) BigInteger(java.math.BigInteger)

Aggregations

Test (org.junit.Test)12 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)10 ArrayList (java.util.ArrayList)9 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)9 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)7 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)6 ByteBuf (io.netty.buffer.ByteBuf)6 Map (java.util.Map)6 ExecutionException (java.util.concurrent.ExecutionException)6 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)6 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 HashMap (java.util.HashMap)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 BigInteger (java.math.BigInteger)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)4 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)4