blob: 78f7cb30e9614e56dc31ac8cfa2d052dd4d9f9a0 [file] [log] [blame]
Pier7b657162018-03-27 11:29:42 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.segmentrouting.mcast;
18
Pierdb27b8d2018-04-17 16:29:56 +020019import com.google.common.collect.ImmutableMap;
Pier7b657162018-03-27 11:29:42 -070020import com.google.common.collect.ImmutableSet;
Charles Chan0b1dd7e2018-08-19 19:21:46 -070021import com.google.common.collect.Lists;
Pierdb27b8d2018-04-17 16:29:56 +020022import com.google.common.collect.Maps;
Charles Chan0b1dd7e2018-08-19 19:21:46 -070023import com.google.common.collect.Sets;
Pierdb27b8d2018-04-17 16:29:56 +020024import com.google.common.hash.HashFunction;
25import com.google.common.hash.Hashing;
Pier7b657162018-03-27 11:29:42 -070026import org.onlab.packet.Ethernet;
27import org.onlab.packet.IpAddress;
28import org.onlab.packet.MacAddress;
29import org.onlab.packet.VlanId;
30import org.onosproject.cluster.NodeId;
31import org.onosproject.core.ApplicationId;
32import org.onosproject.mcast.api.McastRoute;
33import org.onosproject.net.ConnectPoint;
34import org.onosproject.net.DeviceId;
35import org.onosproject.net.HostId;
Charles Chan0b1dd7e2018-08-19 19:21:46 -070036import org.onosproject.net.Link;
Pier7b657162018-03-27 11:29:42 -070037import org.onosproject.net.PortNumber;
38import org.onosproject.net.config.basics.McastConfig;
39import org.onosproject.net.flow.DefaultTrafficSelector;
40import org.onosproject.net.flow.DefaultTrafficTreatment;
41import org.onosproject.net.flow.TrafficSelector;
42import org.onosproject.net.flow.TrafficTreatment;
43import org.onosproject.net.flow.criteria.Criteria;
44import org.onosproject.net.flow.criteria.VlanIdCriterion;
45import org.onosproject.net.flow.instructions.Instructions;
46import org.onosproject.net.flowobjective.DefaultFilteringObjective;
47import org.onosproject.net.flowobjective.DefaultForwardingObjective;
48import org.onosproject.net.flowobjective.DefaultNextObjective;
49import org.onosproject.net.flowobjective.DefaultObjectiveContext;
50import org.onosproject.net.flowobjective.FilteringObjective;
51import org.onosproject.net.flowobjective.ForwardingObjective;
52import org.onosproject.net.flowobjective.NextObjective;
53import org.onosproject.net.flowobjective.ObjectiveContext;
54import org.onosproject.segmentrouting.SegmentRoutingManager;
55import org.onosproject.segmentrouting.SegmentRoutingService;
56import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
57import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig;
58import org.slf4j.Logger;
59
60import java.util.Collection;
Charles Chan0b1dd7e2018-08-19 19:21:46 -070061import java.util.List;
Pier7b657162018-03-27 11:29:42 -070062import java.util.Map;
63import java.util.Set;
64import java.util.stream.Collectors;
65
66import static org.onosproject.net.flow.criteria.Criterion.Type.VLAN_VID;
Pier7b657162018-03-27 11:29:42 -070067
68/**
69 * Utility class for Multicast Handler.
70 */
71class McastUtils {
72
73 // Internal reference to the log
74 private final Logger log;
75 // Internal reference to SR Manager
76 private SegmentRoutingManager srManager;
77 // Internal reference to the app id
78 private ApplicationId coreAppId;
Pierdb27b8d2018-04-17 16:29:56 +020079 // Hashing function for the multicast hasher
80 private static final HashFunction HASH_FN = Hashing.md5();
81 // Read only cache of the Mcast leader
82 private Map<IpAddress, NodeId> mcastLeaderCache;
Pier7b657162018-03-27 11:29:42 -070083
84 /**
85 * Builds a new McastUtils object.
86 *
87 * @param srManager the SR manager
88 * @param coreAppId the core application id
89 * @param log log reference of the McastHandler
90 */
91 McastUtils(SegmentRoutingManager srManager, ApplicationId coreAppId, Logger log) {
92 this.srManager = srManager;
93 this.coreAppId = coreAppId;
94 this.log = log;
Pierdb27b8d2018-04-17 16:29:56 +020095 this.mcastLeaderCache = Maps.newConcurrentMap();
Pier7b657162018-03-27 11:29:42 -070096 }
97
98 /**
Pier72d0e582018-04-20 14:14:34 +020099 * Clean up when deactivating the application.
100 */
101 public void terminate() {
102 mcastLeaderCache.clear();
103 }
104
105 /**
Pier7b657162018-03-27 11:29:42 -0700106 * Get router mac using application config and the connect point.
107 *
108 * @param deviceId the device id
109 * @param port the port number
110 * @return the router mac if the port is configured, otherwise null
111 */
112 private MacAddress getRouterMac(DeviceId deviceId, PortNumber port) {
113 // Do nothing if the port is configured as suppressed
114 ConnectPoint connectPoint = new ConnectPoint(deviceId, port);
115 SegmentRoutingAppConfig appConfig = srManager.cfgService
116 .getConfig(srManager.appId(), SegmentRoutingAppConfig.class);
117 if (appConfig != null && appConfig.suppressSubnet().contains(connectPoint)) {
118 log.info("Ignore suppressed port {}", connectPoint);
119 return MacAddress.NONE;
120 }
121 // Get the router mac using the device configuration
122 MacAddress routerMac;
123 try {
124 routerMac = srManager.deviceConfiguration().getDeviceMac(deviceId);
125 } catch (DeviceConfigNotFoundException dcnfe) {
Esin Karaman93b28892019-07-24 11:26:39 +0000126 log.warn("Failed to get device MAC since the device {} is not configured", deviceId);
127 return null;
Pier7b657162018-03-27 11:29:42 -0700128 }
129 return routerMac;
130 }
131
132 /**
133 * Adds filtering objective for given device and port.
134 *
135 * @param deviceId device ID
136 * @param port ingress port number
137 * @param assignedVlan assigned VLAN ID
138 * @param mcastIp the group address
139 * @param mcastRole the role of the device
140 */
141 void addFilterToDevice(DeviceId deviceId, PortNumber port, VlanId assignedVlan,
142 IpAddress mcastIp, McastRole mcastRole) {
143
Vignesh Ethiraj75790122019-08-26 12:18:42 +0000144 if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
145 log.debug("skip update of fitering objective for unconfigured device: {}", deviceId);
146 return;
147 }
Pier7b657162018-03-27 11:29:42 -0700148 MacAddress routerMac = getRouterMac(deviceId, port);
Esin Karaman93b28892019-07-24 11:26:39 +0000149
150 if (MacAddress.NONE.equals(routerMac)) {
Pier7b657162018-03-27 11:29:42 -0700151 return;
152 }
153
154 FilteringObjective.Builder filtObjBuilder = filterObjBuilder(port, assignedVlan, mcastIp,
155 routerMac, mcastRole);
156 ObjectiveContext context = new DefaultObjectiveContext(
157 (objective) -> log.debug("Successfully add filter on {}/{}, vlan {}",
158 deviceId, port.toLong(), assignedVlan),
159 (objective, error) ->
160 log.warn("Failed to add filter on {}/{}, vlan {}: {}",
161 deviceId, port.toLong(), assignedVlan, error));
162 srManager.flowObjectiveService.filter(deviceId, filtObjBuilder.add(context));
163 }
164
165 /**
166 * Removes filtering objective for given device and port.
167 *
168 * @param deviceId device ID
169 * @param port ingress port number
170 * @param assignedVlan assigned VLAN ID
171 * @param mcastIp multicast IP address
172 * @param mcastRole the multicast role of the device
173 */
174 void removeFilterToDevice(DeviceId deviceId, PortNumber port, VlanId assignedVlan,
175 IpAddress mcastIp, McastRole mcastRole) {
176
Vignesh Ethiraj75790122019-08-26 12:18:42 +0000177 if (!srManager.deviceConfiguration().isConfigured(deviceId)) {
178 log.debug("skip update of fitering objective for unconfigured device: {}", deviceId);
179 return;
180 }
Pier7b657162018-03-27 11:29:42 -0700181 MacAddress routerMac = getRouterMac(deviceId, port);
Esin Karaman93b28892019-07-24 11:26:39 +0000182
183 if (MacAddress.NONE.equals(routerMac)) {
Pier7b657162018-03-27 11:29:42 -0700184 return;
185 }
186
187 FilteringObjective.Builder filtObjBuilder =
188 filterObjBuilder(port, assignedVlan, mcastIp, routerMac, mcastRole);
189 ObjectiveContext context = new DefaultObjectiveContext(
190 (objective) -> log.debug("Successfully removed filter on {}/{}, vlan {}",
191 deviceId, port.toLong(), assignedVlan),
192 (objective, error) ->
193 log.warn("Failed to remove filter on {}/{}, vlan {}: {}",
194 deviceId, port.toLong(), assignedVlan, error));
195 srManager.flowObjectiveService.filter(deviceId, filtObjBuilder.remove(context));
196 }
197
198 /**
199 * Gets assigned VLAN according to the value in the meta.
200 *
201 * @param nextObjective nextObjective to analyze
202 * @return assigned VLAN ID
203 */
204 VlanId assignedVlanFromNext(NextObjective nextObjective) {
205 return ((VlanIdCriterion) nextObjective.meta().getCriterion(VLAN_VID)).vlanId();
206 }
207
208 /**
209 * Gets ingress VLAN from McastConfig.
210 *
211 * @return ingress VLAN or VlanId.NONE if not configured
212 */
213 private VlanId ingressVlan() {
214 McastConfig mcastConfig =
215 srManager.cfgService.getConfig(coreAppId, McastConfig.class);
216 return (mcastConfig != null) ? mcastConfig.ingressVlan() : VlanId.NONE;
217 }
218
219 /**
220 * Gets egress VLAN from McastConfig.
221 *
222 * @return egress VLAN or VlanId.NONE if not configured
223 */
224 private VlanId egressVlan() {
225 McastConfig mcastConfig =
226 srManager.cfgService.getConfig(coreAppId, McastConfig.class);
227 return (mcastConfig != null) ? mcastConfig.egressVlan() : VlanId.NONE;
228 }
229
230 /**
231 * Gets assigned VLAN according to the value of egress VLAN.
232 * If connect point is specified, try to reuse the assigned VLAN on the connect point.
233 *
234 * @param cp connect point; Can be null if not specified
235 * @return assigned VLAN ID
236 */
237 VlanId assignedVlan(ConnectPoint cp) {
238 // Use the egressVlan if it is tagged
239 if (!egressVlan().equals(VlanId.NONE)) {
240 return egressVlan();
241 }
242 // Reuse unicast VLAN if the port has subnet configured
243 if (cp != null) {
244 VlanId untaggedVlan = srManager.getInternalVlanId(cp);
Saurav Das9bf49582018-08-13 15:34:26 -0700245 return (untaggedVlan != null) ? untaggedVlan
246 : srManager.getDefaultInternalVlan();
Pier7b657162018-03-27 11:29:42 -0700247 }
248 // Use DEFAULT_VLAN if none of the above matches
Saurav Das9bf49582018-08-13 15:34:26 -0700249 return srManager.getDefaultInternalVlan();
Pier7b657162018-03-27 11:29:42 -0700250 }
251
252 /**
Pier71c55772018-04-17 17:25:22 +0200253 * Gets sources connect points of given multicast group.
254 *
255 * @param mcastIp multicast IP
256 * @return sources connect points or empty set if not found
257 */
258 Set<ConnectPoint> getSources(IpAddress mcastIp) {
Piere99511d2018-04-19 16:47:06 +0200259 // TODO we should support different types of routes
Pier71c55772018-04-17 17:25:22 +0200260 McastRoute mcastRoute = srManager.multicastRouteService.getRoutes().stream()
261 .filter(mcastRouteInternal -> mcastRouteInternal.group().equals(mcastIp))
262 .findFirst().orElse(null);
263 return mcastRoute == null ? ImmutableSet.of() :
264 srManager.multicastRouteService.sources(mcastRoute);
265 }
266
267 /**
Pier7b657162018-03-27 11:29:42 -0700268 * Gets sinks of given multicast group.
269 *
270 * @param mcastIp multicast IP
271 * @return map of sinks or empty map if not found
272 */
273 Map<HostId, Set<ConnectPoint>> getSinks(IpAddress mcastIp) {
Piere99511d2018-04-19 16:47:06 +0200274 // TODO we should support different types of routes
Pier7b657162018-03-27 11:29:42 -0700275 McastRoute mcastRoute = srManager.multicastRouteService.getRoutes().stream()
276 .filter(mcastRouteInternal -> mcastRouteInternal.group().equals(mcastIp))
277 .findFirst().orElse(null);
278 return mcastRoute == null ?
Pier71c55772018-04-17 17:25:22 +0200279 ImmutableMap.of() :
Pier7b657162018-03-27 11:29:42 -0700280 srManager.multicastRouteService.routeData(mcastRoute).sinks();
281 }
282
283 /**
284 * Get sinks affected by this egress device.
285 *
286 * @param egressDevice the egress device
287 * @param mcastIp the mcast ip address
288 * @return the map of the sinks affected
289 */
290 Map<HostId, Set<ConnectPoint>> getAffectedSinks(DeviceId egressDevice,
Piere99511d2018-04-19 16:47:06 +0200291 IpAddress mcastIp) {
Pier7b657162018-03-27 11:29:42 -0700292 return getSinks(mcastIp).entrySet()
293 .stream()
294 .filter(hostIdSetEntry -> hostIdSetEntry.getValue().stream()
295 .map(ConnectPoint::deviceId)
296 .anyMatch(deviceId -> deviceId.equals(egressDevice))
297 ).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
298 }
299
300 /**
301 * Creates a next objective builder for multicast.
302 *
303 * @param mcastIp multicast group
304 * @param assignedVlan assigned VLAN ID
305 * @param outPorts set of output port numbers
306 * @param nextId the next id
307 * @return next objective builder
308 */
309 NextObjective.Builder nextObjBuilder(IpAddress mcastIp, VlanId assignedVlan,
310 Set<PortNumber> outPorts, Integer nextId) {
311 // If nextId is null allocate a new one
312 if (nextId == null) {
313 nextId = srManager.flowObjectiveService.allocateNextId();
314 }
315 // Build the meta selector with the fwd objective info
316 TrafficSelector metadata =
317 DefaultTrafficSelector.builder()
318 .matchVlanId(assignedVlan)
319 .matchIPDst(mcastIp.toIpPrefix())
320 .build();
321 // Define the nextobjective type
322 NextObjective.Builder nextObjBuilder = DefaultNextObjective
323 .builder().withId(nextId)
324 .withType(NextObjective.Type.BROADCAST)
325 .fromApp(srManager.appId())
326 .withMeta(metadata);
327 // Add the output ports
328 outPorts.forEach(port -> {
329 TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
330 if (egressVlan().equals(VlanId.NONE)) {
331 tBuilder.popVlan();
332 }
333 tBuilder.setOutput(port);
334 nextObjBuilder.addTreatment(tBuilder.build());
335 });
336 // Done return the complete builder
337 return nextObjBuilder;
338 }
339
340 /**
341 * Creates a forwarding objective builder for multicast.
342 *
343 * @param mcastIp multicast group
344 * @param assignedVlan assigned VLAN ID
345 * @param nextId next ID of the L3 multicast group
346 * @return forwarding objective builder
347 */
348 ForwardingObjective.Builder fwdObjBuilder(IpAddress mcastIp,
349 VlanId assignedVlan, int nextId) {
350 TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
351 // Let's the matching on the group address
352 // TODO SSM support in future
353 if (mcastIp.isIp6()) {
354 sbuilder.matchEthType(Ethernet.TYPE_IPV6);
355 sbuilder.matchIPv6Dst(mcastIp.toIpPrefix());
356 } else {
357 sbuilder.matchEthType(Ethernet.TYPE_IPV4);
358 sbuilder.matchIPDst(mcastIp.toIpPrefix());
359 }
360 // Then build the meta selector
361 TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
362 metabuilder.matchVlanId(assignedVlan);
363 // Finally return the completed builder
364 ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective.builder();
365 fwdBuilder.withSelector(sbuilder.build())
366 .withMeta(metabuilder.build())
367 .nextStep(nextId)
368 .withFlag(ForwardingObjective.Flag.SPECIFIC)
369 .fromApp(srManager.appId())
370 .withPriority(SegmentRoutingService.DEFAULT_PRIORITY);
371 return fwdBuilder;
372 }
373
374 /**
375 * Creates a filtering objective builder for multicast.
376 *
377 * @param ingressPort ingress port of the multicast stream
378 * @param assignedVlan assigned VLAN ID
379 * @param mcastIp the group address
380 * @param routerMac router MAC. This is carried in metadata and used from some switches that
381 * need to put unicast entry before multicast entry in TMAC table.
382 * @param mcastRole the Multicast role
383 * @return filtering objective builder
384 */
385 private FilteringObjective.Builder filterObjBuilder(PortNumber ingressPort, VlanId assignedVlan,
Charles Chanba59dd62018-05-10 22:19:49 +0000386 IpAddress mcastIp, MacAddress routerMac, McastRole mcastRole) {
Pier7b657162018-03-27 11:29:42 -0700387 FilteringObjective.Builder filtBuilder = DefaultFilteringObjective.builder();
388 // Let's add the in port matching and the priority
389 filtBuilder.withKey(Criteria.matchInPort(ingressPort))
390 .withPriority(SegmentRoutingService.DEFAULT_PRIORITY);
391 // According to the mcast role we match on the proper vlan
392 // If the role is null we are on the transit or on the egress
393 if (mcastRole == null) {
394 filtBuilder.addCondition(Criteria.matchVlanId(egressVlan()));
395 } else {
396 filtBuilder.addCondition(Criteria.matchVlanId(ingressVlan()));
397 }
398 // According to the IP type we set the proper match on the mac address
399 if (mcastIp.isIp4()) {
400 filtBuilder.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST,
Charles Chanba59dd62018-05-10 22:19:49 +0000401 MacAddress.IPV4_MULTICAST_MASK));
Pier7b657162018-03-27 11:29:42 -0700402 } else {
403 filtBuilder.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV6_MULTICAST,
Charles Chanba59dd62018-05-10 22:19:49 +0000404 MacAddress.IPV6_MULTICAST_MASK));
Pier7b657162018-03-27 11:29:42 -0700405 }
406 // We finally build the meta treatment
Esin Karaman93b28892019-07-24 11:26:39 +0000407 TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
408 tBuilder.pushVlan().setVlanId(assignedVlan);
409
410 if (routerMac != null && !routerMac.equals(MacAddress.NONE)) {
411 tBuilder.setEthDst(routerMac);
412 }
413
414 filtBuilder.withMeta(tBuilder.build());
Pier7b657162018-03-27 11:29:42 -0700415 // Done, we return a permit filtering objective
416 return filtBuilder.permit().fromApp(srManager.appId());
417 }
418
419 /**
420 * Gets output ports information from treatments.
421 *
422 * @param treatments collection of traffic treatments
423 * @return set of output port numbers
424 */
425 Set<PortNumber> getPorts(Collection<TrafficTreatment> treatments) {
426 ImmutableSet.Builder<PortNumber> builder = ImmutableSet.builder();
427 treatments.forEach(treatment -> treatment.allInstructions().stream()
428 .filter(instr -> instr instanceof Instructions.OutputInstruction)
429 .forEach(instr -> builder.add(((Instructions.OutputInstruction) instr).port())));
430 return builder.build();
431 }
Pierdb27b8d2018-04-17 16:29:56 +0200432
433 /**
434 * Returns the hash of the group address.
435 *
436 * @param ipAddress the ip address
437 * @return the hash of the address
438 */
439 private Long hasher(IpAddress ipAddress) {
440 return HASH_FN.newHasher()
441 .putBytes(ipAddress.toOctets())
442 .hash()
443 .asLong();
444 }
445
446 /**
447 * Given a multicast group define a leader for it.
448 *
449 * @param mcastIp the group address
450 * @return true if the instance is the leader of the group
451 */
452 boolean isLeader(IpAddress mcastIp) {
453 // Get our id
454 final NodeId currentNodeId = srManager.clusterService.getLocalNode().id();
455 // Get the leader for this group using the ip address as key
456 final NodeId leader = srManager.workPartitionService.getLeader(mcastIp, this::hasher);
457 // If there is not a leader, let's send an error
458 if (leader == null) {
459 log.error("Fail to elect a leader for {}.", mcastIp);
460 return false;
461 }
462 // Update cache and return operation result
463 mcastLeaderCache.put(mcastIp, leader);
464 return currentNodeId.equals(leader);
465 }
466
467 /**
468 * Given a multicast group withdraw its leader.
469 *
470 * @param mcastIp the group address
471 */
472 void withdrawLeader(IpAddress mcastIp) {
473 // For now just update the cache
474 mcastLeaderCache.remove(mcastIp);
475 }
476
477 Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp) {
478 // If mcast ip is present
479 if (mcastIp != null) {
480 return mcastLeaderCache.entrySet().stream()
481 .filter(entry -> entry.getKey().equals(mcastIp))
482 .collect(Collectors.toMap(Map.Entry::getKey,
483 Map.Entry::getValue));
484 }
485 // Otherwise take all the groups
486 return ImmutableMap.copyOf(mcastLeaderCache);
487 }
Charles Chan0b1dd7e2018-08-19 19:21:46 -0700488
489 /**
490 * Build recursively the mcast paths.
491 *
492 * @param mcastNextObjStore mcast next obj store
493 * @param toVisit the node to visit
494 * @param visited the visited nodes
495 * @param mcastPaths the current mcast paths
496 * @param currentPath the current path
497 * @param mcastIp the group ip
498 * @param source the source
499 */
500 void buildMcastPaths(Map<McastStoreKey, NextObjective> mcastNextObjStore,
501 DeviceId toVisit, Set<DeviceId> visited,
502 Map<ConnectPoint, List<ConnectPoint>> mcastPaths,
503 List<ConnectPoint> currentPath, IpAddress mcastIp,
504 ConnectPoint source) {
505 // If we have visited the node to visit there is a loop
506 if (visited.contains(toVisit)) {
507 return;
508 }
509 // Visit next-hop
510 visited.add(toVisit);
511 VlanId assignedVlan = assignedVlan(toVisit.equals(source.deviceId()) ? source : null);
512 McastStoreKey mcastStoreKey = new McastStoreKey(mcastIp, toVisit, assignedVlan);
513 // Looking for next-hops
514 if (mcastNextObjStore.containsKey(mcastStoreKey)) {
515 // Build egress connect points, get ports and build relative cps
516 NextObjective nextObjective = mcastNextObjStore.get(mcastStoreKey);
517 Set<PortNumber> outputPorts = getPorts(nextObjective.next());
518 ImmutableSet.Builder<ConnectPoint> cpBuilder = ImmutableSet.builder();
519 outputPorts.forEach(portNumber -> cpBuilder.add(new ConnectPoint(toVisit, portNumber)));
520 Set<ConnectPoint> egressPoints = cpBuilder.build();
521 Set<Link> egressLinks;
522 List<ConnectPoint> newCurrentPath;
523 Set<DeviceId> newVisited;
524 DeviceId newToVisit;
525 for (ConnectPoint egressPoint : egressPoints) {
526 egressLinks = srManager.linkService.getEgressLinks(egressPoint);
527 // If it does not have egress links, stop
528 if (egressLinks.isEmpty()) {
529 // Add the connect points to the path
530 newCurrentPath = Lists.newArrayList(currentPath);
531 newCurrentPath.add(0, egressPoint);
532 mcastPaths.put(egressPoint, newCurrentPath);
533 } else {
534 newVisited = Sets.newHashSet(visited);
535 // Iterate over the egress links for the next hops
536 for (Link egressLink : egressLinks) {
537 newToVisit = egressLink.dst().deviceId();
538 newCurrentPath = Lists.newArrayList(currentPath);
539 newCurrentPath.add(0, egressPoint);
540 newCurrentPath.add(0, egressLink.dst());
541 buildMcastPaths(mcastNextObjStore, newToVisit, newVisited, mcastPaths, newCurrentPath, mcastIp,
542 source);
543 }
544 }
545 }
546 }
547 }
Pier7b657162018-03-27 11:29:42 -0700548}