Committed by
Brian O'Connor
ONOS-4107: ISIS Provider - Bug Fixes
Change-Id: I1945f614c02a39326d22e268fbb015e50d075368
Showing
6 changed files
with
257 additions
and
96 deletions
... | @@ -122,4 +122,11 @@ public interface IsisLsdb { | ... | @@ -122,4 +122,11 @@ public interface IsisLsdb { |
122 | * @param l2LspSeqNo link state sequence number | 122 | * @param l2LspSeqNo link state sequence number |
123 | */ | 123 | */ |
124 | void setL2LspSeqNo(int l2LspSeqNo); | 124 | void setL2LspSeqNo(int l2LspSeqNo); |
125 | + /** | ||
126 | + * Removes topology information when neighbor down. | ||
127 | + * | ||
128 | + * @param neighbor ISIS neighbor instance | ||
129 | + * @param isisInterface ISIS interface instance | ||
130 | + */ | ||
131 | + void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface); | ||
125 | } | 132 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
100644 → 100755
... | @@ -356,6 +356,8 @@ public class DefaultIsisNeighbor implements IsisNeighbor { | ... | @@ -356,6 +356,8 @@ public class DefaultIsisNeighbor implements IsisNeighbor { |
356 | stopInactivityTimeCheck(); | 356 | stopInactivityTimeCheck(); |
357 | stopHoldingTimeCheck(); | 357 | stopHoldingTimeCheck(); |
358 | isisInterface.removeNeighbor(this); | 358 | isisInterface.removeNeighbor(this); |
359 | + | ||
360 | + isisInterface.isisLsdb().removeTopology(this, isisInterface); | ||
359 | } | 361 | } |
360 | 362 | ||
361 | /** | 363 | /** | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java
100644 → 100755
... | @@ -15,9 +15,13 @@ | ... | @@ -15,9 +15,13 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.isis.controller.impl; | 16 | package org.onosproject.isis.controller.impl; |
17 | 17 | ||
18 | +import org.onlab.packet.Ip4Address; | ||
19 | +import org.onlab.util.Bandwidth; | ||
18 | import org.onosproject.isis.controller.IsisNetworkType; | 20 | import org.onosproject.isis.controller.IsisNetworkType; |
19 | import org.onosproject.isis.controller.LspWrapper; | 21 | import org.onosproject.isis.controller.LspWrapper; |
20 | import org.onosproject.isis.controller.impl.topology.DefaultIsisLink; | 22 | import org.onosproject.isis.controller.impl.topology.DefaultIsisLink; |
23 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkInformation; | ||
24 | +import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkTed; | ||
21 | import org.onosproject.isis.controller.impl.topology.DefaultIsisRouter; | 25 | import org.onosproject.isis.controller.impl.topology.DefaultIsisRouter; |
22 | import org.onosproject.isis.controller.impl.topology.TopologyForDeviceAndLinkImpl; | 26 | import org.onosproject.isis.controller.impl.topology.TopologyForDeviceAndLinkImpl; |
23 | import org.onosproject.isis.controller.topology.IsisLink; | 27 | import org.onosproject.isis.controller.topology.IsisLink; |
... | @@ -25,16 +29,24 @@ import org.onosproject.isis.controller.topology.IsisLinkTed; | ... | @@ -25,16 +29,24 @@ import org.onosproject.isis.controller.topology.IsisLinkTed; |
25 | import org.onosproject.isis.controller.topology.IsisRouter; | 29 | import org.onosproject.isis.controller.topology.IsisRouter; |
26 | import org.onosproject.isis.controller.topology.LinkInformation; | 30 | import org.onosproject.isis.controller.topology.LinkInformation; |
27 | import org.onosproject.isis.io.isispacket.pdu.LsPdu; | 31 | import org.onosproject.isis.io.isispacket.pdu.LsPdu; |
28 | -import org.onosproject.isis.io.isispacket.tlv.IpExtendedReachabilityTlv; | ||
29 | import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability; | 32 | import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability; |
30 | import org.onosproject.isis.io.isispacket.tlv.IsisTlv; | 33 | import org.onosproject.isis.io.isispacket.tlv.IsisTlv; |
31 | import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs; | 34 | import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs; |
35 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup; | ||
36 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.InterfaceIpAddress; | ||
37 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumBandwidth; | ||
38 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth; | ||
39 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.NeighborIpAddress; | ||
40 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric; | ||
41 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv; | ||
42 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.UnreservedBandwidth; | ||
32 | import org.onosproject.isis.io.util.IsisConstants; | 43 | import org.onosproject.isis.io.util.IsisConstants; |
33 | import org.onosproject.isis.io.util.IsisUtil; | 44 | import org.onosproject.isis.io.util.IsisUtil; |
34 | import org.slf4j.Logger; | 45 | import org.slf4j.Logger; |
35 | import org.slf4j.LoggerFactory; | 46 | import org.slf4j.LoggerFactory; |
36 | 47 | ||
37 | import java.util.ArrayList; | 48 | import java.util.ArrayList; |
49 | +import java.util.LinkedHashMap; | ||
38 | import java.util.List; | 50 | import java.util.List; |
39 | import java.util.Map; | 51 | import java.util.Map; |
40 | import java.util.concurrent.BlockingQueue; | 52 | import java.util.concurrent.BlockingQueue; |
... | @@ -44,10 +56,10 @@ import java.util.concurrent.BlockingQueue; | ... | @@ -44,10 +56,10 @@ import java.util.concurrent.BlockingQueue; |
44 | */ | 56 | */ |
45 | public class LspEventConsumer implements Runnable { | 57 | public class LspEventConsumer implements Runnable { |
46 | private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class); | 58 | private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class); |
47 | - public static List<LsPdu> lsPdus = new ArrayList<>(); | ||
48 | private BlockingQueue queue = null; | 59 | private BlockingQueue queue = null; |
49 | private Controller controller = null; | 60 | private Controller controller = null; |
50 | private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl(); | 61 | private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl(); |
62 | + private Map<String, IsisRouter> isisRouterDetails = new LinkedHashMap<>(); | ||
51 | 63 | ||
52 | /** | 64 | /** |
53 | * Creates an instance of this. | 65 | * Creates an instance of this. |
... | @@ -70,14 +82,8 @@ public class LspEventConsumer implements Runnable { | ... | @@ -70,14 +82,8 @@ public class LspEventConsumer implements Runnable { |
70 | if (wrapper.lspProcessing().equals(IsisConstants.LSPREMOVED)) { | 82 | if (wrapper.lspProcessing().equals(IsisConstants.LSPREMOVED)) { |
71 | callTopologyToRemoveInfo(lsPdu); | 83 | callTopologyToRemoveInfo(lsPdu); |
72 | } else if (wrapper.lspProcessing().equals(IsisConstants.LSPADDED)) { | 84 | } else if (wrapper.lspProcessing().equals(IsisConstants.LSPADDED)) { |
73 | - for (IsisTlv isisTlv : lsPdu.tlvs()) { | 85 | + callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(), |
74 | - if ((isisTlv instanceof IpExtendedReachabilityTlv) || | 86 | + wrapper.isisInterface().systemId() + ".00"); |
75 | - (isisTlv instanceof IsExtendedReachability)) { | ||
76 | - callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(), | ||
77 | - wrapper.isisInterface().systemId() + ".00"); | ||
78 | - break; | ||
79 | - } | ||
80 | - } | ||
81 | } | 87 | } |
82 | } | 88 | } |
83 | } | 89 | } |
... | @@ -91,36 +97,50 @@ public class LspEventConsumer implements Runnable { | ... | @@ -91,36 +97,50 @@ public class LspEventConsumer implements Runnable { |
91 | * | 97 | * |
92 | * @param lsPdu ls pdu instance | 98 | * @param lsPdu ls pdu instance |
93 | * @param isisNetworkType ISIS network type | 99 | * @param isisNetworkType ISIS network type |
100 | + * @param ownSystemId own system ID | ||
94 | */ | 101 | */ |
95 | private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType, | 102 | private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType, |
96 | String ownSystemId) { | 103 | String ownSystemId) { |
97 | if ((lsPdu.lspId().equals(ownSystemId + "-00"))) { | 104 | if ((lsPdu.lspId().equals(ownSystemId + "-00"))) { |
98 | return; | 105 | return; |
99 | } | 106 | } |
100 | - if (isisNetworkType.equals(IsisNetworkType.BROADCAST)) { | 107 | + sendDeviceInfo(createDeviceInfo(lsPdu)); |
101 | - sendDeviceInfo(lsPdu); | 108 | + |
102 | - boolean isDis = IsisUtil.checkIsDis(lsPdu.lspId()); | 109 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { |
103 | - if (isDis) { | 110 | + if (isisTlv instanceof IsExtendedReachability) { |
104 | - sendLinkInfo(lsPdu, ownSystemId); | 111 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; |
105 | - } | 112 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); |
106 | - } else if (isisNetworkType.equals(IsisNetworkType.P2P)) { | 113 | + for (NeighborForExtendedIs teTlv : neighbours) { |
107 | - sendDeviceInfo(lsPdu); | 114 | + String neighbor = teTlv.neighborId(); |
108 | - for (LsPdu wrapper : lsPdus) { | 115 | + IsisRouter isisRouter = isisRouterDetails.get(neighbor); |
109 | - LsPdu lsPduStored = wrapper; | 116 | + if (isisRouter != null) { |
110 | - List<String> neStringList = neighborList(lsPduStored, ownSystemId); | 117 | + IsisRouter sourceRouter = isisRouterDetails.get(IsisUtil.removeTailingZeros(lsPdu.lspId())); |
111 | - String lspId = IsisUtil.removeTailingZeros(lsPdu.lspId()); | 118 | + IsisRouter destinationRouter = isisRouter; |
112 | - if (neStringList.contains(lspId)) { | 119 | + if (sourceRouter.isDis()) { |
113 | - sendLinkInfo(lsPduStored, ownSystemId); | 120 | + LinkInformation linkInformation = createLinkInfo(sourceRouter.systemId(), |
114 | - } | 121 | + destinationRouter.systemId(), |
115 | - } | 122 | + sourceRouter.interfaceId(), |
116 | - List<String> neStringList = neighborList(lsPdu, ownSystemId); | 123 | + destinationRouter.interfaceId(), lsPdu); |
117 | - Map<String, IsisRouter> routerPresence = deviceAndLink.isisDeviceList(); | 124 | + controller.addLinkDetails(createIsisLink(linkInformation, lsPdu)); |
118 | - for (String neighbor : neStringList) { | 125 | + } else if (destinationRouter.isDis()) { |
119 | - IsisRouter isisRouter = routerPresence.get(neighbor); | 126 | + LinkInformation linkInformation1 = createLinkInfo(destinationRouter.systemId(), |
120 | - if (isisRouter != null) { | 127 | + sourceRouter.systemId(), |
121 | - sendLinkInfo(lsPdu, ownSystemId); | 128 | + destinationRouter.interfaceId(), |
122 | - } else { | 129 | + sourceRouter.interfaceId(), lsPdu); |
123 | - lsPdus.add(lsPdu); | 130 | + controller.addLinkDetails(createIsisLink(linkInformation1, lsPdu)); |
131 | + } else { | ||
132 | + LinkInformation linkInformation = createLinkInfo(sourceRouter.systemId(), | ||
133 | + destinationRouter.systemId(), | ||
134 | + sourceRouter.interfaceId(), | ||
135 | + destinationRouter.interfaceId(), lsPdu); | ||
136 | + controller.addLinkDetails(createIsisLink(linkInformation, lsPdu)); | ||
137 | + LinkInformation linkInformation1 = createLinkInfo(destinationRouter.systemId(), | ||
138 | + sourceRouter.systemId(), | ||
139 | + destinationRouter.interfaceId(), | ||
140 | + sourceRouter.interfaceId(), lsPdu); | ||
141 | + controller.addLinkDetails(createIsisLink(linkInformation1, lsPdu)); | ||
142 | + } | ||
143 | + } | ||
124 | } | 144 | } |
125 | } | 145 | } |
126 | } | 146 | } |
... | @@ -132,7 +152,8 @@ public class LspEventConsumer implements Runnable { | ... | @@ -132,7 +152,8 @@ public class LspEventConsumer implements Runnable { |
132 | * @param lsPdu ls pdu instance | 152 | * @param lsPdu ls pdu instance |
133 | */ | 153 | */ |
134 | private void callTopologyToRemoveInfo(LsPdu lsPdu) { | 154 | private void callTopologyToRemoveInfo(LsPdu lsPdu) { |
135 | - IsisRouter isisRouter = deviceAndLink.isisRouter(lsPdu.lspId()); | 155 | + String routerId = IsisUtil.removeTailingZeros(lsPdu.lspId()); |
156 | + IsisRouter isisRouter = isisRouterDetails.get(routerId); | ||
136 | removeDeviceInfo(isisRouter); | 157 | removeDeviceInfo(isisRouter); |
137 | removeLinkInfo(lsPdu); | 158 | removeLinkInfo(lsPdu); |
138 | } | 159 | } |
... | @@ -140,52 +161,95 @@ public class LspEventConsumer implements Runnable { | ... | @@ -140,52 +161,95 @@ public class LspEventConsumer implements Runnable { |
140 | /** | 161 | /** |
141 | * Sends the device information to topology provider. | 162 | * Sends the device information to topology provider. |
142 | * | 163 | * |
143 | - * @param lsPdu ls pdu instance | 164 | + * @param isisRouter ISIS router instance |
144 | */ | 165 | */ |
145 | - private void sendDeviceInfo(LsPdu lsPdu) { | 166 | + private void sendDeviceInfo(IsisRouter isisRouter) { |
146 | - IsisRouter isisRouter = deviceAndLink.createDeviceInfo(lsPdu); | ||
147 | if (isisRouter.systemId() != null) { | 167 | if (isisRouter.systemId() != null) { |
148 | controller.addDeviceDetails(isisRouter); | 168 | controller.addDeviceDetails(isisRouter); |
149 | } | 169 | } |
150 | } | 170 | } |
151 | 171 | ||
152 | /** | 172 | /** |
153 | - * Returns the list of neighbors. | 173 | + * Creates Device instance. |
154 | * | 174 | * |
155 | - * @param lsPdu link state Pdu | 175 | + * @param lsPdu ISIS LSPDU instance |
156 | - * @return neighbor list | 176 | + * @return isisRouter isisRouter instance |
157 | */ | 177 | */ |
158 | - private List<String> neighborList(LsPdu lsPdu, String ownSystemId) { | 178 | + public IsisRouter createDeviceInfo(LsPdu lsPdu) { |
159 | - List<String> neighbourList = new ArrayList<>(); | 179 | + IsisRouter isisRouter = createIsisRouter(lsPdu); |
180 | + if (isisRouter.systemId() != null) { | ||
181 | + isisRouterDetails.put(isisRouter.systemId(), isisRouter); | ||
182 | + } | ||
183 | + return isisRouter; | ||
184 | + } | ||
185 | + | ||
186 | + /** | ||
187 | + * Creates ISIS router instance. | ||
188 | + * | ||
189 | + * @param lsPdu lsp instance | ||
190 | + * @return isisRouter instance | ||
191 | + */ | ||
192 | + private IsisRouter createIsisRouter(LsPdu lsPdu) { | ||
193 | + IsisRouter isisRouter = new DefaultIsisRouter(); | ||
194 | + if (IsisUtil.checkIsDis(lsPdu.lspId())) { | ||
195 | + isisRouter.setDis(true); | ||
196 | + } else { | ||
197 | + isisRouter.setDis(false); | ||
198 | + } | ||
199 | + isisRouter.setSystemId(IsisUtil.removeTailingZeros(lsPdu.lspId())); | ||
160 | for (IsisTlv isisTlv : lsPdu.tlvs()) { | 200 | for (IsisTlv isisTlv : lsPdu.tlvs()) { |
161 | if (isisTlv instanceof IsExtendedReachability) { | 201 | if (isisTlv instanceof IsExtendedReachability) { |
162 | IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | 202 | IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; |
163 | - List<NeighborForExtendedIs> neighborForExtendedIsList = isExtendedReachability.neighbours(); | 203 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); |
164 | - for (NeighborForExtendedIs neighbor : neighborForExtendedIsList) { | 204 | + for (NeighborForExtendedIs teTlv : neighbours) { |
165 | - String neighbourId = neighbor.neighborId(); | 205 | + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv(); |
166 | - if (!(neighbourId.equals(ownSystemId))) { | 206 | + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) { |
167 | - neighbourList.add(neighbourId); | 207 | + if (teSubTlv instanceof InterfaceIpAddress) { |
168 | - } | 208 | + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv; |
209 | + isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress()); | ||
210 | + } else if (teSubTlv instanceof NeighborIpAddress) { | ||
211 | + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv; | ||
212 | + isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress()); | ||
213 | + } | ||
169 | 214 | ||
215 | + } | ||
170 | } | 216 | } |
171 | } | 217 | } |
172 | } | 218 | } |
173 | - return neighbourList; | 219 | + if (isisRouter.interfaceId() == null) { |
220 | + isisRouter.setInterfaceId(IsisConstants.DEFAULTIP); | ||
221 | + } | ||
222 | + if (isisRouter.neighborRouterId() == null) { | ||
223 | + isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP); | ||
224 | + } | ||
225 | + return isisRouter; | ||
174 | } | 226 | } |
175 | 227 | ||
176 | /** | 228 | /** |
177 | - * Creates ISIS router instance. | 229 | + * Creates link information. |
178 | * | 230 | * |
179 | - * @param systemId system ID | 231 | + * @param localSystemId local system ID |
180 | - * @return isisRouter instance | 232 | + * @param remoteSystemId remote system ID |
233 | + * @return link information | ||
234 | + * @param interfaceIp interface address | ||
235 | + * @param neighborIp neighbor address | ||
236 | + * @param lsPdu link state PDU instance | ||
237 | + * @return link information instance | ||
181 | */ | 238 | */ |
182 | - private IsisRouter createIsisRouterDummy(String systemId) { | 239 | + public LinkInformation createLinkInfo(String localSystemId, String remoteSystemId, |
183 | - IsisRouter isisRouter = new DefaultIsisRouter(); | 240 | + Ip4Address interfaceIp, Ip4Address neighborIp, |
184 | - isisRouter.setSystemId(systemId); | 241 | + LsPdu lsPdu) { |
185 | - isisRouter.setDis(false); | 242 | + |
186 | - isisRouter.setInterfaceId(IsisConstants.DEFAULTIP); | 243 | + String linkId = "link:" + localSystemId + "-" + remoteSystemId; |
187 | - isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP); | 244 | + LinkInformation linkInformation = new DefaultIsisLinkInformation(); |
188 | - return isisRouter; | 245 | + linkInformation.setInterfaceIp(interfaceIp); |
246 | + linkInformation.setNeighborIp(neighborIp); | ||
247 | + linkInformation.setLinkId(linkId); | ||
248 | + linkInformation.setAlreadyCreated(false); | ||
249 | + linkInformation.setLinkDestinationId(remoteSystemId); | ||
250 | + linkInformation.setLinkSourceId(localSystemId); | ||
251 | + | ||
252 | + return linkInformation; | ||
189 | } | 253 | } |
190 | 254 | ||
191 | /** | 255 | /** |
... | @@ -197,26 +261,9 @@ public class LspEventConsumer implements Runnable { | ... | @@ -197,26 +261,9 @@ public class LspEventConsumer implements Runnable { |
197 | if (isisRouter.systemId() != null) { | 261 | if (isisRouter.systemId() != null) { |
198 | controller.removeDeviceDetails(isisRouter); | 262 | controller.removeDeviceDetails(isisRouter); |
199 | } | 263 | } |
200 | - deviceAndLink.removeRouter(isisRouter.systemId()); | 264 | + isisRouterDetails.remove(isisRouter.systemId()); |
201 | } | 265 | } |
202 | 266 | ||
203 | - /** | ||
204 | - * Sends the link information to topology provider. | ||
205 | - * | ||
206 | - * @param lsPdu ls pdu instance | ||
207 | - */ | ||
208 | - private void sendLinkInfo(LsPdu lsPdu, String ownSystemId) { | ||
209 | - Map<String, LinkInformation> linkInformationList = deviceAndLink.createLinkInfo(lsPdu, ownSystemId); | ||
210 | - for (String key : linkInformationList.keySet()) { | ||
211 | - LinkInformation linkInformation = linkInformationList.get(key); | ||
212 | - if (linkInformation.isAlreadyCreated()) { | ||
213 | - controller.addDeviceDetails(createIsisRouterDummy(linkInformation.linkDestinationId())); | ||
214 | - controller.addLinkDetails(createIsisLink(linkInformation, lsPdu)); | ||
215 | - } else { | ||
216 | - controller.addLinkDetails(createIsisLink(linkInformation, lsPdu)); | ||
217 | - } | ||
218 | - } | ||
219 | - } | ||
220 | 267 | ||
221 | /** | 268 | /** |
222 | * Removes the link information from topology provider. | 269 | * Removes the link information from topology provider. |
... | @@ -243,18 +290,65 @@ public class LspEventConsumer implements Runnable { | ... | @@ -243,18 +290,65 @@ public class LspEventConsumer implements Runnable { |
243 | isisLink.setRemoteSystemId(linkInformation.linkDestinationId()); | 290 | isisLink.setRemoteSystemId(linkInformation.linkDestinationId()); |
244 | isisLink.setInterfaceIp(linkInformation.interfaceIp()); | 291 | isisLink.setInterfaceIp(linkInformation.interfaceIp()); |
245 | isisLink.setNeighborIp(linkInformation.neighborIp()); | 292 | isisLink.setNeighborIp(linkInformation.neighborIp()); |
246 | - isisLink.setLinkTed(createLinkTedInfo(lsPdu)); | 293 | + isisLink.setLinkTed(createIsisLinkTedInfo(lsPdu)); |
247 | return isisLink; | 294 | return isisLink; |
248 | } | 295 | } |
249 | 296 | ||
250 | /** | 297 | /** |
251 | - * Creates the link TED information. | 298 | + * Creates the ISIS link TED information. |
252 | * | 299 | * |
253 | * @param lsPdu link state PDU | 300 | * @param lsPdu link state PDU |
254 | * @return isisLinkTed | 301 | * @return isisLinkTed |
255 | */ | 302 | */ |
256 | - private IsisLinkTed createLinkTedInfo(LsPdu lsPdu) { | 303 | + public IsisLinkTed createIsisLinkTedInfo(LsPdu lsPdu) { |
257 | - IsisLinkTed isisLinkTed = deviceAndLink.createIsisLinkTedInfo(lsPdu); | 304 | + IsisLinkTed isisLinkTed = new DefaultIsisLinkTed(); |
305 | + for (IsisTlv isisTlv : lsPdu.tlvs()) { | ||
306 | + if (isisTlv instanceof IsExtendedReachability) { | ||
307 | + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv; | ||
308 | + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours(); | ||
309 | + for (NeighborForExtendedIs teTlv : neighbours) { | ||
310 | + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv(); | ||
311 | + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) { | ||
312 | + if (teSubTlv instanceof AdministrativeGroup) { | ||
313 | + AdministrativeGroup ag = (AdministrativeGroup) teSubTlv; | ||
314 | + isisLinkTed.setAdministrativeGroup(ag.administrativeGroup()); | ||
315 | + } | ||
316 | + if (teSubTlv instanceof InterfaceIpAddress) { | ||
317 | + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv; | ||
318 | + isisLinkTed.setIpv4InterfaceAddress(localIpAddress.localInterfaceIPAddress()); | ||
319 | + } | ||
320 | + if (teSubTlv instanceof NeighborIpAddress) { | ||
321 | + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv; | ||
322 | + isisLinkTed.setIpv4NeighborAddress(neighborIpAddress.neighborIPAddress()); | ||
323 | + } | ||
324 | + if (teSubTlv instanceof TrafficEngineeringMetric) { | ||
325 | + TrafficEngineeringMetric teM = (TrafficEngineeringMetric) teSubTlv; | ||
326 | + isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue()); | ||
327 | + } | ||
328 | + if (teSubTlv instanceof MaximumBandwidth) { | ||
329 | + MaximumBandwidth maxLinkBandwidth = (MaximumBandwidth) teSubTlv; | ||
330 | + isisLinkTed.setMaximumLinkBandwidth( | ||
331 | + Bandwidth.bps(maxLinkBandwidth.getMaximumBandwidthValue())); | ||
332 | + } | ||
333 | + if (teSubTlv instanceof MaximumReservableBandwidth) { | ||
334 | + MaximumReservableBandwidth maxReservableBw = (MaximumReservableBandwidth) teSubTlv; | ||
335 | + isisLinkTed.setMaximumReservableLinkBandwidth( | ||
336 | + Bandwidth.bps(maxReservableBw.getMaximumBandwidthValue())); | ||
337 | + } | ||
338 | + if (teSubTlv instanceof UnreservedBandwidth) { | ||
339 | + UnreservedBandwidth unReservedBandwidth = (UnreservedBandwidth) teSubTlv; | ||
340 | + List<Bandwidth> bandwidthList = new ArrayList<>(); | ||
341 | + List<Float> unReservedBandwidthList = unReservedBandwidth.unReservedBandwidthValue(); | ||
342 | + for (Float unReservedBandwidthFloatValue : unReservedBandwidthList) { | ||
343 | + Bandwidth bandwidth = Bandwidth.bps(unReservedBandwidthFloatValue); | ||
344 | + bandwidthList.add(bandwidth); | ||
345 | + } | ||
346 | + isisLinkTed.setUnreservedBandwidth(bandwidthList); | ||
347 | + } | ||
348 | + } | ||
349 | + } | ||
350 | + } | ||
351 | + } | ||
258 | return isisLinkTed; | 352 | return isisLinkTed; |
259 | } | 353 | } |
260 | } | 354 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
100644 → 100755
... | @@ -21,7 +21,9 @@ import org.onosproject.isis.controller.IsisLsdb; | ... | @@ -21,7 +21,9 @@ import org.onosproject.isis.controller.IsisLsdb; |
21 | import org.onosproject.isis.controller.IsisLsdbAge; | 21 | import org.onosproject.isis.controller.IsisLsdbAge; |
22 | import org.onosproject.isis.controller.IsisLspBin; | 22 | import org.onosproject.isis.controller.IsisLspBin; |
23 | import org.onosproject.isis.controller.IsisMessage; | 23 | import org.onosproject.isis.controller.IsisMessage; |
24 | +import org.onosproject.isis.controller.IsisNeighbor; | ||
24 | import org.onosproject.isis.controller.IsisPduType; | 25 | import org.onosproject.isis.controller.IsisPduType; |
26 | +import org.onosproject.isis.controller.IsisRouterType; | ||
25 | import org.onosproject.isis.controller.LspWrapper; | 27 | import org.onosproject.isis.controller.LspWrapper; |
26 | import org.onosproject.isis.controller.impl.Controller; | 28 | import org.onosproject.isis.controller.impl.Controller; |
27 | import org.onosproject.isis.controller.impl.LspEventConsumer; | 29 | import org.onosproject.isis.controller.impl.LspEventConsumer; |
... | @@ -394,4 +396,39 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -394,4 +396,39 @@ public class DefaultIsisLsdb implements IsisLsdb { |
394 | log.debug("Added LSp In Blocking queue: {}", lspWrapper); | 396 | log.debug("Added LSp In Blocking queue: {}", lspWrapper); |
395 | } | 397 | } |
396 | } | 398 | } |
399 | + | ||
400 | + /** | ||
401 | + * Removes topology information when neighbor down. | ||
402 | + * | ||
403 | + * @param neighbor ISIS neighbor instance | ||
404 | + * @param isisInterface ISIS interface instance | ||
405 | + */ | ||
406 | + public void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface) { | ||
407 | + String lspKey = neighbor.neighborSystemId() + ".00-00"; | ||
408 | + LspWrapper lspWrapper = null; | ||
409 | + switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) { | ||
410 | + case L1: | ||
411 | + lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey); | ||
412 | + break; | ||
413 | + case L2: | ||
414 | + lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey); | ||
415 | + break; | ||
416 | + case L1L2: | ||
417 | + lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey); | ||
418 | + if (lspWrapper == null) { | ||
419 | + lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey); | ||
420 | + } | ||
421 | + break; | ||
422 | + default: | ||
423 | + log.debug("Unknown type"); | ||
424 | + } | ||
425 | + try { | ||
426 | + if (lspWrapper != null) { | ||
427 | + lspWrapper.setLspProcessing(IsisConstants.LSPREMOVED); | ||
428 | + lspForProviderQueue.put(lspWrapper); | ||
429 | + } | ||
430 | + } catch (Exception e) { | ||
431 | + log.debug("Added LSp In Blocking queue: {}", lspWrapper); | ||
432 | + } | ||
433 | + } | ||
397 | } | 434 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProvider.java
100644 → 100755
... | @@ -52,6 +52,7 @@ import org.onosproject.net.link.LinkDescription; | ... | @@ -52,6 +52,7 @@ import org.onosproject.net.link.LinkDescription; |
52 | import org.onosproject.net.link.LinkProvider; | 52 | import org.onosproject.net.link.LinkProvider; |
53 | import org.onosproject.net.link.LinkProviderRegistry; | 53 | import org.onosproject.net.link.LinkProviderRegistry; |
54 | import org.onosproject.net.link.LinkProviderService; | 54 | import org.onosproject.net.link.LinkProviderService; |
55 | +import org.onosproject.net.link.LinkService; | ||
55 | import org.onosproject.net.provider.AbstractProvider; | 56 | import org.onosproject.net.provider.AbstractProvider; |
56 | import org.onosproject.net.provider.ProviderId; | 57 | import org.onosproject.net.provider.ProviderId; |
57 | import org.slf4j.Logger; | 58 | import org.slf4j.Logger; |
... | @@ -86,6 +87,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv | ... | @@ -86,6 +87,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv |
86 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 87 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
87 | protected NetworkConfigService networkConfigService; | 88 | protected NetworkConfigService networkConfigService; |
88 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 89 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
90 | + protected LinkService linkService; | ||
91 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
89 | protected IsisController controller; | 92 | protected IsisController controller; |
90 | //This Interface that defines how this provider can interact with the core. | 93 | //This Interface that defines how this provider can interact with the core. |
91 | private LinkProviderService linkProviderService; | 94 | private LinkProviderService linkProviderService; |
... | @@ -155,8 +158,14 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv | ... | @@ -155,8 +158,14 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv |
155 | String localSystemId = isisLink.localSystemId(); | 158 | String localSystemId = isisLink.localSystemId(); |
156 | String remoteSystemId = isisLink.remoteSystemId(); | 159 | String remoteSystemId = isisLink.remoteSystemId(); |
157 | //Changing of port numbers | 160 | //Changing of port numbers |
158 | - srcAddress = isisLink.interfaceIp().toInt(); | 161 | + if (isisLink.interfaceIp() != null) { |
159 | - dstAddress = isisLink.neighborIp().toInt(); | 162 | + //srcAddress = isisLink.interfaceIp().toInt(); |
163 | + srcAddress = (long) Long.parseUnsignedLong(Integer.toBinaryString(isisLink.interfaceIp().toInt()), 2); | ||
164 | + } | ||
165 | + if (isisLink.neighborIp() != null) { | ||
166 | + //dstAddress = isisLink.neighborIp().toInt(); | ||
167 | + dstAddress = (long) Long.parseUnsignedLong(Integer.toBinaryString(isisLink.neighborIp().toInt()), 2); | ||
168 | + } | ||
160 | DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId)); | 169 | DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId)); |
161 | DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId)); | 170 | DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId)); |
162 | if (checkIsDis(isisLink.localSystemId())) { | 171 | if (checkIsDis(isisLink.localSystemId())) { |
... | @@ -283,8 +292,9 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv | ... | @@ -283,8 +292,9 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv |
283 | newBuilder.set("RouterId", systemId); | 292 | newBuilder.set("RouterId", systemId); |
284 | DeviceDescription description = | 293 | DeviceDescription description = |
285 | new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN, | 294 | new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN, |
286 | - UNKNOWN, cId, newBuilder.build()); | 295 | + UNKNOWN, cId, newBuilder.build()); |
287 | deviceProviderService.deviceConnected(deviceId, description); | 296 | deviceProviderService.deviceConnected(deviceId, description); |
297 | + System.out.println("Device added: " + systemId); | ||
288 | } | 298 | } |
289 | 299 | ||
290 | @Override | 300 | @Override |
... | @@ -302,17 +312,26 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv | ... | @@ -302,17 +312,26 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv |
302 | @Override | 312 | @Override |
303 | public void addLink(IsisLink isisLink) { | 313 | public void addLink(IsisLink isisLink) { |
304 | log.debug("Addlink {}", isisLink.localSystemId()); | 314 | log.debug("Addlink {}", isisLink.localSystemId()); |
305 | - if (linkProviderService == null) { | 315 | + |
306 | - return; | ||
307 | - } | ||
308 | LinkDescription linkDes = buildLinkDes(isisLink); | 316 | LinkDescription linkDes = buildLinkDes(isisLink); |
309 | //Updating ports of the link | 317 | //Updating ports of the link |
310 | - deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(), | 318 | + //If already link exists, return |
311 | - linkDes.src().port())); | 319 | + if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) { |
312 | - deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(), | 320 | + return; |
313 | - linkDes.dst().port())); | 321 | + } |
314 | - registerBandwidth(linkDes, isisLink); | 322 | + ConnectPoint destconnectPoint = linkDes.dst(); |
315 | - linkProviderService.linkDetected(linkDes); | 323 | + PortNumber destport = destconnectPoint.port(); |
324 | + if (destport.toLong() != 0) { | ||
325 | + deviceProviderService.updatePorts(linkDes.src().deviceId(), | ||
326 | + buildPortDescriptions(linkDes.src().deviceId(), | ||
327 | + linkDes.src().port())); | ||
328 | + deviceProviderService.updatePorts(linkDes.dst().deviceId(), | ||
329 | + buildPortDescriptions(linkDes.dst().deviceId(), | ||
330 | + linkDes.dst().port())); | ||
331 | + registerBandwidth(linkDes, isisLink); | ||
332 | + linkProviderService.linkDetected(linkDes); | ||
333 | + System.out.println("link desc " + linkDes.toString()); | ||
334 | + } | ||
316 | } | 335 | } |
317 | 336 | ||
318 | @Override | 337 | @Override |
... | @@ -351,4 +370,4 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv | ... | @@ -351,4 +370,4 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv |
351 | } | 370 | } |
352 | } | 371 | } |
353 | } | 372 | } |
354 | -} | 373 | +} |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -81,6 +81,7 @@ public class IsisTopologyProviderTest { | ... | @@ -81,6 +81,7 @@ public class IsisTopologyProviderTest { |
81 | private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry(); | 81 | private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry(); |
82 | private final TestLinkRegistry linkRegistry = new TestLinkRegistry(); | 82 | private final TestLinkRegistry linkRegistry = new TestLinkRegistry(); |
83 | private final TestController controller = new TestController(); | 83 | private final TestController controller = new TestController(); |
84 | + private final TestLinkService linkService = new TestLinkService(); | ||
84 | private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter(); | 85 | private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter(); |
85 | 86 | ||
86 | @Before | 87 | @Before |
... | @@ -89,6 +90,7 @@ public class IsisTopologyProviderTest { | ... | @@ -89,6 +90,7 @@ public class IsisTopologyProviderTest { |
89 | provider.linkProviderRegistry = linkRegistry; | 90 | provider.linkProviderRegistry = linkRegistry; |
90 | provider.networkConfigService = networkConfigService; | 91 | provider.networkConfigService = networkConfigService; |
91 | provider.controller = controller; | 92 | provider.controller = controller; |
93 | + provider.linkService = linkService; | ||
92 | provider.activate(); | 94 | provider.activate(); |
93 | assertNotNull("provider should be registered", nodeRegistry.provider); | 95 | assertNotNull("provider should be registered", nodeRegistry.provider); |
94 | assertNotNull("listener should be registered", controller.nodeListener); | 96 | assertNotNull("listener should be registered", controller.nodeListener); |
... | @@ -289,9 +291,9 @@ public class IsisTopologyProviderTest { | ... | @@ -289,9 +291,9 @@ public class IsisTopologyProviderTest { |
289 | 291 | ||
290 | } | 292 | } |
291 | } | 293 | } |
294 | + } | ||
292 | 295 | ||
293 | 296 | ||
294 | - } | ||
295 | 297 | ||
296 | private class TestDeviceService extends DeviceServiceAdapter { | 298 | private class TestDeviceService extends DeviceServiceAdapter { |
297 | private DeviceListener listener; | 299 | private DeviceListener listener; | ... | ... |
-
Please register or login to post a comment