blob: ec208589c16145ce5eba49164ee746b15d28de62 [file] [log] [blame]
sanghob35a6192015-04-01 13:05:26 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
sanghob35a6192015-04-01 13:05:26 -07003 *
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 */
16package org.onosproject.segmentrouting;
17
Charles Chan7ffd81f2017-02-08 15:52:08 -080018import com.google.common.collect.HashMultimap;
Saurav Dasc88d4662017-05-15 15:34:25 -070019import com.google.common.collect.ImmutableMap;
Charles Chanc81c45b2016-10-20 17:02:44 -070020import com.google.common.collect.Maps;
Charles Chan7ffd81f2017-02-08 15:52:08 -080021import com.google.common.collect.Multimap;
sanghob35a6192015-04-01 13:05:26 -070022import org.apache.felix.scr.annotations.Activate;
23import org.apache.felix.scr.annotations.Component;
24import org.apache.felix.scr.annotations.Deactivate;
25import org.apache.felix.scr.annotations.Reference;
26import org.apache.felix.scr.annotations.ReferenceCardinality;
sangho1e575652015-05-14 00:39:53 -070027import org.apache.felix.scr.annotations.Service;
sanghob35a6192015-04-01 13:05:26 -070028import org.onlab.packet.Ethernet;
Pier Ventre735b8c82016-12-02 08:16:05 -080029import org.onlab.packet.ICMP6;
Charles Chanc42e84e2015-10-20 16:24:19 -070030import org.onlab.packet.IPv4;
Pier Ventre10bd8d12016-11-26 21:05:22 -080031import org.onlab.packet.IPv6;
Charles Chanc42e84e2015-10-20 16:24:19 -070032import org.onlab.packet.IpPrefix;
Jonathan Hartc19f7c12016-04-12 15:39:44 -070033import org.onlab.packet.VlanId;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070034import org.onlab.util.KryoNamespace;
Saurav Das80980c72016-03-23 11:22:49 -070035import org.onosproject.cfg.ComponentConfigService;
sanghob35a6192015-04-01 13:05:26 -070036import org.onosproject.core.ApplicationId;
37import org.onosproject.core.CoreService;
38import org.onosproject.event.Event;
Charles Chan278ce832017-06-26 15:25:09 -070039import org.onosproject.incubator.net.config.basics.InterfaceConfig;
Charles Chand55e84d2016-03-30 17:54:24 -070040import org.onosproject.incubator.net.config.basics.McastConfig;
Ray Milkeyfacf2862017-08-03 11:58:29 -070041import org.onosproject.net.intf.Interface;
42import org.onosproject.net.intf.InterfaceService;
Charles Chan03a73e02016-10-24 14:52:01 -070043import org.onosproject.incubator.net.routing.RouteEvent;
44import org.onosproject.incubator.net.routing.RouteListener;
45import org.onosproject.incubator.net.routing.RouteService;
Pier Ventre735b8c82016-12-02 08:16:05 -080046import org.onosproject.incubator.net.neighbour.NeighbourResolutionService;
Jonathan Hartc19f7c12016-04-12 15:39:44 -070047import org.onosproject.mastership.MastershipService;
Pier Ventre10bd8d12016-11-26 21:05:22 -080048import org.onosproject.net.ConnectPoint;
Jonathan Hartc19f7c12016-04-12 15:39:44 -070049import org.onosproject.net.Device;
50import org.onosproject.net.DeviceId;
51import org.onosproject.net.Link;
52import org.onosproject.net.Port;
Charles Chan68aa62d2015-11-09 16:37:23 -080053import org.onosproject.net.PortNumber;
Charles Chand6832882015-10-05 17:50:33 -070054import org.onosproject.net.config.ConfigFactory;
55import org.onosproject.net.config.NetworkConfigEvent;
Charles Chand6832882015-10-05 17:50:33 -070056import org.onosproject.net.config.NetworkConfigListener;
Jonathan Hartc19f7c12016-04-12 15:39:44 -070057import org.onosproject.net.config.NetworkConfigRegistry;
Charles Chand6832882015-10-05 17:50:33 -070058import org.onosproject.net.config.basics.SubjectFactories;
Jonathan Hartc19f7c12016-04-12 15:39:44 -070059import org.onosproject.net.device.DeviceEvent;
60import org.onosproject.net.device.DeviceListener;
61import org.onosproject.net.device.DeviceService;
Charles Chan68aa62d2015-11-09 16:37:23 -080062import org.onosproject.net.flow.TrafficSelector;
63import org.onosproject.net.flow.TrafficTreatment;
Jonathan Hartc19f7c12016-04-12 15:39:44 -070064import org.onosproject.net.flowobjective.FlowObjectiveService;
Charles Chan68aa62d2015-11-09 16:37:23 -080065import org.onosproject.net.host.HostEvent;
66import org.onosproject.net.host.HostListener;
Pier Ventre10bd8d12016-11-26 21:05:22 -080067import org.onosproject.net.host.HostService;
68import org.onosproject.net.link.LinkEvent;
69import org.onosproject.net.link.LinkListener;
70import org.onosproject.net.link.LinkService;
Charles Chand55e84d2016-03-30 17:54:24 -070071import org.onosproject.net.mcast.McastEvent;
72import org.onosproject.net.mcast.McastListener;
73import org.onosproject.net.mcast.MulticastRouteService;
Pier Ventre10bd8d12016-11-26 21:05:22 -080074import org.onosproject.net.packet.InboundPacket;
75import org.onosproject.net.packet.PacketContext;
76import org.onosproject.net.packet.PacketProcessor;
77import org.onosproject.net.packet.PacketService;
Pier Ventre42287df2016-11-09 14:17:26 -080078import org.onosproject.net.topology.PathService;
Charles Chand55e84d2016-03-30 17:54:24 -070079import org.onosproject.net.topology.TopologyService;
80import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
81import org.onosproject.segmentrouting.config.DeviceConfiguration;
Pier Ventref34966c2016-11-07 16:21:04 -080082import org.onosproject.segmentrouting.config.PwaasConfig;
Pier Ventre10bd8d12016-11-26 21:05:22 -080083import org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig;
Pier Ventref34966c2016-11-07 16:21:04 -080084import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig;
Charles Chanfc5c7802016-05-17 13:13:55 -070085import org.onosproject.segmentrouting.config.XConnectConfig;
Charles Chand55e84d2016-03-30 17:54:24 -070086import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler;
Saurav Das7bcbe702017-06-13 15:35:54 -070087import org.onosproject.segmentrouting.grouphandler.DestinationSet;
88import org.onosproject.segmentrouting.grouphandler.NextNeighbors;
89import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Charles Chand2990362016-04-18 13:44:03 -070090import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
Charles Chan59cc16d2017-02-02 16:20:42 -080091import org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey;
Charles Chanfc5c7802016-05-17 13:13:55 -070092import org.onosproject.segmentrouting.storekey.XConnectStoreKey;
Pier Ventref34966c2016-11-07 16:21:04 -080093import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Jonathan Hartc19f7c12016-04-12 15:39:44 -070094import org.onosproject.store.serializers.KryoNamespaces;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070095import org.onosproject.store.service.EventuallyConsistentMap;
96import org.onosproject.store.service.EventuallyConsistentMapBuilder;
97import org.onosproject.store.service.StorageService;
98import org.onosproject.store.service.WallClockTimestamp;
sanghob35a6192015-04-01 13:05:26 -070099import org.slf4j.Logger;
100import org.slf4j.LoggerFactory;
101
sangho1e575652015-05-14 00:39:53 -0700102import java.util.List;
sanghob35a6192015-04-01 13:05:26 -0700103import java.util.Map;
Saurav Dasc88d4662017-05-15 15:34:25 -0700104import java.util.Map.Entry;
Charles Chan65238242017-06-22 18:03:14 -0700105import java.util.Optional;
Saurav Das0e99e2b2015-10-28 12:39:42 -0700106import java.util.Set;
sanghob35a6192015-04-01 13:05:26 -0700107import java.util.concurrent.ConcurrentHashMap;
108import java.util.concurrent.ConcurrentLinkedQueue;
109import java.util.concurrent.Executors;
110import java.util.concurrent.ScheduledExecutorService;
111import java.util.concurrent.ScheduledFuture;
112import java.util.concurrent.TimeUnit;
Saurav Das7bcbe702017-06-13 15:35:54 -0700113import java.util.concurrent.atomic.AtomicBoolean;
Charles Chan7ffd81f2017-02-08 15:52:08 -0800114import java.util.stream.Collectors;
sanghob35a6192015-04-01 13:05:26 -0700115
Charles Chan3e783d02016-02-26 22:19:52 -0800116import static com.google.common.base.Preconditions.checkState;
Pier Ventree0ae7a32016-11-23 09:57:42 -0800117import static org.onlab.packet.Ethernet.TYPE_ARP;
Yuta HIGUCHI1624df12016-07-21 16:54:33 -0700118import static org.onlab.util.Tools.groupedThreads;
Charles Chan3e783d02016-02-26 22:19:52 -0800119
Charles Chane849c192016-01-11 18:28:54 -0800120/**
121 * Segment routing manager.
122 */
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700123@Service
124@Component(immediate = true)
sangho1e575652015-05-14 00:39:53 -0700125public class SegmentRoutingManager implements SegmentRoutingService {
sanghob35a6192015-04-01 13:05:26 -0700126
Charles Chan2c15aca2016-11-09 20:51:44 -0800127 private static Logger log = LoggerFactory.getLogger(SegmentRoutingManager.class);
sanghob35a6192015-04-01 13:05:26 -0700128
129 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan03a73e02016-10-24 14:52:01 -0700130 private ComponentConfigService compCfgService;
sanghob35a6192015-04-01 13:05:26 -0700131
132 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventre10bd8d12016-11-26 21:05:22 -0800133 private NeighbourResolutionService neighbourResolutionService;
134
135 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventre42287df2016-11-09 14:17:26 -0800136 public PathService pathService;
137
138 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan03a73e02016-10-24 14:52:01 -0700139 CoreService coreService;
sanghob35a6192015-04-01 13:05:26 -0700140
141 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan03a73e02016-10-24 14:52:01 -0700142 PacketService packetService;
sanghob35a6192015-04-01 13:05:26 -0700143
144 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan03a73e02016-10-24 14:52:01 -0700145 HostService hostService;
sanghob35a6192015-04-01 13:05:26 -0700146
147 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan03a73e02016-10-24 14:52:01 -0700148 DeviceService deviceService;
sanghob35a6192015-04-01 13:05:26 -0700149
150 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventre42287df2016-11-09 14:17:26 -0800151 public FlowObjectiveService flowObjectiveService;
sanghob35a6192015-04-01 13:05:26 -0700152
153 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan03a73e02016-10-24 14:52:01 -0700154 LinkService linkService;
sangho1e575652015-05-14 00:39:53 -0700155
Charles Chan5270ed02016-01-30 23:22:37 -0800156 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventre42287df2016-11-09 14:17:26 -0800157 public MastershipService mastershipService;
Charles Chan03a73e02016-10-24 14:52:01 -0700158
159 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventre42287df2016-11-09 14:17:26 -0800160 public StorageService storageService;
Charles Chan03a73e02016-10-24 14:52:01 -0700161
162 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
163 MulticastRouteService multicastRouteService;
164
165 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
166 TopologyService topologyService;
167
168 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan03a73e02016-10-24 14:52:01 -0700169 RouteService routeService;
Charles Chan5270ed02016-01-30 23:22:37 -0800170
171 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan2c15aca2016-11-09 20:51:44 -0800172 public NetworkConfigRegistry cfgService;
Charles Chan5270ed02016-01-30 23:22:37 -0800173
Saurav Das80980c72016-03-23 11:22:49 -0700174 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan2c15aca2016-11-09 20:51:44 -0800175 public InterfaceService interfaceService;
176
Charles Chan03a73e02016-10-24 14:52:01 -0700177 ArpHandler arpHandler = null;
178 IcmpHandler icmpHandler = null;
179 IpHandler ipHandler = null;
180 RoutingRulePopulator routingRulePopulator = null;
Ray Milkeye4afdb52017-04-05 09:42:04 -0700181 ApplicationId appId;
182 DeviceConfiguration deviceConfiguration = null;
sanghob35a6192015-04-01 13:05:26 -0700183
Charles Chan03a73e02016-10-24 14:52:01 -0700184 DefaultRoutingHandler defaultRoutingHandler = null;
sangho1e575652015-05-14 00:39:53 -0700185 private TunnelHandler tunnelHandler = null;
186 private PolicyHandler policyHandler = null;
Charles Chanb8e10c82015-10-14 11:24:40 -0700187 private InternalPacketProcessor processor = null;
188 private InternalLinkListener linkListener = null;
189 private InternalDeviceListener deviceListener = null;
Charles Chanfc5c7802016-05-17 13:13:55 -0700190 private AppConfigHandler appCfgHandler = null;
Charles Chan03a73e02016-10-24 14:52:01 -0700191 XConnectHandler xConnectHandler = null;
Charles Chand2990362016-04-18 13:44:03 -0700192 private McastHandler mcastHandler = null;
Charles Chan65238242017-06-22 18:03:14 -0700193 private HostHandler hostHandler = null;
Pier Ventre10bd8d12016-11-26 21:05:22 -0800194 private RouteHandler routeHandler = null;
Pier Ventre735b8c82016-12-02 08:16:05 -0800195 private SegmentRoutingNeighbourDispatcher neighbourHandler = null;
Pier Ventref34966c2016-11-07 16:21:04 -0800196 private L2TunnelHandler l2TunnelHandler = null;
sanghob35a6192015-04-01 13:05:26 -0700197 private InternalEventHandler eventHandler = new InternalEventHandler();
Charles Chan5270ed02016-01-30 23:22:37 -0800198 private final InternalHostListener hostListener = new InternalHostListener();
Charles Chand55e84d2016-03-30 17:54:24 -0700199 private final InternalConfigListener cfgListener = new InternalConfigListener(this);
200 private final InternalMcastListener mcastListener = new InternalMcastListener();
Charles Chan03a73e02016-10-24 14:52:01 -0700201 private final InternalRouteEventListener routeListener = new InternalRouteEventListener();
sanghob35a6192015-04-01 13:05:26 -0700202
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -0700203 private ScheduledExecutorService executorService = Executors
Yuta HIGUCHI1624df12016-07-21 16:54:33 -0700204 .newScheduledThreadPool(1, groupedThreads("SegmentRoutingManager", "event-%d", log));
sanghob35a6192015-04-01 13:05:26 -0700205
Saurav Das4ce45962015-11-24 23:21:05 -0800206 @SuppressWarnings("unused")
sanghob35a6192015-04-01 13:05:26 -0700207 private static ScheduledFuture<?> eventHandlerFuture = null;
Saurav Das4ce45962015-11-24 23:21:05 -0800208 @SuppressWarnings("rawtypes")
Yuta HIGUCHI1624df12016-07-21 16:54:33 -0700209 private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<>();
Charles Chan68aa62d2015-11-09 16:37:23 -0800210 private Map<DeviceId, DefaultGroupHandler> groupHandlerMap =
Charles Chane849c192016-01-11 18:28:54 -0800211 new ConcurrentHashMap<>();
212 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700213 * Per device next objective ID store with (device id + destination set) as key.
Charles Chane849c192016-01-11 18:28:54 -0800214 */
Saurav Das7bcbe702017-06-13 15:35:54 -0700215 EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey, NextNeighbors>
216 dsNextObjStore = null;
Charles Chane849c192016-01-11 18:28:54 -0800217 /**
218 * Per device next objective ID store with (device id + subnet) as key.
219 */
Ray Milkeye4afdb52017-04-05 09:42:04 -0700220 EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer>
Charles Chan59cc16d2017-02-02 16:20:42 -0800221 vlanNextObjStore = null;
Charles Chane849c192016-01-11 18:28:54 -0800222 /**
223 * Per device next objective ID store with (device id + port) as key.
224 */
Ray Milkeye4afdb52017-04-05 09:42:04 -0700225 EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer>
Saurav Das4ce45962015-11-24 23:21:05 -0800226 portNextObjStore = null;
Charles Chan59cc16d2017-02-02 16:20:42 -0800227
Saurav Dasc88d4662017-05-15 15:34:25 -0700228 // Local store for all links seen and their present status, used for
229 // optimized routing. The existence of the link in the keys is enough to know
230 // if the link has been "seen-before" by this instance of the controller.
231 // The boolean value indicates if the link is currently up or not.
232 // XXX Currently the optimized routing logic depends on "forgetting" a link
233 // when a switch goes down, but "remembering" it when only the link goes down.
234 // Consider changing this logic so we can use the Link Service instead of
235 // a local cache.
236 private Map<Link, Boolean> seenLinks = new ConcurrentHashMap<>();
237
Saurav Das4ce45962015-11-24 23:21:05 -0800238 private EventuallyConsistentMap<String, Tunnel> tunnelStore = null;
239 private EventuallyConsistentMap<String, Policy> policyStore = null;
sangho0b2b6d12015-05-20 22:16:38 -0700240
Saurav Das7bcbe702017-06-13 15:35:54 -0700241 private AtomicBoolean programmingScheduled = new AtomicBoolean();
242
Charles Chand55e84d2016-03-30 17:54:24 -0700243 private final ConfigFactory<DeviceId, SegmentRoutingDeviceConfig> deviceConfigFactory =
Charles Chanfc5c7802016-05-17 13:13:55 -0700244 new ConfigFactory<DeviceId, SegmentRoutingDeviceConfig>(
245 SubjectFactories.DEVICE_SUBJECT_FACTORY,
Charles Chand55e84d2016-03-30 17:54:24 -0700246 SegmentRoutingDeviceConfig.class, "segmentrouting") {
Charles Chand6832882015-10-05 17:50:33 -0700247 @Override
Charles Chan5270ed02016-01-30 23:22:37 -0800248 public SegmentRoutingDeviceConfig createConfig() {
249 return new SegmentRoutingDeviceConfig();
Charles Chand6832882015-10-05 17:50:33 -0700250 }
251 };
Pier Ventref34966c2016-11-07 16:21:04 -0800252
Charles Chand55e84d2016-03-30 17:54:24 -0700253 private final ConfigFactory<ApplicationId, SegmentRoutingAppConfig> appConfigFactory =
Charles Chanfc5c7802016-05-17 13:13:55 -0700254 new ConfigFactory<ApplicationId, SegmentRoutingAppConfig>(
255 SubjectFactories.APP_SUBJECT_FACTORY,
Charles Chand55e84d2016-03-30 17:54:24 -0700256 SegmentRoutingAppConfig.class, "segmentrouting") {
Charles Chan5270ed02016-01-30 23:22:37 -0800257 @Override
258 public SegmentRoutingAppConfig createConfig() {
259 return new SegmentRoutingAppConfig();
260 }
261 };
Pier Ventref34966c2016-11-07 16:21:04 -0800262
Charles Chanfc5c7802016-05-17 13:13:55 -0700263 private final ConfigFactory<ApplicationId, XConnectConfig> xConnectConfigFactory =
264 new ConfigFactory<ApplicationId, XConnectConfig>(
265 SubjectFactories.APP_SUBJECT_FACTORY,
266 XConnectConfig.class, "xconnect") {
267 @Override
268 public XConnectConfig createConfig() {
269 return new XConnectConfig();
270 }
271 };
Pier Ventref34966c2016-11-07 16:21:04 -0800272
Charles Chand55e84d2016-03-30 17:54:24 -0700273 private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory =
Charles Chanfc5c7802016-05-17 13:13:55 -0700274 new ConfigFactory<ApplicationId, McastConfig>(
275 SubjectFactories.APP_SUBJECT_FACTORY,
Charles Chand55e84d2016-03-30 17:54:24 -0700276 McastConfig.class, "multicast") {
277 @Override
278 public McastConfig createConfig() {
279 return new McastConfig();
280 }
281 };
282
Pier Ventref34966c2016-11-07 16:21:04 -0800283 private final ConfigFactory<ApplicationId, PwaasConfig> pwaasConfigFactory =
284 new ConfigFactory<ApplicationId, PwaasConfig>(
285 SubjectFactories.APP_SUBJECT_FACTORY,
286 PwaasConfig.class, "pwaas") {
287 @Override
288 public PwaasConfig createConfig() {
289 return new PwaasConfig();
290 }
291 };
292
Charles Chan65238242017-06-22 18:03:14 -0700293 private static final Object THREAD_SCHED_LOCK = new Object();
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -0700294 private static int numOfEventsQueued = 0;
295 private static int numOfEventsExecuted = 0;
sanghob35a6192015-04-01 13:05:26 -0700296 private static int numOfHandlerExecution = 0;
297 private static int numOfHandlerScheduled = 0;
298
Charles Chan116188d2016-02-18 14:22:42 -0800299 /**
300 * Segment Routing App ID.
301 */
Charles Chan2c15aca2016-11-09 20:51:44 -0800302 public static final String APP_NAME = "org.onosproject.segmentrouting";
Charles Chan59cc16d2017-02-02 16:20:42 -0800303
Charles Chane849c192016-01-11 18:28:54 -0800304 /**
305 * The default VLAN ID assigned to the interfaces without subnet config.
306 */
Charles Chan59cc16d2017-02-02 16:20:42 -0800307 public static final VlanId INTERNAL_VLAN = VlanId.vlanId((short) 4094);
Saurav Das0e99e2b2015-10-28 12:39:42 -0700308
sanghob35a6192015-04-01 13:05:26 -0700309 @Activate
310 protected void activate() {
Charles Chan2c15aca2016-11-09 20:51:44 -0800311 appId = coreService.registerApplication(APP_NAME);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700312
313 log.debug("Creating EC map nsnextobjectivestore");
Saurav Das7bcbe702017-06-13 15:35:54 -0700314 EventuallyConsistentMapBuilder<DestinationSetNextObjectiveStoreKey, NextNeighbors>
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700315 nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
Saurav Das7bcbe702017-06-13 15:35:54 -0700316 dsNextObjStore = nsNextObjMapBuilder
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700317 .withName("nsnextobjectivestore")
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700318 .withSerializer(createSerializer())
Madan Jampanibcf1a482015-06-24 19:05:56 -0700319 .withTimestampProvider((k, v) -> new WallClockTimestamp())
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700320 .build();
Saurav Das7bcbe702017-06-13 15:35:54 -0700321 log.trace("Current size {}", dsNextObjStore.size());
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700322
Charles Chan59cc16d2017-02-02 16:20:42 -0800323 log.debug("Creating EC map vlannextobjectivestore");
324 EventuallyConsistentMapBuilder<VlanNextObjectiveStoreKey, Integer>
325 vlanNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
326 vlanNextObjStore = vlanNextObjMapBuilder
327 .withName("vlannextobjectivestore")
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700328 .withSerializer(createSerializer())
Charles Chanc42e84e2015-10-20 16:24:19 -0700329 .withTimestampProvider((k, v) -> new WallClockTimestamp())
330 .build();
331
Saurav Das4ce45962015-11-24 23:21:05 -0800332 log.debug("Creating EC map subnetnextobjectivestore");
333 EventuallyConsistentMapBuilder<PortNextObjectiveStoreKey, Integer>
334 portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
335 portNextObjStore = portNextObjMapBuilder
336 .withName("portnextobjectivestore")
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700337 .withSerializer(createSerializer())
Saurav Das4ce45962015-11-24 23:21:05 -0800338 .withTimestampProvider((k, v) -> new WallClockTimestamp())
339 .build();
340
sangho0b2b6d12015-05-20 22:16:38 -0700341 EventuallyConsistentMapBuilder<String, Tunnel> tunnelMapBuilder =
342 storageService.eventuallyConsistentMapBuilder();
sangho0b2b6d12015-05-20 22:16:38 -0700343 tunnelStore = tunnelMapBuilder
344 .withName("tunnelstore")
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700345 .withSerializer(createSerializer())
Madan Jampanibcf1a482015-06-24 19:05:56 -0700346 .withTimestampProvider((k, v) -> new WallClockTimestamp())
sangho0b2b6d12015-05-20 22:16:38 -0700347 .build();
348
349 EventuallyConsistentMapBuilder<String, Policy> policyMapBuilder =
350 storageService.eventuallyConsistentMapBuilder();
sangho0b2b6d12015-05-20 22:16:38 -0700351 policyStore = policyMapBuilder
352 .withName("policystore")
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700353 .withSerializer(createSerializer())
Madan Jampanibcf1a482015-06-24 19:05:56 -0700354 .withTimestampProvider((k, v) -> new WallClockTimestamp())
sangho0b2b6d12015-05-20 22:16:38 -0700355 .build();
356
Saurav Das80980c72016-03-23 11:22:49 -0700357 compCfgService.preSetProperty("org.onosproject.net.group.impl.GroupManager",
Pier Luigi9e5c5ca2017-01-12 18:14:58 -0800358 "purgeOnDisconnection", "true");
Saurav Das80980c72016-03-23 11:22:49 -0700359 compCfgService.preSetProperty("org.onosproject.net.flow.impl.FlowRuleManager",
Pier Luigi9e5c5ca2017-01-12 18:14:58 -0800360 "purgeOnDisconnection", "true");
Pier Luigi9e5c5ca2017-01-12 18:14:58 -0800361 compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider",
362 "requestInterceptsEnabled", "false");
Pier Luigi7e415132017-01-12 22:46:39 -0800363 compCfgService.preSetProperty("org.onosproject.incubator.net.neighbour.impl.NeighbourResolutionManager",
364 "requestInterceptsEnabled", "false");
Charles Chanc760f382017-07-24 15:56:10 -0700365 compCfgService.preSetProperty("org.onosproject.dhcprelay.DhcpRelayManager",
Pier Luigi7e415132017-01-12 22:46:39 -0800366 "arpEnabled", "false");
Pier Luigi9b1d6262017-02-02 22:31:34 -0800367 compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager",
368 "greedyLearningIpv6", "true");
Charles Chanc6d227e2017-02-28 15:15:17 -0800369 compCfgService.preSetProperty("org.onosproject.routing.cpr.ControlPlaneRedirectManager",
370 "forceUnprovision", "true");
Charles Chan73316522017-07-20 16:16:25 -0700371 compCfgService.preSetProperty("org.onosproject.incubator.store.routing.impl.RouteStoreImpl",
372 "distributed", "true");
Saurav Das80980c72016-03-23 11:22:49 -0700373
Charles Chanb8e10c82015-10-14 11:24:40 -0700374 processor = new InternalPacketProcessor();
375 linkListener = new InternalLinkListener();
376 deviceListener = new InternalDeviceListener();
Charles Chanfc5c7802016-05-17 13:13:55 -0700377 appCfgHandler = new AppConfigHandler(this);
378 xConnectHandler = new XConnectHandler(this);
Charles Chand2990362016-04-18 13:44:03 -0700379 mcastHandler = new McastHandler(this);
380 hostHandler = new HostHandler(this);
Charles Chan03a73e02016-10-24 14:52:01 -0700381 routeHandler = new RouteHandler(this);
Pier Ventre735b8c82016-12-02 08:16:05 -0800382 neighbourHandler = new SegmentRoutingNeighbourDispatcher(this);
Pier Ventref34966c2016-11-07 16:21:04 -0800383 l2TunnelHandler = new L2TunnelHandler(this);
Charles Chanb8e10c82015-10-14 11:24:40 -0700384
Charles Chan3e783d02016-02-26 22:19:52 -0800385 cfgService.addListener(cfgListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700386 cfgService.registerConfigFactory(deviceConfigFactory);
387 cfgService.registerConfigFactory(appConfigFactory);
Charles Chanfc5c7802016-05-17 13:13:55 -0700388 cfgService.registerConfigFactory(xConnectConfigFactory);
Charles Chand55e84d2016-03-30 17:54:24 -0700389 cfgService.registerConfigFactory(mcastConfigFactory);
Pier Ventref34966c2016-11-07 16:21:04 -0800390 cfgService.registerConfigFactory(pwaasConfigFactory);
Charles Chan5270ed02016-01-30 23:22:37 -0800391 hostService.addListener(hostListener);
Charles Chanb8e10c82015-10-14 11:24:40 -0700392 packetService.addProcessor(processor, PacketProcessor.director(2));
393 linkService.addListener(linkListener);
394 deviceService.addListener(deviceListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700395 multicastRouteService.addListener(mcastListener);
Charles Chanc7a8a682017-06-19 00:43:31 -0700396 routeService.addListener(routeListener);
Charles Chanb8e10c82015-10-14 11:24:40 -0700397
398 cfgListener.configureNetwork();
399
sanghob35a6192015-04-01 13:05:26 -0700400 log.info("Started");
401 }
402
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700403 private KryoNamespace.Builder createSerializer() {
404 return new KryoNamespace.Builder()
405 .register(KryoNamespaces.API)
Saurav Das7bcbe702017-06-13 15:35:54 -0700406 .register(DestinationSetNextObjectiveStoreKey.class,
Charles Chan59cc16d2017-02-02 16:20:42 -0800407 VlanNextObjectiveStoreKey.class,
Saurav Das7bcbe702017-06-13 15:35:54 -0700408 DestinationSet.class,
409 NextNeighbors.class,
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700410 Tunnel.class,
411 DefaultTunnel.class,
412 Policy.class,
413 TunnelPolicy.class,
414 Policy.Type.class,
415 PortNextObjectiveStoreKey.class,
Charles Chanfc5c7802016-05-17 13:13:55 -0700416 XConnectStoreKey.class
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700417 );
418 }
419
sanghob35a6192015-04-01 13:05:26 -0700420 @Deactivate
421 protected void deactivate() {
Charles Chand6832882015-10-05 17:50:33 -0700422 cfgService.removeListener(cfgListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700423 cfgService.unregisterConfigFactory(deviceConfigFactory);
424 cfgService.unregisterConfigFactory(appConfigFactory);
Charles Chan03a73e02016-10-24 14:52:01 -0700425 cfgService.unregisterConfigFactory(xConnectConfigFactory);
Charles Chand55e84d2016-03-30 17:54:24 -0700426 cfgService.unregisterConfigFactory(mcastConfigFactory);
Pier Ventref34966c2016-11-07 16:21:04 -0800427 cfgService.unregisterConfigFactory(pwaasConfigFactory);
Charles Chand6832882015-10-05 17:50:33 -0700428
Charles Chanc7a8a682017-06-19 00:43:31 -0700429 hostService.removeListener(hostListener);
sanghob35a6192015-04-01 13:05:26 -0700430 packetService.removeProcessor(processor);
Charles Chanb8e10c82015-10-14 11:24:40 -0700431 linkService.removeListener(linkListener);
432 deviceService.removeListener(deviceListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700433 multicastRouteService.removeListener(mcastListener);
Charles Chan03a73e02016-10-24 14:52:01 -0700434 routeService.removeListener(routeListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700435
Charles Chan0aa674e2017-02-23 15:44:08 -0800436 neighbourResolutionService.unregisterNeighbourHandlers(appId);
437
sanghob35a6192015-04-01 13:05:26 -0700438 processor = null;
Charles Chanb8e10c82015-10-14 11:24:40 -0700439 linkListener = null;
Charles Chand55e84d2016-03-30 17:54:24 -0700440 deviceListener = null;
Charles Chanb8e10c82015-10-14 11:24:40 -0700441 groupHandlerMap.clear();
442
Saurav Das7bcbe702017-06-13 15:35:54 -0700443 dsNextObjStore.destroy();
Charles Chan59cc16d2017-02-02 16:20:42 -0800444 vlanNextObjStore.destroy();
Charles Chand55e84d2016-03-30 17:54:24 -0700445 portNextObjStore.destroy();
Charles Chand55e84d2016-03-30 17:54:24 -0700446 tunnelStore.destroy();
447 policyStore.destroy();
sanghob35a6192015-04-01 13:05:26 -0700448 log.info("Stopped");
449 }
450
sangho1e575652015-05-14 00:39:53 -0700451 @Override
452 public List<Tunnel> getTunnels() {
453 return tunnelHandler.getTunnels();
454 }
455
456 @Override
sangho71abe1b2015-06-29 14:58:47 -0700457 public TunnelHandler.Result createTunnel(Tunnel tunnel) {
458 return tunnelHandler.createTunnel(tunnel);
sangho1e575652015-05-14 00:39:53 -0700459 }
460
461 @Override
sangho71abe1b2015-06-29 14:58:47 -0700462 public TunnelHandler.Result removeTunnel(Tunnel tunnel) {
sangho1e575652015-05-14 00:39:53 -0700463 for (Policy policy: policyHandler.getPolicies()) {
464 if (policy.type() == Policy.Type.TUNNEL_FLOW) {
465 TunnelPolicy tunnelPolicy = (TunnelPolicy) policy;
466 if (tunnelPolicy.tunnelId().equals(tunnel.id())) {
467 log.warn("Cannot remove the tunnel used by a policy");
sangho71abe1b2015-06-29 14:58:47 -0700468 return TunnelHandler.Result.TUNNEL_IN_USE;
sangho1e575652015-05-14 00:39:53 -0700469 }
470 }
471 }
sangho71abe1b2015-06-29 14:58:47 -0700472 return tunnelHandler.removeTunnel(tunnel);
sangho1e575652015-05-14 00:39:53 -0700473 }
474
475 @Override
sangho71abe1b2015-06-29 14:58:47 -0700476 public PolicyHandler.Result removePolicy(Policy policy) {
477 return policyHandler.removePolicy(policy);
sangho1e575652015-05-14 00:39:53 -0700478 }
479
480 @Override
sangho71abe1b2015-06-29 14:58:47 -0700481 public PolicyHandler.Result createPolicy(Policy policy) {
482 return policyHandler.createPolicy(policy);
sangho1e575652015-05-14 00:39:53 -0700483 }
484
485 @Override
486 public List<Policy> getPolicies() {
487 return policyHandler.getPolicies();
488 }
489
Saurav Das59232cf2016-04-27 18:35:50 -0700490 @Override
491 public void rerouteNetwork() {
492 cfgListener.configureNetwork();
Saurav Das59232cf2016-04-27 18:35:50 -0700493 }
494
Charles Chanc81c45b2016-10-20 17:02:44 -0700495 @Override
Pier Ventre10bd8d12016-11-26 21:05:22 -0800496 public Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap() {
497 Map<DeviceId, Set<IpPrefix>> deviceSubnetMap = Maps.newHashMap();
Charles Chanc81c45b2016-10-20 17:02:44 -0700498 deviceService.getAvailableDevices().forEach(device -> {
499 deviceSubnetMap.put(device.id(), deviceConfiguration.getSubnets(device.id()));
500 });
501 return deviceSubnetMap;
502 }
503
Saurav Dasc88d4662017-05-15 15:34:25 -0700504
505 @Override
506 public ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg() {
507 if (defaultRoutingHandler != null) {
508 return defaultRoutingHandler.getCurrentEmcpSpgMap();
509 } else {
510 return null;
511 }
512 }
513
514 @Override
Saurav Das7bcbe702017-06-13 15:35:54 -0700515 public ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDestinationSet() {
516 if (dsNextObjStore != null) {
517 return ImmutableMap.copyOf(dsNextObjStore.entrySet());
Saurav Dasc88d4662017-05-15 15:34:25 -0700518 } else {
519 return ImmutableMap.of();
520 }
521 }
522
sanghof9d0bf12015-05-19 11:57:42 -0700523 /**
Ray Milkeye4afdb52017-04-05 09:42:04 -0700524 * Extracts the application ID from the manager.
525 *
526 * @return application ID
527 */
528 public ApplicationId appId() {
529 return appId;
530 }
531
532 /**
533 * Returns the device configuration.
534 *
535 * @return device configuration
536 */
537 public DeviceConfiguration deviceConfiguration() {
538 return deviceConfiguration;
539 }
540
541 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700542 * Per device next objective ID store with (device id + destination set) as key.
Ray Milkeye4afdb52017-04-05 09:42:04 -0700543 *
544 * @return next objective ID store
545 */
Saurav Das7bcbe702017-06-13 15:35:54 -0700546 public EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey, NextNeighbors>
547 dsNextObjStore() {
548 return dsNextObjStore;
Ray Milkeye4afdb52017-04-05 09:42:04 -0700549 }
550
551 /**
552 * Per device next objective ID store with (device id + subnet) as key.
553 *
554 * @return vlan next object store
555 */
556 public EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer> vlanNextObjStore() {
557 return vlanNextObjStore;
558 }
559
560 /**
561 * Per device next objective ID store with (device id + port) as key.
562 *
563 * @return port next object store.
564 */
565 public EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer> portNextObjStore() {
566 return portNextObjStore;
567 }
568
569 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700570 * Returns the MPLS-ECMP configuration which indicates whether ECMP on
571 * labeled packets should be programmed or not.
Pier Ventre98161782016-10-31 15:00:01 -0700572 *
573 * @return MPLS-ECMP value
574 */
575 public boolean getMplsEcmp() {
576 SegmentRoutingAppConfig segmentRoutingAppConfig = cfgService
577 .getConfig(this.appId, SegmentRoutingAppConfig.class);
578 return segmentRoutingAppConfig != null && segmentRoutingAppConfig.mplsEcmp();
579 }
580
581 /**
sanghof9d0bf12015-05-19 11:57:42 -0700582 * Returns the tunnel object with the tunnel ID.
583 *
584 * @param tunnelId Tunnel ID
585 * @return Tunnel reference
586 */
sangho1e575652015-05-14 00:39:53 -0700587 public Tunnel getTunnel(String tunnelId) {
588 return tunnelHandler.getTunnel(tunnelId);
589 }
590
Charles Chan7ffd81f2017-02-08 15:52:08 -0800591 // TODO Consider moving these to InterfaceService
sanghob35a6192015-04-01 13:05:26 -0700592 /**
Charles Chan59cc16d2017-02-02 16:20:42 -0800593 * Returns untagged VLAN configured on given connect point.
Charles Chan7ffd81f2017-02-08 15:52:08 -0800594 * <p>
595 * Only returns the first match if there are multiple untagged VLAN configured
596 * on the connect point.
sanghob35a6192015-04-01 13:05:26 -0700597 *
Charles Chan59cc16d2017-02-02 16:20:42 -0800598 * @param connectPoint connect point
599 * @return untagged VLAN or null if not configured
sanghob35a6192015-04-01 13:05:26 -0700600 */
Charles Chan65238242017-06-22 18:03:14 -0700601 VlanId getUntaggedVlanId(ConnectPoint connectPoint) {
Charles Chan59cc16d2017-02-02 16:20:42 -0800602 return interfaceService.getInterfacesByPort(connectPoint).stream()
603 .filter(intf -> !intf.vlanUntagged().equals(VlanId.NONE))
604 .map(Interface::vlanUntagged)
605 .findFirst().orElse(null);
sanghob35a6192015-04-01 13:05:26 -0700606 }
607
sangho1e575652015-05-14 00:39:53 -0700608 /**
Charles Chan7ffd81f2017-02-08 15:52:08 -0800609 * Returns tagged VLAN configured on given connect point.
610 * <p>
611 * Returns all matches if there are multiple tagged VLAN configured
612 * on the connect point.
613 *
614 * @param connectPoint connect point
615 * @return tagged VLAN or empty set if not configured
616 */
Charles Chan65238242017-06-22 18:03:14 -0700617 Set<VlanId> getTaggedVlanId(ConnectPoint connectPoint) {
Charles Chan7ffd81f2017-02-08 15:52:08 -0800618 Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint);
619 return interfaces.stream()
620 .map(Interface::vlanTagged)
Charles Chan65238242017-06-22 18:03:14 -0700621 .flatMap(Set::stream)
Charles Chan7ffd81f2017-02-08 15:52:08 -0800622 .collect(Collectors.toSet());
623 }
624
625 /**
626 * Returns native VLAN configured on given connect point.
627 * <p>
628 * Only returns the first match if there are multiple native VLAN configured
629 * on the connect point.
630 *
631 * @param connectPoint connect point
632 * @return native VLAN or null if not configured
633 */
Charles Chan65238242017-06-22 18:03:14 -0700634 VlanId getNativeVlanId(ConnectPoint connectPoint) {
Charles Chan7ffd81f2017-02-08 15:52:08 -0800635 Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint);
636 return interfaces.stream()
637 .filter(intf -> !intf.vlanNative().equals(VlanId.NONE))
638 .map(Interface::vlanNative)
639 .findFirst()
640 .orElse(null);
641 }
642
643 /**
Charles Chanf9a52702017-06-16 15:19:24 -0700644 * Returns internal VLAN for untagged hosts on given connect point.
645 * <p>
646 * The internal VLAN is either vlan-untagged for an access port,
647 * or vlan-native for a trunk port.
648 *
649 * @param connectPoint connect point
650 * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined
651 */
Charles Chan65238242017-06-22 18:03:14 -0700652 VlanId getInternalVlanId(ConnectPoint connectPoint) {
Charles Chanf9a52702017-06-16 15:19:24 -0700653 VlanId untaggedVlanId = getUntaggedVlanId(connectPoint);
654 VlanId nativeVlanId = getNativeVlanId(connectPoint);
655 return untaggedVlanId != null ? untaggedVlanId : nativeVlanId;
656 }
657
658 /**
Charles Chan65238242017-06-22 18:03:14 -0700659 * Returns optional pair device ID of given device.
660 *
661 * @param deviceId device ID
662 * @return optional pair device ID. Might be empty if pair device is not configured
663 */
664 Optional<DeviceId> getPairDeviceId(DeviceId deviceId) {
665 SegmentRoutingDeviceConfig deviceConfig =
666 cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
667 return Optional.ofNullable(deviceConfig).map(SegmentRoutingDeviceConfig::pairDeviceId);
668 }
669 /**
670 * Returns optional pair device local port of given device.
671 *
672 * @param deviceId device ID
673 * @return optional pair device ID. Might be empty if pair device is not configured
674 */
675 Optional<PortNumber> getPairLocalPorts(DeviceId deviceId) {
676 SegmentRoutingDeviceConfig deviceConfig =
677 cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
678 return Optional.ofNullable(deviceConfig).map(SegmentRoutingDeviceConfig::pairLocalPort);
679 }
680
681 /**
Charles Chan7ffd81f2017-02-08 15:52:08 -0800682 * Returns vlan port map of given device.
683 *
684 * @param deviceId device id
685 * @return vlan-port multimap
686 */
687 public Multimap<VlanId, PortNumber> getVlanPortMap(DeviceId deviceId) {
688 HashMultimap<VlanId, PortNumber> vlanPortMap = HashMultimap.create();
689
690 interfaceService.getInterfaces().stream()
691 .filter(intf -> intf.connectPoint().deviceId().equals(deviceId))
692 .forEach(intf -> {
693 vlanPortMap.put(intf.vlanUntagged(), intf.connectPoint().port());
Charles Chan65238242017-06-22 18:03:14 -0700694 intf.vlanTagged().forEach(vlanTagged ->
695 vlanPortMap.put(vlanTagged, intf.connectPoint().port())
696 );
Charles Chan7ffd81f2017-02-08 15:52:08 -0800697 vlanPortMap.put(intf.vlanNative(), intf.connectPoint().port());
698 });
699 vlanPortMap.removeAll(VlanId.NONE);
700
701 return vlanPortMap;
702 }
703
704 /**
Saurav Das4ce45962015-11-24 23:21:05 -0800705 * Returns the next objective ID for the given subnet prefix. It is expected
Charles Chan59cc16d2017-02-02 16:20:42 -0800706 * Returns the next objective ID for the given vlan id. It is expected
Saurav Das4ce45962015-11-24 23:21:05 -0800707 * that the next-objective has been pre-created from configuration.
Charles Chanc42e84e2015-10-20 16:24:19 -0700708 *
709 * @param deviceId Device ID
Charles Chan59cc16d2017-02-02 16:20:42 -0800710 * @param vlanId VLAN ID
Saurav Das4ce45962015-11-24 23:21:05 -0800711 * @return next objective ID or -1 if it was not found
Charles Chanc42e84e2015-10-20 16:24:19 -0700712 */
Charles Chan65238242017-06-22 18:03:14 -0700713 int getVlanNextObjectiveId(DeviceId deviceId, VlanId vlanId) {
Charles Chanc42e84e2015-10-20 16:24:19 -0700714 if (groupHandlerMap.get(deviceId) != null) {
Charles Chan59cc16d2017-02-02 16:20:42 -0800715 log.trace("getVlanNextObjectiveId query in device {}", deviceId);
716 return groupHandlerMap.get(deviceId).getVlanNextObjectiveId(vlanId);
Charles Chanc42e84e2015-10-20 16:24:19 -0700717 } else {
Charles Chan59cc16d2017-02-02 16:20:42 -0800718 log.warn("getVlanNextObjectiveId query - groupHandler for "
Saurav Das4ce45962015-11-24 23:21:05 -0800719 + "device {} not found", deviceId);
720 return -1;
721 }
722 }
723
724 /**
725 * Returns the next objective ID for the given portNumber, given the treatment.
726 * There could be multiple different treatments to the same outport, which
Saurav Das961beb22017-03-29 19:09:17 -0700727 * would result in different objectives. If the next object does not exist,
728 * and should be created, a new one is created and its id is returned.
Saurav Das4ce45962015-11-24 23:21:05 -0800729 *
730 * @param deviceId Device ID
731 * @param portNum port number on device for which NextObjective is queried
732 * @param treatment the actions to apply on the packets (should include outport)
733 * @param meta metadata passed into the creation of a Next Objective if necessary
Saurav Das961beb22017-03-29 19:09:17 -0700734 * @param createIfMissing true if a next object should be created if not found
Saurav Das59232cf2016-04-27 18:35:50 -0700735 * @return next objective ID or -1 if an error occurred during retrieval or creation
Saurav Das4ce45962015-11-24 23:21:05 -0800736 */
737 public int getPortNextObjectiveId(DeviceId deviceId, PortNumber portNum,
738 TrafficTreatment treatment,
Saurav Das961beb22017-03-29 19:09:17 -0700739 TrafficSelector meta,
740 boolean createIfMissing) {
Saurav Das4ce45962015-11-24 23:21:05 -0800741 DefaultGroupHandler ghdlr = groupHandlerMap.get(deviceId);
742 if (ghdlr != null) {
Saurav Das961beb22017-03-29 19:09:17 -0700743 return ghdlr.getPortNextObjectiveId(portNum, treatment, meta, createIfMissing);
Saurav Das4ce45962015-11-24 23:21:05 -0800744 } else {
Charles Chane849c192016-01-11 18:28:54 -0800745 log.warn("getPortNextObjectiveId query - groupHandler for device {}"
746 + " not found", deviceId);
747 return -1;
748 }
749 }
750
Saurav Dasc88d4662017-05-15 15:34:25 -0700751 /**
752 * Returns the group handler object for the specified device id.
753 *
754 * @param devId the device identifier
755 * @return the groupHandler object for the device id, or null if not found
756 */
Charles Chan65238242017-06-22 18:03:14 -0700757 DefaultGroupHandler getGroupHandler(DeviceId devId) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700758 return groupHandlerMap.get(devId);
759 }
760
761 /**
762 * Returns true if this controller instance has seen this link before. The
763 * link may not be currently up, but as long as the link had been seen before
764 * this method will return true. The one exception is when the link was
765 * indeed seen before, but this controller instance was forced to forget it
766 * by a call to purgeSeenLink method.
767 *
768 * @param link the infrastructure link being queried
769 * @return true if this controller instance has seen this link before
770 */
Charles Chan65238242017-06-22 18:03:14 -0700771 boolean isSeenLink(Link link) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700772 return seenLinks.containsKey(link);
773 }
774
775 /**
776 * Updates the seen link store. Updates can be for links that are currently
777 * available or not.
778 *
779 * @param link the link to update in the seen-link local store
780 * @param up the status of the link, true if up, false if down
781 */
Charles Chan65238242017-06-22 18:03:14 -0700782 void updateSeenLink(Link link, boolean up) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700783 seenLinks.put(link, up);
784 }
785
786 /**
787 * Returns the status of a seen-link (up or down). If the link has not
788 * been seen-before, a null object is returned.
789 *
790 * @param link the infrastructure link being queried
791 * @return null if the link was not seen-before;
792 * true if the seen-link is up;
793 * false if the seen-link is down
794 */
Charles Chan65238242017-06-22 18:03:14 -0700795 Boolean isSeenLinkUp(Link link) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700796 return seenLinks.get(link);
797 }
798
799 /**
800 * Makes this controller instance forget a previously seen before link.
801 *
802 * @param link the infrastructure link to purge
803 */
Charles Chan65238242017-06-22 18:03:14 -0700804 private void purgeSeenLink(Link link) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700805 seenLinks.remove(link);
806 }
807
808 /**
809 * Returns the status of a link as parallel link. A parallel link
810 * is defined as a link which has common src and dst switches as another
811 * seen-link that is currently enabled. It is not necessary for the link being
812 * queried to be a seen-link.
813 *
814 * @param link the infrastructure link being queried
815 * @return true if a seen-link exists that is up, and shares the
816 * same src and dst switches as the link being queried
817 */
Charles Chan65238242017-06-22 18:03:14 -0700818 private boolean isParallelLink(Link link) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700819 for (Entry<Link, Boolean> seen : seenLinks.entrySet()) {
820 Link seenLink = seen.getKey();
821 if (seenLink.equals(link)) {
822 continue;
823 }
824 if (seenLink.src().deviceId().equals(link.src().deviceId()) &&
825 seenLink.dst().deviceId().equals(link.dst().deviceId()) &&
826 seen.getValue()) {
827 return true;
828 }
829 }
830 return false;
831 }
832
Saurav Das7bcbe702017-06-13 15:35:54 -0700833 /**
834 * Returns true if the link being queried is a bidirectional link. A bidi
835 * link is defined as a link, whose reverse link - ie. the link in the reverse
836 * direction - has been seen-before and is up. It is not necessary for the link
837 * being queried to be a seen-link.
838 *
839 * @param link the infrastructure link being queried
840 * @return true if another unidirectional link exists in the reverse direction,
841 * has been seen-before and is up
842 */
843 public boolean isBidirectional(Link link) {
844 Link reverseLink = linkService.getLink(link.dst(), link.src());
845 if (reverseLink == null) {
846 return false;
847 }
848 Boolean result = isSeenLinkUp(reverseLink);
849 if (result == null) {
850 return false;
851 }
852 return result.booleanValue();
853 }
854
855 /**
856 * Determines if the given link should be avoided in routing calculations
857 * by policy or design.
858 *
859 * @param link the infrastructure link being queried
860 * @return true if link should be avoided
861 */
862 public boolean avoidLink(Link link) {
863 // XXX currently only avoids all pair-links. In the future can be
864 // extended to avoid any generic link
865 DeviceId src = link.src().deviceId();
866 PortNumber srcPort = link.src().port();
867 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(src)) {
868 log.warn("Device {} not configured..cannot avoid link {}", src, link);
869 return false;
870 }
871 DeviceId pairDev;
872 PortNumber pairLocalPort, pairRemotePort = null;
873 try {
874 pairDev = deviceConfiguration.getPairDeviceId(src);
875 pairLocalPort = deviceConfiguration.getPairLocalPort(src);
876 if (pairDev != null) {
877 pairRemotePort = deviceConfiguration.getPairLocalPort(pairDev);
878 }
879 } catch (DeviceConfigNotFoundException e) {
880 log.warn("Pair dev for dev {} not configured..cannot avoid link {}",
881 src, link);
882 return false;
883 }
884
885 if (srcPort.equals(pairLocalPort) &&
886 link.dst().deviceId().equals(pairDev) &&
887 link.dst().port().equals(pairRemotePort)) {
888 return true;
889 }
890 return false;
891 }
892
sanghob35a6192015-04-01 13:05:26 -0700893 private class InternalPacketProcessor implements PacketProcessor {
sanghob35a6192015-04-01 13:05:26 -0700894 @Override
895 public void process(PacketContext context) {
896
897 if (context.isHandled()) {
898 return;
899 }
900
901 InboundPacket pkt = context.inPacket();
902 Ethernet ethernet = pkt.parsed();
Pier Luigi7dad71c2017-02-01 13:50:04 -0800903
904 if (ethernet == null) {
905 return;
906 }
907
Saurav Das7bcbe702017-06-13 15:35:54 -0700908 log.trace("Rcvd pktin from {}: {}", context.inPacket().receivedFrom(),
909 ethernet);
Pier Ventree0ae7a32016-11-23 09:57:42 -0800910 if (ethernet.getEtherType() == TYPE_ARP) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700911 log.warn("Received unexpected ARP packet on {}",
912 context.inPacket().receivedFrom());
Saurav Das76ae6812017-03-15 15:15:14 -0700913 log.trace("{}", ethernet);
Pier Ventre968da122016-12-09 17:26:04 -0800914 return;
sanghob35a6192015-04-01 13:05:26 -0700915 } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
Pier Ventre735b8c82016-12-02 08:16:05 -0800916 IPv4 ipv4Packet = (IPv4) ethernet.getPayload();
917 //ipHandler.addToPacketBuffer(ipv4Packet);
918 if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) {
919 icmpHandler.processIcmp(ethernet, pkt.receivedFrom());
sanghob35a6192015-04-01 13:05:26 -0700920 } else {
Charles Chan50035632017-01-13 17:20:44 -0800921 // NOTE: We don't support IP learning at this moment so this
922 // is not necessary. Also it causes duplication of DHCP packets.
Pier Ventre968da122016-12-09 17:26:04 -0800923 // ipHandler.processPacketIn(ipv4Packet, pkt.receivedFrom());
sanghob35a6192015-04-01 13:05:26 -0700924 }
Pier Ventre10bd8d12016-11-26 21:05:22 -0800925 } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV6) {
926 IPv6 ipv6Packet = (IPv6) ethernet.getPayload();
Pier Ventre735b8c82016-12-02 08:16:05 -0800927 //ipHandler.addToPacketBuffer(ipv6Packet);
Pier Luigi7dad71c2017-02-01 13:50:04 -0800928 // We deal with the packet only if the packet is a ICMP6 ECHO/REPLY
Pier Ventre735b8c82016-12-02 08:16:05 -0800929 if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_ICMP6) {
930 ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload();
931 if (icmp6Packet.getIcmpType() == ICMP6.ECHO_REQUEST ||
932 icmp6Packet.getIcmpType() == ICMP6.ECHO_REPLY) {
933 icmpHandler.processIcmpv6(ethernet, pkt.receivedFrom());
934 } else {
Saurav Dasc88d4662017-05-15 15:34:25 -0700935 log.trace("Received ICMPv6 0x{} - not handled",
Charles Chan0ed44fb2017-03-13 13:10:30 -0700936 Integer.toHexString(icmp6Packet.getIcmpType() & 0xff));
Pier Ventre735b8c82016-12-02 08:16:05 -0800937 }
938 } else {
939 // NOTE: We don't support IP learning at this moment so this
940 // is not necessary. Also it causes duplication of DHCPv6 packets.
941 // ipHandler.processPacketIn(ipv6Packet, pkt.receivedFrom());
942 }
sanghob35a6192015-04-01 13:05:26 -0700943 }
944 }
945 }
946
947 private class InternalLinkListener implements LinkListener {
948 @Override
949 public void event(LinkEvent event) {
Charles Chanb1f8c762017-03-29 16:39:05 -0700950 if (event.type() == LinkEvent.Type.LINK_ADDED ||
951 event.type() == LinkEvent.Type.LINK_UPDATED ||
952 event.type() == LinkEvent.Type.LINK_REMOVED) {
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -0700953 log.debug("Event {} received from Link Service", event.type());
sanghob35a6192015-04-01 13:05:26 -0700954 scheduleEventHandlerIfNotScheduled(event);
955 }
956 }
957 }
958
959 private class InternalDeviceListener implements DeviceListener {
sanghob35a6192015-04-01 13:05:26 -0700960 @Override
961 public void event(DeviceEvent event) {
sanghob35a6192015-04-01 13:05:26 -0700962 switch (event.type()) {
963 case DEVICE_ADDED:
Saurav Das1a129a02016-11-18 15:21:57 -0800964 case PORT_UPDATED:
965 case PORT_ADDED:
sangho20eff1d2015-04-13 15:15:58 -0700966 case DEVICE_UPDATED:
967 case DEVICE_AVAILABILITY_CHANGED:
Saurav Dasc88d4662017-05-15 15:34:25 -0700968 log.trace("Event {} received from Device Service", event.type());
sanghob35a6192015-04-01 13:05:26 -0700969 scheduleEventHandlerIfNotScheduled(event);
970 break;
971 default:
972 }
973 }
974 }
975
Saurav Das4ce45962015-11-24 23:21:05 -0800976 @SuppressWarnings("rawtypes")
sanghob35a6192015-04-01 13:05:26 -0700977 private void scheduleEventHandlerIfNotScheduled(Event event) {
Charles Chan65238242017-06-22 18:03:14 -0700978 synchronized (THREAD_SCHED_LOCK) {
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700979 eventQueue.add(event);
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -0700980 numOfEventsQueued++;
981
982 if ((numOfHandlerScheduled - numOfHandlerExecution) == 0) {
983 //No pending scheduled event handling threads. So start a new one.
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700984 eventHandlerFuture = executorService
985 .schedule(eventHandler, 100, TimeUnit.MILLISECONDS);
986 numOfHandlerScheduled++;
987 }
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700988 log.trace("numOfEventsQueued {}, numOfEventHandlerScheduled {}",
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -0700989 numOfEventsQueued,
990 numOfHandlerScheduled);
sanghob35a6192015-04-01 13:05:26 -0700991 }
sanghob35a6192015-04-01 13:05:26 -0700992 }
993
994 private class InternalEventHandler implements Runnable {
Srikanth Vavilapalli4db76e32015-04-07 15:12:32 -0700995 @Override
sanghob35a6192015-04-01 13:05:26 -0700996 public void run() {
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700997 try {
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -0700998 while (true) {
Saurav Das4ce45962015-11-24 23:21:05 -0800999 @SuppressWarnings("rawtypes")
Charles Chan65238242017-06-22 18:03:14 -07001000 Event event;
1001 synchronized (THREAD_SCHED_LOCK) {
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001002 if (!eventQueue.isEmpty()) {
1003 event = eventQueue.poll();
1004 numOfEventsExecuted++;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001005 } else {
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001006 numOfHandlerExecution++;
1007 log.debug("numOfHandlerExecution {} numOfEventsExecuted {}",
1008 numOfHandlerExecution, numOfEventsExecuted);
1009 break;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001010 }
sangho20eff1d2015-04-13 15:15:58 -07001011 }
Charles Chanb1f8c762017-03-29 16:39:05 -07001012 if (event.type() == LinkEvent.Type.LINK_ADDED ||
1013 event.type() == LinkEvent.Type.LINK_UPDATED) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001014 // Note: do not update seenLinks here, otherwise every
1015 // link, even one seen for the first time, will be appear
1016 // to be a previously seen link
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001017 processLinkAdded((Link) event.subject());
1018 } else if (event.type() == LinkEvent.Type.LINK_REMOVED) {
Pier Ventre2c515312016-09-13 21:33:40 -07001019 Link linkRemoved = (Link) event.subject();
Saurav Dasc88d4662017-05-15 15:34:25 -07001020 if (linkRemoved.type() == Link.Type.DIRECT) {
1021 updateSeenLink(linkRemoved, false);
1022 }
1023 // device availability check helps to ensure that
1024 // multiple link-removed events are actually treated as a
1025 // single switch removed event. purgeSeenLink is necessary
1026 // so we do rerouting (instead of rehashing) when switch
1027 // comes back.
Pier Ventre2c515312016-09-13 21:33:40 -07001028 if (linkRemoved.src().elementId() instanceof DeviceId &&
1029 !deviceService.isAvailable(linkRemoved.src().deviceId())) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001030 purgeSeenLink(linkRemoved);
Pier Ventre2c515312016-09-13 21:33:40 -07001031 continue;
1032 }
1033 if (linkRemoved.dst().elementId() instanceof DeviceId &&
1034 !deviceService.isAvailable(linkRemoved.dst().deviceId())) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001035 purgeSeenLink(linkRemoved);
Pier Ventre2c515312016-09-13 21:33:40 -07001036 continue;
1037 }
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001038 processLinkRemoved((Link) event.subject());
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001039 } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED ||
1040 event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
1041 event.type() == DeviceEvent.Type.DEVICE_UPDATED) {
Saurav Das423fe2b2015-12-04 10:52:59 -08001042 DeviceId deviceId = ((Device) event.subject()).id();
1043 if (deviceService.isAvailable(deviceId)) {
Saurav Das837e0bb2015-10-30 17:45:38 -07001044 log.info("Processing device event {} for available device {}",
1045 event.type(), ((Device) event.subject()).id());
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001046 processDeviceAdded((Device) event.subject());
Saurav Das80980c72016-03-23 11:22:49 -07001047 } else {
1048 log.info("Processing device event {} for unavailable device {}",
1049 event.type(), ((Device) event.subject()).id());
1050 processDeviceRemoved((Device) event.subject());
1051 }
Saurav Das1a129a02016-11-18 15:21:57 -08001052 } else if (event.type() == DeviceEvent.Type.PORT_ADDED) {
Saurav Dasd2fded02016-12-02 15:43:47 -08001053 // typically these calls come when device is added first time
1054 // so port filtering rules are handled at the device_added event.
1055 // port added calls represent all ports on the device,
1056 // enabled or not.
Saurav Dasc88d4662017-05-15 15:34:25 -07001057 log.trace("** PORT ADDED {}/{} -> {}",
Saurav Dasd2fded02016-12-02 15:43:47 -08001058 ((DeviceEvent) event).subject().id(),
1059 ((DeviceEvent) event).port().number(),
1060 event.type());
Saurav Das1a129a02016-11-18 15:21:57 -08001061 } else if (event.type() == DeviceEvent.Type.PORT_UPDATED) {
Saurav Dasd2fded02016-12-02 15:43:47 -08001062 // these calls happen for every subsequent event
1063 // ports enabled, disabled, switch goes away, comes back
Saurav Das1a129a02016-11-18 15:21:57 -08001064 log.info("** PORT UPDATED {}/{} -> {}",
1065 event.subject(),
1066 ((DeviceEvent) event).port(),
1067 event.type());
1068 processPortUpdated(((Device) event.subject()),
1069 ((DeviceEvent) event).port());
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001070 } else {
1071 log.warn("Unhandled event type: {}", event.type());
1072 }
sanghob35a6192015-04-01 13:05:26 -07001073 }
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001074 } catch (Exception e) {
1075 log.error("SegmentRouting event handler "
1076 + "thread thrown an exception: {}", e);
sanghob35a6192015-04-01 13:05:26 -07001077 }
sanghob35a6192015-04-01 13:05:26 -07001078 }
1079 }
1080
sanghob35a6192015-04-01 13:05:26 -07001081 private void processLinkAdded(Link link) {
Saurav Dasb5c236e2016-06-07 10:08:06 -07001082 log.info("** LINK ADDED {}", link.toString());
Charles Chan0b4e6182015-11-03 10:42:14 -08001083 if (!deviceConfiguration.isConfigured(link.src().deviceId())) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001084 log.warn("Source device of this link is not configured..not processing");
Charles Chan0b4e6182015-11-03 10:42:14 -08001085 return;
1086 }
Saurav Dasc88d4662017-05-15 15:34:25 -07001087 if (link.type() != Link.Type.DIRECT) {
1088 // NOTE: A DIRECT link might be transiently marked as INDIRECT
1089 // if BDDP is received before LLDP. We can safely ignore that
1090 // until the LLDP is received and the link is marked as DIRECT.
1091 log.info("Ignore link {}->{}. Link type is {} instead of DIRECT.",
1092 link.src(), link.dst(), link.type());
1093 return;
1094 }
1095
1096 //Irrespective of whether the local is a MASTER or not for this device,
1097 //create group handler instance and push default TTP flow rules if needed,
1098 //as in a multi-instance setup, instances can initiate groups for any device.
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001099 DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src()
1100 .deviceId());
1101 if (groupHandler != null) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001102 groupHandler.portUpForLink(link);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001103 } else {
1104 Device device = deviceService.getDevice(link.src().deviceId());
1105 if (device != null) {
1106 log.warn("processLinkAdded: Link Added "
1107 + "Notification without Device Added "
1108 + "event, still handling it");
1109 processDeviceAdded(device);
1110 groupHandler = groupHandlerMap.get(link.src()
1111 .deviceId());
Saurav Dasc88d4662017-05-15 15:34:25 -07001112 groupHandler.portUpForLink(link);
sanghob35a6192015-04-01 13:05:26 -07001113 }
1114 }
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001115
Saurav Das7bcbe702017-06-13 15:35:54 -07001116 /*// process link only if it is bidirectional
1117 if (!isBidirectional(link)) {
1118 log.debug("Link not bidirectional.. waiting for other direction "
1119 + "src {} --> dst {} ", link.dst(), link.src());
1120 // note that if we are not processing for routing, it should at least
1121 // be considered a seen-link
1122 updateSeenLink(link, true);
1123 return;
1124 }
1125 TO DO this ensure that rehash is still done correctly even if link is
1126 not processed for rerouting - perhaps rehash in both directions when
1127 it ultimately becomes bidi?
1128 */
1129
1130 log.debug("Starting optimized route population process for link "
1131 + "{} --> {}", link.src(), link.dst());
Saurav Dasc88d4662017-05-15 15:34:25 -07001132 boolean seenBefore = isSeenLink(link);
1133 defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(null, link, null);
Saurav Das7bcbe702017-06-13 15:35:54 -07001134
1135 // It's possible that linkUp causes no route-path change as ECMP graph does
1136 // not change if the link is a parallel link (same src-dst as another link.
1137 // However we still need to update ECMP hash groups to include new buckets
1138 // for the link that has come up.
Saurav Dasc88d4662017-05-15 15:34:25 -07001139 if (mastershipService.isLocalMaster(link.src().deviceId())) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001140 if (!seenBefore && isParallelLink(link)) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001141 // if link seen first time, we need to ensure hash-groups have all ports
Saurav Das7bcbe702017-06-13 15:35:54 -07001142 log.debug("Attempting retryHash for paralled first-time link {}", link);
Saurav Dasc88d4662017-05-15 15:34:25 -07001143 groupHandler.retryHash(link, false, true);
1144 } else {
1145 //seen before-link
1146 if (isParallelLink(link)) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001147 log.debug("Attempting retryHash for paralled seen-before "
1148 + "link {}", link);
Saurav Dasc88d4662017-05-15 15:34:25 -07001149 groupHandler.retryHash(link, false, false);
1150 }
1151 }
1152 }
Charles Chan2199c302016-04-23 17:36:10 -07001153
1154 mcastHandler.init();
sanghob35a6192015-04-01 13:05:26 -07001155 }
1156
1157 private void processLinkRemoved(Link link) {
Saurav Dasb5c236e2016-06-07 10:08:06 -07001158 log.info("** LINK REMOVED {}", link.toString());
Saurav Dasc88d4662017-05-15 15:34:25 -07001159 defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(link, null, null);
1160
1161 // update local groupHandler stores
sangho834e4b02015-05-01 09:38:25 -07001162 DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src().deviceId());
1163 if (groupHandler != null) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001164 if (mastershipService.isLocalMaster(link.src().deviceId()) &&
1165 isParallelLink(link)) {
1166 groupHandler.retryHash(link, true, false);
1167 }
1168 // ensure local stores are updated
1169 groupHandler.portDown(link.src().port());
1170 } else {
1171 log.warn("group handler not found for dev:{} when removing link: {}",
1172 link.src().deviceId(), link);
sangho834e4b02015-05-01 09:38:25 -07001173 }
Charles Chan2199c302016-04-23 17:36:10 -07001174
1175 mcastHandler.processLinkDown(link);
sanghob35a6192015-04-01 13:05:26 -07001176 }
1177
1178 private void processDeviceAdded(Device device) {
Saurav Dasb5c236e2016-06-07 10:08:06 -07001179 log.info("** DEVICE ADDED with ID {}", device.id());
Charles Chan91ccbf72017-06-27 18:48:32 -07001180
1181 // NOTE: Punt ARP/NDP even when the device is not configured.
1182 // Host learning without network config is required for CORD config generator.
1183 routingRulePopulator.populateIpPunts(device.id());
1184 routingRulePopulator.populateArpNdpPunts(device.id());
1185
Charles Chan0b4e6182015-11-03 10:42:14 -08001186 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001187 log.warn("Device configuration unavailable. Device {} will be "
1188 + "processed after configuration.", device.id());
Saurav Das2857f382015-11-03 14:39:27 -08001189 return;
1190 }
Charles Chan2199c302016-04-23 17:36:10 -07001191 processDeviceAddedInternal(device.id());
1192 }
1193
1194 private void processDeviceAddedInternal(DeviceId deviceId) {
Saurav Das837e0bb2015-10-30 17:45:38 -07001195 // Irrespective of whether the local is a MASTER or not for this device,
1196 // we need to create a SR-group-handler instance. This is because in a
1197 // multi-instance setup, any instance can initiate forwarding/next-objectives
1198 // for any switch (even if this instance is a SLAVE or not even connected
1199 // to the switch). To handle this, a default-group-handler instance is necessary
1200 // per switch.
Charles Chan2199c302016-04-23 17:36:10 -07001201 log.debug("Current groupHandlerMap devs: {}", groupHandlerMap.keySet());
1202 if (groupHandlerMap.get(deviceId) == null) {
Charles Chan0b4e6182015-11-03 10:42:14 -08001203 DefaultGroupHandler groupHandler;
1204 try {
1205 groupHandler = DefaultGroupHandler.
Charles Chan2199c302016-04-23 17:36:10 -07001206 createGroupHandler(deviceId,
1207 appId,
1208 deviceConfiguration,
1209 linkService,
1210 flowObjectiveService,
1211 this);
Charles Chan0b4e6182015-11-03 10:42:14 -08001212 } catch (DeviceConfigNotFoundException e) {
1213 log.warn(e.getMessage() + " Aborting processDeviceAdded.");
1214 return;
1215 }
Charles Chan2199c302016-04-23 17:36:10 -07001216 log.debug("updating groupHandlerMap with new config for device: {}",
1217 deviceId);
1218 groupHandlerMap.put(deviceId, groupHandler);
Saurav Das2857f382015-11-03 14:39:27 -08001219 }
Saurav Dasb5c236e2016-06-07 10:08:06 -07001220
Charles Chan2199c302016-04-23 17:36:10 -07001221 if (mastershipService.isLocalMaster(deviceId)) {
Saurav Das018605f2017-02-18 14:05:44 -08001222 defaultRoutingHandler.populatePortAddressingRules(deviceId);
Charles Chan03a73e02016-10-24 14:52:01 -07001223 hostHandler.init(deviceId);
Charles Chanfc5c7802016-05-17 13:13:55 -07001224 xConnectHandler.init(deviceId);
Charles Chan2199c302016-04-23 17:36:10 -07001225 DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId);
Charles Chan59cc16d2017-02-02 16:20:42 -08001226 groupHandler.createGroupsFromVlanConfig();
Charles Chan2199c302016-04-23 17:36:10 -07001227 routingRulePopulator.populateSubnetBroadcastRule(deviceId);
Charles Chanc42e84e2015-10-20 16:24:19 -07001228 }
Charles Chan5270ed02016-01-30 23:22:37 -08001229
Charles Chan03a73e02016-10-24 14:52:01 -07001230 appCfgHandler.init(deviceId);
1231 routeHandler.init(deviceId);
sanghob35a6192015-04-01 13:05:26 -07001232 }
1233
Saurav Das80980c72016-03-23 11:22:49 -07001234 private void processDeviceRemoved(Device device) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001235 dsNextObjStore.entrySet().stream()
Saurav Das80980c72016-03-23 11:22:49 -07001236 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
1237 .forEach(entry -> {
Saurav Das7bcbe702017-06-13 15:35:54 -07001238 dsNextObjStore.remove(entry.getKey());
Saurav Das80980c72016-03-23 11:22:49 -07001239 });
Charles Chan59cc16d2017-02-02 16:20:42 -08001240 vlanNextObjStore.entrySet().stream()
Saurav Das80980c72016-03-23 11:22:49 -07001241 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
Charles Chan65238242017-06-22 18:03:14 -07001242 .forEach(entry -> vlanNextObjStore.remove(entry.getKey()));
Saurav Das80980c72016-03-23 11:22:49 -07001243 portNextObjStore.entrySet().stream()
1244 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
Charles Chan65238242017-06-22 18:03:14 -07001245 .forEach(entry -> portNextObjStore.remove(entry.getKey()));
Charles Chaned3742352017-06-15 00:44:51 -07001246
1247 seenLinks.keySet().removeIf(key -> key.src().deviceId().equals(device.id()) ||
1248 key.dst().deviceId().equals(device.id()));
1249
Saurav Das80980c72016-03-23 11:22:49 -07001250 groupHandlerMap.remove(device.id());
Saurav Das80980c72016-03-23 11:22:49 -07001251 defaultRoutingHandler.purgeEcmpGraph(device.id());
Saurav Dasc88d4662017-05-15 15:34:25 -07001252 // Note that a switch going down is associated with all of its links
1253 // going down as well, but it is treated as a single switch down event
1254 // while the link-downs are ignored.
1255 defaultRoutingHandler
1256 .populateRoutingRulesForLinkStatusChange(null, null, device.id());
Charles Chan2199c302016-04-23 17:36:10 -07001257 mcastHandler.removeDevice(device.id());
Charles Chanfc5c7802016-05-17 13:13:55 -07001258 xConnectHandler.removeDevice(device.id());
Saurav Das80980c72016-03-23 11:22:49 -07001259 }
1260
Saurav Das1a129a02016-11-18 15:21:57 -08001261 private void processPortUpdated(Device device, Port port) {
1262 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
1263 log.warn("Device configuration uploading. Not handling port event for"
1264 + "dev: {} port: {}", device.id(), port.number());
1265 return;
1266 }
Saurav Das018605f2017-02-18 14:05:44 -08001267
1268 if (!mastershipService.isLocalMaster(device.id())) {
1269 log.debug("Not master for dev:{} .. not handling port updated event"
1270 + "for port {}", device.id(), port.number());
1271 return;
1272 }
1273
1274 // first we handle filtering rules associated with the port
1275 if (port.isEnabled()) {
1276 log.info("Switchport {}/{} enabled..programming filters",
1277 device.id(), port.number());
Charles Chan7e4f8192017-02-26 22:59:35 -08001278 routingRulePopulator.processSinglePortFilters(device.id(), port.number(), true);
Saurav Das018605f2017-02-18 14:05:44 -08001279 } else {
1280 log.info("Switchport {}/{} disabled..removing filters",
1281 device.id(), port.number());
Charles Chan7e4f8192017-02-26 22:59:35 -08001282 routingRulePopulator.processSinglePortFilters(device.id(), port.number(), false);
Saurav Das018605f2017-02-18 14:05:44 -08001283 }
Saurav Das1a129a02016-11-18 15:21:57 -08001284
1285 // portUpdated calls are for ports that have gone down or up. For switch
1286 // to switch ports, link-events should take care of any re-routing or
1287 // group editing necessary for port up/down. Here we only process edge ports
1288 // that are already configured.
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001289 ConnectPoint cp = new ConnectPoint(device.id(), port.number());
1290 VlanId untaggedVlan = getUntaggedVlanId(cp);
1291 VlanId nativeVlan = getNativeVlanId(cp);
1292 Set<VlanId> taggedVlans = getTaggedVlanId(cp);
Charles Chan59cc16d2017-02-02 16:20:42 -08001293
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001294 if (untaggedVlan == null && nativeVlan == null && taggedVlans.isEmpty()) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001295 log.debug("Not handling port updated event for non-edge port (unconfigured) "
Saurav Das1a129a02016-11-18 15:21:57 -08001296 + "dev/port: {}/{}", device.id(), port.number());
1297 return;
1298 }
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001299 if (untaggedVlan != null) {
1300 processEdgePort(device, port, untaggedVlan, true);
1301 }
1302 if (nativeVlan != null) {
1303 processEdgePort(device, port, nativeVlan, true);
1304 }
1305 if (!taggedVlans.isEmpty()) {
1306 taggedVlans.forEach(tag -> processEdgePort(device, port, tag, false));
1307 }
Saurav Das1a129a02016-11-18 15:21:57 -08001308 }
1309
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001310 private void processEdgePort(Device device, Port port, VlanId vlanId,
1311 boolean popVlan) {
Saurav Das1a129a02016-11-18 15:21:57 -08001312 boolean portUp = port.isEnabled();
1313 if (portUp) {
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001314 log.info("Device:EdgePort {}:{} is enabled in vlan: {}", device.id(),
Charles Chan59cc16d2017-02-02 16:20:42 -08001315 port.number(), vlanId);
Saurav Das1a129a02016-11-18 15:21:57 -08001316 } else {
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001317 log.info("Device:EdgePort {}:{} is disabled in vlan: {}", device.id(),
Charles Chan59cc16d2017-02-02 16:20:42 -08001318 port.number(), vlanId);
Saurav Das1a129a02016-11-18 15:21:57 -08001319 }
1320
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -07001321 DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id());
sanghob35a6192015-04-01 13:05:26 -07001322 if (groupHandler != null) {
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001323 groupHandler.processEdgePort(port.number(), vlanId, popVlan, portUp);
Saurav Das1a129a02016-11-18 15:21:57 -08001324 } else {
1325 log.warn("Group handler not found for dev:{}. Not handling edge port"
1326 + " {} event for port:{}", device.id(),
1327 (portUp) ? "UP" : "DOWN", port.number());
sanghob35a6192015-04-01 13:05:26 -07001328 }
1329 }
sangho1e575652015-05-14 00:39:53 -07001330
Pier Ventre10bd8d12016-11-26 21:05:22 -08001331 /**
1332 * Registers the given connect point with the NRS, this is necessary
1333 * to receive the NDP and ARP packets from the NRS.
1334 *
1335 * @param portToRegister connect point to register
1336 */
1337 public void registerConnectPoint(ConnectPoint portToRegister) {
Charles Chan0aa674e2017-02-23 15:44:08 -08001338 neighbourResolutionService.registerNeighbourHandler(
Pier Ventre10bd8d12016-11-26 21:05:22 -08001339 portToRegister,
1340 neighbourHandler,
1341 appId
1342 );
1343 }
1344
Charles Chand6832882015-10-05 17:50:33 -07001345 private class InternalConfigListener implements NetworkConfigListener {
Saurav Das7bcbe702017-06-13 15:35:54 -07001346 private static final long PROGRAM_DELAY = 2;
Charles Chan2c15aca2016-11-09 20:51:44 -08001347 SegmentRoutingManager srManager;
Charles Chan4636be02015-10-07 14:21:45 -07001348
Charles Chane849c192016-01-11 18:28:54 -08001349 /**
1350 * Constructs the internal network config listener.
1351 *
Charles Chan2c15aca2016-11-09 20:51:44 -08001352 * @param srManager segment routing manager
Charles Chane849c192016-01-11 18:28:54 -08001353 */
Charles Chan65238242017-06-22 18:03:14 -07001354 InternalConfigListener(SegmentRoutingManager srManager) {
Charles Chan2c15aca2016-11-09 20:51:44 -08001355 this.srManager = srManager;
Charles Chan4636be02015-10-07 14:21:45 -07001356 }
1357
Charles Chane849c192016-01-11 18:28:54 -08001358 /**
1359 * Reads network config and initializes related data structure accordingly.
1360 */
Charles Chan4636be02015-10-07 14:21:45 -07001361 public void configureNetwork() {
Saurav Das7bcbe702017-06-13 15:35:54 -07001362 if (deviceConfiguration == null) {
1363 deviceConfiguration = new DeviceConfiguration(srManager);
1364 } else {
1365 deviceConfiguration.updateConfig();
1366 }
Charles Chan4636be02015-10-07 14:21:45 -07001367
Charles Chan2c15aca2016-11-09 20:51:44 -08001368 arpHandler = new ArpHandler(srManager);
1369 icmpHandler = new IcmpHandler(srManager);
1370 ipHandler = new IpHandler(srManager);
1371 routingRulePopulator = new RoutingRulePopulator(srManager);
1372 defaultRoutingHandler = new DefaultRoutingHandler(srManager);
Charles Chan4636be02015-10-07 14:21:45 -07001373
1374 tunnelHandler = new TunnelHandler(linkService, deviceConfiguration,
1375 groupHandlerMap, tunnelStore);
1376 policyHandler = new PolicyHandler(appId, deviceConfiguration,
1377 flowObjectiveService,
1378 tunnelHandler, policyStore);
Saurav Das7bcbe702017-06-13 15:35:54 -07001379 // add a small delay to absorb multiple network config added notifications
1380 if (!programmingScheduled.get()) {
1381 programmingScheduled.set(true);
1382 executorService.schedule(new ConfigChange(), PROGRAM_DELAY,
1383 TimeUnit.SECONDS);
Charles Chan4636be02015-10-07 14:21:45 -07001384 }
Charles Chan2199c302016-04-23 17:36:10 -07001385 mcastHandler.init();
Charles Chan4636be02015-10-07 14:21:45 -07001386 }
1387
Charles Chand6832882015-10-05 17:50:33 -07001388 @Override
1389 public void event(NetworkConfigEvent event) {
Charles Chan5270ed02016-01-30 23:22:37 -08001390 // TODO move this part to NetworkConfigEventHandler
1391 if (event.configClass().equals(SegmentRoutingDeviceConfig.class)) {
1392 switch (event.type()) {
1393 case CONFIG_ADDED:
Charles Chan278ce832017-06-26 15:25:09 -07001394 log.info("Segment Routing Device Config added for {}", event.subject());
Charles Chan5270ed02016-01-30 23:22:37 -08001395 configureNetwork();
1396 break;
1397 case CONFIG_UPDATED:
Charles Chan278ce832017-06-26 15:25:09 -07001398 log.info("Segment Routing Config updated for {}", event.subject());
1399 // TODO support dynamic configuration
1400 break;
1401 default:
1402 break;
1403 }
1404 } else if (event.configClass().equals(InterfaceConfig.class)) {
1405 switch (event.type()) {
1406 case CONFIG_ADDED:
1407 log.info("Interface Config added for {}", event.subject());
1408 configureNetwork();
1409 break;
1410 case CONFIG_UPDATED:
1411 log.info("Interface Config updated for {}", event.subject());
Charles Chan5270ed02016-01-30 23:22:37 -08001412 // TODO support dynamic configuration
1413 break;
1414 default:
1415 break;
Charles Chanb8e10c82015-10-14 11:24:40 -07001416 }
Charles Chan5270ed02016-01-30 23:22:37 -08001417 } else if (event.configClass().equals(SegmentRoutingAppConfig.class)) {
Charles Chanfc5c7802016-05-17 13:13:55 -07001418 checkState(appCfgHandler != null, "NetworkConfigEventHandler is not initialized");
Charles Chan5270ed02016-01-30 23:22:37 -08001419 switch (event.type()) {
1420 case CONFIG_ADDED:
Charles Chanfc5c7802016-05-17 13:13:55 -07001421 appCfgHandler.processAppConfigAdded(event);
Charles Chan5270ed02016-01-30 23:22:37 -08001422 break;
1423 case CONFIG_UPDATED:
Charles Chanfc5c7802016-05-17 13:13:55 -07001424 appCfgHandler.processAppConfigUpdated(event);
Charles Chan5270ed02016-01-30 23:22:37 -08001425 break;
1426 case CONFIG_REMOVED:
Charles Chanfc5c7802016-05-17 13:13:55 -07001427 appCfgHandler.processAppConfigRemoved(event);
1428 break;
1429 default:
1430 break;
1431 }
Charles Chan03a73e02016-10-24 14:52:01 -07001432 configureNetwork();
Charles Chanfc5c7802016-05-17 13:13:55 -07001433 } else if (event.configClass().equals(XConnectConfig.class)) {
1434 checkState(xConnectHandler != null, "XConnectHandler is not initialized");
1435 switch (event.type()) {
1436 case CONFIG_ADDED:
1437 xConnectHandler.processXConnectConfigAdded(event);
1438 break;
1439 case CONFIG_UPDATED:
1440 xConnectHandler.processXConnectConfigUpdated(event);
1441 break;
1442 case CONFIG_REMOVED:
1443 xConnectHandler.processXConnectConfigRemoved(event);
Charles Chan5270ed02016-01-30 23:22:37 -08001444 break;
1445 default:
1446 break;
Charles Chanb8e10c82015-10-14 11:24:40 -07001447 }
Pier Ventref34966c2016-11-07 16:21:04 -08001448 } else if (event.configClass().equals(PwaasConfig.class)) {
1449 checkState(l2TunnelHandler != null, "L2TunnelHandler is not initialized");
1450 switch (event.type()) {
1451 case CONFIG_ADDED:
1452 l2TunnelHandler.processPwaasConfigAdded(event);
1453 break;
1454 case CONFIG_UPDATED:
1455 l2TunnelHandler.processPwaasConfigUpdated(event);
1456 break;
1457 case CONFIG_REMOVED:
1458 l2TunnelHandler.processPwaasConfigRemoved(event);
1459 break;
1460 default:
1461 break;
1462 }
Charles Chand6832882015-10-05 17:50:33 -07001463 }
1464 }
Saurav Das7bcbe702017-06-13 15:35:54 -07001465
1466 private final class ConfigChange implements Runnable {
1467 @Override
1468 public void run() {
1469 programmingScheduled.set(false);
1470 for (Device device : deviceService.getDevices()) {
1471 processDeviceAdded(device);
1472 }
1473 defaultRoutingHandler.startPopulationProcess();
1474 }
1475 }
Charles Chand6832882015-10-05 17:50:33 -07001476 }
Charles Chan68aa62d2015-11-09 16:37:23 -08001477
1478 private class InternalHostListener implements HostListener {
Charles Chan68aa62d2015-11-09 16:37:23 -08001479 @Override
1480 public void event(HostEvent event) {
1481 // Do not proceed without mastership
1482 DeviceId deviceId = event.subject().location().deviceId();
1483 if (!mastershipService.isLocalMaster(deviceId)) {
1484 return;
1485 }
1486
1487 switch (event.type()) {
1488 case HOST_ADDED:
Charles Chand2990362016-04-18 13:44:03 -07001489 hostHandler.processHostAddedEvent(event);
Charles Chan68aa62d2015-11-09 16:37:23 -08001490 break;
1491 case HOST_MOVED:
Charles Chand2990362016-04-18 13:44:03 -07001492 hostHandler.processHostMovedEvent(event);
Charles Chan68aa62d2015-11-09 16:37:23 -08001493 break;
1494 case HOST_REMOVED:
Charles Chanf9a52702017-06-16 15:19:24 -07001495 hostHandler.processHostRemovedEvent(event);
Charles Chan68aa62d2015-11-09 16:37:23 -08001496 break;
1497 case HOST_UPDATED:
Charles Chand2990362016-04-18 13:44:03 -07001498 hostHandler.processHostUpdatedEvent(event);
Charles Chan68aa62d2015-11-09 16:37:23 -08001499 break;
1500 default:
1501 log.warn("Unsupported host event type: {}", event.type());
1502 break;
1503 }
1504 }
1505 }
1506
Charles Chand55e84d2016-03-30 17:54:24 -07001507 private class InternalMcastListener implements McastListener {
1508 @Override
1509 public void event(McastEvent event) {
1510 switch (event.type()) {
1511 case SOURCE_ADDED:
Charles Chand2990362016-04-18 13:44:03 -07001512 mcastHandler.processSourceAdded(event);
Charles Chand55e84d2016-03-30 17:54:24 -07001513 break;
1514 case SINK_ADDED:
Charles Chand2990362016-04-18 13:44:03 -07001515 mcastHandler.processSinkAdded(event);
Charles Chand55e84d2016-03-30 17:54:24 -07001516 break;
1517 case SINK_REMOVED:
Charles Chand2990362016-04-18 13:44:03 -07001518 mcastHandler.processSinkRemoved(event);
Charles Chand55e84d2016-03-30 17:54:24 -07001519 break;
1520 case ROUTE_ADDED:
1521 case ROUTE_REMOVED:
1522 default:
1523 break;
1524 }
1525 }
1526 }
Charles Chan35fd1a72016-06-13 18:54:31 -07001527
Charles Chan03a73e02016-10-24 14:52:01 -07001528 private class InternalRouteEventListener implements RouteListener {
1529 @Override
1530 public void event(RouteEvent event) {
1531 switch (event.type()) {
1532 case ROUTE_ADDED:
1533 routeHandler.processRouteAdded(event);
1534 break;
1535 case ROUTE_UPDATED:
1536 routeHandler.processRouteUpdated(event);
1537 break;
1538 case ROUTE_REMOVED:
1539 routeHandler.processRouteRemoved(event);
1540 break;
1541 default:
1542 break;
1543 }
1544 }
1545 }
Saurav Dasc88d4662017-05-15 15:34:25 -07001546
sanghob35a6192015-04-01 13:05:26 -07001547}