ONOS-4361 OSPF Provider Bug Fixes
Change-Id: I840896d3e9a23ad541d56b0a795e2f5c7cb02487
Showing
3 changed files
with
10 additions
and
4 deletions
... | @@ -29,7 +29,7 @@ import static com.google.common.base.Preconditions.checkArgument; | ... | @@ -29,7 +29,7 @@ import static com.google.common.base.Preconditions.checkArgument; |
29 | */ | 29 | */ |
30 | public class OspfRouterId { | 30 | public class OspfRouterId { |
31 | 31 | ||
32 | - private static final String SCHEME = "ospf"; | 32 | + private static final String SCHEME = "l3"; |
33 | private static final long UNKNOWN = 0; | 33 | private static final long UNKNOWN = 0; |
34 | private final IpAddress ipAddress; | 34 | private final IpAddress ipAddress; |
35 | 35 | ... | ... |
... | @@ -42,6 +42,7 @@ import org.onosproject.net.link.LinkDescription; | ... | @@ -42,6 +42,7 @@ import org.onosproject.net.link.LinkDescription; |
42 | import org.onosproject.net.link.LinkProvider; | 42 | import org.onosproject.net.link.LinkProvider; |
43 | import org.onosproject.net.link.LinkProviderRegistry; | 43 | import org.onosproject.net.link.LinkProviderRegistry; |
44 | import org.onosproject.net.link.LinkProviderService; | 44 | import org.onosproject.net.link.LinkProviderService; |
45 | +import org.onosproject.net.link.LinkService; | ||
45 | import org.onosproject.net.provider.AbstractProvider; | 46 | import org.onosproject.net.provider.AbstractProvider; |
46 | import org.onosproject.net.provider.ProviderId; | 47 | import org.onosproject.net.provider.ProviderId; |
47 | import org.onosproject.ospf.controller.OspfController; | 48 | import org.onosproject.ospf.controller.OspfController; |
... | @@ -73,6 +74,8 @@ public class OspfTopologyProvider extends AbstractProvider implements DeviceProv | ... | @@ -73,6 +74,8 @@ public class OspfTopologyProvider extends AbstractProvider implements DeviceProv |
73 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 74 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
74 | protected LinkProviderRegistry linkProviderRegistry; | 75 | protected LinkProviderRegistry linkProviderRegistry; |
75 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 76 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
77 | + protected LinkService linkService; | ||
78 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
76 | protected OspfController controller; | 79 | protected OspfController controller; |
77 | //This Interface that defines how this provider can interact with the core. | 80 | //This Interface that defines how this provider can interact with the core. |
78 | private LinkProviderService linkProviderService; | 81 | private LinkProviderService linkProviderService; |
... | @@ -177,7 +180,7 @@ public class OspfTopologyProvider extends AbstractProvider implements DeviceProv | ... | @@ -177,7 +180,7 @@ public class OspfTopologyProvider extends AbstractProvider implements DeviceProv |
177 | ChassisId cId = new ChassisId(); | 180 | ChassisId cId = new ChassisId(); |
178 | DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); | 181 | DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); |
179 | 182 | ||
180 | - newBuilder.set(AnnotationKeys.TYPE, "L3"); | 183 | + newBuilder.set(AnnotationKeys.TYPE, "l3"); |
181 | newBuilder.set("routerId", routerId); | 184 | newBuilder.set("routerId", routerId); |
182 | DeviceDescription description = | 185 | DeviceDescription description = |
183 | new DefaultDeviceDescription(OspfRouterId.uri(ospfRouter.routerIp()), | 186 | new DefaultDeviceDescription(OspfRouterId.uri(ospfRouter.routerIp()), |
... | @@ -201,10 +204,11 @@ public class OspfTopologyProvider extends AbstractProvider implements DeviceProv | ... | @@ -201,10 +204,11 @@ public class OspfTopologyProvider extends AbstractProvider implements DeviceProv |
201 | @Override | 204 | @Override |
202 | public void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) { | 205 | public void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) { |
203 | log.debug("Addlink {}", ospfRouter.routerIp()); | 206 | log.debug("Addlink {}", ospfRouter.routerIp()); |
204 | - if (linkProviderService == null) { | 207 | + LinkDescription linkDes = buildLinkDes(ospfRouter, ospfLinkTed); |
208 | + //If already link exists, return | ||
209 | + if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) { | ||
205 | return; | 210 | return; |
206 | } | 211 | } |
207 | - LinkDescription linkDes = buildLinkDes(ospfRouter, ospfLinkTed); | ||
208 | //Updating ports of the link | 212 | //Updating ports of the link |
209 | List<PortDescription> srcPortDescriptions = new LinkedList<>(); | 213 | List<PortDescription> srcPortDescriptions = new LinkedList<>(); |
210 | srcPortDescriptions.add(new DefaultPortDescription(linkDes.src().port(), true)); | 214 | srcPortDescriptions.add(new DefaultPortDescription(linkDes.src().port(), true)); | ... | ... |
... | @@ -72,12 +72,14 @@ public class OspfTopologyProviderTest { | ... | @@ -72,12 +72,14 @@ public class OspfTopologyProviderTest { |
72 | private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry(); | 72 | private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry(); |
73 | private final TestLinkRegistry linkRegistry = new TestLinkRegistry(); | 73 | private final TestLinkRegistry linkRegistry = new TestLinkRegistry(); |
74 | private final TestController controller = new TestController(); | 74 | private final TestController controller = new TestController(); |
75 | + private final TestLinkService linkService = new TestLinkService(); | ||
75 | 76 | ||
76 | @Before | 77 | @Before |
77 | public void setUp() throws Exception { | 78 | public void setUp() throws Exception { |
78 | provider.deviceProviderRegistry = nodeRegistry; | 79 | provider.deviceProviderRegistry = nodeRegistry; |
79 | provider.linkProviderRegistry = linkRegistry; | 80 | provider.linkProviderRegistry = linkRegistry; |
80 | provider.controller = controller; | 81 | provider.controller = controller; |
82 | + provider.linkService = linkService; | ||
81 | provider.activate(); | 83 | provider.activate(); |
82 | assertNotNull("provider should be registered", nodeRegistry.provider); | 84 | assertNotNull("provider should be registered", nodeRegistry.provider); |
83 | assertNotNull("listener should be registered", controller.nodeListener); | 85 | assertNotNull("listener should be registered", controller.nodeListener); | ... | ... |
-
Please register or login to post a comment