use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.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.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class EffectiveRibInWriter method onRoutesDeleted.
private void onRoutesDeleted(final RIBSupport<?, ?> ribSupport, final YangInstanceIdentifier effectiveTablePath, final Collection<MapEntryNode> deletedRoutes) {
if (ribSupport.getSafi() == RouteTargetConstrainSubsequentAddressFamily.class) {
final YangInstanceIdentifier routesPath = routeMapPath(ribSupport, effectiveTablePath);
for (final MapEntryNode routeBefore : deletedRoutes) {
deleteRouteTarget(ribSupport, routesPath.node(routeBefore.getIdentifier()), routeBefore);
}
this.rtMembershipsUpdated = true;
}
final TablesKey tablesKey = ribSupport.getTablesKey();
CountersUtil.add(prefixesInstalled.get(tablesKey), tablesKey, -deletedRoutes.size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class SynchronizationAndExceptionTest method testHandleMessageAfterException.
@Test
public void testHandleMessageAfterException() {
final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy());
final RIBImpl ribImpl = new RIBImpl(this.tableRegistry, new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension, this.serverDispatcher, this.codecsRegistry, this.domBroker, this.policies, ImmutableList.of(this.ipv4tt), pathTables);
ribImpl.instantiateServiceInstance();
final BGPPeer bgpPeer = AbstractAddPathTest.configurePeer(this.tableRegistry, neighbor.getIpv4AddressNoZone(), ribImpl, null, PeerRole.Ibgp, this.serverRegistry, AFI_SAFIS_ADVERTIZED, Collections.emptySet());
bgpPeer.instantiateServiceInstance();
final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen, this.classicOpen.getHoldTimer().toJava(), null);
bgpSession.setChannelExtMsgCoder(this.classicOpen);
bgpPeer.onSessionUp(bgpSession);
final Nlri n1 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
final Nlri n2 = new NlriBuilder().setPrefix(new Ipv4Prefix("127.0.0.1/32")).build();
final Nlri n3 = new NlriBuilder().setPrefix(new Ipv4Prefix("2.2.2.2/24")).build();
final List<Nlri> nlris = Lists.newArrayList(n1, n2, n3);
final UpdateBuilder wrongMessage = new UpdateBuilder();
wrongMessage.setNlri(nlris);
final Origin origin = new OriginBuilder().setValue(BgpOrigin.Igp).build();
final AsPath asPath = new AsPathBuilder().setSegments(Collections.emptyList()).build();
final CNextHop nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("127.0.0.1")).build()).build();
final AttributesBuilder ab = new AttributesBuilder();
wrongMessage.setAttributes(ab.setOrigin(origin).setAsPath(asPath).setCNextHop(nextHop).build());
final UpdateBuilder correct = new UpdateBuilder(wrongMessage.build());
correct.setAttributes(ab.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build()).build());
bgpSession.handleMessage(correct.build());
verify(this.tx, times(2)).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
bgpSession.handleMessage(wrongMessage.build());
verify(this.tx, times(2)).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
bgpSession.handleMessage(new UpdateBuilder().build());
verify(this.tx, times(2)).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
verify(this.tx).delete(eq(LogicalDatastoreType.OPERATIONAL), eq(PEER_PATH));
verify(this.tx, times(0)).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(TABLE_PATH), eq(ImmutableNodes.leafNode(UPTODATE_NID, Boolean.TRUE)));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class GracefulRestartUtilTest method getLlGracefulTimersTest.
@Test
public void getLlGracefulTimersTest() {
final List<AfiSafi> afiSafi = new ArrayList<>();
afiSafi.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).setGracefulRestart(new GracefulRestartBuilder().setConfig(new ConfigBuilder().addAugmentation(new Config1Builder().setLlGracefulRestart(new LlGracefulRestartBuilder().setConfig(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.ll.graceful.restart.rev181112.afi.safi.ll.graceful.restart.ll.graceful.restart.ConfigBuilder().setLongLivedStaleTime(new Uint24(Uint32.valueOf(STALE_TIME))).build()).build()).build()).build()).build()).build());
final Map<TablesKey, Integer> llGracefulTimers = GracefulRestartUtil.getLlGracefulTimers(afiSafi, this.tableRegistry);
assertNotNull(llGracefulTimers);
assertEquals(1, llGracefulTimers.size());
assertEquals(STALE_TIME, llGracefulTimers.get(IPV4_KEY).intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class RibImplTest method testRibImpl.
@Test
public void testRibImpl() throws ExecutionException, InterruptedException {
final RibImpl ribImpl = new RibImpl(extension, dispatcher, policyProvider, codecsRegistry, new BGPStateCollector(), domDataBroker);
ribImpl.start(createGlobal(), "rib-test", tableTypeRegistry);
verify(domDataBroker).getExtensions();
assertEquals("RIBImpl{bgpId=Ipv4Address{_value=127.0.0.1}, localTables=[BgpTableTypeImpl [" + "getAfi()=interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types." + "rev200120.Ipv4AddressFamily, " + "getSafi()=interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types." + "rev200120.UnicastSubsequentAddressFamily]]}", ribImpl.toString());
assertEquals(Collections.singleton(new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)), ribImpl.getLocalTablesKeys());
assertNotNull(ribImpl.getService());
assertNotNull(ribImpl.getInstanceIdentifier());
assertEquals(AS, ribImpl.getLocalAs());
assertEquals(BGP_ID, ribImpl.getBgpIdentifier());
assertEquals(Collections.singleton(TABLE_TYPE), ribImpl.getLocalTables());
assertEquals(dispatcher, ribImpl.getDispatcher());
assertEquals(extension, ribImpl.getRibExtensions());
assertNotNull(ribImpl.getRibSupportContext());
assertNotNull(ribImpl.getCodecsRegistry());
ribImpl.stop().get();
}
Aggregations