Manikandan K
Committed by Brian O'Connor

ONOS-4107: ISIS Provider - Bug Fixes

Change-Id: I1945f614c02a39326d22e268fbb015e50d075368
......@@ -122,4 +122,11 @@ public interface IsisLsdb {
* @param l2LspSeqNo link state sequence number
*/
void setL2LspSeqNo(int l2LspSeqNo);
/**
* Removes topology information when neighbor down.
*
* @param neighbor ISIS neighbor instance
* @param isisInterface ISIS interface instance
*/
void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface);
}
\ No newline at end of file
......
......@@ -356,6 +356,8 @@ public class DefaultIsisNeighbor implements IsisNeighbor {
stopInactivityTimeCheck();
stopHoldingTimeCheck();
isisInterface.removeNeighbor(this);
isisInterface.isisLsdb().removeTopology(this, isisInterface);
}
/**
......
......@@ -21,7 +21,9 @@ import org.onosproject.isis.controller.IsisLsdb;
import org.onosproject.isis.controller.IsisLsdbAge;
import org.onosproject.isis.controller.IsisLspBin;
import org.onosproject.isis.controller.IsisMessage;
import org.onosproject.isis.controller.IsisNeighbor;
import org.onosproject.isis.controller.IsisPduType;
import org.onosproject.isis.controller.IsisRouterType;
import org.onosproject.isis.controller.LspWrapper;
import org.onosproject.isis.controller.impl.Controller;
import org.onosproject.isis.controller.impl.LspEventConsumer;
......@@ -394,4 +396,39 @@ public class DefaultIsisLsdb implements IsisLsdb {
log.debug("Added LSp In Blocking queue: {}", lspWrapper);
}
}
/**
* Removes topology information when neighbor down.
*
* @param neighbor ISIS neighbor instance
* @param isisInterface ISIS interface instance
*/
public void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface) {
String lspKey = neighbor.neighborSystemId() + ".00-00";
LspWrapper lspWrapper = null;
switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) {
case L1:
lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey);
break;
case L2:
lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey);
break;
case L1L2:
lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey);
if (lspWrapper == null) {
lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey);
}
break;
default:
log.debug("Unknown type");
}
try {
if (lspWrapper != null) {
lspWrapper.setLspProcessing(IsisConstants.LSPREMOVED);
lspForProviderQueue.put(lspWrapper);
}
} catch (Exception e) {
log.debug("Added LSp In Blocking queue: {}", lspWrapper);
}
}
}
\ No newline at end of file
......
......@@ -52,6 +52,7 @@ import org.onosproject.net.link.LinkDescription;
import org.onosproject.net.link.LinkProvider;
import org.onosproject.net.link.LinkProviderRegistry;
import org.onosproject.net.link.LinkProviderService;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import org.slf4j.Logger;
......@@ -86,6 +87,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected NetworkConfigService networkConfigService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LinkService linkService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected IsisController controller;
//This Interface that defines how this provider can interact with the core.
private LinkProviderService linkProviderService;
......@@ -155,8 +158,14 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
String localSystemId = isisLink.localSystemId();
String remoteSystemId = isisLink.remoteSystemId();
//Changing of port numbers
srcAddress = isisLink.interfaceIp().toInt();
dstAddress = isisLink.neighborIp().toInt();
if (isisLink.interfaceIp() != null) {
//srcAddress = isisLink.interfaceIp().toInt();
srcAddress = (long) Long.parseUnsignedLong(Integer.toBinaryString(isisLink.interfaceIp().toInt()), 2);
}
if (isisLink.neighborIp() != null) {
//dstAddress = isisLink.neighborIp().toInt();
dstAddress = (long) Long.parseUnsignedLong(Integer.toBinaryString(isisLink.neighborIp().toInt()), 2);
}
DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId));
DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId));
if (checkIsDis(isisLink.localSystemId())) {
......@@ -283,8 +292,9 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
newBuilder.set("RouterId", systemId);
DeviceDescription description =
new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
UNKNOWN, cId, newBuilder.build());
UNKNOWN, cId, newBuilder.build());
deviceProviderService.deviceConnected(deviceId, description);
System.out.println("Device added: " + systemId);
}
@Override
......@@ -302,17 +312,26 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
@Override
public void addLink(IsisLink isisLink) {
log.debug("Addlink {}", isisLink.localSystemId());
if (linkProviderService == null) {
return;
}
LinkDescription linkDes = buildLinkDes(isisLink);
//Updating ports of the link
deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(),
linkDes.src().port()));
deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(),
linkDes.dst().port()));
registerBandwidth(linkDes, isisLink);
linkProviderService.linkDetected(linkDes);
//If already link exists, return
if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) {
return;
}
ConnectPoint destconnectPoint = linkDes.dst();
PortNumber destport = destconnectPoint.port();
if (destport.toLong() != 0) {
deviceProviderService.updatePorts(linkDes.src().deviceId(),
buildPortDescriptions(linkDes.src().deviceId(),
linkDes.src().port()));
deviceProviderService.updatePorts(linkDes.dst().deviceId(),
buildPortDescriptions(linkDes.dst().deviceId(),
linkDes.dst().port()));
registerBandwidth(linkDes, isisLink);
linkProviderService.linkDetected(linkDes);
System.out.println("link desc " + linkDes.toString());
}
}
@Override
......@@ -351,4 +370,4 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
}
}
}
}
}
\ No newline at end of file
......
......@@ -81,6 +81,7 @@ public class IsisTopologyProviderTest {
private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry();
private final TestLinkRegistry linkRegistry = new TestLinkRegistry();
private final TestController controller = new TestController();
private final TestLinkService linkService = new TestLinkService();
private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter();
@Before
......@@ -89,6 +90,7 @@ public class IsisTopologyProviderTest {
provider.linkProviderRegistry = linkRegistry;
provider.networkConfigService = networkConfigService;
provider.controller = controller;
provider.linkService = linkService;
provider.activate();
assertNotNull("provider should be registered", nodeRegistry.provider);
assertNotNull("listener should be registered", controller.nodeListener);
......@@ -289,9 +291,9 @@ public class IsisTopologyProviderTest {
}
}
}
}
private class TestDeviceService extends DeviceServiceAdapter {
private DeviceListener listener;
......