use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class BmpRibInWriter method removeRoutes.
private synchronized void removeRoutes(final MpUnreachNlri nlri) {
final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
final TableContext ctx = this.tables.get(key);
if (ctx == null) {
LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
return;
}
LOG.trace("Removing routes {}", nlri);
final DOMDataTreeWriteTransaction tx = this.chain.newWriteOnlyTransaction();
ctx.removeRoutes(tx, nlri);
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Successful commit");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed commit", trw);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class BmpRibInWriter method checkEndOfRib.
/**
* For each received Update message, the upd sync variable needs to be updated to true, for particular AFI/SAFI
* combination. Currently we only assume Unicast SAFI. From the Update message we have to extract the AFI. Each
* Update message can contain BGP Object with one type of AFI. If the object is BGP Link, BGP Node or a BGPPrefix
* the AFI is Linkstate. In case of BGPRoute, the AFI depends on the IP Address of the prefix.
*
* @param msg received Update message
*/
private boolean checkEndOfRib(final UpdateMessage msg) {
TablesKey type = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
boolean isEOR = false;
if (msg.getNlri() == null && msg.getWithdrawnRoutes() == null) {
if (msg.getAttributes() != null) {
if (msg.getAttributes().augmentation(AttributesReach.class) != null) {
final AttributesReach pa = msg.getAttributes().augmentation(AttributesReach.class);
if (pa.getMpReachNlri() != null) {
type = new TablesKey(pa.getMpReachNlri().getAfi(), pa.getMpReachNlri().getSafi());
}
} else if (msg.getAttributes().augmentation(AttributesUnreach.class) != null) {
final AttributesUnreach pa = msg.getAttributes().augmentation(AttributesUnreach.class);
if (pa.getMpUnreachNlri() != null) {
type = new TablesKey(pa.getMpUnreachNlri().getAfi(), pa.getMpUnreachNlri().getSafi());
}
if (pa.getMpUnreachNlri().getWithdrawnRoutes() == null) {
// EOR message contains only MPUnreach attribute and no NLRI
isEOR = true;
}
}
} else {
// true for empty Update Message
isEOR = true;
}
}
if (isEOR) {
markTableUptodated(type);
LOG.debug("BMP Synchronization finished for table {} ", type);
}
return isEOR;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class Ipv4ReachabilityTopologyBuilderTest method setUp.
@Before
@Override
public void setUp() {
super.setUp();
this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID);
this.ipv4TopoBuilder.start();
final InstanceIdentifier<Tables> path = LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class).child(Tables.class, new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)).build();
this.ipv4RouteIID = path.builder().child(Ipv4RoutesCase.class, Ipv4Routes.class).child(Ipv4Route.class, new Ipv4RouteKey(new PathId(PATH_ID), ROUTE_IP4PREFIX)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class AbstractPeer method installRouteRibOut.
private <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>> void installRouteRibOut(final RouteEntryDependenciesContainer entryDep, final List<AdvertizedRoute<C, S>> routes, final DOMDataTreeWriteOperations tx) {
final RIBSupport<C, S> ribSupport = entryDep.getRIBSupport();
final TablesKey tk = ribSupport.getTablesKey();
final BGPPeerTracker peerTracker = entryDep.getPeerTracker();
final boolean addPathSupported = supportsAddPathSupported(tk);
final YangInstanceIdentifier tableRibout = getRibOutIId(ribSupport.tablesKey());
for (final AdvertizedRoute<C, S> advRoute : routes) {
final PeerId fromPeerId = advRoute.getFromPeerId();
if (!filterRoutes(fromPeerId, tk) || !advRoute.isFirstBestPath() && !addPathSupported) {
continue;
}
if (!supportsLLGR() && advRoute.isDepreferenced()) {
// https://tools.ietf.org/html/draft-uttaro-idr-bgp-persistence-04#section-4.3
// o The route SHOULD NOT be advertised to any neighbor from which the
// Long-lived Graceful Restart Capability has not been received. The
// exception is described in the Optional Partial Deployment
// Procedure section (Section 4.7). Note that this requirement
// implies that such routes should be withdrawn from any such
// neighbor.
deleteRoute(ribSupport, addPathSupported, tableRibout, advRoute, tx);
continue;
}
final Peer fromPeer = peerTracker.getPeer(fromPeerId);
final ContainerNode attributes = advRoute.getAttributes();
if (fromPeer != null && attributes != null) {
final YangInstanceIdentifier routePath = createRoutePath(ribSupport, tableRibout, advRoute, addPathSupported);
final MapEntryNode route = advRoute.getRoute();
applyExportPolicy(entryDep, fromPeerId, route, routePath, attributes).ifPresent(attrs -> storeRoute(ribSupport, advRoute, route, routePath, attrs, tx));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class AdjRibOutListener method onDataTreeChanged.
@Override
public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
LOG.debug("Data change received for AdjRibOut {}", changes);
for (final DataTreeCandidate tc : changes) {
LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().getModificationType());
for (final DataTreeCandidateNode child : tc.getRootNode().getChildNodes()) {
for (final DataTreeCandidateNode route : support.changedRoutes(child)) {
processRouteChange(route);
}
}
}
if (initalState) {
final Update endOfRib = BgpPeerUtil.createEndOfRib(tablesKey);
session.write(endOfRib);
initalState = false;
}
session.flush();
}
Aggregations