Committed by
Gerrit Code Review
Adapt FIBs to new route interface
Change-Id: I8ac19ad578aac4607fd8319186b6568a21edc1fd
Showing
8 changed files
with
93 additions
and
145 deletions
... | @@ -89,9 +89,9 @@ public class IntentSynchronizer implements IntentSynchronizationService, | ... | @@ -89,9 +89,9 @@ public class IntentSynchronizer implements IntentSynchronizationService, |
89 | 89 | ||
90 | @Activate | 90 | @Activate |
91 | public void activate() { | 91 | public void activate() { |
92 | - intentsSynchronizerExecutor = createExecutor(); | ||
93 | this.localNodeId = clusterService.getLocalNode().id(); | 92 | this.localNodeId = clusterService.getLocalNode().id(); |
94 | this.appId = coreService.registerApplication(APP_NAME); | 93 | this.appId = coreService.registerApplication(APP_NAME); |
94 | + intentsSynchronizerExecutor = createExecutor(); | ||
95 | 95 | ||
96 | leadershipService.addListener(leadershipEventListener); | 96 | leadershipService.addListener(leadershipEventListener); |
97 | leadershipService.runForLeadership(appId.name()); | 97 | leadershipService.runForLeadership(appId.name()); | ... | ... |
... | @@ -17,9 +17,7 @@ | ... | @@ -17,9 +17,7 @@ |
17 | package org.onosproject.routing.impl; | 17 | package org.onosproject.routing.impl; |
18 | 18 | ||
19 | import com.google.common.collect.ConcurrentHashMultiset; | 19 | import com.google.common.collect.ConcurrentHashMultiset; |
20 | -import com.google.common.collect.HashMultimap; | ||
21 | import com.google.common.collect.Maps; | 20 | import com.google.common.collect.Maps; |
22 | -import com.google.common.collect.Multimap; | ||
23 | import com.google.common.collect.Multiset; | 21 | import com.google.common.collect.Multiset; |
24 | import org.apache.felix.scr.annotations.Activate; | 22 | import org.apache.felix.scr.annotations.Activate; |
25 | import org.apache.felix.scr.annotations.Component; | 23 | import org.apache.felix.scr.annotations.Component; |
... | @@ -40,6 +38,10 @@ import org.onosproject.incubator.net.intf.Interface; | ... | @@ -40,6 +38,10 @@ import org.onosproject.incubator.net.intf.Interface; |
40 | import org.onosproject.incubator.net.intf.InterfaceEvent; | 38 | import org.onosproject.incubator.net.intf.InterfaceEvent; |
41 | import org.onosproject.incubator.net.intf.InterfaceListener; | 39 | import org.onosproject.incubator.net.intf.InterfaceListener; |
42 | import org.onosproject.incubator.net.intf.InterfaceService; | 40 | import org.onosproject.incubator.net.intf.InterfaceService; |
41 | +import org.onosproject.incubator.net.routing.ResolvedRoute; | ||
42 | +import org.onosproject.incubator.net.routing.RouteEvent; | ||
43 | +import org.onosproject.incubator.net.routing.RouteListener; | ||
44 | +import org.onosproject.incubator.net.routing.RouteService; | ||
43 | import org.onosproject.net.ConnectPoint; | 45 | import org.onosproject.net.ConnectPoint; |
44 | import org.onosproject.net.DeviceId; | 46 | import org.onosproject.net.DeviceId; |
45 | import org.onosproject.net.config.NetworkConfigEvent; | 47 | import org.onosproject.net.config.NetworkConfigEvent; |
... | @@ -56,24 +58,19 @@ import org.onosproject.net.flow.criteria.Criteria; | ... | @@ -56,24 +58,19 @@ import org.onosproject.net.flow.criteria.Criteria; |
56 | import org.onosproject.net.flowobjective.DefaultFilteringObjective; | 58 | import org.onosproject.net.flowobjective.DefaultFilteringObjective; |
57 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; | 59 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; |
58 | import org.onosproject.net.flowobjective.DefaultNextObjective; | 60 | import org.onosproject.net.flowobjective.DefaultNextObjective; |
61 | +import org.onosproject.net.flowobjective.DefaultObjectiveContext; | ||
59 | import org.onosproject.net.flowobjective.FilteringObjective; | 62 | import org.onosproject.net.flowobjective.FilteringObjective; |
60 | import org.onosproject.net.flowobjective.FlowObjectiveService; | 63 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
61 | import org.onosproject.net.flowobjective.ForwardingObjective; | 64 | import org.onosproject.net.flowobjective.ForwardingObjective; |
62 | import org.onosproject.net.flowobjective.NextObjective; | 65 | import org.onosproject.net.flowobjective.NextObjective; |
63 | import org.onosproject.net.flowobjective.ObjectiveContext; | 66 | import org.onosproject.net.flowobjective.ObjectiveContext; |
64 | -import org.onosproject.net.flowobjective.DefaultObjectiveContext; | ||
65 | -import org.onosproject.routing.FibEntry; | ||
66 | -import org.onosproject.routing.FibListener; | ||
67 | -import org.onosproject.routing.FibUpdate; | ||
68 | import org.onosproject.routing.RoutingService; | 67 | import org.onosproject.routing.RoutingService; |
69 | import org.onosproject.routing.config.RouterConfig; | 68 | import org.onosproject.routing.config.RouterConfig; |
70 | import org.osgi.service.component.ComponentContext; | 69 | import org.osgi.service.component.ComponentContext; |
71 | import org.slf4j.Logger; | 70 | import org.slf4j.Logger; |
72 | import org.slf4j.LoggerFactory; | 71 | import org.slf4j.LoggerFactory; |
73 | 72 | ||
74 | -import java.util.Collection; | ||
75 | import java.util.Dictionary; | 73 | import java.util.Dictionary; |
76 | -import java.util.HashMap; | ||
77 | import java.util.List; | 74 | import java.util.List; |
78 | import java.util.Map; | 75 | import java.util.Map; |
79 | import java.util.Set; | 76 | import java.util.Set; |
... | @@ -96,7 +93,7 @@ public class SingleSwitchFibInstaller { | ... | @@ -96,7 +93,7 @@ public class SingleSwitchFibInstaller { |
96 | protected CoreService coreService; | 93 | protected CoreService coreService; |
97 | 94 | ||
98 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 95 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
99 | - protected RoutingService routingService; | 96 | + protected RouteService routeService; |
100 | 97 | ||
101 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 98 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
102 | protected InterfaceService interfaceService; | 99 | protected InterfaceService interfaceService; |
... | @@ -137,11 +134,9 @@ public class SingleSwitchFibInstaller { | ... | @@ -137,11 +134,9 @@ public class SingleSwitchFibInstaller { |
137 | // Mapping from next hop IP to next hop object containing group info | 134 | // Mapping from next hop IP to next hop object containing group info |
138 | private final Map<IpAddress, Integer> nextHops = Maps.newHashMap(); | 135 | private final Map<IpAddress, Integer> nextHops = Maps.newHashMap(); |
139 | 136 | ||
140 | - // Stores FIB updates that are waiting for groups to be set up | ||
141 | - private final Multimap<NextHopGroupKey, FibEntry> pendingUpdates = HashMultimap.create(); | ||
142 | - | ||
143 | //interface object for event | 137 | //interface object for event |
144 | private InternalInterfaceListener internalInterfaceList = new InternalInterfaceListener(); | 138 | private InternalInterfaceListener internalInterfaceList = new InternalInterfaceListener(); |
139 | + private InternalRouteListener routeListener = new InternalRouteListener(); | ||
145 | 140 | ||
146 | @Activate | 141 | @Activate |
147 | protected void activate(ComponentContext context) { | 142 | protected void activate(ComponentContext context) { |
... | @@ -155,9 +150,6 @@ public class SingleSwitchFibInstaller { | ... | @@ -155,9 +150,6 @@ public class SingleSwitchFibInstaller { |
155 | 150 | ||
156 | interfaceService.addListener(internalInterfaceList); | 151 | interfaceService.addListener(internalInterfaceList); |
157 | 152 | ||
158 | - routingService.addFibListener(new InternalFibListener()); | ||
159 | - routingService.start(); | ||
160 | - | ||
161 | updateConfig(); | 153 | updateConfig(); |
162 | 154 | ||
163 | log.info("Started"); | 155 | log.info("Started"); |
... | @@ -165,10 +157,8 @@ public class SingleSwitchFibInstaller { | ... | @@ -165,10 +157,8 @@ public class SingleSwitchFibInstaller { |
165 | 157 | ||
166 | @Deactivate | 158 | @Deactivate |
167 | protected void deactivate() { | 159 | protected void deactivate() { |
168 | - routingService.stop(); | 160 | + routeService.removeListener(routeListener); |
169 | - | ||
170 | deviceService.removeListener(deviceListener); | 161 | deviceService.removeListener(deviceListener); |
171 | - | ||
172 | interfaceService.removeListener(internalInterfaceList); | 162 | interfaceService.removeListener(internalInterfaceList); |
173 | 163 | ||
174 | //processIntfFilters(false, configService.getInterfaces()); //TODO necessary? | 164 | //processIntfFilters(false, configService.getInterfaces()); //TODO necessary? |
... | @@ -208,6 +198,8 @@ public class SingleSwitchFibInstaller { | ... | @@ -208,6 +198,8 @@ public class SingleSwitchFibInstaller { |
208 | interfaces = routerConfig.getInterfaces(); | 198 | interfaces = routerConfig.getInterfaces(); |
209 | log.info("Using interfaces: {}", interfaces.isEmpty() ? "all" : interfaces); | 199 | log.info("Using interfaces: {}", interfaces.isEmpty() ? "all" : interfaces); |
210 | 200 | ||
201 | + routeService.addListener(routeListener); | ||
202 | + | ||
211 | updateDevice(); | 203 | updateDevice(); |
212 | } | 204 | } |
213 | 205 | ||
... | @@ -229,55 +221,30 @@ public class SingleSwitchFibInstaller { | ... | @@ -229,55 +221,30 @@ public class SingleSwitchFibInstaller { |
229 | } | 221 | } |
230 | } | 222 | } |
231 | 223 | ||
232 | - private void updateFibEntry(Collection<FibUpdate> updates) { | 224 | + private void updateRoute(ResolvedRoute route) { |
233 | - Map<FibEntry, Integer> toInstall = new HashMap<>(updates.size()); | 225 | + addNextHop(route); |
234 | - | ||
235 | - for (FibUpdate update : updates) { | ||
236 | - FibEntry entry = update.entry(); | ||
237 | - | ||
238 | - addNextHop(entry); | ||
239 | - | ||
240 | - Integer nextId; | ||
241 | - synchronized (pendingUpdates) { | ||
242 | - nextId = nextHops.get(entry.nextHopIp()); | ||
243 | - } | ||
244 | - | ||
245 | - toInstall.put(update.entry(), nextId); | ||
246 | - } | ||
247 | - | ||
248 | - installFlows(toInstall); | ||
249 | - } | ||
250 | - | ||
251 | - private void installFlows(Map<FibEntry, Integer> entriesToInstall) { | ||
252 | - | ||
253 | - for (Map.Entry<FibEntry, Integer> entry : entriesToInstall.entrySet()) { | ||
254 | - FibEntry fibEntry = entry.getKey(); | ||
255 | - Integer nextId = entry.getValue(); | ||
256 | 226 | ||
257 | - flowObjectiveService.forward(deviceId, | 227 | + Integer nextId; |
258 | - generateRibForwardingObj(fibEntry.prefix(), nextId).add()); | 228 | + synchronized (this) { |
259 | - log.trace("Sending forwarding objective {} -> nextId:{}", fibEntry, nextId); | 229 | + nextId = nextHops.get(route.nextHop()); |
260 | } | 230 | } |
261 | 231 | ||
232 | + flowObjectiveService.forward(deviceId, | ||
233 | + generateRibForwardingObj(route.prefix(), nextId).add()); | ||
234 | + log.trace("Sending forwarding objective {} -> nextId:{}", route, nextId); | ||
262 | } | 235 | } |
263 | 236 | ||
264 | - private synchronized void deleteFibEntry(Collection<FibUpdate> withdraws) { | 237 | + private synchronized void deleteRoute(ResolvedRoute route) { |
265 | - | 238 | + //Integer nextId = nextHops.get(route.nextHop()); |
266 | - for (FibUpdate update : withdraws) { | ||
267 | - FibEntry entry = update.entry(); | ||
268 | - //Integer nextId = nextHops.get(entry.nextHopIp()); | ||
269 | - | ||
270 | - /* Group group = deleteNextHop(entry.prefix()); | ||
271 | - if (group == null) { | ||
272 | - log.warn("Group not found when deleting {}", entry); | ||
273 | - return; | ||
274 | - }*/ | ||
275 | - | ||
276 | - flowObjectiveService.forward(deviceId, | ||
277 | - generateRibForwardingObj(entry.prefix(), null).remove()); | ||
278 | 239 | ||
279 | - } | 240 | + /* Group group = deleteNextHop(route.prefix()); |
241 | + if (group == null) { | ||
242 | + log.warn("Group not found when deleting {}", route); | ||
243 | + return; | ||
244 | + }*/ | ||
280 | 245 | ||
246 | + flowObjectiveService.forward(deviceId, | ||
247 | + generateRibForwardingObj(route.prefix(), null).remove()); | ||
281 | } | 248 | } |
282 | 249 | ||
283 | private ForwardingObjective.Builder generateRibForwardingObj(IpPrefix prefix, | 250 | private ForwardingObjective.Builder generateRibForwardingObj(IpPrefix prefix, |
... | @@ -306,20 +273,20 @@ public class SingleSwitchFibInstaller { | ... | @@ -306,20 +273,20 @@ public class SingleSwitchFibInstaller { |
306 | return fwdBuilder; | 273 | return fwdBuilder; |
307 | } | 274 | } |
308 | 275 | ||
309 | - private synchronized void addNextHop(FibEntry entry) { | 276 | + private synchronized void addNextHop(ResolvedRoute route) { |
310 | - prefixToNextHop.put(entry.prefix(), entry.nextHopIp()); | 277 | + prefixToNextHop.put(route.prefix(), route.nextHop()); |
311 | - if (nextHopsCount.count(entry.nextHopIp()) == 0) { | 278 | + if (nextHopsCount.count(route.nextHop()) == 0) { |
312 | // There was no next hop in the multiset | 279 | // There was no next hop in the multiset |
313 | 280 | ||
314 | - Interface egressIntf = interfaceService.getMatchingInterface(entry.nextHopIp()); | 281 | + Interface egressIntf = interfaceService.getMatchingInterface(route.nextHop()); |
315 | if (egressIntf == null) { | 282 | if (egressIntf == null) { |
316 | - log.warn("no egress interface found for {}", entry); | 283 | + log.warn("no egress interface found for {}", route); |
317 | return; | 284 | return; |
318 | } | 285 | } |
319 | 286 | ||
320 | - NextHopGroupKey groupKey = new NextHopGroupKey(entry.nextHopIp()); | 287 | + NextHopGroupKey groupKey = new NextHopGroupKey(route.nextHop()); |
321 | 288 | ||
322 | - NextHop nextHop = new NextHop(entry.nextHopIp(), entry.nextHopMac(), groupKey); | 289 | + NextHop nextHop = new NextHop(route.nextHop(), route.nextHopMac(), groupKey); |
323 | 290 | ||
324 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder() | 291 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder() |
325 | .setEthSrc(egressIntf.mac()) | 292 | .setEthSrc(egressIntf.mac()) |
... | @@ -356,12 +323,12 @@ public class SingleSwitchFibInstaller { | ... | @@ -356,12 +323,12 @@ public class SingleSwitchFibInstaller { |
356 | if (routeToNextHop) { | 323 | if (routeToNextHop) { |
357 | // Install route to next hop | 324 | // Install route to next hop |
358 | ForwardingObjective fob = | 325 | ForwardingObjective fob = |
359 | - generateRibForwardingObj(IpPrefix.valueOf(entry.nextHopIp(), 32), nextId).add(); | 326 | + generateRibForwardingObj(IpPrefix.valueOf(route.nextHop(), 32), nextId).add(); |
360 | flowObjectiveService.forward(deviceId, fob); | 327 | flowObjectiveService.forward(deviceId, fob); |
361 | } | 328 | } |
362 | } | 329 | } |
363 | 330 | ||
364 | - nextHopsCount.add(entry.nextHopIp()); | 331 | + nextHopsCount.add(route.nextHop()); |
365 | } | 332 | } |
366 | 333 | ||
367 | /*private synchronized Group deleteNextHop(IpPrefix prefix) { | 334 | /*private synchronized Group deleteNextHop(IpPrefix prefix) { |
... | @@ -452,13 +419,21 @@ public class SingleSwitchFibInstaller { | ... | @@ -452,13 +419,21 @@ public class SingleSwitchFibInstaller { |
452 | flowObjectiveService.filter(deviceId, filter); | 419 | flowObjectiveService.filter(deviceId, filter); |
453 | } | 420 | } |
454 | 421 | ||
455 | - private class InternalFibListener implements FibListener { | 422 | + private class InternalRouteListener implements RouteListener { |
456 | - | ||
457 | @Override | 423 | @Override |
458 | - public void update(Collection<FibUpdate> updates, | 424 | + public void event(RouteEvent event) { |
459 | - Collection<FibUpdate> withdraws) { | 425 | + ResolvedRoute route = event.subject(); |
460 | - SingleSwitchFibInstaller.this.deleteFibEntry(withdraws); | 426 | + switch (event.type()) { |
461 | - SingleSwitchFibInstaller.this.updateFibEntry(updates); | 427 | + case ROUTE_ADDED: |
428 | + case ROUTE_UPDATED: | ||
429 | + updateRoute(route); | ||
430 | + break; | ||
431 | + case ROUTE_REMOVED: | ||
432 | + deleteRoute(route); | ||
433 | + break; | ||
434 | + default: | ||
435 | + break; | ||
436 | + } | ||
462 | } | 437 | } |
463 | } | 438 | } |
464 | 439 | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -73,7 +73,6 @@ public class SdnIp { | ... | @@ -73,7 +73,6 @@ public class SdnIp { |
73 | private static List<String> components = new ArrayList<>(); | 73 | private static List<String> components = new ArrayList<>(); |
74 | static { | 74 | static { |
75 | components.add("org.onosproject.routing.bgp.BgpSessionManager"); | 75 | components.add("org.onosproject.routing.bgp.BgpSessionManager"); |
76 | - components.add("org.onosproject.routing.impl.Router"); | ||
77 | components.add(org.onosproject.sdnip.SdnIpFib.class.getName()); | 76 | components.add(org.onosproject.sdnip.SdnIpFib.class.getName()); |
78 | } | 77 | } |
79 | 78 | ... | ... |
... | @@ -34,6 +34,10 @@ import org.onosproject.incubator.net.intf.Interface; | ... | @@ -34,6 +34,10 @@ import org.onosproject.incubator.net.intf.Interface; |
34 | import org.onosproject.incubator.net.intf.InterfaceEvent; | 34 | import org.onosproject.incubator.net.intf.InterfaceEvent; |
35 | import org.onosproject.incubator.net.intf.InterfaceListener; | 35 | import org.onosproject.incubator.net.intf.InterfaceListener; |
36 | import org.onosproject.incubator.net.intf.InterfaceService; | 36 | import org.onosproject.incubator.net.intf.InterfaceService; |
37 | +import org.onosproject.incubator.net.routing.ResolvedRoute; | ||
38 | +import org.onosproject.incubator.net.routing.RouteEvent; | ||
39 | +import org.onosproject.incubator.net.routing.RouteListener; | ||
40 | +import org.onosproject.incubator.net.routing.RouteService; | ||
37 | import org.onosproject.net.ConnectPoint; | 41 | import org.onosproject.net.ConnectPoint; |
38 | import org.onosproject.net.flow.DefaultTrafficSelector; | 42 | import org.onosproject.net.flow.DefaultTrafficSelector; |
39 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 43 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
... | @@ -43,21 +47,15 @@ import org.onosproject.net.intent.Constraint; | ... | @@ -43,21 +47,15 @@ import org.onosproject.net.intent.Constraint; |
43 | import org.onosproject.net.intent.Key; | 47 | import org.onosproject.net.intent.Key; |
44 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; | 48 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
45 | import org.onosproject.net.intent.constraint.PartialFailureConstraint; | 49 | import org.onosproject.net.intent.constraint.PartialFailureConstraint; |
46 | -import org.onosproject.routing.FibListener; | ||
47 | -import org.onosproject.routing.FibUpdate; | ||
48 | import org.onosproject.routing.IntentSynchronizationService; | 50 | import org.onosproject.routing.IntentSynchronizationService; |
49 | -import org.onosproject.routing.RoutingService; | ||
50 | import org.slf4j.Logger; | 51 | import org.slf4j.Logger; |
51 | import org.slf4j.LoggerFactory; | 52 | import org.slf4j.LoggerFactory; |
52 | 53 | ||
53 | -import java.util.Collection; | ||
54 | import java.util.HashSet; | 54 | import java.util.HashSet; |
55 | import java.util.Map; | 55 | import java.util.Map; |
56 | import java.util.Set; | 56 | import java.util.Set; |
57 | import java.util.concurrent.ConcurrentHashMap; | 57 | import java.util.concurrent.ConcurrentHashMap; |
58 | 58 | ||
59 | -import static com.google.common.base.Preconditions.checkArgument; | ||
60 | - | ||
61 | /** | 59 | /** |
62 | * FIB component of SDN-IP. | 60 | * FIB component of SDN-IP. |
63 | */ | 61 | */ |
... | @@ -75,9 +73,9 @@ public class SdnIpFib { | ... | @@ -75,9 +73,9 @@ public class SdnIpFib { |
75 | protected CoreService coreService; | 73 | protected CoreService coreService; |
76 | 74 | ||
77 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 75 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
78 | - protected RoutingService routingService; | 76 | + protected RouteService routeService; |
79 | 77 | ||
80 | - private final InternalFibListener fibListener = new InternalFibListener(); | 78 | + private final InternalRouteListener routeListener = new InternalRouteListener(); |
81 | private final InternalInterfaceListener interfaceListener = new InternalInterfaceListener(); | 79 | private final InternalInterfaceListener interfaceListener = new InternalInterfaceListener(); |
82 | 80 | ||
83 | private static final int PRIORITY_OFFSET = 100; | 81 | private static final int PRIORITY_OFFSET = 100; |
... | @@ -96,69 +94,41 @@ public class SdnIpFib { | ... | @@ -96,69 +94,41 @@ public class SdnIpFib { |
96 | 94 | ||
97 | interfaceService.addListener(interfaceListener); | 95 | interfaceService.addListener(interfaceListener); |
98 | 96 | ||
99 | - routingService.addFibListener(fibListener); | 97 | + routeService.addListener(routeListener); |
100 | - routingService.start(); | ||
101 | } | 98 | } |
102 | 99 | ||
103 | @Deactivate | 100 | @Deactivate |
104 | public void deactivate() { | 101 | public void deactivate() { |
105 | interfaceService.removeListener(interfaceListener); | 102 | interfaceService.removeListener(interfaceListener); |
106 | - // TODO remove listener | 103 | + routeService.removeListener(routeListener); |
107 | - routingService.stop(); | ||
108 | } | 104 | } |
109 | 105 | ||
110 | - private void update(Collection<FibUpdate> updates, Collection<FibUpdate> withdraws) { | 106 | + private void update(ResolvedRoute route) { |
111 | - int submitCount = 0, withdrawCount = 0; | ||
112 | - // | ||
113 | - // NOTE: Semantically, we MUST withdraw existing intents before | ||
114 | - // submitting new intents. | ||
115 | - // | ||
116 | synchronized (this) { | 107 | synchronized (this) { |
117 | - MultiPointToSinglePointIntent intent; | 108 | + IpPrefix prefix = route.prefix(); |
118 | - | 109 | + MultiPointToSinglePointIntent intent = |
119 | - // | 110 | + generateRouteIntent(prefix, route.nextHop(), route.nextHopMac()); |
120 | - // Prepare the Intent batch operations for the intents to withdraw | 111 | + |
121 | - // | 112 | + if (intent == null) { |
122 | - for (FibUpdate withdraw : withdraws) { | 113 | + log.debug("SDN-IP no interface found for route {}", route); |
123 | - checkArgument(withdraw.type() == FibUpdate.Type.DELETE, | 114 | + return; |
124 | - "FibUpdate with wrong type in withdraws list"); | ||
125 | - | ||
126 | - IpPrefix prefix = withdraw.entry().prefix(); | ||
127 | - intent = routeIntents.remove(prefix); | ||
128 | - if (intent == null) { | ||
129 | - log.trace("SDN-IP No intent in routeIntents to delete " + | ||
130 | - "for prefix: {}", prefix); | ||
131 | - continue; | ||
132 | - } | ||
133 | - intentSynchronizer.withdraw(intent); | ||
134 | - withdrawCount++; | ||
135 | } | 115 | } |
136 | 116 | ||
137 | - // | 117 | + routeIntents.put(prefix, intent); |
138 | - // Prepare the Intent batch operations for the intents to submit | 118 | + intentSynchronizer.submit(intent); |
139 | - // | 119 | + } |
140 | - for (FibUpdate update : updates) { | 120 | + } |
141 | - checkArgument(update.type() == FibUpdate.Type.UPDATE, | ||
142 | - "FibUpdate with wrong type in updates list"); | ||
143 | - | ||
144 | - IpPrefix prefix = update.entry().prefix(); | ||
145 | - intent = generateRouteIntent(prefix, update.entry().nextHopIp(), | ||
146 | - update.entry().nextHopMac()); | ||
147 | - | ||
148 | - if (intent == null) { | ||
149 | - // This preserves the old semantics - if an intent can't be | ||
150 | - // generated, we don't do anything with that prefix. But | ||
151 | - // perhaps we should withdraw the old intent anyway? | ||
152 | - continue; | ||
153 | - } | ||
154 | 121 | ||
155 | - routeIntents.put(prefix, intent); | 122 | + private void withdraw(ResolvedRoute route) { |
156 | - intentSynchronizer.submit(intent); | 123 | + synchronized (this) { |
157 | - submitCount++; | 124 | + IpPrefix prefix = route.prefix(); |
125 | + MultiPointToSinglePointIntent intent = routeIntents.remove(prefix); | ||
126 | + if (intent == null) { | ||
127 | + log.trace("SDN-IP no intent in routeIntents to delete " + | ||
128 | + "for prefix: {}", prefix); | ||
129 | + return; | ||
158 | } | 130 | } |
159 | - | 131 | + intentSynchronizer.withdraw(intent); |
160 | - log.debug("SDN-IP submitted {}/{}, withdrew = {}/{}", submitCount, | ||
161 | - updates.size(), withdrawCount, withdraws.size()); | ||
162 | } | 132 | } |
163 | } | 133 | } |
164 | 134 | ||
... | @@ -292,10 +262,20 @@ public class SdnIpFib { | ... | @@ -292,10 +262,20 @@ public class SdnIpFib { |
292 | } | 262 | } |
293 | } | 263 | } |
294 | 264 | ||
295 | - private class InternalFibListener implements FibListener { | 265 | + private class InternalRouteListener implements RouteListener { |
296 | @Override | 266 | @Override |
297 | - public void update(Collection<FibUpdate> updates, Collection<FibUpdate> withdraws) { | 267 | + public void event(RouteEvent event) { |
298 | - SdnIpFib.this.update(updates, withdraws); | 268 | + switch (event.type()) { |
269 | + case ROUTE_ADDED: | ||
270 | + case ROUTE_UPDATED: | ||
271 | + update(event.subject()); | ||
272 | + break; | ||
273 | + case ROUTE_REMOVED: | ||
274 | + withdraw(event.subject()); | ||
275 | + break; | ||
276 | + default: | ||
277 | + break; | ||
278 | + } | ||
299 | } | 279 | } |
300 | } | 280 | } |
301 | 281 | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -49,7 +49,6 @@ public class Vrouter { | ... | @@ -49,7 +49,6 @@ public class Vrouter { |
49 | 49 | ||
50 | private final List<String> components = ImmutableList.<String>builder() | 50 | private final List<String> components = ImmutableList.<String>builder() |
51 | .add("org.onosproject.routing.fpm.FpmManager") | 51 | .add("org.onosproject.routing.fpm.FpmManager") |
52 | - .add("org.onosproject.routing.impl.Router") | ||
53 | .add("org.onosproject.routing.impl.SingleSwitchFibInstaller") | 52 | .add("org.onosproject.routing.impl.SingleSwitchFibInstaller") |
54 | .add("org.onosproject.routing.impl.ControlPlaneRedirectManager") | 53 | .add("org.onosproject.routing.impl.ControlPlaneRedirectManager") |
55 | .build(); | 54 | .build(); | ... | ... |
... | @@ -182,11 +182,6 @@ public class InterfaceIpAddress { | ... | @@ -182,11 +182,6 @@ public class InterfaceIpAddress { |
182 | 182 | ||
183 | @Override | 183 | @Override |
184 | public String toString() { | 184 | public String toString() { |
185 | - /*return toStringHelper(this).add("ipAddress", ipAddress) | ||
186 | - .add("subnetAddress", subnetAddress) | ||
187 | - .add("broadcastAddress", broadcastAddress) | ||
188 | - .add("peerAddress", peerAddress) | ||
189 | - .omitNullValues().toString();*/ | ||
190 | return ipAddress.toString() + "/" + subnetAddress.prefixLength(); | 185 | return ipAddress.toString() + "/" + subnetAddress.prefixLength(); |
191 | } | 186 | } |
192 | } | 187 | } | ... | ... |
-
Please register or login to post a comment