blob: bca9571323a91dcaa75a1f2a7e15f6a4dd70339f [file] [log] [blame]
sangho80f11cb2015-04-01 13:05:26 -07001/*
Brian O'Connor43b53542016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
sangho80f11cb2015-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 Chand7844e52016-10-20 17:02:44 -070018import com.google.common.collect.Maps;
sangho80f11cb2015-04-01 13:05:26 -070019import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
sangho27462c62015-05-14 00:39:53 -070024import org.apache.felix.scr.annotations.Service;
sangho80f11cb2015-04-01 13:05:26 -070025import org.onlab.packet.Ethernet;
Charles Chan77277672015-10-20 16:24:19 -070026import org.onlab.packet.IPv4;
Charles Chan77277672015-10-20 16:24:19 -070027import org.onlab.packet.Ip4Prefix;
Charles Chan77277672015-10-20 16:24:19 -070028import org.onlab.packet.IpPrefix;
Jonathan Hart54541d12016-04-12 15:39:44 -070029import org.onlab.packet.VlanId;
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -070030import org.onlab.util.KryoNamespace;
Saurav Dasc3604f12016-03-23 11:22:49 -070031import org.onosproject.cfg.ComponentConfigService;
sangho80f11cb2015-04-01 13:05:26 -070032import org.onosproject.core.ApplicationId;
33import org.onosproject.core.CoreService;
34import org.onosproject.event.Event;
Charles Chanc91c8782016-03-30 17:54:24 -070035import org.onosproject.incubator.net.config.basics.McastConfig;
Charles Chan46fdfaf2016-11-09 20:51:44 -080036import org.onosproject.incubator.net.intf.InterfaceService;
Charles Chandebfea32016-10-24 14:52:01 -070037import org.onosproject.incubator.net.routing.RouteEvent;
38import org.onosproject.incubator.net.routing.RouteListener;
39import org.onosproject.incubator.net.routing.RouteService;
Jonathan Hart54541d12016-04-12 15:39:44 -070040import org.onosproject.mastership.MastershipService;
Jonathan Hart54541d12016-04-12 15:39:44 -070041import org.onosproject.net.Device;
42import org.onosproject.net.DeviceId;
43import org.onosproject.net.Link;
44import org.onosproject.net.Port;
Charles Chanf4586112015-11-09 16:37:23 -080045import org.onosproject.net.PortNumber;
Charles Chan72f556a2015-10-05 17:50:33 -070046import org.onosproject.net.config.ConfigFactory;
47import org.onosproject.net.config.NetworkConfigEvent;
Charles Chan72f556a2015-10-05 17:50:33 -070048import org.onosproject.net.config.NetworkConfigListener;
Jonathan Hart54541d12016-04-12 15:39:44 -070049import org.onosproject.net.config.NetworkConfigRegistry;
Charles Chan72f556a2015-10-05 17:50:33 -070050import org.onosproject.net.config.basics.SubjectFactories;
Jonathan Hart54541d12016-04-12 15:39:44 -070051import org.onosproject.net.device.DeviceEvent;
52import org.onosproject.net.device.DeviceListener;
53import org.onosproject.net.device.DeviceService;
Charles Chanf4586112015-11-09 16:37:23 -080054import org.onosproject.net.flow.TrafficSelector;
55import org.onosproject.net.flow.TrafficTreatment;
Jonathan Hart54541d12016-04-12 15:39:44 -070056import org.onosproject.net.flowobjective.FlowObjectiveService;
Charles Chanf4586112015-11-09 16:37:23 -080057import org.onosproject.net.host.HostEvent;
58import org.onosproject.net.host.HostListener;
Charles Chanc91c8782016-03-30 17:54:24 -070059import org.onosproject.net.mcast.McastEvent;
60import org.onosproject.net.mcast.McastListener;
61import org.onosproject.net.mcast.MulticastRouteService;
Charles Chanc91c8782016-03-30 17:54:24 -070062import org.onosproject.net.topology.TopologyService;
63import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
64import org.onosproject.segmentrouting.config.DeviceConfiguration;
65import org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig;
66import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig;
Charles Chan82f19972016-05-17 13:13:55 -070067import org.onosproject.segmentrouting.config.XConnectConfig;
Charles Chanc91c8782016-03-30 17:54:24 -070068import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler;
69import org.onosproject.segmentrouting.grouphandler.NeighborSet;
Charles Chan1eaf4802016-04-18 13:44:03 -070070import org.onosproject.segmentrouting.storekey.NeighborSetNextObjectiveStoreKey;
71import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
sangho80f11cb2015-04-01 13:05:26 -070072import org.onosproject.net.host.HostService;
sangho80f11cb2015-04-01 13:05:26 -070073import org.onosproject.net.link.LinkEvent;
74import org.onosproject.net.link.LinkListener;
75import org.onosproject.net.link.LinkService;
76import org.onosproject.net.packet.InboundPacket;
77import org.onosproject.net.packet.PacketContext;
78import org.onosproject.net.packet.PacketProcessor;
79import org.onosproject.net.packet.PacketService;
Charles Chan1eaf4802016-04-18 13:44:03 -070080import org.onosproject.segmentrouting.storekey.SubnetAssignedVidStoreKey;
81import org.onosproject.segmentrouting.storekey.SubnetNextObjectiveStoreKey;
Charles Chan82f19972016-05-17 13:13:55 -070082import org.onosproject.segmentrouting.storekey.XConnectStoreKey;
Jonathan Hart54541d12016-04-12 15:39:44 -070083import org.onosproject.store.serializers.KryoNamespaces;
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -070084import org.onosproject.store.service.EventuallyConsistentMap;
85import org.onosproject.store.service.EventuallyConsistentMapBuilder;
86import org.onosproject.store.service.StorageService;
87import org.onosproject.store.service.WallClockTimestamp;
Charles Chan41f5ec02016-06-13 18:54:31 -070088import org.opencord.cordconfig.CordConfigEvent;
89import org.opencord.cordconfig.CordConfigListener;
90import org.opencord.cordconfig.CordConfigService;
sangho80f11cb2015-04-01 13:05:26 -070091import org.slf4j.Logger;
92import org.slf4j.LoggerFactory;
93
Saurav Das7c305372015-10-28 12:39:42 -070094import java.util.Collections;
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -070095import java.util.HashSet;
sangho27462c62015-05-14 00:39:53 -070096import java.util.List;
sangho80f11cb2015-04-01 13:05:26 -070097import java.util.Map;
Saurav Das7c305372015-10-28 12:39:42 -070098import java.util.Set;
sangho80f11cb2015-04-01 13:05:26 -070099import java.util.concurrent.ConcurrentHashMap;
100import java.util.concurrent.ConcurrentLinkedQueue;
101import java.util.concurrent.Executors;
102import java.util.concurrent.ScheduledExecutorService;
103import java.util.concurrent.ScheduledFuture;
104import java.util.concurrent.TimeUnit;
105
Charles Chand6d25332016-02-26 22:19:52 -0800106import static com.google.common.base.Preconditions.checkState;
Yuta HIGUCHIebee2f12016-07-21 16:54:33 -0700107import static org.onlab.util.Tools.groupedThreads;
Charles Chand6d25332016-02-26 22:19:52 -0800108
Charles Chanb7f75ac2016-01-11 18:28:54 -0800109/**
110 * Segment routing manager.
111 */
Jonathan Hart54541d12016-04-12 15:39:44 -0700112@Service
113@Component(immediate = true)
sangho27462c62015-05-14 00:39:53 -0700114public class SegmentRoutingManager implements SegmentRoutingService {
sangho80f11cb2015-04-01 13:05:26 -0700115
Charles Chan46fdfaf2016-11-09 20:51:44 -0800116 private static Logger log = LoggerFactory.getLogger(SegmentRoutingManager.class);
sangho80f11cb2015-04-01 13:05:26 -0700117
118 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700119 private ComponentConfigService compCfgService;
sangho80f11cb2015-04-01 13:05:26 -0700120
121 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700122 CoreService coreService;
sangho80f11cb2015-04-01 13:05:26 -0700123
124 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700125 PacketService packetService;
sangho80f11cb2015-04-01 13:05:26 -0700126
127 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700128 HostService hostService;
sangho80f11cb2015-04-01 13:05:26 -0700129
130 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700131 DeviceService deviceService;
sangho80f11cb2015-04-01 13:05:26 -0700132
133 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700134 FlowObjectiveService flowObjectiveService;
sangho80f11cb2015-04-01 13:05:26 -0700135
136 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700137 LinkService linkService;
sangho27462c62015-05-14 00:39:53 -0700138
Charles Chan82ab1932016-01-30 23:22:37 -0800139 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700140 MastershipService mastershipService;
141
142 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
143 StorageService storageService;
144
145 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
146 MulticastRouteService multicastRouteService;
147
148 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
149 TopologyService topologyService;
150
151 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
152 CordConfigService cordConfigService;
153
154 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
155 RouteService routeService;
Charles Chan82ab1932016-01-30 23:22:37 -0800156
157 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan46fdfaf2016-11-09 20:51:44 -0800158 public NetworkConfigRegistry cfgService;
Charles Chan82ab1932016-01-30 23:22:37 -0800159
Saurav Dasc3604f12016-03-23 11:22:49 -0700160 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan46fdfaf2016-11-09 20:51:44 -0800161 public InterfaceService interfaceService;
162
Charles Chandebfea32016-10-24 14:52:01 -0700163 ArpHandler arpHandler = null;
164 IcmpHandler icmpHandler = null;
165 IpHandler ipHandler = null;
166 RoutingRulePopulator routingRulePopulator = null;
Charles Chan46fdfaf2016-11-09 20:51:44 -0800167 public ApplicationId appId;
sangho9b169e32015-04-14 16:27:13 -0700168 protected DeviceConfiguration deviceConfiguration = null;
sangho80f11cb2015-04-01 13:05:26 -0700169
Charles Chandebfea32016-10-24 14:52:01 -0700170 DefaultRoutingHandler defaultRoutingHandler = null;
sangho27462c62015-05-14 00:39:53 -0700171 private TunnelHandler tunnelHandler = null;
172 private PolicyHandler policyHandler = null;
Charles Chan2b078ae2015-10-14 11:24:40 -0700173 private InternalPacketProcessor processor = null;
174 private InternalLinkListener linkListener = null;
175 private InternalDeviceListener deviceListener = null;
Charles Chan82f19972016-05-17 13:13:55 -0700176 private AppConfigHandler appCfgHandler = null;
Charles Chandebfea32016-10-24 14:52:01 -0700177 XConnectHandler xConnectHandler = null;
Charles Chan1eaf4802016-04-18 13:44:03 -0700178 private McastHandler mcastHandler = null;
Charles Chandebfea32016-10-24 14:52:01 -0700179 HostHandler hostHandler = null;
Charles Chan41f5ec02016-06-13 18:54:31 -0700180 private CordConfigHandler cordConfigHandler = null;
Charles Chandebfea32016-10-24 14:52:01 -0700181 RouteHandler routeHandler = null;
sangho80f11cb2015-04-01 13:05:26 -0700182 private InternalEventHandler eventHandler = new InternalEventHandler();
Charles Chan82ab1932016-01-30 23:22:37 -0800183 private final InternalHostListener hostListener = new InternalHostListener();
Charles Chanc91c8782016-03-30 17:54:24 -0700184 private final InternalConfigListener cfgListener = new InternalConfigListener(this);
185 private final InternalMcastListener mcastListener = new InternalMcastListener();
Charles Chan41f5ec02016-06-13 18:54:31 -0700186 private final InternalCordConfigListener cordConfigListener = new InternalCordConfigListener();
Charles Chandebfea32016-10-24 14:52:01 -0700187 private final InternalRouteEventListener routeListener = new InternalRouteEventListener();
sangho80f11cb2015-04-01 13:05:26 -0700188
Srikanth Vavilapalli64505482015-04-21 13:04:13 -0700189 private ScheduledExecutorService executorService = Executors
Yuta HIGUCHIebee2f12016-07-21 16:54:33 -0700190 .newScheduledThreadPool(1, groupedThreads("SegmentRoutingManager", "event-%d", log));
sangho80f11cb2015-04-01 13:05:26 -0700191
Saurav Das2d94d312015-11-24 23:21:05 -0800192 @SuppressWarnings("unused")
sangho80f11cb2015-04-01 13:05:26 -0700193 private static ScheduledFuture<?> eventHandlerFuture = null;
Saurav Das2d94d312015-11-24 23:21:05 -0800194 @SuppressWarnings("rawtypes")
Yuta HIGUCHIebee2f12016-07-21 16:54:33 -0700195 private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<>();
Charles Chanf4586112015-11-09 16:37:23 -0800196 private Map<DeviceId, DefaultGroupHandler> groupHandlerMap =
Charles Chanb7f75ac2016-01-11 18:28:54 -0800197 new ConcurrentHashMap<>();
198 /**
199 * Per device next objective ID store with (device id + neighbor set) as key.
200 */
201 public EventuallyConsistentMap<NeighborSetNextObjectiveStoreKey, Integer>
Charles Chanf4586112015-11-09 16:37:23 -0800202 nsNextObjStore = null;
Charles Chanb7f75ac2016-01-11 18:28:54 -0800203 /**
204 * Per device next objective ID store with (device id + subnet) as key.
205 */
206 public EventuallyConsistentMap<SubnetNextObjectiveStoreKey, Integer>
Charles Chanf4586112015-11-09 16:37:23 -0800207 subnetNextObjStore = null;
Charles Chanb7f75ac2016-01-11 18:28:54 -0800208 /**
209 * Per device next objective ID store with (device id + port) as key.
210 */
211 public EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer>
Saurav Das2d94d312015-11-24 23:21:05 -0800212 portNextObjStore = null;
Saurav Das7c305372015-10-28 12:39:42 -0700213 // Per device, per-subnet assigned-vlans store, with (device id + subnet
214 // IPv4 prefix) as key
215 private EventuallyConsistentMap<SubnetAssignedVidStoreKey, VlanId>
Charles Chanb7f75ac2016-01-11 18:28:54 -0800216 subnetVidStore = null;
Saurav Das2d94d312015-11-24 23:21:05 -0800217 private EventuallyConsistentMap<String, Tunnel> tunnelStore = null;
218 private EventuallyConsistentMap<String, Policy> policyStore = null;
sangho4a5c42a2015-05-20 22:16:38 -0700219
Charles Chanc91c8782016-03-30 17:54:24 -0700220 private final ConfigFactory<DeviceId, SegmentRoutingDeviceConfig> deviceConfigFactory =
Charles Chan82f19972016-05-17 13:13:55 -0700221 new ConfigFactory<DeviceId, SegmentRoutingDeviceConfig>(
222 SubjectFactories.DEVICE_SUBJECT_FACTORY,
Charles Chanc91c8782016-03-30 17:54:24 -0700223 SegmentRoutingDeviceConfig.class, "segmentrouting") {
Charles Chan72f556a2015-10-05 17:50:33 -0700224 @Override
Charles Chan82ab1932016-01-30 23:22:37 -0800225 public SegmentRoutingDeviceConfig createConfig() {
226 return new SegmentRoutingDeviceConfig();
Charles Chan72f556a2015-10-05 17:50:33 -0700227 }
228 };
Charles Chanc91c8782016-03-30 17:54:24 -0700229 private final ConfigFactory<ApplicationId, SegmentRoutingAppConfig> appConfigFactory =
Charles Chan82f19972016-05-17 13:13:55 -0700230 new ConfigFactory<ApplicationId, SegmentRoutingAppConfig>(
231 SubjectFactories.APP_SUBJECT_FACTORY,
Charles Chanc91c8782016-03-30 17:54:24 -0700232 SegmentRoutingAppConfig.class, "segmentrouting") {
Charles Chan82ab1932016-01-30 23:22:37 -0800233 @Override
234 public SegmentRoutingAppConfig createConfig() {
235 return new SegmentRoutingAppConfig();
236 }
237 };
Charles Chan82f19972016-05-17 13:13:55 -0700238 private final ConfigFactory<ApplicationId, XConnectConfig> xConnectConfigFactory =
239 new ConfigFactory<ApplicationId, XConnectConfig>(
240 SubjectFactories.APP_SUBJECT_FACTORY,
241 XConnectConfig.class, "xconnect") {
242 @Override
243 public XConnectConfig createConfig() {
244 return new XConnectConfig();
245 }
246 };
Charles Chanc91c8782016-03-30 17:54:24 -0700247 private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory =
Charles Chan82f19972016-05-17 13:13:55 -0700248 new ConfigFactory<ApplicationId, McastConfig>(
249 SubjectFactories.APP_SUBJECT_FACTORY,
Charles Chanc91c8782016-03-30 17:54:24 -0700250 McastConfig.class, "multicast") {
251 @Override
252 public McastConfig createConfig() {
253 return new McastConfig();
254 }
255 };
256
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700257 private Object threadSchedulerLock = new Object();
258 private static int numOfEventsQueued = 0;
259 private static int numOfEventsExecuted = 0;
sangho80f11cb2015-04-01 13:05:26 -0700260 private static int numOfHandlerExecution = 0;
261 private static int numOfHandlerScheduled = 0;
262
Charles Chan1963f4f2016-02-18 14:22:42 -0800263 /**
264 * Segment Routing App ID.
265 */
Charles Chan46fdfaf2016-11-09 20:51:44 -0800266 public static final String APP_NAME = "org.onosproject.segmentrouting";
Charles Chanb7f75ac2016-01-11 18:28:54 -0800267 /**
268 * The starting value of per-subnet VLAN ID assignment.
269 */
Saurav Das7c305372015-10-28 12:39:42 -0700270 private static final short ASSIGNED_VLAN_START = 4093;
Charles Chanb7f75ac2016-01-11 18:28:54 -0800271 /**
272 * The default VLAN ID assigned to the interfaces without subnet config.
273 */
Saurav Das7c305372015-10-28 12:39:42 -0700274 public static final short ASSIGNED_VLAN_NO_SUBNET = 4094;
275
sangho80f11cb2015-04-01 13:05:26 -0700276 @Activate
277 protected void activate() {
Charles Chan46fdfaf2016-11-09 20:51:44 -0800278 appId = coreService.registerApplication(APP_NAME);
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700279
280 log.debug("Creating EC map nsnextobjectivestore");
281 EventuallyConsistentMapBuilder<NeighborSetNextObjectiveStoreKey, Integer>
282 nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700283 nsNextObjStore = nsNextObjMapBuilder
284 .withName("nsnextobjectivestore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700285 .withSerializer(createSerializer())
Madan Jampani675ae202015-06-24 19:05:56 -0700286 .withTimestampProvider((k, v) -> new WallClockTimestamp())
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700287 .build();
288 log.trace("Current size {}", nsNextObjStore.size());
289
Charles Chan77277672015-10-20 16:24:19 -0700290 log.debug("Creating EC map subnetnextobjectivestore");
291 EventuallyConsistentMapBuilder<SubnetNextObjectiveStoreKey, Integer>
292 subnetNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
Charles Chan77277672015-10-20 16:24:19 -0700293 subnetNextObjStore = subnetNextObjMapBuilder
294 .withName("subnetnextobjectivestore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700295 .withSerializer(createSerializer())
Charles Chan77277672015-10-20 16:24:19 -0700296 .withTimestampProvider((k, v) -> new WallClockTimestamp())
297 .build();
298
Saurav Das2d94d312015-11-24 23:21:05 -0800299 log.debug("Creating EC map subnetnextobjectivestore");
300 EventuallyConsistentMapBuilder<PortNextObjectiveStoreKey, Integer>
301 portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
302 portNextObjStore = portNextObjMapBuilder
303 .withName("portnextobjectivestore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700304 .withSerializer(createSerializer())
Saurav Das2d94d312015-11-24 23:21:05 -0800305 .withTimestampProvider((k, v) -> new WallClockTimestamp())
306 .build();
307
sangho4a5c42a2015-05-20 22:16:38 -0700308 EventuallyConsistentMapBuilder<String, Tunnel> tunnelMapBuilder =
309 storageService.eventuallyConsistentMapBuilder();
sangho4a5c42a2015-05-20 22:16:38 -0700310 tunnelStore = tunnelMapBuilder
311 .withName("tunnelstore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700312 .withSerializer(createSerializer())
Madan Jampani675ae202015-06-24 19:05:56 -0700313 .withTimestampProvider((k, v) -> new WallClockTimestamp())
sangho4a5c42a2015-05-20 22:16:38 -0700314 .build();
315
316 EventuallyConsistentMapBuilder<String, Policy> policyMapBuilder =
317 storageService.eventuallyConsistentMapBuilder();
sangho4a5c42a2015-05-20 22:16:38 -0700318 policyStore = policyMapBuilder
319 .withName("policystore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700320 .withSerializer(createSerializer())
Madan Jampani675ae202015-06-24 19:05:56 -0700321 .withTimestampProvider((k, v) -> new WallClockTimestamp())
sangho4a5c42a2015-05-20 22:16:38 -0700322 .build();
323
Saurav Das7c305372015-10-28 12:39:42 -0700324 EventuallyConsistentMapBuilder<SubnetAssignedVidStoreKey, VlanId>
325 subnetVidStoreMapBuilder = storageService.eventuallyConsistentMapBuilder();
Saurav Das7c305372015-10-28 12:39:42 -0700326 subnetVidStore = subnetVidStoreMapBuilder
327 .withName("subnetvidstore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700328 .withSerializer(createSerializer())
Saurav Das7c305372015-10-28 12:39:42 -0700329 .withTimestampProvider((k, v) -> new WallClockTimestamp())
330 .build();
331
Saurav Dasc3604f12016-03-23 11:22:49 -0700332 compCfgService.preSetProperty("org.onosproject.net.group.impl.GroupManager",
Pier Luigib9632ba2017-01-12 18:14:58 -0800333 "purgeOnDisconnection", "true");
Saurav Dasc3604f12016-03-23 11:22:49 -0700334 compCfgService.preSetProperty("org.onosproject.net.flow.impl.FlowRuleManager",
Pier Luigib9632ba2017-01-12 18:14:58 -0800335 "purgeOnDisconnection", "true");
Charles Chandebfea32016-10-24 14:52:01 -0700336 compCfgService.preSetProperty("org.onosproject.vrouter.Vrouter",
Pier Luigib9632ba2017-01-12 18:14:58 -0800337 "fibInstalledEnabled", "false");
338 compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider",
339 "requestInterceptsEnabled", "false");
Pier Luigibc976df2017-01-12 22:46:39 -0800340 compCfgService.preSetProperty("org.onosproject.incubator.net.neighbour.impl.NeighbourResolutionManager",
341 "requestInterceptsEnabled", "false");
342 compCfgService.preSetProperty("org.onosproject.dhcprelay.DhcpRelay",
343 "arpEnabled", "false");
Saurav Dasc3604f12016-03-23 11:22:49 -0700344
Charles Chan2b078ae2015-10-14 11:24:40 -0700345 processor = new InternalPacketProcessor();
346 linkListener = new InternalLinkListener();
347 deviceListener = new InternalDeviceListener();
Charles Chan82f19972016-05-17 13:13:55 -0700348 appCfgHandler = new AppConfigHandler(this);
349 xConnectHandler = new XConnectHandler(this);
Charles Chan1eaf4802016-04-18 13:44:03 -0700350 mcastHandler = new McastHandler(this);
351 hostHandler = new HostHandler(this);
Charles Chan41f5ec02016-06-13 18:54:31 -0700352 cordConfigHandler = new CordConfigHandler(this);
Charles Chandebfea32016-10-24 14:52:01 -0700353 routeHandler = new RouteHandler(this);
Charles Chan2b078ae2015-10-14 11:24:40 -0700354
Charles Chand6d25332016-02-26 22:19:52 -0800355 cfgService.addListener(cfgListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700356 cfgService.registerConfigFactory(deviceConfigFactory);
357 cfgService.registerConfigFactory(appConfigFactory);
Charles Chan82f19972016-05-17 13:13:55 -0700358 cfgService.registerConfigFactory(xConnectConfigFactory);
Charles Chanc91c8782016-03-30 17:54:24 -0700359 cfgService.registerConfigFactory(mcastConfigFactory);
Charles Chan82ab1932016-01-30 23:22:37 -0800360 hostService.addListener(hostListener);
Charles Chan2b078ae2015-10-14 11:24:40 -0700361 packetService.addProcessor(processor, PacketProcessor.director(2));
362 linkService.addListener(linkListener);
363 deviceService.addListener(deviceListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700364 multicastRouteService.addListener(mcastListener);
Charles Chan41f5ec02016-06-13 18:54:31 -0700365 cordConfigService.addListener(cordConfigListener);
Charles Chan2b078ae2015-10-14 11:24:40 -0700366
367 cfgListener.configureNetwork();
368
Charles Chandebfea32016-10-24 14:52:01 -0700369 routeService.addListener(routeListener);
370
sangho80f11cb2015-04-01 13:05:26 -0700371 log.info("Started");
372 }
373
Jonathan Hart54541d12016-04-12 15:39:44 -0700374 private KryoNamespace.Builder createSerializer() {
375 return new KryoNamespace.Builder()
376 .register(KryoNamespaces.API)
377 .register(NeighborSetNextObjectiveStoreKey.class,
378 SubnetNextObjectiveStoreKey.class,
379 SubnetAssignedVidStoreKey.class,
380 NeighborSet.class,
381 Tunnel.class,
382 DefaultTunnel.class,
383 Policy.class,
384 TunnelPolicy.class,
385 Policy.Type.class,
386 PortNextObjectiveStoreKey.class,
Charles Chan82f19972016-05-17 13:13:55 -0700387 XConnectStoreKey.class
Jonathan Hart54541d12016-04-12 15:39:44 -0700388 );
389 }
390
sangho80f11cb2015-04-01 13:05:26 -0700391 @Deactivate
392 protected void deactivate() {
Charles Chan72f556a2015-10-05 17:50:33 -0700393 cfgService.removeListener(cfgListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700394 cfgService.unregisterConfigFactory(deviceConfigFactory);
395 cfgService.unregisterConfigFactory(appConfigFactory);
Charles Chandebfea32016-10-24 14:52:01 -0700396 cfgService.unregisterConfigFactory(xConnectConfigFactory);
Charles Chanc91c8782016-03-30 17:54:24 -0700397 cfgService.unregisterConfigFactory(mcastConfigFactory);
Charles Chan72f556a2015-10-05 17:50:33 -0700398
sangho80f11cb2015-04-01 13:05:26 -0700399 packetService.removeProcessor(processor);
Charles Chan2b078ae2015-10-14 11:24:40 -0700400 linkService.removeListener(linkListener);
401 deviceService.removeListener(deviceListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700402 multicastRouteService.removeListener(mcastListener);
Charles Chan41f5ec02016-06-13 18:54:31 -0700403 cordConfigService.removeListener(cordConfigListener);
Charles Chandebfea32016-10-24 14:52:01 -0700404 routeService.removeListener(routeListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700405
sangho80f11cb2015-04-01 13:05:26 -0700406 processor = null;
Charles Chan2b078ae2015-10-14 11:24:40 -0700407 linkListener = null;
Charles Chanc91c8782016-03-30 17:54:24 -0700408 deviceListener = null;
Charles Chan2b078ae2015-10-14 11:24:40 -0700409 groupHandlerMap.clear();
410
Charles Chanc91c8782016-03-30 17:54:24 -0700411 nsNextObjStore.destroy();
412 subnetNextObjStore.destroy();
413 portNextObjStore.destroy();
Charles Chanc91c8782016-03-30 17:54:24 -0700414 tunnelStore.destroy();
415 policyStore.destroy();
416 subnetVidStore.destroy();
sangho80f11cb2015-04-01 13:05:26 -0700417 log.info("Stopped");
418 }
419
sangho27462c62015-05-14 00:39:53 -0700420 @Override
421 public List<Tunnel> getTunnels() {
422 return tunnelHandler.getTunnels();
423 }
424
425 @Override
sanghobd812f82015-06-29 14:58:47 -0700426 public TunnelHandler.Result createTunnel(Tunnel tunnel) {
427 return tunnelHandler.createTunnel(tunnel);
sangho27462c62015-05-14 00:39:53 -0700428 }
429
430 @Override
sanghobd812f82015-06-29 14:58:47 -0700431 public TunnelHandler.Result removeTunnel(Tunnel tunnel) {
sangho27462c62015-05-14 00:39:53 -0700432 for (Policy policy: policyHandler.getPolicies()) {
433 if (policy.type() == Policy.Type.TUNNEL_FLOW) {
434 TunnelPolicy tunnelPolicy = (TunnelPolicy) policy;
435 if (tunnelPolicy.tunnelId().equals(tunnel.id())) {
436 log.warn("Cannot remove the tunnel used by a policy");
sanghobd812f82015-06-29 14:58:47 -0700437 return TunnelHandler.Result.TUNNEL_IN_USE;
sangho27462c62015-05-14 00:39:53 -0700438 }
439 }
440 }
sanghobd812f82015-06-29 14:58:47 -0700441 return tunnelHandler.removeTunnel(tunnel);
sangho27462c62015-05-14 00:39:53 -0700442 }
443
444 @Override
sanghobd812f82015-06-29 14:58:47 -0700445 public PolicyHandler.Result removePolicy(Policy policy) {
446 return policyHandler.removePolicy(policy);
sangho27462c62015-05-14 00:39:53 -0700447 }
448
449 @Override
sanghobd812f82015-06-29 14:58:47 -0700450 public PolicyHandler.Result createPolicy(Policy policy) {
451 return policyHandler.createPolicy(policy);
sangho27462c62015-05-14 00:39:53 -0700452 }
453
454 @Override
455 public List<Policy> getPolicies() {
456 return policyHandler.getPolicies();
457 }
458
Saurav Das07c74602016-04-27 18:35:50 -0700459 @Override
460 public void rerouteNetwork() {
461 cfgListener.configureNetwork();
462 for (Device device : deviceService.getDevices()) {
463 defaultRoutingHandler.populatePortAddressingRules(device.id());
464 }
465 defaultRoutingHandler.startPopulationProcess();
466 }
467
Charles Chand7844e52016-10-20 17:02:44 -0700468 @Override
469 public Map<DeviceId, Set<Ip4Prefix>> getDeviceSubnetMap() {
470 Map<DeviceId, Set<Ip4Prefix>> deviceSubnetMap = Maps.newHashMap();
471 deviceService.getAvailableDevices().forEach(device -> {
472 deviceSubnetMap.put(device.id(), deviceConfiguration.getSubnets(device.id()));
473 });
474 return deviceSubnetMap;
475 }
476
sangho80f1f892015-05-19 11:57:42 -0700477 /**
Pier Ventre7a78de22016-10-31 15:00:01 -0700478 * Returns the MPLS-ECMP configuration.
479 *
480 * @return MPLS-ECMP value
481 */
482 public boolean getMplsEcmp() {
483 SegmentRoutingAppConfig segmentRoutingAppConfig = cfgService
484 .getConfig(this.appId, SegmentRoutingAppConfig.class);
485 return segmentRoutingAppConfig != null && segmentRoutingAppConfig.mplsEcmp();
486 }
487
488 /**
sangho80f1f892015-05-19 11:57:42 -0700489 * Returns the tunnel object with the tunnel ID.
490 *
491 * @param tunnelId Tunnel ID
492 * @return Tunnel reference
493 */
sangho27462c62015-05-14 00:39:53 -0700494 public Tunnel getTunnel(String tunnelId) {
495 return tunnelHandler.getTunnel(tunnelId);
496 }
497
sangho80f11cb2015-04-01 13:05:26 -0700498 /**
Saurav Das7c305372015-10-28 12:39:42 -0700499 * Returns the vlan-id assigned to the subnet configured for a device.
500 * If no vlan-id has been assigned, a new one is assigned out of a pool of ids,
501 * if and only if this controller instance is the master for the device.
502 * <p>
503 * USAGE: The assigned vlans are meant to be applied to untagged packets on those
504 * switches/pipelines that need this functionality. These vids are meant
505 * to be used internally within a switch, and thus need to be unique only
506 * on a switch level. Note that packets never go out on the wire with these
507 * vlans. Currently, vlan ids are assigned from value 4093 down.
508 * Vlan id 4094 expected to be used for all ports that are not assigned subnets.
509 * Vlan id 4095 is reserved and unused. Only a single vlan id is assigned
510 * per subnet.
sangho80f11cb2015-04-01 13:05:26 -0700511 *
Saurav Das7c305372015-10-28 12:39:42 -0700512 * @param deviceId switch dpid
513 * @param subnet IPv4 prefix for which assigned vlan is desired
514 * @return VlanId assigned for the subnet on the device, or
515 * null if no vlan assignment was found and this instance is not
516 * the master for the device.
sangho80f11cb2015-04-01 13:05:26 -0700517 */
Charles Chanb7f75ac2016-01-11 18:28:54 -0800518 // TODO: We should avoid assigning VLAN IDs that are used by VLAN cross-connection.
Saurav Das7c305372015-10-28 12:39:42 -0700519 public VlanId getSubnetAssignedVlanId(DeviceId deviceId, Ip4Prefix subnet) {
520 VlanId assignedVid = subnetVidStore.get(new SubnetAssignedVidStoreKey(
521 deviceId, subnet));
522 if (assignedVid != null) {
523 log.debug("Query for subnet:{} on device:{} returned assigned-vlan "
524 + "{}", subnet, deviceId, assignedVid);
525 return assignedVid;
526 }
527 //check mastership for the right to assign a vlan
528 if (!mastershipService.isLocalMaster(deviceId)) {
529 log.warn("This controller instance is not the master for device {}. "
530 + "Cannot assign vlan-id for subnet {}", deviceId, subnet);
531 return null;
532 }
533 // vlan assignment is expensive but done only once
Charles Chanc6ad7752015-10-29 14:58:10 -0700534 Set<Ip4Prefix> configuredSubnets = deviceConfiguration.getSubnets(deviceId);
Saurav Das7c305372015-10-28 12:39:42 -0700535 Set<Short> assignedVlans = new HashSet<>();
536 Set<Ip4Prefix> unassignedSubnets = new HashSet<>();
537 for (Ip4Prefix sub : configuredSubnets) {
538 VlanId v = subnetVidStore.get(new SubnetAssignedVidStoreKey(deviceId,
539 sub));
540 if (v != null) {
541 assignedVlans.add(v.toShort());
542 } else {
543 unassignedSubnets.add(sub);
544 }
545 }
546 short nextAssignedVlan = ASSIGNED_VLAN_START;
547 if (!assignedVlans.isEmpty()) {
548 nextAssignedVlan = (short) (Collections.min(assignedVlans) - 1);
549 }
550 for (Ip4Prefix unsub : unassignedSubnets) {
Charles Chan82ab1932016-01-30 23:22:37 -0800551 // Special case for default route. Assign default VLAN ID to /32 and /0 subnets
552 if (unsub.prefixLength() == IpPrefix.MAX_INET_MASK_LENGTH ||
553 unsub.prefixLength() == 0) {
554 subnetVidStore.put(new SubnetAssignedVidStoreKey(deviceId, unsub),
555 VlanId.vlanId(ASSIGNED_VLAN_NO_SUBNET));
556 } else {
557 subnetVidStore.put(new SubnetAssignedVidStoreKey(deviceId, unsub),
558 VlanId.vlanId(nextAssignedVlan--));
559 log.info("Assigned vlan: {} to subnet: {} on device: {}",
560 nextAssignedVlan + 1, unsub, deviceId);
561 }
sangho80f11cb2015-04-01 13:05:26 -0700562 }
563
Saurav Das7c305372015-10-28 12:39:42 -0700564 return subnetVidStore.get(new SubnetAssignedVidStoreKey(deviceId, subnet));
sangho80f11cb2015-04-01 13:05:26 -0700565 }
566
sangho27462c62015-05-14 00:39:53 -0700567 /**
Saurav Das7c305372015-10-28 12:39:42 -0700568 * Returns the next objective ID for the given NeighborSet.
Saurav Das4c35fc42015-11-20 15:27:53 -0800569 * If the nextObjective does not exist, a new one is created and
Saurav Das2d94d312015-11-24 23:21:05 -0800570 * its id is returned.
sangho27462c62015-05-14 00:39:53 -0700571 *
sangho80f1f892015-05-19 11:57:42 -0700572 * @param deviceId Device ID
573 * @param ns NegighborSet
Saurav Das4c35fc42015-11-20 15:27:53 -0800574 * @param meta metadata passed into the creation of a Next Objective
575 * @return next objective ID or -1 if an error was encountered during the
576 * creation of the nextObjective
sangho27462c62015-05-14 00:39:53 -0700577 */
Saurav Das4c35fc42015-11-20 15:27:53 -0800578 public int getNextObjectiveId(DeviceId deviceId, NeighborSet ns,
579 TrafficSelector meta) {
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700580 if (groupHandlerMap.get(deviceId) != null) {
581 log.trace("getNextObjectiveId query in device {}", deviceId);
582 return groupHandlerMap
Saurav Das4c35fc42015-11-20 15:27:53 -0800583 .get(deviceId).getNextObjectiveId(ns, meta);
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700584 } else {
Saurav Das2d94d312015-11-24 23:21:05 -0800585 log.warn("getNextObjectiveId query - groupHandler for device {} "
586 + "not found", deviceId);
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700587 return -1;
588 }
Srikanth Vavilapalli64505482015-04-21 13:04:13 -0700589 }
590
Charles Chan77277672015-10-20 16:24:19 -0700591 /**
Saurav Das2d94d312015-11-24 23:21:05 -0800592 * Returns the next objective ID for the given subnet prefix. It is expected
593 * that the next-objective has been pre-created from configuration.
Charles Chan77277672015-10-20 16:24:19 -0700594 *
595 * @param deviceId Device ID
596 * @param prefix Subnet
Saurav Das2d94d312015-11-24 23:21:05 -0800597 * @return next objective ID or -1 if it was not found
Charles Chan77277672015-10-20 16:24:19 -0700598 */
599 public int getSubnetNextObjectiveId(DeviceId deviceId, IpPrefix prefix) {
600 if (groupHandlerMap.get(deviceId) != null) {
601 log.trace("getSubnetNextObjectiveId query in device {}", deviceId);
602 return groupHandlerMap
603 .get(deviceId).getSubnetNextObjectiveId(prefix);
604 } else {
Saurav Das2d94d312015-11-24 23:21:05 -0800605 log.warn("getSubnetNextObjectiveId query - groupHandler for "
606 + "device {} not found", deviceId);
607 return -1;
608 }
609 }
610
611 /**
612 * Returns the next objective ID for the given portNumber, given the treatment.
613 * There could be multiple different treatments to the same outport, which
614 * would result in different objectives. If the next object
615 * does not exist, a new one is created and its id is returned.
616 *
617 * @param deviceId Device ID
618 * @param portNum port number on device for which NextObjective is queried
619 * @param treatment the actions to apply on the packets (should include outport)
620 * @param meta metadata passed into the creation of a Next Objective if necessary
Saurav Das07c74602016-04-27 18:35:50 -0700621 * @return next objective ID or -1 if an error occurred during retrieval or creation
Saurav Das2d94d312015-11-24 23:21:05 -0800622 */
623 public int getPortNextObjectiveId(DeviceId deviceId, PortNumber portNum,
624 TrafficTreatment treatment,
625 TrafficSelector meta) {
626 DefaultGroupHandler ghdlr = groupHandlerMap.get(deviceId);
627 if (ghdlr != null) {
628 return ghdlr.getPortNextObjectiveId(portNum, treatment, meta);
629 } else {
Charles Chanb7f75ac2016-01-11 18:28:54 -0800630 log.warn("getPortNextObjectiveId query - groupHandler for device {}"
631 + " not found", deviceId);
632 return -1;
633 }
634 }
635
sangho80f11cb2015-04-01 13:05:26 -0700636 private class InternalPacketProcessor implements PacketProcessor {
sangho80f11cb2015-04-01 13:05:26 -0700637 @Override
638 public void process(PacketContext context) {
639
640 if (context.isHandled()) {
641 return;
642 }
643
644 InboundPacket pkt = context.inPacket();
645 Ethernet ethernet = pkt.parsed();
Saurav Das2d94d312015-11-24 23:21:05 -0800646 log.trace("Rcvd pktin: {}", ethernet);
sangho80f11cb2015-04-01 13:05:26 -0700647 if (ethernet.getEtherType() == Ethernet.TYPE_ARP) {
648 arpHandler.processPacketIn(pkt);
649 } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
650 IPv4 ipPacket = (IPv4) ethernet.getPayload();
Charles Chand041ad82017-01-13 17:20:44 -0800651 // ipHandler.addToPacketBuffer(ipPacket);
sangho80f11cb2015-04-01 13:05:26 -0700652 if (ipPacket.getProtocol() == IPv4.PROTOCOL_ICMP) {
653 icmpHandler.processPacketIn(pkt);
654 } else {
Charles Chand041ad82017-01-13 17:20:44 -0800655 // NOTE: We don't support IP learning at this moment so this
656 // is not necessary. Also it causes duplication of DHCP packets.
657 // ipHandler.processPacketIn(pkt);
sangho80f11cb2015-04-01 13:05:26 -0700658 }
659 }
660 }
661 }
662
663 private class InternalLinkListener implements LinkListener {
664 @Override
665 public void event(LinkEvent event) {
Srikanth Vavilapalli64505482015-04-21 13:04:13 -0700666 if (event.type() == LinkEvent.Type.LINK_ADDED
667 || event.type() == LinkEvent.Type.LINK_REMOVED) {
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700668 log.debug("Event {} received from Link Service", event.type());
sangho80f11cb2015-04-01 13:05:26 -0700669 scheduleEventHandlerIfNotScheduled(event);
670 }
671 }
672 }
673
674 private class InternalDeviceListener implements DeviceListener {
sangho80f11cb2015-04-01 13:05:26 -0700675 @Override
676 public void event(DeviceEvent event) {
sangho80f11cb2015-04-01 13:05:26 -0700677 switch (event.type()) {
678 case DEVICE_ADDED:
Saurav Dasf0f592d2016-11-18 15:21:57 -0800679 case PORT_UPDATED:
680 case PORT_ADDED:
sanghofb7c7292015-04-13 15:15:58 -0700681 case DEVICE_UPDATED:
682 case DEVICE_AVAILABILITY_CHANGED:
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700683 log.debug("Event {} received from Device Service", event.type());
sangho80f11cb2015-04-01 13:05:26 -0700684 scheduleEventHandlerIfNotScheduled(event);
685 break;
686 default:
687 }
688 }
689 }
690
Saurav Das2d94d312015-11-24 23:21:05 -0800691 @SuppressWarnings("rawtypes")
sangho80f11cb2015-04-01 13:05:26 -0700692 private void scheduleEventHandlerIfNotScheduled(Event event) {
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700693 synchronized (threadSchedulerLock) {
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700694 eventQueue.add(event);
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700695 numOfEventsQueued++;
696
697 if ((numOfHandlerScheduled - numOfHandlerExecution) == 0) {
698 //No pending scheduled event handling threads. So start a new one.
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700699 eventHandlerFuture = executorService
700 .schedule(eventHandler, 100, TimeUnit.MILLISECONDS);
701 numOfHandlerScheduled++;
702 }
Jonathan Hart54541d12016-04-12 15:39:44 -0700703 log.trace("numOfEventsQueued {}, numOfEventHandlerScheduled {}",
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700704 numOfEventsQueued,
705 numOfHandlerScheduled);
sangho80f11cb2015-04-01 13:05:26 -0700706 }
sangho80f11cb2015-04-01 13:05:26 -0700707 }
708
709 private class InternalEventHandler implements Runnable {
Srikanth Vavilapalli37a461b2015-04-07 15:12:32 -0700710 @Override
sangho80f11cb2015-04-01 13:05:26 -0700711 public void run() {
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700712 try {
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700713 while (true) {
Saurav Das2d94d312015-11-24 23:21:05 -0800714 @SuppressWarnings("rawtypes")
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700715 Event event = null;
716 synchronized (threadSchedulerLock) {
717 if (!eventQueue.isEmpty()) {
718 event = eventQueue.poll();
719 numOfEventsExecuted++;
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700720 } else {
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700721 numOfHandlerExecution++;
722 log.debug("numOfHandlerExecution {} numOfEventsExecuted {}",
723 numOfHandlerExecution, numOfEventsExecuted);
724 break;
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700725 }
sanghofb7c7292015-04-13 15:15:58 -0700726 }
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700727 if (event.type() == LinkEvent.Type.LINK_ADDED) {
728 processLinkAdded((Link) event.subject());
729 } else if (event.type() == LinkEvent.Type.LINK_REMOVED) {
Pier Ventre6d593892016-09-13 21:33:40 -0700730 Link linkRemoved = (Link) event.subject();
731 if (linkRemoved.src().elementId() instanceof DeviceId &&
732 !deviceService.isAvailable(linkRemoved.src().deviceId())) {
733 continue;
734 }
735 if (linkRemoved.dst().elementId() instanceof DeviceId &&
736 !deviceService.isAvailable(linkRemoved.dst().deviceId())) {
737 continue;
738 }
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700739 processLinkRemoved((Link) event.subject());
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700740 } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED ||
741 event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
742 event.type() == DeviceEvent.Type.DEVICE_UPDATED) {
Saurav Das62af8802015-12-04 10:52:59 -0800743 DeviceId deviceId = ((Device) event.subject()).id();
744 if (deviceService.isAvailable(deviceId)) {
Saurav Dasc28b3432015-10-30 17:45:38 -0700745 log.info("Processing device event {} for available device {}",
746 event.type(), ((Device) event.subject()).id());
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700747 processDeviceAdded((Device) event.subject());
Saurav Dasc3604f12016-03-23 11:22:49 -0700748 } else {
749 log.info("Processing device event {} for unavailable device {}",
750 event.type(), ((Device) event.subject()).id());
751 processDeviceRemoved((Device) event.subject());
752 }
Saurav Dasf0f592d2016-11-18 15:21:57 -0800753 } else if (event.type() == DeviceEvent.Type.PORT_ADDED) {
Saurav Dasd1872b02016-12-02 15:43:47 -0800754 // typically these calls come when device is added first time
755 // so port filtering rules are handled at the device_added event.
756 // port added calls represent all ports on the device,
757 // enabled or not.
Saurav Dasf0f592d2016-11-18 15:21:57 -0800758 log.debug("** PORT ADDED {}/{} -> {}",
Saurav Dasd1872b02016-12-02 15:43:47 -0800759 ((DeviceEvent) event).subject().id(),
760 ((DeviceEvent) event).port().number(),
761 event.type());
Saurav Dasf0f592d2016-11-18 15:21:57 -0800762 } else if (event.type() == DeviceEvent.Type.PORT_UPDATED) {
Saurav Dasd1872b02016-12-02 15:43:47 -0800763 // these calls happen for every subsequent event
764 // ports enabled, disabled, switch goes away, comes back
Saurav Dasf0f592d2016-11-18 15:21:57 -0800765 log.info("** PORT UPDATED {}/{} -> {}",
766 event.subject(),
767 ((DeviceEvent) event).port(),
768 event.type());
769 processPortUpdated(((Device) event.subject()),
770 ((DeviceEvent) event).port());
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700771 } else {
772 log.warn("Unhandled event type: {}", event.type());
773 }
sangho80f11cb2015-04-01 13:05:26 -0700774 }
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700775 } catch (Exception e) {
776 log.error("SegmentRouting event handler "
777 + "thread thrown an exception: {}", e);
sangho80f11cb2015-04-01 13:05:26 -0700778 }
sangho80f11cb2015-04-01 13:05:26 -0700779 }
780 }
781
sangho80f11cb2015-04-01 13:05:26 -0700782 private void processLinkAdded(Link link) {
Saurav Dasb149be12016-06-07 10:08:06 -0700783 log.info("** LINK ADDED {}", link.toString());
Charles Chan319d1a22015-11-03 10:42:14 -0800784 if (!deviceConfiguration.isConfigured(link.src().deviceId())) {
785 log.warn("Source device of this link is not configured.");
786 return;
787 }
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700788 //Irrespective whether the local is a MASTER or not for this device,
789 //create group handler instance and push default TTP flow rules.
790 //Because in a multi-instance setup, instances can initiate
791 //groups for any devices. Also the default TTP rules are needed
792 //to be pushed before inserting any IP table entries for any device
793 DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src()
794 .deviceId());
795 if (groupHandler != null) {
Saurav Das4c35fc42015-11-20 15:27:53 -0800796 groupHandler.linkUp(link, mastershipService.isLocalMaster(
797 link.src().deviceId()));
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700798 } else {
799 Device device = deviceService.getDevice(link.src().deviceId());
800 if (device != null) {
801 log.warn("processLinkAdded: Link Added "
802 + "Notification without Device Added "
803 + "event, still handling it");
804 processDeviceAdded(device);
805 groupHandler = groupHandlerMap.get(link.src()
806 .deviceId());
Saurav Das4c35fc42015-11-20 15:27:53 -0800807 groupHandler.linkUp(link, mastershipService.isLocalMaster(device.id()));
sangho80f11cb2015-04-01 13:05:26 -0700808 }
809 }
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700810
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700811 log.trace("Starting optimized route population process");
812 defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(null);
813 //log.trace("processLinkAdded: re-starting route population process");
814 //defaultRoutingHandler.startPopulationProcess();
Charles Chan72779502016-04-23 17:36:10 -0700815
816 mcastHandler.init();
sangho80f11cb2015-04-01 13:05:26 -0700817 }
818
819 private void processLinkRemoved(Link link) {
Saurav Dasb149be12016-06-07 10:08:06 -0700820 log.info("** LINK REMOVED {}", link.toString());
sangho2165d222015-05-01 09:38:25 -0700821 DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src().deviceId());
822 if (groupHandler != null) {
Saurav Das62af8802015-12-04 10:52:59 -0800823 groupHandler.portDown(link.src().port(),
824 mastershipService.isLocalMaster(link.src().deviceId()));
sangho2165d222015-05-01 09:38:25 -0700825 }
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -0700826 log.trace("Starting optimized route population process");
827 defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(link);
828 //log.trace("processLinkRemoved: re-starting route population process");
829 //defaultRoutingHandler.startPopulationProcess();
Charles Chan72779502016-04-23 17:36:10 -0700830
831 mcastHandler.processLinkDown(link);
sangho80f11cb2015-04-01 13:05:26 -0700832 }
833
834 private void processDeviceAdded(Device device) {
Saurav Dasb149be12016-06-07 10:08:06 -0700835 log.info("** DEVICE ADDED with ID {}", device.id());
Charles Chan319d1a22015-11-03 10:42:14 -0800836 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
Saurav Das8ec0ec42015-11-03 14:39:27 -0800837 log.warn("Device configuration uploading. Device {} will be "
838 + "processed after config completes.", device.id());
839 return;
840 }
Charles Chan72779502016-04-23 17:36:10 -0700841 processDeviceAddedInternal(device.id());
842 }
843
844 private void processDeviceAddedInternal(DeviceId deviceId) {
Saurav Dasc28b3432015-10-30 17:45:38 -0700845 // Irrespective of whether the local is a MASTER or not for this device,
846 // we need to create a SR-group-handler instance. This is because in a
847 // multi-instance setup, any instance can initiate forwarding/next-objectives
848 // for any switch (even if this instance is a SLAVE or not even connected
849 // to the switch). To handle this, a default-group-handler instance is necessary
850 // per switch.
Charles Chan72779502016-04-23 17:36:10 -0700851 log.debug("Current groupHandlerMap devs: {}", groupHandlerMap.keySet());
852 if (groupHandlerMap.get(deviceId) == null) {
Charles Chan319d1a22015-11-03 10:42:14 -0800853 DefaultGroupHandler groupHandler;
854 try {
855 groupHandler = DefaultGroupHandler.
Charles Chan72779502016-04-23 17:36:10 -0700856 createGroupHandler(deviceId,
857 appId,
858 deviceConfiguration,
859 linkService,
860 flowObjectiveService,
861 this);
Charles Chan319d1a22015-11-03 10:42:14 -0800862 } catch (DeviceConfigNotFoundException e) {
863 log.warn(e.getMessage() + " Aborting processDeviceAdded.");
864 return;
865 }
Charles Chan72779502016-04-23 17:36:10 -0700866 log.debug("updating groupHandlerMap with new config for device: {}",
867 deviceId);
868 groupHandlerMap.put(deviceId, groupHandler);
Saurav Das8ec0ec42015-11-03 14:39:27 -0800869 }
Saurav Dasb149be12016-06-07 10:08:06 -0700870 // Also, in some cases, drivers may need extra
871 // information to process rules (eg. Router IP/MAC); and so, we send
872 // port addressing rules to the driver as well irrespective of whether
873 // this instance is the master or not.
874 defaultRoutingHandler.populatePortAddressingRules(deviceId);
875
Charles Chan72779502016-04-23 17:36:10 -0700876 if (mastershipService.isLocalMaster(deviceId)) {
Charles Chandebfea32016-10-24 14:52:01 -0700877 hostHandler.init(deviceId);
Charles Chan82f19972016-05-17 13:13:55 -0700878 xConnectHandler.init(deviceId);
Charles Chan41f5ec02016-06-13 18:54:31 -0700879 cordConfigHandler.init(deviceId);
Charles Chan72779502016-04-23 17:36:10 -0700880 DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId);
Charles Chan77277672015-10-20 16:24:19 -0700881 groupHandler.createGroupsFromSubnetConfig();
Charles Chan72779502016-04-23 17:36:10 -0700882 routingRulePopulator.populateSubnetBroadcastRule(deviceId);
Charles Chan77277672015-10-20 16:24:19 -0700883 }
Charles Chan82ab1932016-01-30 23:22:37 -0800884
Charles Chandebfea32016-10-24 14:52:01 -0700885 appCfgHandler.init(deviceId);
886 routeHandler.init(deviceId);
sangho80f11cb2015-04-01 13:05:26 -0700887 }
888
Saurav Dasc3604f12016-03-23 11:22:49 -0700889 private void processDeviceRemoved(Device device) {
890 nsNextObjStore.entrySet().stream()
891 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
892 .forEach(entry -> {
893 nsNextObjStore.remove(entry.getKey());
894 });
Saurav Dasc3604f12016-03-23 11:22:49 -0700895 subnetNextObjStore.entrySet().stream()
896 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
897 .forEach(entry -> {
898 subnetNextObjStore.remove(entry.getKey());
899 });
Saurav Dasc3604f12016-03-23 11:22:49 -0700900 portNextObjStore.entrySet().stream()
901 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
902 .forEach(entry -> {
903 portNextObjStore.remove(entry.getKey());
904 });
Saurav Dasc3604f12016-03-23 11:22:49 -0700905 subnetVidStore.entrySet().stream()
906 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
907 .forEach(entry -> {
908 subnetVidStore.remove(entry.getKey());
909 });
Saurav Dasc3604f12016-03-23 11:22:49 -0700910 groupHandlerMap.remove(device.id());
Saurav Dasc3604f12016-03-23 11:22:49 -0700911 defaultRoutingHandler.purgeEcmpGraph(device.id());
Charles Chan72779502016-04-23 17:36:10 -0700912 mcastHandler.removeDevice(device.id());
Charles Chan82f19972016-05-17 13:13:55 -0700913 xConnectHandler.removeDevice(device.id());
Saurav Dasc3604f12016-03-23 11:22:49 -0700914 }
915
Saurav Dasf0f592d2016-11-18 15:21:57 -0800916 private void processPortUpdated(Device device, Port port) {
917 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
918 log.warn("Device configuration uploading. Not handling port event for"
919 + "dev: {} port: {}", device.id(), port.number());
920 return;
921 }
922 /* XXX create method for single port filtering rules which are needed
923 for both switch-to-switch ports and edge ports
924 if (defaultRoutingHandler != null) {
925 defaultRoutingHandler.populatePortAddressingRules(
926 ((Device) event.subject()).id());
927 }*/
928
929 // portUpdated calls are for ports that have gone down or up. For switch
930 // to switch ports, link-events should take care of any re-routing or
931 // group editing necessary for port up/down. Here we only process edge ports
932 // that are already configured.
933 Ip4Prefix configuredSubnet = deviceConfiguration.getPortSubnet(device.id(),
934 port.number());
935 if (configuredSubnet == null) {
936 log.debug("Not handling port updated event for unconfigured port "
937 + "dev/port: {}/{}", device.id(), port.number());
938 return;
939 }
940 processEdgePort(device, port, configuredSubnet);
941 }
942
943 private void processEdgePort(Device device, Port port, Ip4Prefix subnet) {
944 boolean portUp = port.isEnabled();
945 if (portUp) {
946 log.info("Device:EdgePort {}:{} is enabled in subnet: {}", device.id(),
947 port.number(), subnet);
948 } else {
949 log.info("Device:EdgePort {}:{} is disabled in subnet: {}", device.id(),
950 port.number(), subnet);
951 }
952
Srikanth Vavilapalli64505482015-04-21 13:04:13 -0700953 DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id());
sangho80f11cb2015-04-01 13:05:26 -0700954 if (groupHandler != null) {
Saurav Dasf0f592d2016-11-18 15:21:57 -0800955 groupHandler.processEdgePort(port.number(), subnet, portUp,
Saurav Das62af8802015-12-04 10:52:59 -0800956 mastershipService.isLocalMaster(device.id()));
Saurav Dasf0f592d2016-11-18 15:21:57 -0800957 } else {
958 log.warn("Group handler not found for dev:{}. Not handling edge port"
959 + " {} event for port:{}", device.id(),
960 (portUp) ? "UP" : "DOWN", port.number());
sangho80f11cb2015-04-01 13:05:26 -0700961 }
962 }
sangho27462c62015-05-14 00:39:53 -0700963
Charles Chan72f556a2015-10-05 17:50:33 -0700964 private class InternalConfigListener implements NetworkConfigListener {
Charles Chan46fdfaf2016-11-09 20:51:44 -0800965 SegmentRoutingManager srManager;
Charles Chane7c61022015-10-07 14:21:45 -0700966
Charles Chanb7f75ac2016-01-11 18:28:54 -0800967 /**
968 * Constructs the internal network config listener.
969 *
Charles Chan46fdfaf2016-11-09 20:51:44 -0800970 * @param srManager segment routing manager
Charles Chanb7f75ac2016-01-11 18:28:54 -0800971 */
Charles Chan46fdfaf2016-11-09 20:51:44 -0800972 public InternalConfigListener(SegmentRoutingManager srManager) {
973 this.srManager = srManager;
Charles Chane7c61022015-10-07 14:21:45 -0700974 }
975
Charles Chanb7f75ac2016-01-11 18:28:54 -0800976 /**
977 * Reads network config and initializes related data structure accordingly.
978 */
Charles Chane7c61022015-10-07 14:21:45 -0700979 public void configureNetwork() {
Charles Chan46fdfaf2016-11-09 20:51:44 -0800980 deviceConfiguration = new DeviceConfiguration(srManager);
Charles Chane7c61022015-10-07 14:21:45 -0700981
Charles Chan46fdfaf2016-11-09 20:51:44 -0800982 arpHandler = new ArpHandler(srManager);
983 icmpHandler = new IcmpHandler(srManager);
984 ipHandler = new IpHandler(srManager);
985 routingRulePopulator = new RoutingRulePopulator(srManager);
986 defaultRoutingHandler = new DefaultRoutingHandler(srManager);
Charles Chane7c61022015-10-07 14:21:45 -0700987
988 tunnelHandler = new TunnelHandler(linkService, deviceConfiguration,
989 groupHandlerMap, tunnelStore);
990 policyHandler = new PolicyHandler(appId, deviceConfiguration,
991 flowObjectiveService,
992 tunnelHandler, policyStore);
993
Charles Chane7c61022015-10-07 14:21:45 -0700994 for (Device device : deviceService.getDevices()) {
Charles Chan72779502016-04-23 17:36:10 -0700995 processDeviceAddedInternal(device.id());
Charles Chane7c61022015-10-07 14:21:45 -0700996 }
997
998 defaultRoutingHandler.startPopulationProcess();
Charles Chan72779502016-04-23 17:36:10 -0700999 mcastHandler.init();
Charles Chane7c61022015-10-07 14:21:45 -07001000 }
1001
Charles Chan72f556a2015-10-05 17:50:33 -07001002 @Override
1003 public void event(NetworkConfigEvent event) {
Charles Chan82ab1932016-01-30 23:22:37 -08001004 // TODO move this part to NetworkConfigEventHandler
1005 if (event.configClass().equals(SegmentRoutingDeviceConfig.class)) {
1006 switch (event.type()) {
1007 case CONFIG_ADDED:
1008 log.info("Segment Routing Config added.");
1009 configureNetwork();
1010 break;
1011 case CONFIG_UPDATED:
1012 log.info("Segment Routing Config updated.");
1013 // TODO support dynamic configuration
1014 break;
1015 default:
1016 break;
Charles Chan2b078ae2015-10-14 11:24:40 -07001017 }
Charles Chan82ab1932016-01-30 23:22:37 -08001018 } else if (event.configClass().equals(SegmentRoutingAppConfig.class)) {
Charles Chan82f19972016-05-17 13:13:55 -07001019 checkState(appCfgHandler != null, "NetworkConfigEventHandler is not initialized");
Charles Chan82ab1932016-01-30 23:22:37 -08001020 switch (event.type()) {
1021 case CONFIG_ADDED:
Charles Chan82f19972016-05-17 13:13:55 -07001022 appCfgHandler.processAppConfigAdded(event);
Charles Chan82ab1932016-01-30 23:22:37 -08001023 break;
1024 case CONFIG_UPDATED:
Charles Chan82f19972016-05-17 13:13:55 -07001025 appCfgHandler.processAppConfigUpdated(event);
Charles Chan82ab1932016-01-30 23:22:37 -08001026 break;
1027 case CONFIG_REMOVED:
Charles Chan82f19972016-05-17 13:13:55 -07001028 appCfgHandler.processAppConfigRemoved(event);
1029 break;
1030 default:
1031 break;
1032 }
Charles Chandebfea32016-10-24 14:52:01 -07001033 configureNetwork();
Charles Chan82f19972016-05-17 13:13:55 -07001034 } else if (event.configClass().equals(XConnectConfig.class)) {
1035 checkState(xConnectHandler != null, "XConnectHandler is not initialized");
1036 switch (event.type()) {
1037 case CONFIG_ADDED:
1038 xConnectHandler.processXConnectConfigAdded(event);
1039 break;
1040 case CONFIG_UPDATED:
1041 xConnectHandler.processXConnectConfigUpdated(event);
1042 break;
1043 case CONFIG_REMOVED:
1044 xConnectHandler.processXConnectConfigRemoved(event);
Charles Chan82ab1932016-01-30 23:22:37 -08001045 break;
1046 default:
1047 break;
Charles Chan2b078ae2015-10-14 11:24:40 -07001048 }
Charles Chan72f556a2015-10-05 17:50:33 -07001049 }
1050 }
1051 }
Charles Chanf4586112015-11-09 16:37:23 -08001052
1053 private class InternalHostListener implements HostListener {
Charles Chanf4586112015-11-09 16:37:23 -08001054 @Override
1055 public void event(HostEvent event) {
1056 // Do not proceed without mastership
1057 DeviceId deviceId = event.subject().location().deviceId();
1058 if (!mastershipService.isLocalMaster(deviceId)) {
1059 return;
1060 }
1061
1062 switch (event.type()) {
1063 case HOST_ADDED:
Charles Chan1eaf4802016-04-18 13:44:03 -07001064 hostHandler.processHostAddedEvent(event);
Charles Chanf4586112015-11-09 16:37:23 -08001065 break;
1066 case HOST_MOVED:
Charles Chan1eaf4802016-04-18 13:44:03 -07001067 hostHandler.processHostMovedEvent(event);
Charles Chanf4586112015-11-09 16:37:23 -08001068 break;
1069 case HOST_REMOVED:
Charles Chan1eaf4802016-04-18 13:44:03 -07001070 hostHandler.processHostRemoveEvent(event);
Charles Chanf4586112015-11-09 16:37:23 -08001071 break;
1072 case HOST_UPDATED:
Charles Chan1eaf4802016-04-18 13:44:03 -07001073 hostHandler.processHostUpdatedEvent(event);
Charles Chanf4586112015-11-09 16:37:23 -08001074 break;
1075 default:
1076 log.warn("Unsupported host event type: {}", event.type());
1077 break;
1078 }
1079 }
1080 }
1081
Charles Chanc91c8782016-03-30 17:54:24 -07001082 private class InternalMcastListener implements McastListener {
1083 @Override
1084 public void event(McastEvent event) {
1085 switch (event.type()) {
1086 case SOURCE_ADDED:
Charles Chan1eaf4802016-04-18 13:44:03 -07001087 mcastHandler.processSourceAdded(event);
Charles Chanc91c8782016-03-30 17:54:24 -07001088 break;
1089 case SINK_ADDED:
Charles Chan1eaf4802016-04-18 13:44:03 -07001090 mcastHandler.processSinkAdded(event);
Charles Chanc91c8782016-03-30 17:54:24 -07001091 break;
1092 case SINK_REMOVED:
Charles Chan1eaf4802016-04-18 13:44:03 -07001093 mcastHandler.processSinkRemoved(event);
Charles Chanc91c8782016-03-30 17:54:24 -07001094 break;
1095 case ROUTE_ADDED:
1096 case ROUTE_REMOVED:
1097 default:
1098 break;
1099 }
1100 }
1101 }
Charles Chan41f5ec02016-06-13 18:54:31 -07001102
1103 private class InternalCordConfigListener implements CordConfigListener {
1104 @Override
1105 public void event(CordConfigEvent event) {
1106 switch (event.type()) {
1107 case ACCESS_AGENT_ADDED:
1108 cordConfigHandler.processAccessAgentAddedEvent(event);
1109 break;
1110 case ACCESS_AGENT_UPDATED:
1111 cordConfigHandler.processAccessAgentUpdatedEvent(event);
1112 break;
1113 case ACCESS_AGENT_REMOVED:
1114 cordConfigHandler.processAccessAgentRemovedEvent(event);
1115 break;
1116 case ACCESS_DEVICE_ADDED:
1117 case ACCESS_DEVICE_UPDATED:
1118 case ACCESS_DEVICE_REMOVED:
1119 default:
1120 break;
1121 }
1122 }
1123 }
Charles Chandebfea32016-10-24 14:52:01 -07001124
1125 private class InternalRouteEventListener implements RouteListener {
1126 @Override
1127 public void event(RouteEvent event) {
1128 switch (event.type()) {
1129 case ROUTE_ADDED:
1130 routeHandler.processRouteAdded(event);
1131 break;
1132 case ROUTE_UPDATED:
1133 routeHandler.processRouteUpdated(event);
1134 break;
1135 case ROUTE_REMOVED:
1136 routeHandler.processRouteRemoved(event);
1137 break;
1138 default:
1139 break;
1140 }
1141 }
1142 }
sangho80f11cb2015-04-01 13:05:26 -07001143}