Bug 5566: BGP listener TCP MD5 support is not working 64/36564/6
authorMilos Fabian <milfabia@cisco.com>
Tue, 22 Mar 2016 10:42:45 +0000 (11:42 +0100)
committerRobert Varga <nite@hq.sk>
Fri, 1 Apr 2016 20:54:36 +0000 (20:54 +0000)
The BGP server have to be aware of all configured peers
MD5 keys.
Update (add/remove) server's keys whenever a peer is
configured/disconfigured by listening to the PeerRegistry
changes.

Change-Id: Ie9cab438a6d4358a08465e1bd9d7df28d923187f
Signed-off-by: Milos Fabian <milfabia@cisco.com>
14 files changed:
bgp/rib-impl/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPPeerAcceptorModule.java
bgp/rib-impl/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPPeerModule.java
bgp/rib-impl/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/StrictBgpPeerRegistryModule.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPPeerRegistry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPSessionPreferences.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/PeerRegistryListener.java [new file with mode: 0644]
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImplTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/FSMTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistryTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/TestClientDispatcher.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/Main.java
bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/BGPSpeakerMock.java

index a7491ee7011c091779c95e62b8b975403c473d0c..10ed6e67ee4f2808581f54820714bb39c2ac71ca 100644 (file)
@@ -2,6 +2,8 @@ package org.opendaylight.controller.config.yang.bgp.rib.impl;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelConfig;
 import io.netty.channel.ChannelFuture;
 import io.netty.util.concurrent.Future;
 import io.netty.util.concurrent.GenericFutureListener;
@@ -11,6 +13,14 @@ import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.security.AccessControlException;
 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
