import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
-import static org.opendaylight.protocol.bgp.rib.spi.RouterIds.createPeerId;
+import static org.opendaylight.protocol.util.CheckUtil.readData;
+import static org.opendaylight.protocol.util.CheckUtil.waitFutureSuccess;
import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import com.google.common.net.InetAddresses;
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelOption;
import io.netty.channel.epoll.Epoll;
-import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.util.concurrent.DefaultPromise;
-import java.net.InetAddress;
+import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
import javassist.ClassPool;
import org.junit.After;
import org.junit.Assert;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.protocol.bgp.inet.RIBActivator;
+import org.opendaylight.protocol.bgp.parser.BGPError;
+import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
import org.opendaylight.protocol.bgp.parser.impl.BGPActivator;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.NotifyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Open;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.PathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.UpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.update.message.WithdrawnRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.CParameters1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.CParameters1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.SendReceive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.mp.reach.nlri.AdvertizedRoutes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.BgpRib;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.Peer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
class AbstractAddPathTest extends AbstractDataBrokerTest {
+ private static final int RETRY_TIMER = 10;
static final String RIB_ID = "127.0.0.1";
+ static final BgpId BGP_ID = new BgpId(RIB_ID);
static final Ipv4Address PEER1 = new Ipv4Address("127.0.0.2");
static final Ipv4Address PEER2 = new Ipv4Address("127.0.0.3");
static final Ipv4Address PEER3 = new Ipv4Address("127.0.0.4");
static final int PORT = InetSocketAddressUtil.getRandomPort();
static final Ipv4Prefix PREFIX1 = new Ipv4Prefix("1.1.1.1/32");
private static final ClusterIdentifier CLUSTER_ID = new ClusterIdentifier(RIB_ID);
- private static final PeerId PEER1_ID = createPeerId(PEER1);
- private static final PeerId PEER2_ID = createPeerId(PEER2);
- private static final PeerId PEER3_ID = createPeerId(PEER3);
- private static final PeerId PEER4_ID = createPeerId(PEER4);
- private static final PeerId PEER5_ID = createPeerId(PEER5);
- private static final int HOLDTIMER = 2180;
+ static final int HOLDTIMER = 2180;
private static final Ipv4Address NH1 = new Ipv4Address("2.2.2.2");
static final Update UPD_100 = createSimpleUpdate(PREFIX1, new PathId(1L), CLUSTER_ID, 100);
static final Update UPD_50 = createSimpleUpdate(PREFIX1, new PathId(2L), CLUSTER_ID, 50);
static final Update UPD_200 = createSimpleUpdate(PREFIX1, new PathId(3L), CLUSTER_ID, 200);
static final Update UPD_20 = createSimpleUpdate(PREFIX1, new PathId(1L), CLUSTER_ID, 20);
static final Update UPD_NA_100 = createSimpleUpdate(PREFIX1, null, CLUSTER_ID, 100);
- static final Update UPD_NA_100_EBGP = createSimpleUpdateEbgp(PREFIX1, null);
+ static final Update UPD_NA_100_EBGP = createSimpleUpdateEbgp(PREFIX1);
static final Update UPD_NA_200 = createSimpleUpdate(PREFIX1, null, CLUSTER_ID, 200);
- static final Update UPD_NA_200_EBGP = createSimpleUpdateEbgp(PREFIX1, null);
- protected BGPExtensionProviderContext context;
+ static final Update UPD_NA_200_EBGP = createSimpleUpdateEbgp(PREFIX1);
+ static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ static final List<BgpTableType> TABLES_TYPE = ImmutableList.of(new BgpTableTypeImpl(TABLES_KEY.getAfi(),
+ TABLES_KEY.getSafi()));
+ static final Set<TablesKey> AFI_SAFIS_ADVERTIZED = Collections.singleton(TABLES_KEY);
+ private BGPExtensionProviderContext context;
+ private static final InstanceIdentifier<BgpRib> BGP_IID = InstanceIdentifier.create(BgpRib.class);
protected SchemaContext schemaContext;
@Mock
protected ClusterSingletonServiceProvider clusterSingletonServiceProvider;
BindingToNormalizedNodeCodec mappingService;
- BGPDispatcherImpl dispatcher;
+ BGPDispatcherImpl serverDispatcher;
RIBExtensionProviderContext ribExtension;
private RIBActivator ribActivator;
private BGPActivator bgpActivator;
private NioEventLoopGroup worker;
private NioEventLoopGroup boss;
private org.opendaylight.protocol.bgp.inet.BGPActivator inetActivator;
+ protected StrictBGPPeerRegistry serverRegistry;
@Before
public void setUp() throws Exception {
this.bgpActivator.start(this.context);
this.inetActivator.start(this.context);
- this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
- new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
+ this.mappingService = new BindingToNormalizedNodeCodec(
+ GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
+ new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(
+ JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MpReachNlri.class));
this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
this.schemaContext = moduleInfoBackedContext.getSchemaContext();
-
- this.worker = new NioEventLoopGroup();
- this.boss = new NioEventLoopGroup();
- this.dispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker);
+ if (!Epoll.isAvailable()) {
+ this.worker = new NioEventLoopGroup();
+ this.boss = new NioEventLoopGroup();
+ }
+ this.serverRegistry = new StrictBGPPeerRegistry();
+ this.serverDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker,
+ this.serverRegistry);
doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
.registerClusterSingletonService(any(ClusterSingletonService.class));
}
@After
- public void tearDown() {
- this.dispatcher.close();
- this.worker.shutdownGracefully().awaitUninterruptibly();
- this.boss.shutdownGracefully().awaitUninterruptibly();
+ public void tearDown() throws ExecutionException, InterruptedException {
+ this.serverDispatcher.close();
+ if (!Epoll.isAvailable()) {
+ this.worker.shutdownGracefully(0, 0, TimeUnit.SECONDS);
+ this.boss.shutdownGracefully(0, 0, TimeUnit.SECONDS);
+ }
this.mappingService.close();
this.ribActivator.close();
this.inetActivator.close();
this.bgpActivator.close();
}
- void checkRibOut(final int nAddPathRoutesExpected) throws ExecutionException, InterruptedException {
- final ReadOnlyTransaction rTx = getDataBroker().newReadOnlyTransaction();
- final BgpRib bgpRib = rTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(BgpRib.class)).get().get();
- rTx.close();
-
- //check peer's rib-out
- for (final Peer peer : bgpRib.getRib().get(0).getPeer()) {
- final int ribOut = getPeerRibOutSize(peer);
- if (peer.getPeerId().equals(PEER1_ID)) {
- Assert.assertEquals(0, ribOut);
- } else if (peer.getPeerId().equals(PEER2_ID)) {
- Assert.assertEquals(0, ribOut);
- } else if (peer.getPeerId().equals(PEER3_ID)) {
- Assert.assertEquals(0, ribOut);
- } else if (peer.getPeerId().equals(PEER4_ID)) {
- Assert.assertEquals(1, ribOut);
- } else if (peer.getPeerId().equals(PEER5_ID)) {
- Assert.assertEquals(nAddPathRoutesExpected, ribOut);
- } else {
- Assert.fail("Failed to verify " + peer);
- }
- }
- }
-
- void sendRouteAndCheckIsOnLocRib(final Channel session, final Ipv4Prefix prefix, final long localPreference, final int expectedRoutesOnDS)
- throws InterruptedException, ExecutionException {
- session.writeAndFlush(createSimpleUpdate(prefix, null, null, localPreference));
- Thread.sleep(2000);
+ void sendRouteAndCheckIsOnLocRib(final BGPSessionImpl session, final Ipv4Prefix prefix, final long localPreference,
+ final int expectedRoutesOnDS) throws Exception {
+ waitFutureSuccess(session.writeAndFlush(createSimpleUpdate(prefix, null, null, localPreference)));
checkLocRib(expectedRoutesOnDS);
-
}
- void sendWithdrawalRouteAndCheckIsOnLocRib(final Channel session, final Ipv4Prefix prefix, final long localPreference, final int expectedRoutesOnDS)
- throws InterruptedException, ExecutionException {
- session.writeAndFlush(createSimpleWithdrawalUpdate(prefix, localPreference));
- Thread.sleep(2000);
+ void sendWithdrawalRouteAndCheckIsOnLocRib(final BGPSessionImpl session, final Ipv4Prefix prefix,
+ final long localPreference, final int expectedRoutesOnDS) throws Exception {
+ waitFutureSuccess(session.writeAndFlush(createSimpleWithdrawalUpdate(prefix, localPreference)));
checkLocRib(expectedRoutesOnDS);
}
- private void checkLocRib(final int expectedRoutesOnDS) throws ExecutionException, InterruptedException {
- final ReadOnlyTransaction rTx = getDataBroker().newReadOnlyTransaction();
- final BgpRib bgpRib = rTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(BgpRib.class)).get().get();
- rTx.close();
- final Ipv4RoutesCase routes = ((Ipv4RoutesCase) bgpRib.getRib().get(0).getLocRib().getTables().get(0).getRoutes());
- final List<Ipv4Route> routeList = routes.getIpv4Routes().getIpv4Route();
- Assert.assertEquals(expectedRoutesOnDS, routeList.size());
+ void sendNotification(final BGPSessionImpl session) {
+ final Notification notMsg = new NotifyBuilder().setErrorCode(BGPError.OPT_PARAM_NOT_SUPPORTED.getCode())
+ .setErrorSubcode(BGPError.OPT_PARAM_NOT_SUPPORTED.getSubcode()).setData(new byte[] { 4, 9 }).build();
+ waitFutureSuccess(session.writeAndFlush(notMsg));
}
- void checkPeersPresentOnDataStore(final int numberOfPeers) throws ExecutionException, InterruptedException {
- Thread.sleep(1000);
- final ReadOnlyTransaction rTx = getDataBroker().newReadOnlyTransaction();
- final BgpRib bgpRib = rTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(BgpRib.class)).get().get();
- rTx.close();
-
- //check 5 peers present in the DS
- Assert.assertEquals(numberOfPeers, bgpRib.getRib().get(0).getPeer().size());
+ void causeBGPError(final BGPSessionImpl session) {
+ final Open openObj = new OpenBuilder().setBgpIdentifier(new Ipv4Address("1.1.1.1"))
+ .setHoldTimer(50).setMyAsNumber(72).build();
+ waitFutureSuccess(session.writeAndFlush(openObj));
}
- Channel createPeerSession(final Ipv4Address peer, final PeerRole peerRole, final BgpParameters nonAddPathParams, final RIBImpl ribImpl,
- final BGPHandlerFactory hf, final SimpleSessionListener sessionListsner) throws InterruptedException, ExecutionException {
- configurePeer(peer, ribImpl, nonAddPathParams, peerRole);
- return connectPeer(peer, nonAddPathParams, this.dispatcher, hf, sessionListsner);
+ private void checkLocRib(final int expectedRoutesOnDS) throws Exception {
+ Thread.sleep(100);
+ readData(getDataBroker(), BGP_IID, bgpRib -> {
+ final Ipv4RoutesCase routes = ((Ipv4RoutesCase) bgpRib.getRib().get(0).getLocRib().getTables().get(0)
+ .getRoutes());
+ final List<Ipv4Route> routeList = routes.getIpv4Routes().getIpv4Route();
+ Assert.assertEquals(expectedRoutesOnDS, routeList.size());
+ return bgpRib;
+ });
}
- private static int getPeerRibOutSize(final Peer peer) {
- return ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.bgp.rib.rib.peer.adj.rib.out.tables.routes.Ipv4RoutesCase) peer.getAdjRibOut().getTables().get(0).getRoutes()).getIpv4Routes().getIpv4Route().size();
+ void checkPeersPresentOnDataStore(final int numberOfPeers) throws Exception {
+ readData(getDataBroker(), BGP_IID, bgpRib -> {
+ Assert.assertEquals(numberOfPeers, bgpRib.getRib().get(0).getPeer().size());
+ return bgpRib;
+ });
}
- private static ChannelFuture createClient(final BGPDispatcherImpl dispatcher, final InetSocketAddress remoteAddress,
- final BGPPeerRegistry registry, final InetSocketAddress localAddress, final BGPHandlerFactory hf) throws InterruptedException {
- final BGPClientSessionNegotiatorFactory snf = new BGPClientSessionNegotiatorFactory(registry);
+ BGPSessionImpl createPeerSession(final Ipv4Address peer, final BgpParameters bgpParameters,
+ final SimpleSessionListener sessionListener) throws InterruptedException {
+ StrictBGPPeerRegistry clientRegistry = new StrictBGPPeerRegistry();
+ BGPDispatcherImpl clientDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss,
+ this.worker, clientRegistry);
+ clientRegistry.addPeer(new IpAddress(new Ipv4Address(RIB_ID)), sessionListener,
+ new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(peer),
+ AS_NUMBER, Lists.newArrayList(bgpParameters), Optional.absent()));
- final Bootstrap bootstrap = dispatcher.createClientBootStrap(Optional.absent(), Epoll.isAvailable() ? new EpollEventLoopGroup() : new NioEventLoopGroup());
- bootstrap.localAddress(localAddress);
- bootstrap.option(ChannelOption.SO_REUSEADDR, true);
- bootstrap.handler(new ChannelInitializer<SocketChannel>() {
- @Override
- protected void initChannel(final SocketChannel ch) throws Exception {
- ch.pipeline().addLast(hf.getDecoders());
- ch.pipeline().addLast("negotiator", snf.getSessionNegotiator(ch, new DefaultPromise<>(ch.eventLoop())));
- ch.pipeline().addLast(hf.getEncoders());
- }
- });
- return bootstrap.connect(remoteAddress).sync();
+ return connectPeer(peer, clientDispatcher);
}
- private static void configurePeer(final Ipv4Address localAddress, final RIBImpl ribImpl, final BgpParameters bgpParameters, final PeerRole peerRole) {
- final InetAddress inetAddress = InetAddresses.forString(localAddress.getValue());
+ protected static BGPPeer configurePeer(final Ipv4Address peerAddress, final RIBImpl ribImpl,
+ final BgpParameters bgpParameters, final PeerRole peerRole, BGPPeerRegistry bgpPeerRegistry) {
+ final IpAddress ipAddress = new IpAddress(peerAddress);
- final BGPPeer bgpPeer = new BGPPeer(inetAddress.getHostAddress(), ribImpl, peerRole, null);
+ final BGPPeer bgpPeer = new BGPPeer(peerAddress.getValue(), ribImpl, peerRole, null,
+ AFI_SAFIS_ADVERTIZED, Collections.emptySet());
final List<BgpParameters> tlvs = Lists.newArrayList(bgpParameters);
- StrictBGPPeerRegistry.GLOBAL.addPeer(new IpAddress(new Ipv4Address(inetAddress.getHostAddress())), bgpPeer,
- new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(RIB_ID),
- AS_NUMBER, tlvs, Optional.absent()));
+ bgpPeerRegistry.addPeer(ipAddress, bgpPeer,
+ new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(RIB_ID), AS_NUMBER, tlvs, Optional.absent()));
bgpPeer.instantiateServiceInstance();
+ return bgpPeer;
}
- private static Channel connectPeer(final Ipv4Address localAddress, final BgpParameters bgpParameters,
- final BGPDispatcherImpl dispatcherImpl, final BGPHandlerFactory hf, final BGPSessionListener sessionListsner) throws InterruptedException {
- final BGPPeerRegistry peerRegistry = new StrictBGPPeerRegistry();
- peerRegistry.addPeer(new IpAddress(new Ipv4Address(RIB_ID)), sessionListsner,
- new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(localAddress),
- AS_NUMBER, Lists.newArrayList(bgpParameters), Optional.absent()));
-
- final ChannelFuture createClient = createClient(dispatcherImpl, new InetSocketAddress(RIB_ID, PORT), peerRegistry, new InetSocketAddress(localAddress.getValue(), PORT), hf);
- Thread.sleep(1000);
- return createClient.channel();
+ private static BGPSessionImpl connectPeer(final Ipv4Address localAddress, final BGPDispatcherImpl dispatcherImpl)
+ throws InterruptedException {
+ final Future<BGPSessionImpl> future = dispatcherImpl.createClient(new InetSocketAddress(localAddress.getValue(), PORT),
+ new InetSocketAddress(RIB_ID, PORT), RETRY_TIMER, true);
+ Thread.sleep(200);
+ waitFutureSuccess(future);
+ Thread.sleep(100);
+ return future.getNow();
}
protected static BgpParameters createParameter(final boolean addPath) {
return new UpdateBuilder().setAttributes(attBuilder.build()).build();
}
- private static Update createSimpleUpdateEbgp(final Ipv4Prefix prefix, final PathId pathId) {
+ private static Update createSimpleUpdateEbgp(final Ipv4Prefix prefix) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.singletonList(
new SegmentsBuilder().setAsSequence(Collections.singletonList(AS_NUMBER)).build())).build());
- addAttributeAugmentation(attBuilder, prefix, pathId);
+ addAttributeAugmentation(attBuilder, prefix, null);
return new UpdateBuilder().setAttributes(attBuilder.build()).build();
}
- private static void addAttributeAugmentation(final AttributesBuilder attBuilder, final Ipv4Prefix prefix, final PathId pathId) {
+ private static void addAttributeAugmentation(final AttributesBuilder attBuilder, final Ipv4Prefix prefix,
+ final PathId pathId) {
attBuilder.setUnrecognizedAttributes(Collections.emptyList());
attBuilder.addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(
new MpReachNlriBuilder()
- .setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(NH1).build()).build())
+ .setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(NH1)
+ .build()).build())
.setAfi(Ipv4AddressFamily.class)
.setSafi(UnicastSubsequentAddressFamily.class)
.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationIpv4CaseBuilder().setDestinationIpv4(
new DestinationIpv4Builder().setIpv4Prefixes(Collections.singletonList(
- new Ipv4PrefixesBuilder().setPathId(pathId).setPrefix(new Ipv4Prefix(prefix)).build())).build())
+ new Ipv4PrefixesBuilder().setPathId(pathId).setPrefix(new Ipv4Prefix(prefix)).build()))
+ .build())
.build()).build())
.build()).build());
}
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
attBuilder.setUnrecognizedAttributes(Collections.emptyList());
- return new UpdateBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setWithdrawnRoutes(Collections.singletonList(prefix)).build()).build();
+ return new UpdateBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder()
+ .setWithdrawnRoutes(Collections.singletonList(prefix)).build()).build();
}
}