sunish vk
Committed by Gerrit Code Review

ONOS-4505: Bug Fixes

Change-Id: I190b4e6b950381eef8d6fba1e3ac345ea6854e40
......@@ -112,10 +112,6 @@ public class Controller {
if (isisProcesses.size() > 0) {
processes = isisProcesses;
connectPeer();
//Initializing the interface map in channel handler
if (isisChannelHandler != null) {
isisChannelHandler.initializeInterfaceMap();
}
}
} else {
isisChannelHandler.updateInterfaceMap(isisProcesses);
......@@ -154,7 +150,6 @@ public class Controller {
isisChannelHandler = new IsisChannelHandler(this, processes);
ChannelPipelineFactory pfact = new IsisPipelineFactory(isisChannelHandler);
peerBootstrap.setPipelineFactory(pfact);
ChannelFuture connection = peerBootstrap.connect(new InetSocketAddress(IsisConstants.SHOST, isisPort.toInt()));
}
/**
......@@ -499,6 +494,7 @@ public class Controller {
public void run() {
log.debug("Connect to peer {}", IsisConstants.SHOST);
initConnection();
isisChannelHandler.sentConfigPacket(configPacket);
InetSocketAddress connectToSocket = new InetSocketAddress(IsisConstants.SHOST, isisPort.toInt());
try {
peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
......@@ -517,13 +513,13 @@ public class Controller {
}
scheduleConnectionRetry(connectRetryTime);
} else {
//Send the config packet
isisChannelHandler.sentConfigPacket(configPacket);
connectRetryCounter++;
log.info("Connected to remote host {}, Connect Counter {}", IsisConstants.SHOST,
connectRetryCounter);
disconnectExecutor();
isisChannelHandler.initializeInterfaceMap();
//Send the config packet
isisChannelHandler.sentConfigPacket(configPacket);
return;
}
}
......
......@@ -88,6 +88,7 @@ public class DefaultIsisInterface implements IsisInterface {
private IsisLsdb isisLsdb = null;
private List<Ip4Address> allConfiguredInterfaceIps = null;
private Channel channel;
private boolean helloSenderStarted = false;
/**
* Returns ISIS LSDB instance.
......@@ -1103,12 +1104,14 @@ public class DefaultIsisInterface implements IsisInterface {
*/
public void startHelloSender(Channel channel) {
log.debug("IsisInterfaceImpl::startHelloSender");
if (!helloSenderStarted) {
isisHelloPduSender = new IsisHelloPduSender(channel, this);
exServiceHello = Executors.newSingleThreadScheduledExecutor();
final ScheduledFuture<?> helloHandle =
exServiceHello.scheduleAtFixedRate(isisHelloPduSender, 0,
helloInterval, TimeUnit.SECONDS);
helloSenderStarted = true;
}
}
/**
......@@ -1117,5 +1120,6 @@ public class DefaultIsisInterface implements IsisInterface {
public void stopHelloSender() {
log.debug("IsisInterfaceImpl::stopHelloSender");
exServiceHello.shutdown();
helloSenderStarted = false;
}
}
\ No newline at end of file
......
......@@ -50,7 +50,7 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler {
private static final Logger log = LoggerFactory.getLogger(IsisChannelHandler.class);
private static Map<Integer, Object> isisDb = null;
private Channel channel;
private Channel channel = null;
private Controller controller;
private List<IsisProcess> processes = null;
private List<ScheduledExecutorService> executorList = new ArrayList<>();
......@@ -76,10 +76,13 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler {
public void initializeInterfaceMap() {
for (IsisProcess process : processes) {
for (IsisInterface isisInterface : process.isisInterfaceList()) {
IsisInterface anInterface = isisInterfaceMap.get(isisInterface.interfaceIndex());
if (anInterface == null) {
isisInterfaceMap.put(isisInterface.interfaceIndex(), isisInterface);
interfaceIps.add(isisInterface.interfaceIpAddress());
}
}
}
//Initializes the interface with all interface ip details - for ls pdu generation
initializeInterfaceIpList();
}
......@@ -150,6 +153,7 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler {
+ configPacket.length);
sentConfigPacket(configPacket);
}
initializeInterfaceMap();
//start the hello timer
startHelloSender();
//Initialize Database
......@@ -168,6 +172,7 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler {
log.debug("IsisChannelHandler::channelDisconnected...!!!");
if (controller != null) {
controller.connectPeer();
stopHelloSender();
}
}
......@@ -255,8 +260,11 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler {
*/
public void stopHelloSender() {
log.debug("ISISChannelHandler::stopHelloTimer ");
for (ScheduledExecutorService exServiceHello : executorList) {
exServiceHello.shutdown();
log.debug("IsisController::startHelloSender");
Set<Integer> interfaceIndexes = isisInterfaceMap.keySet();
for (Integer interfaceIndex : interfaceIndexes) {
IsisInterface isisInterface = isisInterfaceMap.get(interfaceIndex);
isisInterface.stopHelloSender();
}
}
......
......@@ -44,6 +44,7 @@ public class DefaultIsisLsdbAge implements IsisLsdbAge {
private int ageCounterRollOver = 0;
private IsisLspQueueConsumer queueConsumer = null;
private BlockingQueue<LspWrapper> lsaQueue = new ArrayBlockingQueue<>(1024);
private boolean timerStarted = false;
/**
* Creates an instance of LSDB age.
......@@ -128,9 +129,12 @@ public class DefaultIsisLsdbAge implements IsisLsdbAge {
* Starts the aging timer and queue consumer.
*/
public void startDbAging() {
if (!timerStarted) {
startDbAgeTimer();
queueConsumer = new IsisLspQueueConsumer(lsaQueue);
new Thread(queueConsumer).start();
timerStarted = true;
}
}
/**
......
......@@ -188,7 +188,9 @@ public class Csnp extends IsisHeader {
TlvType tlvValue = TlvType.get(tlvHeader.tlvType());
if (tlvValue != null) {
IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
if (tlv != null) {
this.variableLengths.add(tlv);
}
} else {
channelBuffer.readBytes(tlvHeader.tlvLength());
}
......
......@@ -145,7 +145,9 @@ public class L1L2HelloPdu extends HelloPdu {
TlvType tlvType = TlvType.get(tlvHeader.tlvType());
if (tlvType != null) {
IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
if (tlv != null) {
this.variableLengths.add(tlv);
}
} else {
channelBuffer.readBytes(tlvHeader.tlvLength());
}
......
......@@ -354,7 +354,9 @@ public class LsPdu extends IsisHeader {
TlvType tlvValue = TlvType.get(tlvHeader.tlvType());
if (tlvValue != null) {
IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
if (tlv != null) {
this.variableLengths.add(tlv);
}
} else {
channelBuffer.readBytes(tlvHeader.tlvLength());
}
......
......@@ -124,7 +124,9 @@ public class P2PHelloPdu extends HelloPdu {
TlvType tlvType = TlvType.get(tlvHeader.tlvType());
if (tlvType != null) {
IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
if (tlv != null) {
this.variableLengths.add(tlv);
}
} else {
channelBuffer.readBytes(tlvHeader.tlvLength());
}
......
......@@ -205,8 +205,11 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv {
tlvHeader.setTlvLength(channelBuffer.readByte());
SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType());
if (tlvValue != null) {
this.addSubTlv(SubTlvFinder.findSubTlv(tlvHeader,
channelBuffer.readBytes(tlvHeader.tlvLength())));
TrafficEngineeringSubTlv subTlv =
SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
if (subTlv != null) {
this.addSubTlv(subTlv);
}
} else {
channelBuffer.readBytes(tlvHeader.tlvLength());
}
......
......@@ -49,9 +49,10 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv {
this.neighbors.add(neighbor);
}
@Override
public void readFrom(ChannelBuffer channelBuffer) {
while (channelBuffer.readableBytes() >= IsisUtil.EIGHT_BYTES + IsisUtil.THREE_BYTES) {
while (channelBuffer.readableBytes() >= (IsisUtil.EIGHT_BYTES + IsisUtil.THREE_BYTES)) {
NeighborForExtendedIs extendedIs = new NeighborForExtendedIs();
extendedIs.readFrom(channelBuffer);
this.addNeighbor(extendedIs);
......
......@@ -18,6 +18,7 @@ package org.onosproject.isis.io.isispacket.tlv;
import com.google.common.base.MoreObjects;
import com.google.common.primitives.Bytes;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.isis.io.util.IsisUtil;
import java.util.ArrayList;
import java.util.List;
......@@ -58,9 +59,9 @@ public class LspEntriesTlv extends TlvHeader implements IsisTlv {
@Override
public void readFrom(ChannelBuffer channelBuffer) {
while (channelBuffer.readableBytes() >= 16) {
while (channelBuffer.readableBytes() >= (IsisUtil.EIGHT_BYTES * 2)) {
LspEntry lspEntry = new LspEntry();
lspEntry.readFrom(channelBuffer.readBytes(16));
lspEntry.readFrom(channelBuffer.readBytes(IsisUtil.EIGHT_BYTES * 2));
lspEntryList.add(lspEntry);
}
}
......
......@@ -101,8 +101,11 @@ public class NeighborForExtendedIs {
int tlvLength = tlvHeader.tlvLength();
if (tlvValue != null) {
if (channelBuffer.readableBytes() >= tlvLength) {
this.addSubTlv(SubTlvFinder.findSubTlv(tlvHeader,
channelBuffer.readBytes(tlvHeader.tlvLength())));
TrafficEngineeringSubTlv subTlv =
SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
if (subTlv != null) {
this.addSubTlv(subTlv);
}
}
} else {
if (channelBuffer.readableBytes() >= tlvLength) {
......