Search in sources :

Example 11 with MpReachNlri

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();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder) NlriParser(org.opendaylight.protocol.bgp.parser.spi.NlriParser) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlriBuilder)

Example 12 with MpReachNlri

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;
}
Also used : AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)

Example 13 with MpReachNlri

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();
}
Also used : AttributesUnreachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder) AttributesReachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.CNextHop) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri)

Example 14 with MpReachNlri

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));
    }
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri)

Example 15 with MpReachNlri

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();
}
Also used : Origin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin) BgpOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpOrigin) LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder) AttributesUnreachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder) AsPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPath) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref) AttributesReachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)

Aggregations

MpReachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri)22 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlriBuilder)20 ByteBuf (io.netty.buffer.ByteBuf)17 Test (org.junit.Test)17 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)15 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutesBuilder)15 AttributesReachBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder)12 MpUnreachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri)7 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)6 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder)5 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)5 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)5 UnicastSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily)5 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)5 Ipv4NextHopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder)5 ArrayList (java.util.ArrayList)4 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)4 Attributes1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder)4 MpReachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri)4 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)4