+import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
+import org.opendaylight.protocol.bgp.rib.impl.spi.PeerRegistryListener;
+import org.opendaylight.tcpmd5.api.KeyMapping;
+import org.opendaylight.tcpmd5.netty.MD5ChannelOption;
+import org.opendaylight.tcpmd5.netty.MD5NioServerSocketChannel;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 
 /**
 * BGP peer acceptor that handles incoming bgp connections.
@@ -41,25 +51,35 @@ public class BGPPeerAcceptorModule extends org.opendaylight.controller.config.ya
         }
     }
 
+    private AutoCloseable listenerRegistration;
+
     @Override
     public java.lang.AutoCloseable createInstance() {
-        final ChannelFuture future = getAcceptingBgpDispatcherDependency().createServer(getAcceptingPeerRegistryDependency(), getAddress());
+        final BGPPeerRegistry peerRegistry = getAcceptingPeerRegistryDependency();
+        final ChannelFuture futureChannel = getAcceptingBgpDispatcherDependency().createServer(peerRegistry, getAddress());
 
         // Validate future success
-        future.addListener(new GenericFutureListener<Future<Void>>() {
+        futureChannel.addListener(new GenericFutureListener<Future<Void>>() {
             @Override
             public void operationComplete(final Future<Void> future) {
                 Preconditions.checkArgument(future.isSuccess(), "Unable to start bgp server on %s", getAddress(), future.cause());
+                final Channel channel = futureChannel.channel();
+                if (channel instanceof MD5NioServerSocketChannel) {
+                    BGPPeerAcceptorModule.this.listenerRegistration = peerRegistry.registerPeerRegisterListener(new PeerRegistryListenerImpl(channel.config()));
+                }
             }
         });
 
         return new AutoCloseable() {
             @Override
-            public void close() {
+            public void close() throws Exception {
                 // This closes the acceptor and no new bgp connections will be accepted
                 // Connections already established will be preserved
-                future.cancel(true);
-                future.channel().close();
+                futureChannel.cancel(true);
+                futureChannel.channel().close();
+                if (BGPPeerAcceptorModule.this.listenerRegistration != null) {
+                    BGPPeerAcceptorModule.this.listenerRegistration.close();
+                }
             }
         };
     }
@@ -77,4 +97,32 @@ public class BGPPeerAcceptorModule extends org.opendaylight.controller.config.ya
         return new InetSocketAddress(inetAddr, getBindingPort().getValue());
     }
 
+    private static final class PeerRegistryListenerImpl implements PeerRegistryListener {
+
+        private final ChannelConfig channelConfig;
+
+        private final KeyMapping keys;
+
+        PeerRegistryListenerImpl(final ChannelConfig channelConfig) {
+            this.channelConfig = channelConfig;
+            this.keys = new KeyMapping();
+        }
+
+        @Override
+        public void onPeerAdded(final IpAddress ip, final BGPSessionPreferences prefs) {
+            if (prefs.getMd5Password().isPresent()) {
+                this.keys.put(IetfInetUtil.INSTANCE.inetAddressFor(ip), prefs.getMd5Password().get());
+                this.channelConfig.setOption(MD5ChannelOption.TCP_MD5SIG, this.keys);
+            }
+        }
+
+        @Override
+        public void onPeerRemoved(final IpAddress ip) {
+            if (this.keys.remove(IetfInetUtil.INSTANCE.inetAddressFor(ip)) != null) {
+                this.channelConfig.setOption(MD5ChannelOption.TCP_MD5SIG, this.keys);
+            }
+        }
+
+    }
+
 }
index 5f447d43402e282fd15f61ef5aca4c5580bee139..af43b12a8456eed64a3558f3ac0af5fefe2e9bd6 100644 (file)
@@ -124,7 +124,8 @@ public final class BGPPeerModule extends org.opendaylight.controller.config.yang
 
         final List<BgpParameters> tlvs = getTlvs(r);
         final AsNumber remoteAs = getAsOrDefault(r);
-        final BGPSessionPreferences prefs = new BGPSessionPreferences(r.getLocalAs(), getHoldtimer(), r.getBgpIdentifier(), remoteAs, tlvs);
+        final BGPSessionPreferences prefs = new BGPSessionPreferences(r.getLocalAs(), getHoldtimer(), r.getBgpIdentifier(), remoteAs, tlvs,
+                getMD5Password(getPassword()));
         final BGPPeer bgpClientPeer;
         final IpAddress host = getNormalizedHost();
         if (getPeerRole() != null) {
@@ -273,4 +274,8 @@ public final class BGPPeerModule extends org.opendaylight.controller.config.yang
         return password != null && ! password.getValue().isEmpty() ? Optional.of(password) : Optional.<Rfc2385Key>absent();
     }
 
+    private static Optional<byte[]> getMD5Password(final Rfc2385Key password) {
+        return password != null && ! password.getValue().isEmpty() ? Optional.of(password.getValue().getBytes(Charsets.US_ASCII)) : Optional.<byte[]>absent();
+    }
+
 }
index f73ed6b7d22a608f33c13755a2dc202fefaa444b..81cc5cd4942401301c3a8c498f4e026a597e1e92 100644 (file)
@@ -5,6 +5,7 @@ import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
+import org.opendaylight.protocol.bgp.rib.impl.spi.PeerRegistryListener;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
@@ -85,5 +86,10 @@ public class StrictBgpPeerRegistryModule extends org.opendaylight.controller.con
                     .add("peers", this.global)
                     .toString();
         }
+
+        @Override
+        public AutoCloseable registerPeerRegisterListener(final PeerRegistryListener listener) {
+            return this.global.registerPeerRegisterListener(listener);
+        }
     }
 }
index 6583d0fb944c941631392e869de48f6be40a2326..008649d353137ff210b021a3628d9fb1991de253 100644 (file)
@@ -56,7 +56,6 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
     private final BGPHandlerFactory handlerFactory;
     private final EventLoopGroup bossGroup;
     private final EventLoopGroup workerGroup;
-    private Optional<KeyMapping> keys;
 
     public BGPDispatcherImpl(final MessageRegistry messageRegistry, final EventLoopGroup bossGroup, final EventLoopGroup workerGroup) {
         this(messageRegistry, bossGroup, workerGroup, null, null);
@@ -68,7 +67,6 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         this.handlerFactory = new BGPHandlerFactory(messageRegistry);
         this.channelFactory = cf;
         this.serverChannelFactory = scf;
-        this.keys = Optional.absent();
     }
 
     @Override
@@ -76,7 +74,7 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         final BGPClientSessionNegotiatorFactory snf = new BGPClientSessionNegotiatorFactory(listener);
         final ChannelPipelineInitializer initializer = BGPChannel.createChannelPipelineInitializer(BGPDispatcherImpl.this.handlerFactory, snf);
 
-        final Bootstrap bootstrap = createClientBootStrap();
+        final Bootstrap bootstrap = createClientBootStrap(Optional.<KeyMapping>absent());
         final BGPProtocolSessionPromise sessionPromise = new BGPProtocolSessionPromise(address, strategy, bootstrap);
         bootstrap.handler(BGPChannel.createClientChannelHandler(initializer, sessionPromise));
         sessionPromise.connect();
@@ -84,14 +82,14 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         return sessionPromise;
     }
 
-    protected Bootstrap createClientBootStrap() {
+    protected Bootstrap createClientBootStrap(final Optional<KeyMapping> keys) {
         final Bootstrap bootstrap = new Bootstrap();
-        if (this.keys.isPresent()) {
+        if (keys.isPresent()) {
             if (this.channelFactory == null) {
                 throw new UnsupportedOperationException("No key access instance available, cannot use key mapping");
             }
             bootstrap.channelFactory(this.channelFactory);
-            bootstrap.option(MD5ChannelOption.TCP_MD5SIG, this.keys.get());
+            bootstrap.option(MD5ChannelOption.TCP_MD5SIG, keys.get());
         } else {
             bootstrap.channel(NioSocketChannel.class);
         }
@@ -117,12 +115,10 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
     public synchronized Future<Void> createReconnectingClient(final InetSocketAddress address, final BGPPeerRegistry peerRegistry,
         final ReconnectStrategyFactory connectStrategyFactory, final Optional<KeyMapping> keys) {
         final BGPClientSessionNegotiatorFactory snf = new BGPClientSessionNegotiatorFactory(peerRegistry);
-        this.keys = keys;
-        final Bootstrap bootstrap = createClientBootStrap();
+        final Bootstrap bootstrap = createClientBootStrap(keys);
         final BGPReconnectPromise reconnectPromise = new BGPReconnectPromise(GlobalEventExecutor.INSTANCE, address,
             connectStrategyFactory, bootstrap, BGPChannel.createChannelPipelineInitializer(BGPDispatcherImpl.this.handlerFactory, snf));
         reconnectPromise.connect();
-        this.keys = Optional.absent();
         return reconnectPromise;
     }
 
@@ -138,6 +134,7 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
 
     private ServerBootstrap createServerBootstrap(final ChannelPipelineInitializer initializer) {
         final ServerBootstrap serverBootstrap = new ServerBootstrap();
+        final boolean md5Supported = this.serverChannelFactory != null;
         final ChannelHandler serverChannelHandler = BGPChannel.createServerChannelHandler(initializer);
         serverBootstrap.childHandler(serverChannelHandler);
 
@@ -145,12 +142,8 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         serverBootstrap.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
         serverBootstrap.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, HIGH_WATER_MARK);
         serverBootstrap.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, LOW_WATER_MARK);
-        if (this.keys.isPresent()) {
-            if (this.serverChannelFactory == null) {
-                throw new UnsupportedOperationException("No key access instance available, cannot use key mapping");
-            }
+        if (md5Supported) {
             serverBootstrap.channelFactory(this.serverChannelFactory);
-            serverBootstrap.option(MD5ChannelOption.TCP_MD5SIG, this.keys.get());
         } else {
             serverBootstrap.channel(NioServerSocketChannel.class);
         }
index 25433f74117d7f886c52bbe393cd79099ee3149e..1d2ffa2c0e611c6fc4ecbec0a6025fc9fc7ef29a 100644 (file)
@@ -21,8 +21,11 @@ import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
 import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.ThreadSafe;
 import org.opendaylight.protocol.bgp.parser.AsNumberUtil;
@@ -31,6 +34,7 @@ import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.impl.message.open.As4CapabilityHandler;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
+import org.opendaylight.protocol.bgp.rib.impl.spi.PeerRegistryListener;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil;
@@ -42,6 +46,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.message.bgp.parameters.optional.capabilities.CParameters;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.message.bgp.parameters.optional.capabilities.CParametersBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapability;
+import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -64,6 +69,8 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry {
     private final Map<IpAddress, BGPSessionId> sessionIds = Maps.newHashMap();
     @GuardedBy("this")
     private final Map<IpAddress, BGPSessionPreferences> peerPreferences = Maps.newHashMap();
+    @GuardedBy("this")
+    private final Set<PeerRegistryListener> listeners = new HashSet<>();
 
     @Override
     public synchronized void addPeer(final IpAddress ip, final BGPSessionListener peer, final BGPSessionPreferences preferences) {
@@ -75,12 +82,18 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry {
         Preconditions.checkNotNull(preferences.getParams());
         Preconditions.checkNotNull(preferences.getBgpId());
         this.peerPreferences.put(ip, preferences);
+        for (final PeerRegistryListener peerRegistryListener : this.listeners) {
+            peerRegistryListener.onPeerAdded(ip, preferences);
+        }
     }
 
     @Override
     public synchronized void removePeer(final IpAddress ip) {
         Preconditions.checkNotNull(ip);
         this.peers.remove(ip);
+        for (final PeerRegistryListener peerRegistryListener : this.listeners) {
+            peerRegistryListener.onPeerRemoved(ip);
+        }
     }
 
     @Override
@@ -319,4 +332,20 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry {
                 .toString();
         }
     }
+
+    @Override
+    public synchronized AutoCloseable registerPeerRegisterListener(final PeerRegistryListener listener) {
+        this.listeners.add(listener);
+        for (final Entry<IpAddress, BGPSessionPreferences> entry : this.peerPreferences.entrySet()) {
+            listener.onPeerAdded(entry.getKey(), entry.getValue());
+        }
+        return new AbstractRegistration() {
+            @Override
+            protected void removeRegistration() {
+                synchronized (StrictBGPPeerRegistry.this) {
+                    StrictBGPPeerRegistry.this.listeners.remove(listener);
+                }
+            }
+        };
+    }
 }
\ No newline at end of file
index b6c520954bbd2aae5b073b9f98d239a3e0796783..bc4a6e0d9fd6c4656e7eec976c527678f3f2a52a 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.protocol.bgp.rib.impl.spi;
 
+import javax.annotation.Nonnull;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
@@ -73,4 +74,14 @@ public interface BGPPeerRegistry extends AutoCloseable {
      */
     BGPSessionPreferences getPeerPreferences(IpAddress ip);
 
