use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri in project bgpcep by opendaylight.
the class SimpleNlriRegistry method convertMpReachToMpUnReach.
@Override
public Optional<MpUnreachNlri> convertMpReachToMpUnReach(final MpReachNlri mpReachNlri, final MpUnreachNlri mpUnreachNlri) {
if (mpUnreachNlri == null) {
return Optional.of(new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(mpReachNlri.getAdvertizedRoutes().getDestinationType()).build()).build());
}
final BgpTableType key = createKey(mpUnreachNlri.getAfi(), mpUnreachNlri.getSafi());
final NlriParser parser = this.handlers.get(key);
if (parser == null) {
LOG.debug("Parser for {} not found", key);
return Optional.empty();
}
final MpUnreachNlriBuilder builder = new MpUnreachNlriBuilder(mpUnreachNlri);
return parser.convertMpReachToMpUnReach(mpReachNlri, builder) ? Optional.of(builder.build()) : Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri in project bgpcep by opendaylight.
the class BGPPeer method nextHopToAttribute.
private static Attributes nextHopToAttribute(final Attributes attrs, final MpReachNlri mpReach) {
if (attrs.getCNextHop() == null && mpReach.getCNextHop() != null) {
final AttributesBuilder attributesBuilder = new AttributesBuilder(attrs);
attributesBuilder.setCNextHop(mpReach.getCNextHop());
return attributesBuilder.build();
}
return attrs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri in project bgpcep by opendaylight.
the class AbstractRIBSupport method buildUpdate.
@Override
public final Update buildUpdate(final Collection<MapEntryNode> advertised, final Collection<MapEntryNode> withdrawn, final Attributes attr) {
final UpdateBuilder ub = new UpdateBuilder();
final AttributesBuilder ab = new AttributesBuilder(attr);
final CNextHop hop = ab.getCNextHop();
LOG.debug("cnextHop before={}", hop);
// do not preserve next hop in attributes if we are using MpReach
ab.setCNextHop(null);
if (!advertised.isEmpty()) {
final MpReachNlri mb = buildReach(advertised, hop);
ab.addAugmentation(new AttributesReachBuilder().setMpReachNlri(mb).build());
LOG.debug("mpreach nexthop={}", mb);
}
if (!withdrawn.isEmpty()) {
final MpUnreachNlri mb = buildUnreach(withdrawn);
ab.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mb).build());
LOG.debug("mpunrach mb={}", mb);
}
ub.setAttributes(ab.build());
LOG.debug("update {}", ub.build());
return ub.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri 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.multiprotocol.rev180329.attributes.reach.MpReachNlri in project bgpcep by opendaylight.
the class PeerUtil method createUpdate.
static Update createUpdate(final BgpOrigin bgpOrigin, final List<Segments> pathSegments, // FIXME: consider using Uint32
final long preference, final MpReachNlri mpReach, final MpUnreachNlri mpUnreach) {
final Origin origin = new OriginBuilder().setValue(bgpOrigin).build();
final AsPath asPath = new AsPathBuilder().setSegments(pathSegments).build();
final LocalPref localPref = new LocalPrefBuilder().setPref(Uint32.valueOf(preference)).build();
final AttributesBuilder attributeBuilder = new AttributesBuilder().setOrigin(origin).setAsPath(asPath).setLocalPref(localPref);
if (mpReach != null) {
attributeBuilder.addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReach).build());
}
if (mpUnreach != null) {
attributeBuilder.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreach).build());
}
return new UpdateBuilder().setAttributes(new AttributesBuilder().setOrigin(origin).setAsPath(asPath).setLocalPref(localPref).addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReach).build()).build()).build();
}
Aggregations