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 Ipv4NlriParserTest method setUp.
@Before
public void setUp() {
final Ipv4Prefix prefix1 = new Ipv4Prefix(this.ipPrefix1);
final Ipv4Prefix prefix2 = new Ipv4Prefix(this.ipPrefix2);
final Ipv4Prefix wrongPrefix = new Ipv4Prefix(this.additionalIpWD);
this.prefixes.add(new Ipv4PrefixesBuilder().setPrefix(prefix1).build());
this.prefixes.add(new Ipv4PrefixesBuilder().setPrefix(prefix2).build());
this.ip4caseWD = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(this.prefixes).build()).build();
this.ip4caseAD = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(this.prefixes).build()).build();
final ArrayList<Ipv4Prefixes> fakePrefixes = new ArrayList<>(this.prefixes);
fakePrefixes.add(new Ipv4PrefixesBuilder().setPrefix(wrongPrefix).build());
this.ip4caseWDWrong = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
this.ip4caseADWrong = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
final ByteBuf buffer1 = Unpooled.buffer(5);
Ipv4Util.writeMinimalPrefix(prefix1, buffer1);
this.inputBytes.writeBytes(buffer1.array());
final ByteBuf buffer2 = Unpooled.buffer(5);
Ipv4Util.writeMinimalPrefix(prefix2, buffer2);
this.inputBytes.writeBytes(buffer2.array());
Mockito.doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(Mockito.any());
Mockito.doReturn(true).when(this.muliPathSupport).isTableTypeSupported(Mockito.any());
}
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 prefixes.
private static DestinationIpv4 prefixes(final ByteBuf nlri, final PeerSpecificParserConstraint constraints, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
final List<Ipv4Prefixes> prefixes = new ArrayList<>();
while (nlri.isReadable()) {
final Ipv4PrefixesBuilder prefixesBuilder = new Ipv4PrefixesBuilder();
if (MultiPathSupportUtil.isTableTypeSupported(constraints, new BgpTableTypeImpl(afi, safi))) {
prefixesBuilder.setPathId(PathIdUtil.readPathId(nlri));
}
prefixesBuilder.setPrefix(Ipv4Util.prefixForByteBuf(nlri));
prefixes.add(prefixesBuilder.build());
}
return new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build();
}
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 insertRoutes.
private static void insertRoutes(final List<Ipv4Prefix> ipv4prefixes, final Ipv4AddressNoZone ipv4NeighborAddress, final List<Ipv6Prefix> ipv6prefixes, final Ipv6AddressNoZone ipv6NeighborAddress, final BGPSessionImpl session, final BgpOrigin peerRole) {
if (ipv4prefixes == null && ipv6prefixes == null) {
waitFutureSuccess(session.writeAndFlush(BgpPeerUtil.createEndOfRib(TABLES_KEY)));
waitFutureSuccess(session.writeAndFlush(BgpPeerUtil.createEndOfRib(IPV6_TABLES_KEY)));
return;
}
if (ipv4prefixes != null && !ipv4prefixes.isEmpty()) {
final MpReachNlri reachIpv4 = PeerUtil.createMpReachNlri(new IpAddressNoZone(ipv4NeighborAddress), ipv4prefixes.stream().map(IpPrefix::new).collect(Collectors.toList()));
final Update update1 = PeerUtil.createUpdate(peerRole, Collections.emptyList(), 100, reachIpv4, null);
waitFutureSuccess(session.writeAndFlush(update1));
}
if (ipv6prefixes != null && !ipv4prefixes.isEmpty()) {
final MpReachNlri reachIpv6 = PeerUtil.createMpReachNlri(new IpAddressNoZone(ipv6NeighborAddress), ipv6prefixes.stream().map(IpPrefix::new).collect(Collectors.toList()));
final Update update2 = PeerUtil.createUpdate(peerRole, Collections.emptyList(), 100, reachIpv6, null);
waitFutureSuccess(session.writeAndFlush(update2));
}
}
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 performLocalGracefulRestart.
/**
* Perform local graceful restart and verify routes are preserved.
*
* @throws Exception on reading Rib failure
*/
@Test
public void performLocalGracefulRestart() throws Exception {
final List<Ipv4Prefix> ipv4prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1), new Ipv4Prefix(PREFIX2));
final List<Ipv6Prefix> ipv6prefixes = Arrays.asList(new Ipv6Prefix(PREFIX3));
insertRoutes(ipv4prefixes, ipv6prefixes);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(1);
this.peer.restartGracefully(DEFERRAL_TIMER).get();
this.session = createPeerSession(PEER1, this.parameters, this.listener);
checkUpState(this.listener);
checkUpState(this.peer);
checkLocRibIpv4Routes(2);
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 GracefulRestartTest method waitForEORonLocalGracefulRestart.
/**
* Wait with route selection until EOT is received.
*
* @throws Exception on reading Rib failure
*/
@Test
public void waitForEORonLocalGracefulRestart() 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);
insertRoutes(null, null);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(1);
}
Aggregations