+    /**
+     * Register PeerRegistryListener, which listens to the changes in peer
+     * registry (add peer, remove peer). After registration, an initial
+     * drop is provided by calling onPeerAdded().
+     *
+     * @param listener The PeerRegistryListener to be registered.
+     * @return Registration ticked, used for closing of registration.
+     */
+    @Nonnull AutoCloseable registerPeerRegisterListener(@Nonnull PeerRegistryListener listener);
+
 }
index 47b5f164cd9c293b1a56e7826d3b99c40a7f3111..7d1f4125184237cd5924b8ff8dab0f53a4a477b3 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.bgp.rib.impl.spi;
 
+import com.google.common.base.Optional;
 import java.util.List;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
@@ -27,6 +28,8 @@ public final class BGPSessionPreferences {
 
     private final AsNumber remoteAs;
 
+    private final Optional<byte[]> md5Password;
+
     /**
      * Creates a new DTO for Open message.
      *
@@ -37,12 +40,13 @@ public final class BGPSessionPreferences {
      * @param params list of advertised parameters
      */
     public BGPSessionPreferences(final AsNumber as, final int hold, final Ipv4Address bgpId, final AsNumber remoteAs,
-        final List<BgpParameters> params) {
+        final List<BgpParameters> params, final Optional<byte[]> md5Password) {
         this.as = as;
         this.hold = hold;
         this.bgpId = bgpId;
         this.remoteAs = remoteAs;
         this.params = params;
+        this.md5Password = md5Password;
     }
 
     /**
@@ -89,4 +93,12 @@ public final class BGPSessionPreferences {
     public List<BgpParameters> getParams() {
         return this.params;
     }
+
+    /**
+     * Optionally returns peer's MD5 password.
+     * @return Encoded MD5 password.
+     */
+    public Optional<byte[]> getMd5Password() {
+        return this.md5Password;
+    }
 }
diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/PeerRegistryListener.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/PeerRegistryListener.java
new file mode 100644 (file)
index 0000000..e405db4
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.rib.impl.spi;
+
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+
+/**
+ * Listens to the changes in a PeerRegisty.
+ *
+ */
+public interface PeerRegistryListener {
+
+    /**
+     * Invoked when new peer is added into the registry.
+     * @param ip The new peer's IP address.
+     * @param prefs The new peer's preferences.
+     */
+    void onPeerAdded(@Nonnull IpAddress ip, @Nonnull BGPSessionPreferences prefs);
+
+    /**
+     * Invoked when peer is removed from registry.
+     * @param ip The removed peer's IP address.
+     */
+    void onPeerRemoved(@Nonnull IpAddress ip);
+
+}
index 940da922ab9a5b92ad29b3d11f8984f964be83d7..32aa23a0b1ebff56aea1473de4661ee198322b2e 100644 (file)
@@ -137,7 +137,8 @@ public class BGPDispatcherImplTest {
                 .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build()).build())
             .setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(30L)).build()).build()).build());
         tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
-        return new BGPSessionPreferences(AS_NUMBER, (short) 4, new Ipv4Address(socketAddress.getAddress().getHostAddress()), AS_NUMBER, tlvs);
+        return new BGPSessionPreferences(AS_NUMBER, (short) 4, new Ipv4Address(socketAddress.getAddress().getHostAddress()), AS_NUMBER, tlvs,
+                Optional.<byte[]>absent());
     }
 
 }
