blob: e82049b084e852274db2c3e6796f2e492ec878ff [file] [log] [blame]
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -08003 *
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 */
Srikanth Vavilapalli4db76e32015-04-07 15:12:32 -070016package org.onosproject.segmentrouting.grouphandler;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080017
18import static com.google.common.base.Preconditions.checkNotNull;
19import static org.slf4j.LoggerFactory.getLogger;
20
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -070021import java.net.URI;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080022import java.util.ArrayList;
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -070023import java.util.Collections;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080024import java.util.HashSet;
25import java.util.List;
sangho1e575652015-05-14 00:39:53 -070026import java.util.Map;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080027import java.util.Set;
Saurav Das8a0732e2015-11-20 15:27:53 -080028import java.util.concurrent.ConcurrentHashMap;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070029import java.util.stream.Collectors;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080030
Charles Chanc42e84e2015-10-20 16:24:19 -070031import org.onlab.packet.Ip4Prefix;
32import org.onlab.packet.IpPrefix;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080033import org.onlab.packet.MacAddress;
sangho32a59322015-02-17 12:07:41 -080034import org.onlab.packet.MplsLabel;
Saurav Das423fe2b2015-12-04 10:52:59 -080035import org.onlab.packet.VlanId;
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -070036import org.onlab.util.KryoNamespace;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080037import org.onosproject.core.ApplicationId;
38import org.onosproject.net.DeviceId;
39import org.onosproject.net.Link;
40import org.onosproject.net.PortNumber;
Saurav Das423fe2b2015-12-04 10:52:59 -080041import org.onosproject.net.flow.DefaultTrafficSelector;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080042import org.onosproject.net.flow.DefaultTrafficTreatment;
Saurav Das8a0732e2015-11-20 15:27:53 -080043import org.onosproject.net.flow.TrafficSelector;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080044import org.onosproject.net.flow.TrafficTreatment;
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -070045import org.onosproject.net.flowobjective.DefaultNextObjective;
Charles Chan216e3c82016-04-23 14:48:16 -070046import org.onosproject.net.flowobjective.DefaultObjectiveContext;
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -070047import org.onosproject.net.flowobjective.FlowObjectiveService;
48import org.onosproject.net.flowobjective.NextObjective;
Srikanth Vavilapallif3a8bc02015-05-22 13:47:31 -070049import org.onosproject.net.flowobjective.ObjectiveContext;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080050import org.onosproject.net.link.LinkService;
Saurav Das423fe2b2015-12-04 10:52:59 -080051import org.onosproject.segmentrouting.SegmentRoutingManager;
Charles Chan0b4e6182015-11-03 10:42:14 -080052import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
53import org.onosproject.segmentrouting.config.DeviceProperties;
Charles Chand2990362016-04-18 13:44:03 -070054import org.onosproject.segmentrouting.storekey.NeighborSetNextObjectiveStoreKey;
55import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
56import org.onosproject.segmentrouting.storekey.SubnetNextObjectiveStoreKey;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070057import org.onosproject.store.service.EventuallyConsistentMap;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080058import org.slf4j.Logger;
59
60/**
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -070061 * Default ECMP group handler creation module. This component creates a set of
62 * ECMP groups for every neighbor that this device is connected to based on
63 * whether the current device is an edge device or a transit device.
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080064 */
65public class DefaultGroupHandler {
Srikanth Vavilapallif3a8bc02015-05-22 13:47:31 -070066 protected static final Logger log = getLogger(DefaultGroupHandler.class);
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080067
68 protected final DeviceId deviceId;
69 protected final ApplicationId appId;
70 protected final DeviceProperties deviceConfig;
71 protected final List<Integer> allSegmentIds;
Charles Chan0b4e6182015-11-03 10:42:14 -080072 protected int nodeSegmentId = -1;
73 protected boolean isEdgeRouter = false;
74 protected MacAddress nodeMacAddr = null;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080075 protected LinkService linkService;
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -070076 protected FlowObjectiveService flowObjectiveService;
Saurav Das423fe2b2015-12-04 10:52:59 -080077 // local store for neighbor-device-ids and the set of ports on this device
78 // that connect to the same neighbor
Saurav Das8a0732e2015-11-20 15:27:53 -080079 protected ConcurrentHashMap<DeviceId, Set<PortNumber>> devicePortMap =
80 new ConcurrentHashMap<>();
Saurav Das423fe2b2015-12-04 10:52:59 -080081 //local store for ports on this device connected to neighbor-device-id
Saurav Das8a0732e2015-11-20 15:27:53 -080082 protected ConcurrentHashMap<PortNumber, DeviceId> portDeviceMap =
83 new ConcurrentHashMap<>();
Charles Chane849c192016-01-11 18:28:54 -080084 protected EventuallyConsistentMap<NeighborSetNextObjectiveStoreKey, Integer>
85 nsNextObjStore = null;
86 protected EventuallyConsistentMap<SubnetNextObjectiveStoreKey, Integer>
87 subnetNextObjStore = null;
88 protected EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer>
89 portNextObjStore = null;
Charles Chan188ebf52015-12-23 00:15:11 -080090 private SegmentRoutingManager srManager;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080091
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -070092 protected KryoNamespace.Builder kryo = new KryoNamespace.Builder()
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -070093 .register(URI.class).register(HashSet.class)
94 .register(DeviceId.class).register(PortNumber.class)
95 .register(NeighborSet.class).register(PolicyGroupIdentifier.class)
96 .register(PolicyGroupParams.class)
97 .register(GroupBucketIdentifier.class)
98 .register(GroupBucketIdentifier.BucketOutputType.class);
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -080099
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700100 protected DefaultGroupHandler(DeviceId deviceId, ApplicationId appId,
101 DeviceProperties config,
102 LinkService linkService,
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700103 FlowObjectiveService flowObjService,
Charles Chan188ebf52015-12-23 00:15:11 -0800104 SegmentRoutingManager srManager) {
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800105 this.deviceId = checkNotNull(deviceId);
106 this.appId = checkNotNull(appId);
107 this.deviceConfig = checkNotNull(config);
108 this.linkService = checkNotNull(linkService);
Charles Chan0b4e6182015-11-03 10:42:14 -0800109 this.allSegmentIds = checkNotNull(config.getAllDeviceSegmentIds());
110 try {
111 this.nodeSegmentId = config.getSegmentId(deviceId);
112 this.isEdgeRouter = config.isEdgeDevice(deviceId);
113 this.nodeMacAddr = checkNotNull(config.getDeviceMac(deviceId));
114 } catch (DeviceConfigNotFoundException e) {
115 log.warn(e.getMessage()
116 + " Skipping value assignment in DefaultGroupHandler");
117 }
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700118 this.flowObjectiveService = flowObjService;
Charles Chane849c192016-01-11 18:28:54 -0800119 this.nsNextObjStore = srManager.nsNextObjStore;
120 this.subnetNextObjStore = srManager.subnetNextObjStore;
121 this.portNextObjStore = srManager.portNextObjStore;
Charles Chan188ebf52015-12-23 00:15:11 -0800122 this.srManager = srManager;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800123
124 populateNeighborMaps();
125 }
126
127 /**
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700128 * Creates a group handler object based on the type of device. If device is
129 * of edge type it returns edge group handler, else it returns transit group
130 * handler.
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800131 *
132 * @param deviceId device identifier
133 * @param appId application identifier
134 * @param config interface to retrieve the device properties
135 * @param linkService link service object
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700136 * @param flowObjService flow objective service object
Charles Chane849c192016-01-11 18:28:54 -0800137 * @param srManager segment routing manager
Charles Chan0b4e6182015-11-03 10:42:14 -0800138 * @throws DeviceConfigNotFoundException if the device configuration is not found
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800139 * @return default group handler type
140 */
Saurav Das4ce45962015-11-24 23:21:05 -0800141 public static DefaultGroupHandler createGroupHandler(
142 DeviceId deviceId,
143 ApplicationId appId,
144 DeviceProperties config,
145 LinkService linkService,
146 FlowObjectiveService flowObjService,
Charles Chan188ebf52015-12-23 00:15:11 -0800147 SegmentRoutingManager srManager)
Saurav Das4ce45962015-11-24 23:21:05 -0800148 throws DeviceConfigNotFoundException {
Charles Chan0b4e6182015-11-03 10:42:14 -0800149 // handle possible exception in the caller
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800150 if (config.isEdgeDevice(deviceId)) {
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700151 return new DefaultEdgeGroupHandler(deviceId, appId, config,
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700152 linkService,
153 flowObjService,
Charles Chan188ebf52015-12-23 00:15:11 -0800154 srManager
155 );
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800156 } else {
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700157 return new DefaultTransitGroupHandler(deviceId, appId, config,
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700158 linkService,
159 flowObjService,
Charles Chan188ebf52015-12-23 00:15:11 -0800160 srManager);
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800161 }
162 }
163
164 /**
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700165 * Creates the auto created groups for this device based on the current
166 * snapshot of the topology.
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800167 */
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700168 // Empty implementations to be overridden by derived classes
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800169 public void createGroups() {
170 }
171
172 /**
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700173 * Performs group creation or update procedures when a new link is
174 * discovered on this device.
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800175 *
176 * @param newLink new neighbor link
Charles Chane849c192016-01-11 18:28:54 -0800177 * @param isMaster true if local instance is the master
178 *
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800179 */
Saurav Das8a0732e2015-11-20 15:27:53 -0800180 public void linkUp(Link newLink, boolean isMaster) {
sanghob35a6192015-04-01 13:05:26 -0700181
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800182 if (newLink.type() != Link.Type.DIRECT) {
183 log.warn("linkUp: unknown link type");
184 return;
185 }
186
187 if (!newLink.src().deviceId().equals(deviceId)) {
188 log.warn("linkUp: deviceId{} doesn't match with link src{}",
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700189 deviceId, newLink.src().deviceId());
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800190 return;
191 }
192
Saurav Das8a0732e2015-11-20 15:27:53 -0800193 log.info("* LinkUP: Device {} linkUp at local port {} to neighbor {}", deviceId,
194 newLink.src().port(), newLink.dst().deviceId());
Saurav Das59232cf2016-04-27 18:35:50 -0700195 // ensure local state is updated even if linkup is aborted later on
196 addNeighborAtPort(newLink.dst().deviceId(),
197 newLink.src().port());
198
Charles Chan0b4e6182015-11-03 10:42:14 -0800199 MacAddress dstMac;
200 try {
201 dstMac = deviceConfig.getDeviceMac(newLink.dst().deviceId());
202 } catch (DeviceConfigNotFoundException e) {
203 log.warn(e.getMessage() + " Aborting linkUp.");
204 return;
205 }
206
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700207 /*if (devicePortMap.get(newLink.dst().deviceId()) == null) {
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800208 // New Neighbor
209 newNeighbor(newLink);
210 } else {
211 // Old Neighbor
212 newPortToExistingNeighbor(newLink);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700213 }*/
214 Set<NeighborSet> nsSet = nsNextObjStore.keySet()
215 .stream()
216 .filter((nsStoreEntry) -> (nsStoreEntry.deviceId().equals(deviceId)))
217 .map((nsStoreEntry) -> (nsStoreEntry.neighborSet()))
218 .filter((ns) -> (ns.getDeviceIds()
219 .contains(newLink.dst().deviceId())))
220 .collect(Collectors.toSet());
221 log.trace("linkUp: nsNextObjStore contents for device {}:",
sangho0b2b6d12015-05-20 22:16:38 -0700222 deviceId,
223 nsSet);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700224 for (NeighborSet ns : nsSet) {
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700225 Integer nextId = nsNextObjStore.
226 get(new NeighborSetNextObjectiveStoreKey(deviceId, ns));
Saurav Das4ce45962015-11-24 23:21:05 -0800227 if (nextId != null && isMaster) {
Saurav Das423fe2b2015-12-04 10:52:59 -0800228 // Create the new bucket to be updated
229 TrafficTreatment.Builder tBuilder =
230 DefaultTrafficTreatment.builder();
231 tBuilder.setOutput(newLink.src().port())
232 .setEthDst(dstMac)
233 .setEthSrc(nodeMacAddr);
234 if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) {
235 tBuilder.pushMpls()
236 .copyTtlOut()
237 .setMpls(MplsLabel.mplsLabel(ns.getEdgeLabel()));
238 }
239 // setup metadata to pass to nextObjective - indicate the vlan on egress
240 // if needed by the switch pipeline. Since hashed next-hops are always to
241 // other neighboring routers, there is no subnet assigned on those ports.
242 TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
243 metabuilder.matchVlanId(
244 VlanId.vlanId(SegmentRoutingManager.ASSIGNED_VLAN_NO_SUBNET));
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700245
Saurav Das423fe2b2015-12-04 10:52:59 -0800246 NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
247 .withId(nextId)
248 .withType(NextObjective.Type.HASHED)
249 .addTreatment(tBuilder.build())
250 .withMeta(metabuilder.build())
251 .fromApp(appId);
Saurav Das8a0732e2015-11-20 15:27:53 -0800252 log.info("**linkUp in device {}: Adding Bucket "
Saurav Das4ce45962015-11-24 23:21:05 -0800253 + "with Port {} to next object id {}",
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700254 deviceId,
255 newLink.src().port(),
Saurav Das4ce45962015-11-24 23:21:05 -0800256 nextId);
Charles Chan216e3c82016-04-23 14:48:16 -0700257
258 ObjectiveContext context = new DefaultObjectiveContext(
259 (objective) -> log.debug("LinkUp installed NextObj {} on {}",
260 nextId, deviceId),
261 (objective, error) ->
262 log.warn("LinkUp failed to install NextObj {} on {}: {}",
263 nextId, deviceId, error));
264 NextObjective nextObjective = nextObjBuilder.addToExisting(context);
Saurav Das4ce45962015-11-24 23:21:05 -0800265 flowObjectiveService.next(deviceId, nextObjective);
Saurav Das423fe2b2015-12-04 10:52:59 -0800266
267 // the addition of a bucket may actually change the neighborset
268 // update the global store
269 /*
270 Set<DeviceId> neighbors = new HashSet<DeviceId>(ns.getDeviceIds());
271 boolean newadd = neighbors.add(newLink.dst().deviceId());
272 if (newadd) {
273 NeighborSet nsnew = new NeighborSet(neighbors, ns.getEdgeLabel());
274 nsNextObjStore.put(new NeighborSetNextObjectiveStoreKey(deviceId, nsnew),
275 nextId);
276 nsNextObjStore.remove(new NeighborSetNextObjectiveStoreKey(deviceId, ns));
277 }*/
Saurav Das4ce45962015-11-24 23:21:05 -0800278 } else if (isMaster) {
Saurav Das8a0732e2015-11-20 15:27:53 -0800279 log.warn("linkUp in device {}, but global store has no record "
280 + "for neighbor-set {}", deviceId, ns);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700281 }
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800282 }
283 }
284
285 /**
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700286 * Performs group recovery procedures when a port goes down on this device.
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800287 *
288 * @param port port number that has gone down
Charles Chane849c192016-01-11 18:28:54 -0800289 * @param isMaster true if local instance is the master
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800290 */
Saurav Das423fe2b2015-12-04 10:52:59 -0800291 public void portDown(PortNumber port, boolean isMaster) {
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800292 if (portDeviceMap.get(port) == null) {
293 log.warn("portDown: unknown port");
294 return;
295 }
Charles Chan0b4e6182015-11-03 10:42:14 -0800296
Saurav Das80980c72016-03-23 11:22:49 -0700297 @SuppressWarnings("unused")
Charles Chan0b4e6182015-11-03 10:42:14 -0800298 MacAddress dstMac;
299 try {
300 dstMac = deviceConfig.getDeviceMac(portDeviceMap.get(port));
301 } catch (DeviceConfigNotFoundException e) {
302 log.warn(e.getMessage() + " Aborting portDown.");
303 return;
304 }
305
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700306 log.debug("Device {} portDown {} to neighbor {}", deviceId, port,
307 portDeviceMap.get(port));
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700308 /*Set<NeighborSet> nsSet = computeImpactedNeighborsetForPortEvent(portDeviceMap
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700309 .get(port),
310 devicePortMap
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700311 .keySet());*/
312 Set<NeighborSet> nsSet = nsNextObjStore.keySet()
313 .stream()
314 .filter((nsStoreEntry) -> (nsStoreEntry.deviceId().equals(deviceId)))
315 .map((nsStoreEntry) -> (nsStoreEntry.neighborSet()))
316 .filter((ns) -> (ns.getDeviceIds()
317 .contains(portDeviceMap.get(port))))
318 .collect(Collectors.toSet());
Saurav Das423fe2b2015-12-04 10:52:59 -0800319 log.debug("portDown: nsNextObjStore contents for device {}:{}",
320 deviceId, nsSet);
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800321 for (NeighborSet ns : nsSet) {
Saurav Das80980c72016-03-23 11:22:49 -0700322 NeighborSetNextObjectiveStoreKey nsStoreKey =
323 new NeighborSetNextObjectiveStoreKey(deviceId, ns);
324 Integer nextId = nsNextObjStore.get(nsStoreKey);
Saurav Das423fe2b2015-12-04 10:52:59 -0800325 if (nextId != null && isMaster) {
Saurav Das80980c72016-03-23 11:22:49 -0700326 // XXX This is a workaround for BUG (CORD-611) in current switches.
327 // Should be temporary because this workaround prevents correct
328 // functionality in LAG recovery.
329 log.info("**portDown port:{} in device {}: Invalidating nextId {}",
330 port, deviceId, nextId);
331 nsNextObjStore.remove(nsStoreKey);
332 /*
Saurav Das8a0732e2015-11-20 15:27:53 -0800333 log.info("**portDown in device {}: Removing Bucket "
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700334 + "with Port {} to next object id {}",
335 deviceId,
336 port,
337 nextId);
Saurav Das423fe2b2015-12-04 10:52:59 -0800338 // Create the bucket to be removed
339 TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment
340 .builder();
341 tBuilder.setOutput(port)
342 .setEthDst(dstMac)
343 .setEthSrc(nodeMacAddr);
344 if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) {
345 tBuilder.pushMpls()
346 .copyTtlOut()
347 .setMpls(MplsLabel.mplsLabel(ns.getEdgeLabel()));
348 }
349 NextObjective.Builder nextObjBuilder = DefaultNextObjective
350 .builder()
351 .withType(NextObjective.Type.HASHED) //same as original
352 .withId(nextId)
353 .fromApp(appId)
354 .addTreatment(tBuilder.build());
355 NextObjective nextObjective = nextObjBuilder.
356 removeFromExisting(new SRNextObjectiveContext(deviceId));
sangho834e4b02015-05-01 09:38:25 -0700357
Saurav Das423fe2b2015-12-04 10:52:59 -0800358 flowObjectiveService.next(deviceId, nextObjective);
Saurav Das80980c72016-03-23 11:22:49 -0700359 */
Saurav Das423fe2b2015-12-04 10:52:59 -0800360 // the removal of a bucket may actually change the neighborset
361 // update the global store
362 /*
363 Set<DeviceId> neighbors = new HashSet<DeviceId>(ns.getDeviceIds());
364 boolean removed = neighbors.remove(portDeviceMap.get(port));
365 if (removed) {
366 NeighborSet nsnew = new NeighborSet(neighbors, ns.getEdgeLabel());
367 nsNextObjStore.put(new NeighborSetNextObjectiveStoreKey(deviceId, nsnew),
368 nextId);
369 nsNextObjStore.remove(new NeighborSetNextObjectiveStoreKey(deviceId, ns));
370 }*/
sangho834e4b02015-05-01 09:38:25 -0700371 }
372
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800373 }
374
375 devicePortMap.get(portDeviceMap.get(port)).remove(port);
376 portDeviceMap.remove(port);
377 }
378
379 /**
Saurav Das4ce45962015-11-24 23:21:05 -0800380 * Returns the next objective of type hashed associated with the neighborset.
381 * If there is no next objective for this neighborset, this method
Saurav Das8a0732e2015-11-20 15:27:53 -0800382 * would create a next objective and return. Optionally metadata can be
383 * passed in for the creation of the next objective.
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800384 *
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700385 * @param ns neighborset
Saurav Das8a0732e2015-11-20 15:27:53 -0800386 * @param meta metadata passed into the creation of a Next Objective
387 * @return int if found or -1 if there are errors in the creation of the
388 * neighbor set.
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800389 */
Saurav Das8a0732e2015-11-20 15:27:53 -0800390 public int getNextObjectiveId(NeighborSet ns, TrafficSelector meta) {
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700391 Integer nextId = nsNextObjStore.
392 get(new NeighborSetNextObjectiveStoreKey(deviceId, ns));
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700393 if (nextId == null) {
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700394 log.trace("getNextObjectiveId in device{}: Next objective id "
395 + "not found for {} and creating", deviceId, ns);
396 log.trace("getNextObjectiveId: nsNextObjStore contents for device {}: {}",
397 deviceId,
398 nsNextObjStore.entrySet()
399 .stream()
400 .filter((nsStoreEntry) ->
401 (nsStoreEntry.getKey().deviceId().equals(deviceId)))
402 .collect(Collectors.toList()));
Saurav Das8a0732e2015-11-20 15:27:53 -0800403 createGroupsFromNeighborsets(Collections.singleton(ns), meta);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700404 nextId = nsNextObjStore.
405 get(new NeighborSetNextObjectiveStoreKey(deviceId, ns));
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700406 if (nextId == null) {
407 log.warn("getNextObjectiveId: unable to create next objective");
408 return -1;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700409 } else {
410 log.debug("getNextObjectiveId in device{}: Next objective id {} "
Sho SHIMIZUaf973432015-09-11 14:24:50 -0700411 + "created for {}", deviceId, nextId, ns);
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700412 }
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700413 } else {
414 log.trace("getNextObjectiveId in device{}: Next objective id {} "
Sho SHIMIZUaf973432015-09-11 14:24:50 -0700415 + "found for {}", deviceId, nextId, ns);
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700416 }
Sho SHIMIZUaf973432015-09-11 14:24:50 -0700417 return nextId;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800418 }
419
sangho0b2b6d12015-05-20 22:16:38 -0700420 /**
Saurav Das4ce45962015-11-24 23:21:05 -0800421 * Returns the next objective of type broadcast associated with the subnet,
422 * or -1 if no such objective exists. Note that this method does NOT create
423 * the next objective as a side-effect. It is expected that is objective is
424 * created at startup from network configuration.
Charles Chanc42e84e2015-10-20 16:24:19 -0700425 *
426 * @param prefix subnet information
427 * @return int if found or -1
428 */
429 public int getSubnetNextObjectiveId(IpPrefix prefix) {
430 Integer nextId = subnetNextObjStore.
431 get(new SubnetNextObjectiveStoreKey(deviceId, prefix));
Charles Chan9f676b62015-10-29 14:58:10 -0700432
433 return (nextId != null) ? nextId : -1;
Charles Chanc42e84e2015-10-20 16:24:19 -0700434 }
435
436 /**
Saurav Das4ce45962015-11-24 23:21:05 -0800437 * Returns the next objective of type simple associated with the port on the
438 * device, given the treatment. Different treatments to the same port result
439 * in different next objectives. If no such objective exists, this method
440 * creates one and returns the id. Optionally metadata can be passed in for
441 * the creation of the objective.
442 *
443 * @param portNum the port number for the simple next objective
444 * @param treatment the actions to apply on the packets (should include outport)
445 * @param meta optional metadata passed into the creation of the next objective
446 * @return int if found or created, -1 if there are errors during the
447 * creation of the next objective.
448 */
449 public int getPortNextObjectiveId(PortNumber portNum, TrafficTreatment treatment,
450 TrafficSelector meta) {
Charles Chane849c192016-01-11 18:28:54 -0800451 Integer nextId = portNextObjStore
452 .get(new PortNextObjectiveStoreKey(deviceId, portNum, treatment));
Saurav Das4ce45962015-11-24 23:21:05 -0800453 if (nextId == null) {
454 log.trace("getPortNextObjectiveId in device{}: Next objective id "
455 + "not found for {} and {} creating", deviceId, portNum);
456 createGroupFromPort(portNum, treatment, meta);
457 nextId = portNextObjStore.get(
458 new PortNextObjectiveStoreKey(deviceId, portNum, treatment));
459 if (nextId == null) {
460 log.warn("getPortNextObjectiveId: unable to create next obj"
Charles Chane849c192016-01-11 18:28:54 -0800461 + "for dev:{} port:{}", deviceId, portNum);
462 return -1;
463 }
464 }
465 return nextId;
466 }
467
468 /**
sangho0b2b6d12015-05-20 22:16:38 -0700469 * Checks if the next objective ID (group) for the neighbor set exists or not.
470 *
471 * @param ns neighbor set to check
472 * @return true if it exists, false otherwise
473 */
474 public boolean hasNextObjectiveId(NeighborSet ns) {
475 Integer nextId = nsNextObjStore.
476 get(new NeighborSetNextObjectiveStoreKey(deviceId, ns));
477 if (nextId == null) {
478 return false;
479 }
480
481 return true;
482 }
483
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700484 // Empty implementation
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800485 protected void newNeighbor(Link newLink) {
486 }
487
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700488 // Empty implementation
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800489 protected void newPortToExistingNeighbor(Link newLink) {
490 }
491
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700492 // Empty implementation
493 protected Set<NeighborSet>
494 computeImpactedNeighborsetForPortEvent(DeviceId impactedNeighbor,
495 Set<DeviceId> updatedNeighbors) {
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800496 return null;
497 }
498
499 private void populateNeighborMaps() {
500 Set<Link> outgoingLinks = linkService.getDeviceEgressLinks(deviceId);
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700501 for (Link link : outgoingLinks) {
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800502 if (link.type() != Link.Type.DIRECT) {
503 continue;
504 }
505 addNeighborAtPort(link.dst().deviceId(), link.src().port());
506 }
507 }
508
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700509 protected void addNeighborAtPort(DeviceId neighborId,
510 PortNumber portToNeighbor) {
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800511 // Update DeviceToPort database
512 log.debug("Device {} addNeighborAtPort: neighbor {} at port {}",
513 deviceId, neighborId, portToNeighbor);
Saurav Das8a0732e2015-11-20 15:27:53 -0800514 Set<PortNumber> ports = Collections
515 .newSetFromMap(new ConcurrentHashMap<PortNumber, Boolean>());
516 ports.add(portToNeighbor);
517 Set<PortNumber> portnums = devicePortMap.putIfAbsent(neighborId, ports);
518 if (portnums != null) {
519 portnums.add(portToNeighbor);
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800520 }
521
522 // Update portToDevice database
Saurav Das8a0732e2015-11-20 15:27:53 -0800523 DeviceId prev = portDeviceMap.putIfAbsent(portToNeighbor, neighborId);
524 if (prev != null) {
525 log.warn("Device: {} port: {} has neighbor: {}. NOT updating "
526 + "to neighbor: {}", deviceId, portToNeighbor, prev, neighborId);
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800527 }
528 }
529
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700530 protected Set<Set<DeviceId>> getPowerSetOfNeighbors(Set<DeviceId> neighbors) {
Sho SHIMIZU6cfc02d2015-09-11 11:19:11 -0700531 List<DeviceId> list = new ArrayList<>(neighbors);
532 Set<Set<DeviceId>> sets = new HashSet<>();
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800533 // get the number of elements in the neighbors
534 int elements = list.size();
535 // the number of members of a power set is 2^n
536 // including the empty set
537 int powerElements = (1 << elements);
538
539 // run a binary counter for the number of power elements
540 // NOTE: Exclude empty set
541 for (long i = 1; i < powerElements; i++) {
Sho SHIMIZU6cfc02d2015-09-11 11:19:11 -0700542 Set<DeviceId> neighborSubSet = new HashSet<>();
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800543 for (int j = 0; j < elements; j++) {
544 if ((i >> j) % 2 == 1) {
545 neighborSubSet.add(list.get(j));
546 }
547 }
548 sets.add(neighborSubSet);
549 }
550 return sets;
551 }
552
553 private boolean isSegmentIdSameAsNodeSegmentId(DeviceId deviceId, int sId) {
Charles Chan0b4e6182015-11-03 10:42:14 -0800554 int segmentId;
555 try {
556 segmentId = deviceConfig.getSegmentId(deviceId);
557 } catch (DeviceConfigNotFoundException e) {
558 log.warn(e.getMessage() + " Aborting isSegmentIdSameAsNodeSegmentId.");
559 return false;
560 }
561
562 return segmentId == sId;
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800563 }
564
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700565 protected List<Integer> getSegmentIdsTobePairedWithNeighborSet(Set<DeviceId> neighbors) {
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800566
Sho SHIMIZU6cfc02d2015-09-11 11:19:11 -0700567 List<Integer> nsSegmentIds = new ArrayList<>();
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800568
sanghob35a6192015-04-01 13:05:26 -0700569 // Always pair up with no edge label
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700570 // If (neighbors.size() == 1) {
sanghob35a6192015-04-01 13:05:26 -0700571 nsSegmentIds.add(-1);
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700572 // }
sanghob35a6192015-04-01 13:05:26 -0700573
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800574 // Filter out SegmentIds matching with the
575 // nodes in the combo
576 for (Integer sId : allSegmentIds) {
577 if (sId.equals(nodeSegmentId)) {
578 continue;
579 }
580 boolean filterOut = false;
581 // Check if the edge label being set is of
582 // any node in the Neighbor set
583 for (DeviceId deviceId : neighbors) {
584 if (isSegmentIdSameAsNodeSegmentId(deviceId, sId)) {
585 filterOut = true;
586 break;
587 }
588 }
589 if (!filterOut) {
590 nsSegmentIds.add(sId);
591 }
592 }
593 return nsSegmentIds;
594 }
595
sangho1e575652015-05-14 00:39:53 -0700596 /**
597 * Creates Groups from a set of NeighborSet given.
598 *
599 * @param nsSet a set of NeighborSet
Saurav Das8a0732e2015-11-20 15:27:53 -0800600 * @param meta metadata passed into the creation of a Next Objective
sangho1e575652015-05-14 00:39:53 -0700601 */
Saurav Das8a0732e2015-11-20 15:27:53 -0800602 public void createGroupsFromNeighborsets(Set<NeighborSet> nsSet,
603 TrafficSelector meta) {
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800604 for (NeighborSet ns : nsSet) {
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700605 int nextId = flowObjectiveService.allocateNextId();
606 NextObjective.Builder nextObjBuilder = DefaultNextObjective
607 .builder().withId(nextId)
608 .withType(NextObjective.Type.HASHED).fromApp(appId);
Saurav Das8a0732e2015-11-20 15:27:53 -0800609 for (DeviceId neighborId : ns.getDeviceIds()) {
610 if (devicePortMap.get(neighborId) == null) {
611 log.warn("Neighbor {} is not in the port map yet for dev:{}",
612 neighborId, deviceId);
sangho834e4b02015-05-01 09:38:25 -0700613 return;
Saurav Das8a0732e2015-11-20 15:27:53 -0800614 } else if (devicePortMap.get(neighborId).size() == 0) {
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700615 log.warn("There are no ports for "
Saurav Das8a0732e2015-11-20 15:27:53 -0800616 + "the Device {} in the port map yet", neighborId);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700617 return;
sangho834e4b02015-05-01 09:38:25 -0700618 }
619
Saurav Das8a0732e2015-11-20 15:27:53 -0800620 MacAddress neighborMac;
Charles Chan0b4e6182015-11-03 10:42:14 -0800621 try {
Saurav Das8a0732e2015-11-20 15:27:53 -0800622 neighborMac = deviceConfig.getDeviceMac(neighborId);
Charles Chan0b4e6182015-11-03 10:42:14 -0800623 } catch (DeviceConfigNotFoundException e) {
624 log.warn(e.getMessage() + " Aborting createGroupsFromNeighborsets.");
625 return;
626 }
627
Saurav Das8a0732e2015-11-20 15:27:53 -0800628 for (PortNumber sp : devicePortMap.get(neighborId)) {
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700629 TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment
630 .builder();
Saurav Das8a0732e2015-11-20 15:27:53 -0800631 tBuilder.setEthDst(neighborMac)
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700632 .setEthSrc(nodeMacAddr);
633 if (ns.getEdgeLabel() != NeighborSet.NO_EDGE_LABEL) {
Charles Chan68aa62d2015-11-09 16:37:23 -0800634 tBuilder.pushMpls()
635 .copyTtlOut()
636 .setMpls(MplsLabel.mplsLabel(ns.getEdgeLabel()));
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700637 }
Saurav Das8a0732e2015-11-20 15:27:53 -0800638 tBuilder.setOutput(sp);
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700639 nextObjBuilder.addTreatment(tBuilder.build());
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800640 }
641 }
Saurav Das8a0732e2015-11-20 15:27:53 -0800642 if (meta != null) {
Saurav Das4ce45962015-11-24 23:21:05 -0800643 nextObjBuilder.withMeta(meta);
Saurav Das8a0732e2015-11-20 15:27:53 -0800644 }
Charles Chan216e3c82016-04-23 14:48:16 -0700645
646 ObjectiveContext context = new DefaultObjectiveContext(
647 (objective) -> log.debug("createGroupsFromNeighborsets installed NextObj {} on {}",
648 nextId, deviceId),
649 (objective, error) ->
650 log.warn("createGroupsFromNeighborsets failed to install NextObj {} on {}: {}",
651 nextId, deviceId, error));
652 NextObjective nextObj = nextObjBuilder.add(context);
653 log.debug("**createGroupsFromNeighborsets: Submited "
Saurav Das8a0732e2015-11-20 15:27:53 -0800654 + "next objective {} in device {}",
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700655 nextId, deviceId);
Saurav Das8a0732e2015-11-20 15:27:53 -0800656 flowObjectiveService.next(deviceId, nextObj);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700657 nsNextObjStore.put(new NeighborSetNextObjectiveStoreKey(deviceId, ns),
658 nextId);
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800659 }
660 }
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700661
Saurav Das4ce45962015-11-24 23:21:05 -0800662 /**
663 * Creates broadcast groups for all ports in the same configured subnet.
Saurav Das4ce45962015-11-24 23:21:05 -0800664 */
Charles Chanc42e84e2015-10-20 16:24:19 -0700665 public void createGroupsFromSubnetConfig() {
Saurav Das7a1ffca2016-03-28 19:00:18 -0700666 Map<Ip4Prefix, List<PortNumber>> subnetPortMap;
667 try {
668 subnetPortMap = this.deviceConfig.getSubnetPortsMap(this.deviceId);
669 } catch (DeviceConfigNotFoundException e) {
670 log.warn(e.getMessage()
671 + " Not creating broadcast groups for device: " + deviceId);
672 return;
673 }
Charles Chanc42e84e2015-10-20 16:24:19 -0700674 // Construct a broadcast group for each subnet
675 subnetPortMap.forEach((subnet, ports) -> {
Charles Chan9f676b62015-10-29 14:58:10 -0700676 SubnetNextObjectiveStoreKey key =
677 new SubnetNextObjectiveStoreKey(deviceId, subnet);
678
679 if (subnetNextObjStore.containsKey(key)) {
680 log.debug("Broadcast group for device {} and subnet {} exists",
681 deviceId, subnet);
682 return;
683 }
684
Charles Chan188ebf52015-12-23 00:15:11 -0800685 VlanId assignedVlanId =
686 srManager.getSubnetAssignedVlanId(this.deviceId, subnet);
687 TrafficSelector metadata =
688 DefaultTrafficSelector.builder().matchVlanId(assignedVlanId).build();
689
Charles Chanc42e84e2015-10-20 16:24:19 -0700690 int nextId = flowObjectiveService.allocateNextId();
691
692 NextObjective.Builder nextObjBuilder = DefaultNextObjective
693 .builder().withId(nextId)
Charles Chan188ebf52015-12-23 00:15:11 -0800694 .withType(NextObjective.Type.BROADCAST).fromApp(appId)
695 .withMeta(metadata);
Charles Chanc42e84e2015-10-20 16:24:19 -0700696
697 ports.forEach(port -> {
698 TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
Saurav Das4f980082015-11-05 13:39:15 -0800699 tBuilder.popVlan();
Charles Chanc42e84e2015-10-20 16:24:19 -0700700 tBuilder.setOutput(port);
701 nextObjBuilder.addTreatment(tBuilder.build());
702 });
703
704 NextObjective nextObj = nextObjBuilder.add();
705 flowObjectiveService.next(deviceId, nextObj);
706 log.debug("createGroupFromSubnetConfig: Submited "
707 + "next objective {} in device {}",
708 nextId, deviceId);
Charles Chan9f676b62015-10-29 14:58:10 -0700709
Charles Chanc42e84e2015-10-20 16:24:19 -0700710 subnetNextObjStore.put(key, nextId);
711 });
712 }
713
Charles Chane849c192016-01-11 18:28:54 -0800714 /**
Saurav Das4ce45962015-11-24 23:21:05 -0800715 * Create simple next objective for a single port. The treatments can include
716 * all outgoing actions that need to happen on the packet.
717 *
718 * @param portNum the outgoing port on the device
719 * @param treatment the actions to apply on the packets (should include outport)
720 * @param meta optional data to pass to the driver
721 */
722 public void createGroupFromPort(PortNumber portNum, TrafficTreatment treatment,
723 TrafficSelector meta) {
724 int nextId = flowObjectiveService.allocateNextId();
725 PortNextObjectiveStoreKey key = new PortNextObjectiveStoreKey(
726 deviceId, portNum, treatment);
727
728 NextObjective.Builder nextObjBuilder = DefaultNextObjective
729 .builder().withId(nextId)
730 .withType(NextObjective.Type.SIMPLE)
731 .addTreatment(treatment)
732 .fromApp(appId)
733 .withMeta(meta);
734
735 NextObjective nextObj = nextObjBuilder.add();
736 flowObjectiveService.next(deviceId, nextObj);
737 log.debug("createGroupFromPort: Submited next objective {} in device {} "
738 + "for port {}", nextId, deviceId, portNum);
739
740 portNextObjStore.put(key, nextId);
741 }
742
sangho1e575652015-05-14 00:39:53 -0700743 /**
744 * Removes groups for the next objective ID given.
745 *
746 * @param objectiveId next objective ID to remove
747 * @return true if succeeds, false otherwise
748 */
749 public boolean removeGroup(int objectiveId) {
750
751 if (nsNextObjStore.containsValue(objectiveId)) {
752 NextObjective.Builder nextObjBuilder = DefaultNextObjective
753 .builder().withId(objectiveId)
754 .withType(NextObjective.Type.HASHED).fromApp(appId);
Charles Chan216e3c82016-04-23 14:48:16 -0700755 ObjectiveContext context = new DefaultObjectiveContext(
756 (objective) -> log.debug("RemoveGroup removes NextObj {} on {}",
757 objectiveId, deviceId),
758 (objective, error) ->
759 log.warn("RemoveGroup failed to remove NextObj {} on {}: {}",
760 objectiveId, deviceId, error));
761 NextObjective nextObjective = nextObjBuilder.remove(context);
Saurav Das8a0732e2015-11-20 15:27:53 -0800762 log.info("**removeGroup: Submited "
763 + "next objective {} in device {}",
764 objectiveId, deviceId);
sangho1e575652015-05-14 00:39:53 -0700765 flowObjectiveService.next(deviceId, nextObjective);
766
767 for (Map.Entry<NeighborSetNextObjectiveStoreKey, Integer> entry: nsNextObjStore.entrySet()) {
768 if (entry.getValue().equals(objectiveId)) {
769 nsNextObjStore.remove(entry.getKey());
770 break;
771 }
772 }
sangho0b2b6d12015-05-20 22:16:38 -0700773 return true;
sangho1e575652015-05-14 00:39:53 -0700774 }
775
776 return false;
777 }
Srikanth Vavilapallif3a8bc02015-05-22 13:47:31 -0700778
Charles Chane849c192016-01-11 18:28:54 -0800779 /**
780 * Removes all groups from all next objective stores.
781 */
Saurav Das423fe2b2015-12-04 10:52:59 -0800782 public void removeAllGroups() {
783 for (Map.Entry<NeighborSetNextObjectiveStoreKey, Integer> entry:
784 nsNextObjStore.entrySet()) {
785 removeGroup(entry.getValue());
786 }
787 for (Map.Entry<PortNextObjectiveStoreKey, Integer> entry:
788 portNextObjStore.entrySet()) {
789 removeGroup(entry.getValue());
790 }
791 for (Map.Entry<SubnetNextObjectiveStoreKey, Integer> entry:
792 subnetNextObjStore.entrySet()) {
793 removeGroup(entry.getValue());
794 }
795 // should probably clean local stores port-neighbor
796 }
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800797}