use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.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;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.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);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.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");
}
Aggregations