Manikandan K
Committed by Gerrit Code Review

ONOS-4107: ISIS Provider - Bug Fixes

Change-Id: I3c5cb3d1f45f7cf417267fe975256cba2dd066ab
......@@ -45,8 +45,6 @@ import java.util.concurrent.BlockingQueue;
public class LspEventConsumer implements Runnable {
private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class);
public static List<LsPdu> lsPdus = new ArrayList<>();
private String lspAdded = "LSP_ADDED";
private String lspRemoved = "LSP_REMOVED";
private BlockingQueue queue = null;
private Controller controller = null;
private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl();
......@@ -64,24 +62,21 @@ public class LspEventConsumer implements Runnable {
@Override
public void run() {
log.debug("LspsForProvider:run...!!!");
try {
while (true) {
if (!queue.isEmpty()) {
LspWrapper wrapper = (LspWrapper) queue.take();
LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
for (IsisTlv isisTlv : lsPdu.tlvs()) {
if ((isisTlv instanceof IpExtendedReachabilityTlv) ||
(isisTlv instanceof IsExtendedReachability)) {
lsPdus.add(lsPdu);
if (wrapper.lspProcessing().equals(lspAdded)) {
if (wrapper.lspProcessing().equals(IsisConstants.LSPREMOVED)) {
callTopologyToRemoveInfo(lsPdu);
} else if (wrapper.lspProcessing().equals(IsisConstants.LSPADDED)) {
for (IsisTlv isisTlv : lsPdu.tlvs()) {
if ((isisTlv instanceof IpExtendedReachabilityTlv) ||
(isisTlv instanceof IsExtendedReachability)) {
callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(),
wrapper.isisInterface().systemId() + ".00");
break;
}
if (wrapper.lspProcessing().equals(lspRemoved)) {
callTopologyToRemoveInfo(lsPdu);
}
break;
}
}
}
......@@ -99,6 +94,9 @@ public class LspEventConsumer implements Runnable {
*/
private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType,
String ownSystemId) {
if ((lsPdu.lspId().equals(ownSystemId + "-00"))) {
return;
}
if (isisNetworkType.equals(IsisNetworkType.BROADCAST)) {
sendDeviceInfo(lsPdu);
boolean isDis = IsisUtil.checkIsDis(lsPdu.lspId());
......@@ -106,9 +104,7 @@ public class LspEventConsumer implements Runnable {
sendLinkInfo(lsPdu, ownSystemId);
}
} else if (isisNetworkType.equals(IsisNetworkType.P2P)) {
sendDeviceInfo(lsPdu);
for (LsPdu wrapper : lsPdus) {
LsPdu lsPduStored = wrapper;
List<String> neStringList = neighborList(lsPduStored, ownSystemId);
......@@ -117,7 +113,6 @@ public class LspEventConsumer implements Runnable {
sendLinkInfo(lsPduStored, ownSystemId);
}
}
List<String> neStringList = neighborList(lsPdu, ownSystemId);
Map<String, IsisRouter> routerPresence = deviceAndLink.isisDeviceList();
for (String neighbor : neStringList) {
......@@ -137,7 +132,8 @@ public class LspEventConsumer implements Runnable {
* @param lsPdu ls pdu instance
*/
private void callTopologyToRemoveInfo(LsPdu lsPdu) {
removeDeviceInfo(lsPdu);
IsisRouter isisRouter = deviceAndLink.isisRouter(lsPdu.lspId());
removeDeviceInfo(isisRouter);
removeLinkInfo(lsPdu);
}
......@@ -195,13 +191,13 @@ public class LspEventConsumer implements Runnable {
/**
* Removes the device information from topology provider.
*
* @param lsPdu ls pdu instance
* @param isisRouter ISIS router instance
*/
private void removeDeviceInfo(LsPdu lsPdu) {
IsisRouter isisRouter = deviceAndLink.removeDeviceAndLinkInfo(lsPdu);
private void removeDeviceInfo(IsisRouter isisRouter) {
if (isisRouter.systemId() != null) {
controller.removeDeviceDetails(isisRouter);
}
deviceAndLink.removeRouter(isisRouter.systemId());
}
/**
......@@ -228,7 +224,7 @@ public class LspEventConsumer implements Runnable {
* @param lsPdu ls pdu instance
*/
private void removeLinkInfo(LsPdu lsPdu) {
Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu);
Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu.lspId());
for (String key : linkInformationList.keySet()) {
LinkInformation linkInformation = linkInformationList.get(key);
controller.removeLinkDetails(createIsisLink(linkInformation, lsPdu));
......
......@@ -46,6 +46,15 @@ public class NeighborForExtendedIs {
}
/**
* Returns list of sub tlvs.
*
* @return teSubTlv list of sub tlvs
*/
public List<TrafficEngineeringSubTlv> teSubTlv() {
return teSubTlv;
}
/**
* Sets neighbor ID.
*
* @param neighborId neighbor ID
......
......@@ -67,10 +67,15 @@ public final class SubTlvFinder {
subTlv = unreservedBandwidth;
break;
case INTERFACEADDRESS:
NeighborIpAddress ipInterfaceAddressTlv = new NeighborIpAddress(tlvHeader);
InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader);
ipInterfaceAddressTlv.readFrom(channelBuffer);
subTlv = ipInterfaceAddressTlv;
break;
case NEIGHBORADDRESS:
NeighborIpAddress ipNeighborAddressTlv = new NeighborIpAddress(tlvHeader);
ipNeighborAddressTlv.readFrom(channelBuffer);
subTlv = ipNeighborAddressTlv;
break;
default:
//TODO
break;
......
......@@ -54,7 +54,7 @@ public class UnreservedBandwidth extends TlvHeader implements TrafficEngineering
*
* @return List of un reserved bandwidth
*/
public List<Float> getUnReservedBandwidthValue() {
public List<Float> unReservedBandwidthValue() {
return this.unReservedBandwidth;
}
......
......@@ -59,6 +59,7 @@ import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -132,7 +133,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
@Override
public boolean isReachable(DeviceId deviceId) {
log.debug("IsisDeviceProvider::isReachable...!!!!");
return false;
return true;
}
@Override
......@@ -149,6 +150,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
private LinkDescription buildLinkDes(IsisLink isisLink) {
long srcAddress = 0;
long dstAddress = 0;
boolean localPseduo = false;
boolean remotePseduo = false;
String localSystemId = isisLink.localSystemId();
String remoteSystemId = isisLink.remoteSystemId();
//Changing of port numbers
......@@ -156,9 +159,17 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
dstAddress = isisLink.neighborIp().toInt();
DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId));
DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId));
if (srcAddress == 0) {
if (checkIsDis(isisLink.localSystemId())) {
localPseduo = true;
} else if (checkIsDis(isisLink.remoteSystemId())) {
remotePseduo = true;
} else {
log.debug("IsisDeviceProvider::buildLinkDes : unknown type.!");
}
if (localPseduo && srcAddress == 0) {
srcAddress = PSEUDO_PORT;
} else if (dstAddress == 0) {
} else if (remotePseduo && dstAddress == 0) {
dstAddress = PSEUDO_PORT;
}
......@@ -173,6 +184,28 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
}
/**
* Return the DIS value from the systemId.
*
* @param systemId system Id.
* @return return true if DIS else false
*/
public static boolean checkIsDis(String systemId) {
StringTokenizer stringTokenizer = new StringTokenizer(systemId, "." + "-");
int count = 0;
while (stringTokenizer.hasMoreTokens()) {
String str = stringTokenizer.nextToken();
if (count == 3) {
int x = Integer.parseInt(str);
if (x > 0) {
return true;
}
}
count++;
}
return false;
}
/**
* Builds port description.
*
* @param deviceId device ID for the port
......@@ -181,9 +214,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
*/
private List<PortDescription> buildPortDescriptions(DeviceId deviceId,
PortNumber portNumber) {
List<PortDescription> portList;
if (portMap.containsKey(deviceId)) {
portList = portMap.get(deviceId);
} else {
......@@ -193,8 +224,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
PortDescription portDescriptions = new DefaultPortDescription(portNumber, true);
portList.add(portDescriptions);
}
portMap.put(deviceId, portList);
return portList;
}
......@@ -215,6 +246,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
//TE Info
IsisLinkTed isisLinkTed = isisLink.linkTed();
log.info("Ted Information: {}", isisLinkTed.toString());
administrativeGroup = isisLinkTed.administrativeGroup();
teMetric = isisLinkTed.teDefaultMetric();
maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth();
......@@ -251,7 +283,7 @@ 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);
}
......@@ -276,9 +308,9 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
LinkDescription linkDes = buildLinkDes(isisLink);
//Updating ports of the link
deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(),
linkDes.src().port()));
linkDes.src().port()));
deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(),
linkDes.dst().port()));
linkDes.dst().port()));
registerBandwidth(linkDes, isisLink);
linkProviderService.linkDetected(linkDes);
}
......@@ -319,4 +351,4 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
}
}
}
}
\ No newline at end of file
}
......