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; ...@@ -45,8 +45,6 @@ import java.util.concurrent.BlockingQueue;
45 public class LspEventConsumer implements Runnable { 45 public class LspEventConsumer implements Runnable {
46 private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class); 46 private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class);
47 public static List<LsPdu> lsPdus = new ArrayList<>(); 47 public static List<LsPdu> lsPdus = new ArrayList<>();
48 - private String lspAdded = "LSP_ADDED";
49 - private String lspRemoved = "LSP_REMOVED";
50 private BlockingQueue queue = null; 48 private BlockingQueue queue = null;
51 private Controller controller = null; 49 private Controller controller = null;
52 private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl(); 50 private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl();
...@@ -64,24 +62,21 @@ public class LspEventConsumer implements Runnable { ...@@ -64,24 +62,21 @@ public class LspEventConsumer implements Runnable {
64 62
65 @Override 63 @Override
66 public void run() { 64 public void run() {
67 - log.debug("LspsForProvider:run...!!!");
68 try { 65 try {
69 while (true) { 66 while (true) {
70 if (!queue.isEmpty()) { 67 if (!queue.isEmpty()) {
71 LspWrapper wrapper = (LspWrapper) queue.take(); 68 LspWrapper wrapper = (LspWrapper) queue.take();
72 LsPdu lsPdu = (LsPdu) wrapper.lsPdu(); 69 LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
73 - for (IsisTlv isisTlv : lsPdu.tlvs()) { 70 + if (wrapper.lspProcessing().equals(IsisConstants.LSPREMOVED)) {
74 - if ((isisTlv instanceof IpExtendedReachabilityTlv) || 71 + callTopologyToRemoveInfo(lsPdu);
75 - (isisTlv instanceof IsExtendedReachability)) { 72 + } else if (wrapper.lspProcessing().equals(IsisConstants.LSPADDED)) {
76 - lsPdus.add(lsPdu); 73 + for (IsisTlv isisTlv : lsPdu.tlvs()) {
77 - if (wrapper.lspProcessing().equals(lspAdded)) { 74 + if ((isisTlv instanceof IpExtendedReachabilityTlv) ||
75 + (isisTlv instanceof IsExtendedReachability)) {
78 callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(), 76 callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(),
79 wrapper.isisInterface().systemId() + ".00"); 77 wrapper.isisInterface().systemId() + ".00");
78 + break;
80 } 79 }
81 - if (wrapper.lspProcessing().equals(lspRemoved)) {
82 - callTopologyToRemoveInfo(lsPdu);
83 - }
84 - break;
85 } 80 }
86 } 81 }
87 } 82 }
...@@ -99,6 +94,9 @@ public class LspEventConsumer implements Runnable { ...@@ -99,6 +94,9 @@ public class LspEventConsumer implements Runnable {
99 */ 94 */
100 private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType, 95 private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType,
101 String ownSystemId) { 96 String ownSystemId) {
97 + if ((lsPdu.lspId().equals(ownSystemId + "-00"))) {
98 + return;
99 + }
102 if (isisNetworkType.equals(IsisNetworkType.BROADCAST)) { 100 if (isisNetworkType.equals(IsisNetworkType.BROADCAST)) {
103 sendDeviceInfo(lsPdu); 101 sendDeviceInfo(lsPdu);
104 boolean isDis = IsisUtil.checkIsDis(lsPdu.lspId()); 102 boolean isDis = IsisUtil.checkIsDis(lsPdu.lspId());
...@@ -106,9 +104,7 @@ public class LspEventConsumer implements Runnable { ...@@ -106,9 +104,7 @@ public class LspEventConsumer implements Runnable {
106 sendLinkInfo(lsPdu, ownSystemId); 104 sendLinkInfo(lsPdu, ownSystemId);
107 } 105 }
108 } else if (isisNetworkType.equals(IsisNetworkType.P2P)) { 106 } else if (isisNetworkType.equals(IsisNetworkType.P2P)) {
109 -
110 sendDeviceInfo(lsPdu); 107 sendDeviceInfo(lsPdu);
111 -
112 for (LsPdu wrapper : lsPdus) { 108 for (LsPdu wrapper : lsPdus) {
113 LsPdu lsPduStored = wrapper; 109 LsPdu lsPduStored = wrapper;
114 List<String> neStringList = neighborList(lsPduStored, ownSystemId); 110 List<String> neStringList = neighborList(lsPduStored, ownSystemId);
...@@ -117,7 +113,6 @@ public class LspEventConsumer implements Runnable { ...@@ -117,7 +113,6 @@ public class LspEventConsumer implements Runnable {
117 sendLinkInfo(lsPduStored, ownSystemId); 113 sendLinkInfo(lsPduStored, ownSystemId);
118 } 114 }
119 } 115 }
120 -
121 List<String> neStringList = neighborList(lsPdu, ownSystemId); 116 List<String> neStringList = neighborList(lsPdu, ownSystemId);
122 Map<String, IsisRouter> routerPresence = deviceAndLink.isisDeviceList(); 117 Map<String, IsisRouter> routerPresence = deviceAndLink.isisDeviceList();
123 for (String neighbor : neStringList) { 118 for (String neighbor : neStringList) {
...@@ -137,7 +132,8 @@ public class LspEventConsumer implements Runnable { ...@@ -137,7 +132,8 @@ public class LspEventConsumer implements Runnable {
137 * @param lsPdu ls pdu instance 132 * @param lsPdu ls pdu instance
138 */ 133 */
139 private void callTopologyToRemoveInfo(LsPdu lsPdu) { 134 private void callTopologyToRemoveInfo(LsPdu lsPdu) {
140 - removeDeviceInfo(lsPdu); 135 + IsisRouter isisRouter = deviceAndLink.isisRouter(lsPdu.lspId());
136 + removeDeviceInfo(isisRouter);
141 removeLinkInfo(lsPdu); 137 removeLinkInfo(lsPdu);
142 } 138 }
143 139
...@@ -195,13 +191,13 @@ public class LspEventConsumer implements Runnable { ...@@ -195,13 +191,13 @@ public class LspEventConsumer implements Runnable {
195 /** 191 /**
196 * Removes the device information from topology provider. 192 * Removes the device information from topology provider.
197 * 193 *
198 - * @param lsPdu ls pdu instance 194 + * @param isisRouter ISIS router instance
199 */ 195 */
200 - private void removeDeviceInfo(LsPdu lsPdu) { 196 + private void removeDeviceInfo(IsisRouter isisRouter) {
201 - IsisRouter isisRouter = deviceAndLink.removeDeviceAndLinkInfo(lsPdu);
202 if (isisRouter.systemId() != null) { 197 if (isisRouter.systemId() != null) {
203 controller.removeDeviceDetails(isisRouter); 198 controller.removeDeviceDetails(isisRouter);
204 } 199 }
200 + deviceAndLink.removeRouter(isisRouter.systemId());
205 } 201 }
206 202
207 /** 203 /**
...@@ -228,7 +224,7 @@ public class LspEventConsumer implements Runnable { ...@@ -228,7 +224,7 @@ public class LspEventConsumer implements Runnable {
228 * @param lsPdu ls pdu instance 224 * @param lsPdu ls pdu instance
229 */ 225 */
230 private void removeLinkInfo(LsPdu lsPdu) { 226 private void removeLinkInfo(LsPdu lsPdu) {
231 - Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu); 227 + Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu.lspId());
232 for (String key : linkInformationList.keySet()) { 228 for (String key : linkInformationList.keySet()) {
233 LinkInformation linkInformation = linkInformationList.get(key); 229 LinkInformation linkInformation = linkInformationList.get(key);
234 controller.removeLinkDetails(createIsisLink(linkInformation, lsPdu)); 230 controller.removeLinkDetails(createIsisLink(linkInformation, lsPdu));
......
...@@ -46,6 +46,15 @@ public class NeighborForExtendedIs { ...@@ -46,6 +46,15 @@ public class NeighborForExtendedIs {
46 } 46 }
47 47
48 /** 48 /**
49 + * Returns list of sub tlvs.
50 + *
51 + * @return teSubTlv list of sub tlvs
52 + */
53 + public List<TrafficEngineeringSubTlv> teSubTlv() {
54 + return teSubTlv;
55 + }
56 +
57 + /**
49 * Sets neighbor ID. 58 * Sets neighbor ID.
50 * 59 *
51 * @param neighborId neighbor ID 60 * @param neighborId neighbor ID
......
...@@ -67,10 +67,15 @@ public final class SubTlvFinder { ...@@ -67,10 +67,15 @@ public final class SubTlvFinder {
67 subTlv = unreservedBandwidth; 67 subTlv = unreservedBandwidth;
68 break; 68 break;
69 case INTERFACEADDRESS: 69 case INTERFACEADDRESS:
70 - NeighborIpAddress ipInterfaceAddressTlv = new NeighborIpAddress(tlvHeader); 70 + InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader);
71 ipInterfaceAddressTlv.readFrom(channelBuffer); 71 ipInterfaceAddressTlv.readFrom(channelBuffer);
72 subTlv = ipInterfaceAddressTlv; 72 subTlv = ipInterfaceAddressTlv;
73 break; 73 break;
74 + case NEIGHBORADDRESS:
75 + NeighborIpAddress ipNeighborAddressTlv = new NeighborIpAddress(tlvHeader);
76 + ipNeighborAddressTlv.readFrom(channelBuffer);
77 + subTlv = ipNeighborAddressTlv;
78 + break;
74 default: 79 default:
75 //TODO 80 //TODO
76 break; 81 break;
......
...@@ -54,7 +54,7 @@ public class UnreservedBandwidth extends TlvHeader implements TrafficEngineering ...@@ -54,7 +54,7 @@ public class UnreservedBandwidth extends TlvHeader implements TrafficEngineering
54 * 54 *
55 * @return List of un reserved bandwidth 55 * @return List of un reserved bandwidth
56 */ 56 */
57 - public List<Float> getUnReservedBandwidthValue() { 57 + public List<Float> unReservedBandwidthValue() {
58 return this.unReservedBandwidth; 58 return this.unReservedBandwidth;
59 } 59 }
60 60
......
...@@ -59,6 +59,7 @@ import org.slf4j.Logger; ...@@ -59,6 +59,7 @@ import org.slf4j.Logger;
59 import java.util.ArrayList; 59 import java.util.ArrayList;
60 import java.util.HashMap; 60 import java.util.HashMap;
61 import java.util.List; 61 import java.util.List;
62 +import java.util.StringTokenizer;
62 63
63 import static org.slf4j.LoggerFactory.getLogger; 64 import static org.slf4j.LoggerFactory.getLogger;
64 65
...@@ -132,7 +133,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -132,7 +133,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
132 @Override 133 @Override
133 public boolean isReachable(DeviceId deviceId) { 134 public boolean isReachable(DeviceId deviceId) {
134 log.debug("IsisDeviceProvider::isReachable...!!!!"); 135 log.debug("IsisDeviceProvider::isReachable...!!!!");
135 - return false; 136 + return true;
136 } 137 }
137 138
138 @Override 139 @Override
...@@ -149,6 +150,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -149,6 +150,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
149 private LinkDescription buildLinkDes(IsisLink isisLink) { 150 private LinkDescription buildLinkDes(IsisLink isisLink) {
150 long srcAddress = 0; 151 long srcAddress = 0;
151 long dstAddress = 0; 152 long dstAddress = 0;
153 + boolean localPseduo = false;
154 + boolean remotePseduo = false;
152 String localSystemId = isisLink.localSystemId(); 155 String localSystemId = isisLink.localSystemId();
153 String remoteSystemId = isisLink.remoteSystemId(); 156 String remoteSystemId = isisLink.remoteSystemId();
154 //Changing of port numbers 157 //Changing of port numbers
...@@ -156,9 +159,17 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -156,9 +159,17 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
156 dstAddress = isisLink.neighborIp().toInt(); 159 dstAddress = isisLink.neighborIp().toInt();
157 DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId)); 160 DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId));
158 DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId)); 161 DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId));
159 - if (srcAddress == 0) { 162 + if (checkIsDis(isisLink.localSystemId())) {
163 + localPseduo = true;
164 + } else if (checkIsDis(isisLink.remoteSystemId())) {
165 + remotePseduo = true;
166 + } else {
167 + log.debug("IsisDeviceProvider::buildLinkDes : unknown type.!");
168 + }
169 +
170 + if (localPseduo && srcAddress == 0) {
160 srcAddress = PSEUDO_PORT; 171 srcAddress = PSEUDO_PORT;
161 - } else if (dstAddress == 0) { 172 + } else if (remotePseduo && dstAddress == 0) {
162 dstAddress = PSEUDO_PORT; 173 dstAddress = PSEUDO_PORT;
163 } 174 }
164 175
...@@ -173,6 +184,28 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -173,6 +184,28 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
173 } 184 }
174 185
175 /** 186 /**
187 + * Return the DIS value from the systemId.
188 + *
189 + * @param systemId system Id.
190 + * @return return true if DIS else false
191 + */
192 + public static boolean checkIsDis(String systemId) {
193 + StringTokenizer stringTokenizer = new StringTokenizer(systemId, "." + "-");
194 + int count = 0;
195 + while (stringTokenizer.hasMoreTokens()) {
196 + String str = stringTokenizer.nextToken();
197 + if (count == 3) {
198 + int x = Integer.parseInt(str);
199 + if (x > 0) {
200 + return true;
201 + }
202 + }
203 + count++;
204 + }
205 + return false;
206 + }
207 +
208 + /**
176 * Builds port description. 209 * Builds port description.
177 * 210 *
178 * @param deviceId device ID for the port 211 * @param deviceId device ID for the port
...@@ -181,9 +214,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -181,9 +214,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
181 */ 214 */
182 private List<PortDescription> buildPortDescriptions(DeviceId deviceId, 215 private List<PortDescription> buildPortDescriptions(DeviceId deviceId,
183 PortNumber portNumber) { 216 PortNumber portNumber) {
184 -
185 List<PortDescription> portList; 217 List<PortDescription> portList;
186 -
187 if (portMap.containsKey(deviceId)) { 218 if (portMap.containsKey(deviceId)) {
188 portList = portMap.get(deviceId); 219 portList = portMap.get(deviceId);
189 } else { 220 } else {
...@@ -193,8 +224,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -193,8 +224,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
193 PortDescription portDescriptions = new DefaultPortDescription(portNumber, true); 224 PortDescription portDescriptions = new DefaultPortDescription(portNumber, true);
194 portList.add(portDescriptions); 225 portList.add(portDescriptions);
195 } 226 }
196 -
197 portMap.put(deviceId, portList); 227 portMap.put(deviceId, portList);
228 +
198 return portList; 229 return portList;
199 } 230 }
200 231
...@@ -215,6 +246,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -215,6 +246,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
215 246
216 //TE Info 247 //TE Info
217 IsisLinkTed isisLinkTed = isisLink.linkTed(); 248 IsisLinkTed isisLinkTed = isisLink.linkTed();
249 + log.info("Ted Information: {}", isisLinkTed.toString());
218 administrativeGroup = isisLinkTed.administrativeGroup(); 250 administrativeGroup = isisLinkTed.administrativeGroup();
219 teMetric = isisLinkTed.teDefaultMetric(); 251 teMetric = isisLinkTed.teDefaultMetric();
220 maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth(); 252 maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth();
...@@ -251,7 +283,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -251,7 +283,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
251 newBuilder.set("RouterId", systemId); 283 newBuilder.set("RouterId", systemId);
252 DeviceDescription description = 284 DeviceDescription description =
253 new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN, 285 new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
254 - UNKNOWN, cId, newBuilder.build()); 286 + UNKNOWN, cId, newBuilder.build());
255 deviceProviderService.deviceConnected(deviceId, description); 287 deviceProviderService.deviceConnected(deviceId, description);
256 } 288 }
257 289
...@@ -276,9 +308,9 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -276,9 +308,9 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
276 LinkDescription linkDes = buildLinkDes(isisLink); 308 LinkDescription linkDes = buildLinkDes(isisLink);
277 //Updating ports of the link 309 //Updating ports of the link
278 deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(), 310 deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(),
279 - linkDes.src().port())); 311 + linkDes.src().port()));
280 deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(), 312 deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(),
281 - linkDes.dst().port())); 313 + linkDes.dst().port()));
282 registerBandwidth(linkDes, isisLink); 314 registerBandwidth(linkDes, isisLink);
283 linkProviderService.linkDetected(linkDes); 315 linkProviderService.linkDetected(linkDes);
284 } 316 }
...@@ -319,4 +351,4 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -319,4 +351,4 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
319 } 351 }
320 } 352 }
321 } 353 }
322 -}
...\ No newline at end of file ...\ No newline at end of file
354 +}
......