use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes in project bgpcep by opendaylight.
the class GracefulRestartTest method verifySendEORafterRestartTest.
/**
* After graceful restart is performed from peer side we have to re-advertise routes followed by
* End-of-RIB marker.
*
* @throws Exception on reading Rib failure
*/
@Test
public void verifySendEORafterRestartTest() throws Exception {
final SimpleSessionListener listener2 = new SimpleSessionListener();
configurePeer(this.tableRegistry, PEER2, this.ribImpl, this.parameters, PeerRole.Ebgp, this.serverRegistry, afiSafiAdvertised, gracefulAfiSafiAdvertised);
final BGPSessionImpl session2 = createPeerSession(PEER2, this.parameters, listener2);
final List<Ipv4Prefix> ipv4Prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
final List<Ipv4Prefix> ipv4Prefixes2 = Arrays.asList(new Ipv4Prefix(PREFIX2));
final List<Ipv6Prefix> ipv6Prefixes = Collections.singletonList(new Ipv6Prefix(PREFIX3));
insertRoutes(ipv4Prefixes, ipv6Prefixes);
insertRoutes(ipv4Prefixes2, PEER2, null, null, session2, BgpOrigin.Egp);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(1);
org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 3);
// verify sending of Ipv4 EOT, Ipv6 EOT and Ipv4 update with route
checkReceivedMessages(this.listener, 3);
assertTrue(this.listener.getListMsg().get(0) instanceof Update);
assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(0)));
assertTrue(this.listener.getListMsg().get(1) instanceof Update);
assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(1)));
assertTrue(this.listener.getListMsg().get(2) instanceof Update);
assertFalse(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(2)));
this.session.close();
checkIdleState(this.peer);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(0);
// verify nothing new was sent
checkReceivedMessages(this.listener, 3);
this.session = createPeerSession(PEER1, createParameter(false, true, Collections.singletonMap(TABLES_KEY, true)), this.listener);
checkUpState(listener);
checkUpState(this.peer);
org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 6);
// verify sending of Ipv4 update with route, Ipv4 EOT and Ipv6 EOT; order can vary based on ODTC order
final List<Notification> subList = this.listener.getListMsg().subList(3, 6);
int eotCount = 0;
int routeUpdateCount = 0;
for (Notification message : subList) {
if (BgpPeerUtil.isEndOfRib((Update) message)) {
eotCount++;
} else {
routeUpdateCount++;
}
}
assertEquals(2, eotCount);
assertEquals(1, routeUpdateCount);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes in project bgpcep by opendaylight.
the class GracefulRestartTest method waitForDeferralTimerOnLocalGracefulRestart.
/**
* Wait with route selection until deferral time is expired.
*
* @throws Exception on reading Rib failure
*/
@Test
public void waitForDeferralTimerOnLocalGracefulRestart() throws Exception {
performLocalGracefulRestart();
final List<Ipv4Prefix> ipv4prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
final List<Ipv6Prefix> ipv6prefixes = Arrays.asList(new Ipv6Prefix(PREFIX3));
insertRoutes(ipv4prefixes, ipv6prefixes);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(0);
checkStateIsNotRestarting(this.peer, DEFERRAL_TIMER);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(1);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes in project bgpcep by opendaylight.
the class GracefulRestartTest method removeStaleRoutesAfterRestartTest.
/**
* Once the End-of-RIB marker for an address family is received from the peer, it MUST
* immediately remove any routes from the peer that are still marked as stale for that
* address family.
*
* @throws Exception on reading Rib failure
*/
@Test
public void removeStaleRoutesAfterRestartTest() throws Exception {
retainRoutesOnPeerRestartTest();
this.session = createPeerSession(PEER1, createParameter(false, true, Collections.singletonMap(TABLES_KEY, true)), this.listener);
checkUpState(this.listener);
final List<Ipv4Prefix> ipv4prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
insertRoutes(ipv4prefixes, null);
insertRoutes(null, null);
checkLocRibIpv4Routes(1);
checkLocRibIpv6Routes(0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes in project bgpcep by opendaylight.
the class IPv4RIBSupport method extractPrefixes.
private List<Ipv4Prefixes> extractPrefixes(final Collection<MapEntryNode> routes) {
final List<Ipv4Prefixes> prefs = new ArrayList<>(routes.size());
for (final MapEntryNode route : routes) {
final String prefix = (String) NormalizedNodes.findNode(route, routePrefixIdentifier()).get().body();
final Ipv4PrefixesBuilder prefixBuilder = new Ipv4PrefixesBuilder().setPrefix(new Ipv4Prefix(prefix));
prefixBuilder.setPathId(PathIdUtil.buildPathId(route, routePathIdNid()));
prefs.add(prefixBuilder.build());
}
return prefs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes in project bgpcep by opendaylight.
the class Ipv4NlriParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
final AttributesUnreach pathAttributes2 = pathAttributes.augmentation(AttributesUnreach.class);
if (pathAttributes1 != null) {
final AdvertizedRoutes advertizedRoutes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (advertizedRoutes != null && advertizedRoutes.getDestinationType() instanceof DestinationIpv4Case) {
final DestinationIpv4Case destinationIpv4Case = (DestinationIpv4Case) advertizedRoutes.getDestinationType();
for (final Ipv4Prefixes ipv4Prefix : destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes()) {
PathIdUtil.writePathId(ipv4Prefix.getPathId(), byteAggregator);
Ipv4Util.writeMinimalPrefix(ipv4Prefix.getPrefix(), byteAggregator);
}
}
} else if (pathAttributes2 != null) {
final WithdrawnRoutes withdrawnRoutes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case destinationIpv4Case = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case) withdrawnRoutes.getDestinationType();
for (final Ipv4Prefixes ipv4Prefix : destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes()) {
PathIdUtil.writePathId(ipv4Prefix.getPathId(), byteAggregator);
Ipv4Util.writeMinimalPrefix(ipv4Prefix.getPrefix(), byteAggregator);
}
}
}
}
Aggregations