BUG-604 : Holdtimer value now calculated as the lower from local/remote session prefs. 22/5822/1
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 31 Mar 2014 13:51:25 +0000 (15:51 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 31 Mar 2014 13:51:25 +0000 (15:51 +0200)
Change-Id: I08bb324fec9816cd9110c24601a322c982810303
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionNegotiator.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SpeakerSessionMock.java

index d308fed2d91857fde6f0267a17f2851cc01356b4..ad1c50bf44b7c912dc2d813a0ffce5ae223c0ab4 100644 (file)
@@ -115,12 +115,13 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
        private final AsNumber asNumber;
        private final Ipv4Address bgpId;
 
-       BGPSessionImpl(final Timer timer, final BGPSessionListener listener, final Channel channel, final Open remoteOpen) {
+       BGPSessionImpl(final Timer timer, final BGPSessionListener listener, final Channel channel, final Open remoteOpen, final int localHoldTimer) {
                this.listener = Preconditions.checkNotNull(listener);
                this.stateTimer = Preconditions.checkNotNull(timer);
                this.channel = Preconditions.checkNotNull(channel);
-               this.keepAlive = remoteOpen.getHoldTimer() / 3;
-               this.holdTimerValue = remoteOpen.getHoldTimer();
+               this.holdTimerValue = (remoteOpen.getHoldTimer() < localHoldTimer) ? remoteOpen.getHoldTimer() : localHoldTimer;
+               LOG.info("HoldTimer new value: {}", this.holdTimerValue);
+               this.keepAlive = this.holdTimerValue / 3;
                this.asNumber = AsNumberUtil.advertizedAsNumber(remoteOpen);
 
                final Set<TablesKey> tts = Sets.newHashSet();
@@ -140,14 +141,14 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
                this.sync = new BGPSynchronization(this, this.listener, tts);
                this.tableTypes = tats;
 
-               if (remoteOpen.getHoldTimer() != 0) {
+               if (this.holdTimerValue != 0) {
                        this.stateTimer.newTimeout(new TimerTask() {
 
                                @Override
                                public void run(final Timeout timeout) throws Exception {
                                        handleHoldTimer();
                                }
-                       }, remoteOpen.getHoldTimer(), TimeUnit.SECONDS);
+                       }, this.holdTimerValue, TimeUnit.SECONDS);
 
                        this.stateTimer.newTimeout(new TimerTask() {
                                @Override
@@ -251,7 +252,7 @@ public class BGPSessionImpl extends AbstractProtocolSession<Notification> implem
                }
 
                final long ct = System.nanoTime();
-               final long nextHold = this.lastMessageReceivedAt + TimeUnit.SECONDS.toNanos(holdTimerValue);
+               final long nextHold = this.lastMessageReceivedAt + TimeUnit.SECONDS.toNanos(this.holdTimerValue);
 
                if (ct >= nextHold) {
                        LOG.debug("HoldTimer expired. " + new Date());
index 6ce29ed122f8fcca2995b630d88632e536787ca4..ea83c2edd87f930351bb7e1bb11319046b93c00e 100644 (file)
@@ -169,10 +169,10 @@ public final class BGPSessionNegotiator extends AbstractSessionNegotiator<Notifi
                final List<BgpParameters> prefs = openObj.getBgpParameters();
                if (prefs != null && !prefs.isEmpty()) {
                        if (!prefs.containsAll(this.localPref.getParams())) {
-                               LOG.info("Open message unacceptable. Check the configuration of BGP speaker.");
+                               LOG.info("Open message recieved does not match open message sent. Session still accepted.");
                        }
                        this.sendMessage(new KeepaliveBuilder().build());
-                       this.session = new BGPSessionImpl(this.timer, this.listener, this.channel, openObj);
+                       this.session = new BGPSessionImpl(this.timer, this.listener, this.channel, openObj, this.localPref.getHoldTime());
                        this.state = State.OpenConfirm;
                        LOG.debug("Channel {} moved to OpenConfirm state with remote proposal {}", this.channel, openObj);
                        return;
index 07601d5037c9b39e48ceac355cdae3e2a5f1b0f3..6d5648a11c0d92aef44a8e1be8929288a9191501 100644 (file)
@@ -23,7 +23,7 @@ public class SpeakerSessionMock extends BGPSessionImpl {
        private final BGPSessionListener client;
 
        SpeakerSessionMock(final BGPSessionListener listener, final BGPSessionListener client) {
-               super(new HashedWheelTimer(), listener, mock(Channel.class), new OpenBuilder().setHoldTimer(5).build());
+               super(new HashedWheelTimer(), listener, mock(Channel.class), new OpenBuilder().setHoldTimer(5).build(), 10);
                this.client = client;
        }