Search in sources :

Example 6 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Rib in project bgpcep by opendaylight.

the class LocRibWriter method update.

@SuppressWarnings("unchecked")
private Map<RouteUpdateKey, RouteEntry> update(final WriteTransaction tx, final Collection<DataTreeModification<Tables>> changes) {
    final Map<RouteUpdateKey, RouteEntry> ret = new HashMap<>();
    for (final DataTreeModification<Tables> tc : changes) {
        final DataObjectModification<Tables> table = tc.getRootNode();
        final DataTreeIdentifier<Tables> rootPath = tc.getRootPath();
        final KeyedInstanceIdentifier<Peer, PeerKey> peerKIid = (KeyedInstanceIdentifier<Peer, PeerKey>) rootPath.getRootIdentifier().firstIdentifierOf(Peer.class);
        final UnsignedInteger peerUuid = RouterIds.routerIdForPeerId(peerKIid.getKey().getPeerId());
        /*
            Initialize Peer with routes under loc rib
             */
        if (!this.routeEntries.isEmpty() && table.getDataBefore() == null) {
            final org.opendaylight.protocol.bgp.rib.spi.Peer peer = this.peerTracker.getPeer(peerKIid.getKey().getPeerId());
            if (peer != null && peer.supportsTable(this.entryDep.getLocalTablesKey())) {
                LOG.debug("Peer {} table has been created, inserting existent routes", peer.getPeerId());
                this.routeEntries.forEach((key, value) -> value.initializeBestPaths(this.entryDep, new RouteEntryInfoImpl(peer, key), tx));
            }
        }
        /*
            Process new routes from Peer
             */
        updateNodes(table, peerUuid, tx, ret);
    }
    return ret;
}
Also used : RouteEntry(org.opendaylight.protocol.bgp.mode.api.RouteEntry) HashMap(java.util.HashMap) Peer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer) PeerKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.PeerKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) UnsignedInteger(com.google.common.primitives.UnsignedInteger)

Example 7 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Rib in project bgpcep by opendaylight.

the class BGPClusterSingletonService method onGlobalChanged.

synchronized void onGlobalChanged(final DataObjectModification<Global> dataObjectModification) {
    switch(dataObjectModification.getModificationType()) {
        case DELETE:
            LOG.debug("Removing RIB instance: {}", this.bgpIid);
            if (this.ribImpl != null) {
                LOG.debug("RIB instance removed {}", this.ribImpl);
                closeAllBindedPeers();
                closeRibService();
            }
            break;
        case SUBTREE_MODIFIED:
        case WRITE:
            final Global global = dataObjectModification.getDataAfter();
            if (this.ribImpl == null) {
                onGlobalCreated(global);
            } else if (!this.ribImpl.isGlobalEqual(global)) {
                onGlobalUpdated(global);
            }
            break;
        default:
            break;
    }
}
Also used : Global(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global)

Example 8 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Rib in project bgpcep by opendaylight.

the class ParserTest method testEORLS.

/*
     * End of Rib for LS consists of empty MP_UNREACH_NLRI, with AFI 16388 and SAFI 71
     *
     * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
     * 00 1d <- length (29) - including header
     * 02 <- message type
     * 00 00 <- withdrawn routes length
     * 00 06 <- total path attribute length
     * 80 <- attribute flags
     * 0f <- attribute type (15 - MP_UNREACH_NLRI)
     * 03 <- attribute length
     * 40 04 <- value (AFI 16388: LS)
     * 47 <- value (SAFI 71)
     */
@Test
public void testEORLS() throws Exception {
    final byte[] body = ByteArray.cutBytes(inputBytes.get(0), MessageUtil.COMMON_HEADER_LENGTH);
    final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(0), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
    final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
    final Class<? extends AddressFamily> afi = message.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getAfi();
    final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getSafi();
    assertEquals(LinkstateAddressFamily.class, afi);
    assertEquals(LinkstateSubsequentAddressFamily.class, safi);
    final ByteBuf buffer = Unpooled.buffer();
    ParserTest.updateParser.serializeMessage(message, buffer);
    assertArrayEquals(inputBytes.get(0), ByteArray.readAllBytes(buffer));
}
Also used : Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 9 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Rib in project bgpcep by opendaylight.

the class GlobalUtil method buildAfiSafi.

/**
 * Build Afi Safi containing State.
 *
 * @param ribState             containing RIb Operational State
 * @param tablesKey            table Key
 * @param bgpTableTypeRegistry BGP TableType Registry
 * @return Afi Safi Operational State
 */
public static AfiSafi buildAfiSafi(final BGPRibState ribState, final TablesKey tablesKey, final BGPTableTypeRegistryConsumer bgpTableTypeRegistry) {
    final Optional<Class<? extends AfiSafiType>> optAfiSafi = bgpTableTypeRegistry.getAfiSafiType(tablesKey);
    if (!optAfiSafi.isPresent()) {
        return null;
    }
    final State state = new StateBuilder().addAugmentation(GlobalAfiSafiStateAugmentation.class, new GlobalAfiSafiStateAugmentationBuilder().setTotalPaths(ribState.getPathCount(tablesKey)).setTotalPrefixes(ribState.getPrefixesCount(tablesKey)).build()).build();
    return new AfiSafiBuilder().setAfiSafiName(optAfiSafi.get()).setState(state).build();
}
Also used : GlobalAfiSafiStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentation) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) GlobalAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentationBuilder) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) State(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType)

Example 10 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Rib in project bgpcep by opendaylight.

the class ParserToSalTest method testWithLinkstate.

@Test
public void testWithLinkstate() throws ReadFailedException {
    final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
    final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2, this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
    rib.instantiateServiceInstance();
    assertTablesExists(tables);
    rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
    final BGPPeer peer = new BGPPeer(this.localAddress, rib, PeerRole.Ibgp, null, Collections.emptySet(), Collections.emptySet());
    peer.instantiateServiceInstance();
    final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
    reg.close();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) LinkstateSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.LinkstateSubsequentAddressFamily) LinkstateAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.LinkstateAddressFamily) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId)6 ByteBuf (io.netty.buffer.ByteBuf)4 Before (org.junit.Before)4 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)4 ChannelFuture (io.netty.channel.ChannelFuture)3 InetSocketAddress (java.net.InetSocketAddress)3 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)3 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)3 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)3 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)3 ExecutionException (java.util.concurrent.ExecutionException)2 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)2 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)2 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)2 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)2 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)2 BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId)2 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1