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();
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
}
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());
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;
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;
}