index 823a7f920ccb28dffa864f62bbe514c466983201..8158ad1a19937d8ea586f46a4d31fc7a993d768e 100644 (file)
@@ -14,6 +14,8 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+
+import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
@@ -106,7 +108,8 @@ public class FSMTest {
 
 
         tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
-        final BGPSessionPreferences prefs = new BGPSessionPreferences(new AsNumber(30L), (short) 3, new Ipv4Address("1.1.1.1"), new AsNumber(30L), tlvs);
+        final BGPSessionPreferences prefs = new BGPSessionPreferences(new AsNumber(30L), (short) 3, new Ipv4Address("1.1.1.1"), new AsNumber(30L), tlvs,
+                Optional.<byte[]>absent());
 
         final ChannelFuture f = mock(ChannelFuture.class);
         doReturn(null).when(f).addListener(any(GenericFutureListener.class));
index fd48d6581d437d2cffa6c4b6ea4b122ab5a3a21e..0802d60a39422c8ab4f50d66b96464a7e72a4fb5 100644 (file)
@@ -11,6 +11,8 @@ package org.opendaylight.protocol.bgp.rib.impl;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.fail;
+
+import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import java.net.InetSocketAddress;
 import java.util.Collections;
@@ -57,7 +59,8 @@ public class StrictBGPPeerRegistryTest {
     @Before
     public void setUp() throws Exception {
         this.peerRegistry = new StrictBGPPeerRegistry();
-        this.mockPreferences =  new BGPSessionPreferences(LOCAL_AS, 1, new Ipv4Address("0.0.0.1"), LOCAL_AS, Collections.<BgpParameters> emptyList());
+        this.mockPreferences =  new BGPSessionPreferences(LOCAL_AS, 1, new Ipv4Address("0.0.0.1"), LOCAL_AS, Collections.<BgpParameters> emptyList(),
+                Optional.<byte[]>absent());
     }
 
     private static BGPSessionListener getMockSession() {
index e20259d92d262a91d1b16bb6b0bf76235f0e3491..50baf9f3973851b49affd105fba2c0e89bedf7e0 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
 import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
+import org.opendaylight.tcpmd5.api.KeyMapping;
 
 public class TestClientDispatcher {
 
@@ -31,7 +32,7 @@ public class TestClientDispatcher {
                                    final InetSocketAddress locaAddress) {
         this.disp = new BGPDispatcherImpl(messageRegistry, bossGroup, workerGroup) {
             @Override
-            protected Bootstrap createClientBootStrap() {
+            protected Bootstrap createClientBootStrap(final Optional<KeyMapping> keys) {
                 final Bootstrap bootstrap = new Bootstrap();
                 bootstrap.channel(NioSocketChannel.class);
                 // Make sure we are doing round-robin processing
index 1fa8130ae424fe1c82e5c33c94b1b93e39b991bf..3466b5c955208afe79cfa84a5fa70b781e5f890b 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.testtool;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.util.concurrent.GlobalEventExecutor;
@@ -111,7 +112,7 @@ public final class Main {
                 createMPCapability(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class)));
 
         final BGPSessionPreferences proposal = new BGPSessionPreferences(as, holdTimerValue, new Ipv4Address("25.25.25.2"), as,
-                Collections.singletonList(bgpParameters));
+                Collections.singletonList(bgpParameters), Optional.<byte[]>absent());
 
         LOG.debug("{} {} {}", address, sessionListener, proposal);
 
index 27fd94c1368a01d9109137aa25c61e9b61061c7c..40564db4d43636440b113fdd04fe16e746e8ba50 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.bgp.testtool;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import io.netty.channel.nio.NioEventLoopGroup;
@@ -22,6 +23,7 @@ import org.opendaylight.protocol.bgp.rib.impl.BGPServerSessionNegotiatorFactory;
 import org.opendaylight.protocol.bgp.rib.impl.BGPSessionImpl;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
+import org.opendaylight.protocol.bgp.rib.impl.spi.PeerRegistryListener;
 import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
@@ -71,7 +73,8 @@ public class BGPSpeakerMock {
                 final BgpParameters bgpParameters = Main.createBgpParameters(Lists.newArrayList(
                         Main.createMPCapability(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class),
                         Main.createMPCapability(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class)));
-                return new BGPSessionPreferences(new AsNumber(72L), (short) 90, new Ipv4Address("127.0.0.2"), new AsNumber(72L), Collections.singletonList(bgpParameters));
+                return new BGPSessionPreferences(new AsNumber(72L), (short) 90, new Ipv4Address("127.0.0.2"), new AsNumber(72L),
+                        Collections.singletonList(bgpParameters), Optional.<byte[]>absent());
             }
 
             @Override
@@ -82,6 +85,11 @@ public class BGPSpeakerMock {
             @Override
             public void removePeerSession(final IpAddress ip) {
             }
+
+            @Override
+            public AutoCloseable registerPeerRegisterListener(final PeerRegistryListener listener) {
+                return null;
+            }
         };
     }