blob: 12c52bf2e14bfc2ad8a285851b4b1f617151ac39 [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;
Ray Milkey69ec8712017-08-08 13:00:43 -070043import org.onosproject.routeservice.RouteEvent;
44import org.onosproject.routeservice.RouteListener;
45import org.onosproject.routeservice.RouteService;
Ray Milkeyb65d7842017-08-03 16:28:24 -070046import org.onosproject.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");
Charles Chand3baaba2017-08-08 15:13:37 -0700363 compCfgService.preSetProperty("org.onosproject.net.neighbour.impl.NeighbourResolutionManager",
Pier Luigi7e415132017-01-12 22:46:39 -0800364 "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 Chanef624ed2017-08-10 16:57:28 -0700371 compCfgService.preSetProperty("org.onosproject.routeservice.store.RouteStoreImpl",
Charles Chan73316522017-07-20 16:16:25 -0700372 "distributed", "true");
Charles Chan35a32322017-08-14 11:42:11 -0700373 compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider",
374 "multihomingEnabled", "true");
Saurav Das80980c72016-03-23 11:22:49 -0700375
Charles Chanb8e10c82015-10-14 11:24:40 -0700376 processor = new InternalPacketProcessor();
377 linkListener = new InternalLinkListener();
378 deviceListener = new InternalDeviceListener();
Charles Chanfc5c7802016-05-17 13:13:55 -0700379 appCfgHandler = new AppConfigHandler(this);
380 xConnectHandler = new XConnectHandler(this);
Charles Chand2990362016-04-18 13:44:03 -0700381 mcastHandler = new McastHandler(this);
382 hostHandler = new HostHandler(this);
Charles Chan03a73e02016-10-24 14:52:01 -0700383 routeHandler = new RouteHandler(this);
Pier Ventre735b8c82016-12-02 08:16:05 -0800384 neighbourHandler = new SegmentRoutingNeighbourDispatcher(this);
Pier Ventref34966c2016-11-07 16:21:04 -0800385 l2TunnelHandler = new L2TunnelHandler(this);
Charles Chanb8e10c82015-10-14 11:24:40 -0700386
Charles Chan3e783d02016-02-26 22:19:52 -0800387 cfgService.addListener(cfgListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700388 cfgService.registerConfigFactory(deviceConfigFactory);
389 cfgService.registerConfigFactory(appConfigFactory);
Charles Chanfc5c7802016-05-17 13:13:55 -0700390 cfgService.registerConfigFactory(xConnectConfigFactory);
Charles Chand55e84d2016-03-30 17:54:24 -0700391 cfgService.registerConfigFactory(mcastConfigFactory);
Pier Ventref34966c2016-11-07 16:21:04 -0800392 cfgService.registerConfigFactory(pwaasConfigFactory);
Charles Chan5270ed02016-01-30 23:22:37 -0800393 hostService.addListener(hostListener);
Charles Chanb8e10c82015-10-14 11:24:40 -0700394 packetService.addProcessor(processor, PacketProcessor.director(2));
395 linkService.addListener(linkListener);
396 deviceService.addListener(deviceListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700397 multicastRouteService.addListener(mcastListener);
Charles Chanc7a8a682017-06-19 00:43:31 -0700398 routeService.addListener(routeListener);
Charles Chanb8e10c82015-10-14 11:24:40 -0700399
400 cfgListener.configureNetwork();
401
sanghob35a6192015-04-01 13:05:26 -0700402 log.info("Started");
403 }
404
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700405 private KryoNamespace.Builder createSerializer() {
406 return new KryoNamespace.Builder()
407 .register(KryoNamespaces.API)
Saurav Das7bcbe702017-06-13 15:35:54 -0700408 .register(DestinationSetNextObjectiveStoreKey.class,
Charles Chan59cc16d2017-02-02 16:20:42 -0800409 VlanNextObjectiveStoreKey.class,
Saurav Das7bcbe702017-06-13 15:35:54 -0700410 DestinationSet.class,
411 NextNeighbors.class,
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700412 Tunnel.class,
413 DefaultTunnel.class,
414 Policy.class,
415 TunnelPolicy.class,
416 Policy.Type.class,
417 PortNextObjectiveStoreKey.class,
Charles Chanfc5c7802016-05-17 13:13:55 -0700418 XConnectStoreKey.class
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700419 );
420 }
421
sanghob35a6192015-04-01 13:05:26 -0700422 @Deactivate
423 protected void deactivate() {
Charles Chand6832882015-10-05 17:50:33 -0700424 cfgService.removeListener(cfgListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700425 cfgService.unregisterConfigFactory(deviceConfigFactory);
426 cfgService.unregisterConfigFactory(appConfigFactory);
Charles Chan03a73e02016-10-24 14:52:01 -0700427 cfgService.unregisterConfigFactory(xConnectConfigFactory);
Charles Chand55e84d2016-03-30 17:54:24 -0700428 cfgService.unregisterConfigFactory(mcastConfigFactory);
Pier Ventref34966c2016-11-07 16:21:04 -0800429 cfgService.unregisterConfigFactory(pwaasConfigFactory);
Charles Chand6832882015-10-05 17:50:33 -0700430
Charles Chanc7a8a682017-06-19 00:43:31 -0700431 hostService.removeListener(hostListener);
sanghob35a6192015-04-01 13:05:26 -0700432 packetService.removeProcessor(processor);
Charles Chanb8e10c82015-10-14 11:24:40 -0700433 linkService.removeListener(linkListener);
434 deviceService.removeListener(deviceListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700435 multicastRouteService.removeListener(mcastListener);
Charles Chan03a73e02016-10-24 14:52:01 -0700436 routeService.removeListener(routeListener);
Charles Chand55e84d2016-03-30 17:54:24 -0700437
Charles Chan0aa674e2017-02-23 15:44:08 -0800438 neighbourResolutionService.unregisterNeighbourHandlers(appId);
439
sanghob35a6192015-04-01 13:05:26 -0700440 processor = null;
Charles Chanb8e10c82015-10-14 11:24:40 -0700441 linkListener = null;
Charles Chand55e84d2016-03-30 17:54:24 -0700442 deviceListener = null;
Charles Chanb8e10c82015-10-14 11:24:40 -0700443 groupHandlerMap.clear();
444
Saurav Das7bcbe702017-06-13 15:35:54 -0700445 dsNextObjStore.destroy();
Charles Chan59cc16d2017-02-02 16:20:42 -0800446 vlanNextObjStore.destroy();
Charles Chand55e84d2016-03-30 17:54:24 -0700447 portNextObjStore.destroy();
Charles Chand55e84d2016-03-30 17:54:24 -0700448 tunnelStore.destroy();
449 policyStore.destroy();
sanghob35a6192015-04-01 13:05:26 -0700450 log.info("Stopped");
451 }
452
sangho1e575652015-05-14 00:39:53 -0700453 @Override
454 public List<Tunnel> getTunnels() {
455 return tunnelHandler.getTunnels();
456 }
457
458 @Override
sangho71abe1b2015-06-29 14:58:47 -0700459 public TunnelHandler.Result createTunnel(Tunnel tunnel) {
460 return tunnelHandler.createTunnel(tunnel);
sangho1e575652015-05-14 00:39:53 -0700461 }
462
463 @Override
sangho71abe1b2015-06-29 14:58:47 -0700464 public TunnelHandler.Result removeTunnel(Tunnel tunnel) {
sangho1e575652015-05-14 00:39:53 -0700465 for (Policy policy: policyHandler.getPolicies()) {
466 if (policy.type() == Policy.Type.TUNNEL_FLOW) {
467 TunnelPolicy tunnelPolicy = (TunnelPolicy) policy;
468 if (tunnelPolicy.tunnelId().equals(tunnel.id())) {
469 log.warn("Cannot remove the tunnel used by a policy");
sangho71abe1b2015-06-29 14:58:47 -0700470 return TunnelHandler.Result.TUNNEL_IN_USE;
sangho1e575652015-05-14 00:39:53 -0700471 }
472 }
473 }
sangho71abe1b2015-06-29 14:58:47 -0700474 return tunnelHandler.removeTunnel(tunnel);
sangho1e575652015-05-14 00:39:53 -0700475 }
476
477 @Override
sangho71abe1b2015-06-29 14:58:47 -0700478 public PolicyHandler.Result removePolicy(Policy policy) {
479 return policyHandler.removePolicy(policy);
sangho1e575652015-05-14 00:39:53 -0700480 }
481
482 @Override
sangho71abe1b2015-06-29 14:58:47 -0700483 public PolicyHandler.Result createPolicy(Policy policy) {
484 return policyHandler.createPolicy(policy);
sangho1e575652015-05-14 00:39:53 -0700485 }
486
487 @Override
488 public List<Policy> getPolicies() {
489 return policyHandler.getPolicies();
490 }
491
Saurav Das59232cf2016-04-27 18:35:50 -0700492 @Override
493 public void rerouteNetwork() {
494 cfgListener.configureNetwork();
Saurav Das59232cf2016-04-27 18:35:50 -0700495 }
496
Charles Chanc81c45b2016-10-20 17:02:44 -0700497 @Override
Pier Ventre10bd8d12016-11-26 21:05:22 -0800498 public Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap() {
499 Map<DeviceId, Set<IpPrefix>> deviceSubnetMap = Maps.newHashMap();
Charles Chanc81c45b2016-10-20 17:02:44 -0700500 deviceService.getAvailableDevices().forEach(device -> {
501 deviceSubnetMap.put(device.id(), deviceConfiguration.getSubnets(device.id()));
502 });
503 return deviceSubnetMap;
504 }
505
Saurav Dasc88d4662017-05-15 15:34:25 -0700506
507 @Override
508 public ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg() {
509 if (defaultRoutingHandler != null) {
510 return defaultRoutingHandler.getCurrentEmcpSpgMap();
511 } else {
512 return null;
513 }
514 }
515
516 @Override
Saurav Das7bcbe702017-06-13 15:35:54 -0700517 public ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDestinationSet() {
518 if (dsNextObjStore != null) {
519 return ImmutableMap.copyOf(dsNextObjStore.entrySet());
Saurav Dasc88d4662017-05-15 15:34:25 -0700520 } else {
521 return ImmutableMap.of();
522 }
523 }
524
sanghof9d0bf12015-05-19 11:57:42 -0700525 /**
Ray Milkeye4afdb52017-04-05 09:42:04 -0700526 * Extracts the application ID from the manager.
527 *
528 * @return application ID
529 */
530 public ApplicationId appId() {
531 return appId;
532 }
533
534 /**
535 * Returns the device configuration.
536 *
537 * @return device configuration
538 */
539 public DeviceConfiguration deviceConfiguration() {
540 return deviceConfiguration;
541 }
542
543 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700544 * Per device next objective ID store with (device id + destination set) as key.
Ray Milkeye4afdb52017-04-05 09:42:04 -0700545 *
546 * @return next objective ID store
547 */
Saurav Das7bcbe702017-06-13 15:35:54 -0700548 public EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey, NextNeighbors>
549 dsNextObjStore() {
550 return dsNextObjStore;
Ray Milkeye4afdb52017-04-05 09:42:04 -0700551 }
552
553 /**
554 * Per device next objective ID store with (device id + subnet) as key.
555 *
556 * @return vlan next object store
557 */
558 public EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer> vlanNextObjStore() {
559 return vlanNextObjStore;
560 }
561
562 /**
563 * Per device next objective ID store with (device id + port) as key.
564 *
565 * @return port next object store.
566 */
567 public EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer> portNextObjStore() {
568 return portNextObjStore;
569 }
570
571 /**
Saurav Das7bcbe702017-06-13 15:35:54 -0700572 * Returns the MPLS-ECMP configuration which indicates whether ECMP on
573 * labeled packets should be programmed or not.
Pier Ventre98161782016-10-31 15:00:01 -0700574 *
575 * @return MPLS-ECMP value
576 */
577 public boolean getMplsEcmp() {
578 SegmentRoutingAppConfig segmentRoutingAppConfig = cfgService
579 .getConfig(this.appId, SegmentRoutingAppConfig.class);
580 return segmentRoutingAppConfig != null && segmentRoutingAppConfig.mplsEcmp();
581 }
582
583 /**
sanghof9d0bf12015-05-19 11:57:42 -0700584 * Returns the tunnel object with the tunnel ID.
585 *
586 * @param tunnelId Tunnel ID
587 * @return Tunnel reference
588 */
sangho1e575652015-05-14 00:39:53 -0700589 public Tunnel getTunnel(String tunnelId) {
590 return tunnelHandler.getTunnel(tunnelId);
591 }
592
Charles Chan7ffd81f2017-02-08 15:52:08 -0800593 // TODO Consider moving these to InterfaceService
sanghob35a6192015-04-01 13:05:26 -0700594 /**
Charles Chan59cc16d2017-02-02 16:20:42 -0800595 * Returns untagged VLAN configured on given connect point.
Charles Chan7ffd81f2017-02-08 15:52:08 -0800596 * <p>
597 * Only returns the first match if there are multiple untagged VLAN configured
598 * on the connect point.
sanghob35a6192015-04-01 13:05:26 -0700599 *
Charles Chan59cc16d2017-02-02 16:20:42 -0800600 * @param connectPoint connect point
601 * @return untagged VLAN or null if not configured
sanghob35a6192015-04-01 13:05:26 -0700602 */
Charles Chan65238242017-06-22 18:03:14 -0700603 VlanId getUntaggedVlanId(ConnectPoint connectPoint) {
Charles Chan59cc16d2017-02-02 16:20:42 -0800604 return interfaceService.getInterfacesByPort(connectPoint).stream()
605 .filter(intf -> !intf.vlanUntagged().equals(VlanId.NONE))
606 .map(Interface::vlanUntagged)
607 .findFirst().orElse(null);
sanghob35a6192015-04-01 13:05:26 -0700608 }
609
sangho1e575652015-05-14 00:39:53 -0700610 /**
Charles Chan7ffd81f2017-02-08 15:52:08 -0800611 * Returns tagged VLAN configured on given connect point.
612 * <p>
613 * Returns all matches if there are multiple tagged VLAN configured
614 * on the connect point.
615 *
616 * @param connectPoint connect point
617 * @return tagged VLAN or empty set if not configured
618 */
Charles Chan65238242017-06-22 18:03:14 -0700619 Set<VlanId> getTaggedVlanId(ConnectPoint connectPoint) {
Charles Chan7ffd81f2017-02-08 15:52:08 -0800620 Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint);
621 return interfaces.stream()
622 .map(Interface::vlanTagged)
Charles Chan65238242017-06-22 18:03:14 -0700623 .flatMap(Set::stream)
Charles Chan7ffd81f2017-02-08 15:52:08 -0800624 .collect(Collectors.toSet());
625 }
626
627 /**
628 * Returns native VLAN configured on given connect point.
629 * <p>
630 * Only returns the first match if there are multiple native VLAN configured
631 * on the connect point.
632 *
633 * @param connectPoint connect point
634 * @return native VLAN or null if not configured
635 */
Charles Chan65238242017-06-22 18:03:14 -0700636 VlanId getNativeVlanId(ConnectPoint connectPoint) {
Charles Chan7ffd81f2017-02-08 15:52:08 -0800637 Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint);
638 return interfaces.stream()
639 .filter(intf -> !intf.vlanNative().equals(VlanId.NONE))
640 .map(Interface::vlanNative)
641 .findFirst()
642 .orElse(null);
643 }
644
645 /**
Charles Chanf9a52702017-06-16 15:19:24 -0700646 * Returns internal VLAN for untagged hosts on given connect point.
647 * <p>
648 * The internal VLAN is either vlan-untagged for an access port,
649 * or vlan-native for a trunk port.
650 *
651 * @param connectPoint connect point
652 * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined
653 */
Charles Chan65238242017-06-22 18:03:14 -0700654 VlanId getInternalVlanId(ConnectPoint connectPoint) {
Charles Chanf9a52702017-06-16 15:19:24 -0700655 VlanId untaggedVlanId = getUntaggedVlanId(connectPoint);
656 VlanId nativeVlanId = getNativeVlanId(connectPoint);
657 return untaggedVlanId != null ? untaggedVlanId : nativeVlanId;
658 }
659
660 /**
Charles Chan65238242017-06-22 18:03:14 -0700661 * Returns optional pair device ID of given device.
662 *
663 * @param deviceId device ID
664 * @return optional pair device ID. Might be empty if pair device is not configured
665 */
666 Optional<DeviceId> getPairDeviceId(DeviceId deviceId) {
667 SegmentRoutingDeviceConfig deviceConfig =
668 cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
669 return Optional.ofNullable(deviceConfig).map(SegmentRoutingDeviceConfig::pairDeviceId);
670 }
671 /**
672 * Returns optional pair device local port of given device.
673 *
674 * @param deviceId device ID
675 * @return optional pair device ID. Might be empty if pair device is not configured
676 */
677 Optional<PortNumber> getPairLocalPorts(DeviceId deviceId) {
678 SegmentRoutingDeviceConfig deviceConfig =
679 cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
680 return Optional.ofNullable(deviceConfig).map(SegmentRoutingDeviceConfig::pairLocalPort);
681 }
682
683 /**
Charles Chan7ffd81f2017-02-08 15:52:08 -0800684 * Returns vlan port map of given device.
685 *
686 * @param deviceId device id
687 * @return vlan-port multimap
688 */
689 public Multimap<VlanId, PortNumber> getVlanPortMap(DeviceId deviceId) {
690 HashMultimap<VlanId, PortNumber> vlanPortMap = HashMultimap.create();
691
692 interfaceService.getInterfaces().stream()
693 .filter(intf -> intf.connectPoint().deviceId().equals(deviceId))
694 .forEach(intf -> {
695 vlanPortMap.put(intf.vlanUntagged(), intf.connectPoint().port());
Charles Chan65238242017-06-22 18:03:14 -0700696 intf.vlanTagged().forEach(vlanTagged ->
697 vlanPortMap.put(vlanTagged, intf.connectPoint().port())
698 );
Charles Chan7ffd81f2017-02-08 15:52:08 -0800699 vlanPortMap.put(intf.vlanNative(), intf.connectPoint().port());
700 });
701 vlanPortMap.removeAll(VlanId.NONE);
702
703 return vlanPortMap;
704 }
705
706 /**
Saurav Das4ce45962015-11-24 23:21:05 -0800707 * Returns the next objective ID for the given subnet prefix. It is expected
Charles Chan59cc16d2017-02-02 16:20:42 -0800708 * Returns the next objective ID for the given vlan id. It is expected
Saurav Das4ce45962015-11-24 23:21:05 -0800709 * that the next-objective has been pre-created from configuration.
Charles Chanc42e84e2015-10-20 16:24:19 -0700710 *
711 * @param deviceId Device ID
Charles Chan59cc16d2017-02-02 16:20:42 -0800712 * @param vlanId VLAN ID
Saurav Das4ce45962015-11-24 23:21:05 -0800713 * @return next objective ID or -1 if it was not found
Charles Chanc42e84e2015-10-20 16:24:19 -0700714 */
Charles Chan65238242017-06-22 18:03:14 -0700715 int getVlanNextObjectiveId(DeviceId deviceId, VlanId vlanId) {
Charles Chanc42e84e2015-10-20 16:24:19 -0700716 if (groupHandlerMap.get(deviceId) != null) {
Charles Chan59cc16d2017-02-02 16:20:42 -0800717 log.trace("getVlanNextObjectiveId query in device {}", deviceId);
718 return groupHandlerMap.get(deviceId).getVlanNextObjectiveId(vlanId);
Charles Chanc42e84e2015-10-20 16:24:19 -0700719 } else {
Charles Chan59cc16d2017-02-02 16:20:42 -0800720 log.warn("getVlanNextObjectiveId query - groupHandler for "
Saurav Das4ce45962015-11-24 23:21:05 -0800721 + "device {} not found", deviceId);
722 return -1;
723 }
724 }
725
726 /**
727 * Returns the next objective ID for the given portNumber, given the treatment.
728 * There could be multiple different treatments to the same outport, which
Saurav Das961beb22017-03-29 19:09:17 -0700729 * would result in different objectives. If the next object does not exist,
730 * and should be created, a new one is created and its id is returned.
Saurav Das4ce45962015-11-24 23:21:05 -0800731 *
732 * @param deviceId Device ID
733 * @param portNum port number on device for which NextObjective is queried
734 * @param treatment the actions to apply on the packets (should include outport)
735 * @param meta metadata passed into the creation of a Next Objective if necessary
Saurav Das961beb22017-03-29 19:09:17 -0700736 * @param createIfMissing true if a next object should be created if not found
Saurav Das59232cf2016-04-27 18:35:50 -0700737 * @return next objective ID or -1 if an error occurred during retrieval or creation
Saurav Das4ce45962015-11-24 23:21:05 -0800738 */
739 public int getPortNextObjectiveId(DeviceId deviceId, PortNumber portNum,
740 TrafficTreatment treatment,
Saurav Das961beb22017-03-29 19:09:17 -0700741 TrafficSelector meta,
742 boolean createIfMissing) {
Saurav Das4ce45962015-11-24 23:21:05 -0800743 DefaultGroupHandler ghdlr = groupHandlerMap.get(deviceId);
744 if (ghdlr != null) {
Saurav Das961beb22017-03-29 19:09:17 -0700745 return ghdlr.getPortNextObjectiveId(portNum, treatment, meta, createIfMissing);
Saurav Das4ce45962015-11-24 23:21:05 -0800746 } else {
Charles Chane849c192016-01-11 18:28:54 -0800747 log.warn("getPortNextObjectiveId query - groupHandler for device {}"
748 + " not found", deviceId);
749 return -1;
750 }
751 }
752
Saurav Dasc88d4662017-05-15 15:34:25 -0700753 /**
754 * Returns the group handler object for the specified device id.
755 *
756 * @param devId the device identifier
757 * @return the groupHandler object for the device id, or null if not found
758 */
Charles Chan65238242017-06-22 18:03:14 -0700759 DefaultGroupHandler getGroupHandler(DeviceId devId) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700760 return groupHandlerMap.get(devId);
761 }
762
763 /**
764 * Returns true if this controller instance has seen this link before. The
765 * link may not be currently up, but as long as the link had been seen before
766 * this method will return true. The one exception is when the link was
767 * indeed seen before, but this controller instance was forced to forget it
768 * by a call to purgeSeenLink method.
769 *
770 * @param link the infrastructure link being queried
771 * @return true if this controller instance has seen this link before
772 */
Charles Chan65238242017-06-22 18:03:14 -0700773 boolean isSeenLink(Link link) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700774 return seenLinks.containsKey(link);
775 }
776
777 /**
778 * Updates the seen link store. Updates can be for links that are currently
779 * available or not.
780 *
781 * @param link the link to update in the seen-link local store
782 * @param up the status of the link, true if up, false if down
783 */
Charles Chan65238242017-06-22 18:03:14 -0700784 void updateSeenLink(Link link, boolean up) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700785 seenLinks.put(link, up);
786 }
787
788 /**
789 * Returns the status of a seen-link (up or down). If the link has not
790 * been seen-before, a null object is returned.
791 *
792 * @param link the infrastructure link being queried
793 * @return null if the link was not seen-before;
794 * true if the seen-link is up;
795 * false if the seen-link is down
796 */
Charles Chan65238242017-06-22 18:03:14 -0700797 Boolean isSeenLinkUp(Link link) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700798 return seenLinks.get(link);
799 }
800
801 /**
802 * Makes this controller instance forget a previously seen before link.
803 *
804 * @param link the infrastructure link to purge
805 */
Charles Chan65238242017-06-22 18:03:14 -0700806 private void purgeSeenLink(Link link) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700807 seenLinks.remove(link);
808 }
809
810 /**
811 * Returns the status of a link as parallel link. A parallel link
812 * is defined as a link which has common src and dst switches as another
813 * seen-link that is currently enabled. It is not necessary for the link being
814 * queried to be a seen-link.
815 *
816 * @param link the infrastructure link being queried
817 * @return true if a seen-link exists that is up, and shares the
818 * same src and dst switches as the link being queried
819 */
Charles Chan65238242017-06-22 18:03:14 -0700820 private boolean isParallelLink(Link link) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700821 for (Entry<Link, Boolean> seen : seenLinks.entrySet()) {
822 Link seenLink = seen.getKey();
823 if (seenLink.equals(link)) {
824 continue;
825 }
826 if (seenLink.src().deviceId().equals(link.src().deviceId()) &&
827 seenLink.dst().deviceId().equals(link.dst().deviceId()) &&
828 seen.getValue()) {
829 return true;
830 }
831 }
832 return false;
833 }
834
Saurav Das7bcbe702017-06-13 15:35:54 -0700835 /**
836 * Returns true if the link being queried is a bidirectional link. A bidi
837 * link is defined as a link, whose reverse link - ie. the link in the reverse
838 * direction - has been seen-before and is up. It is not necessary for the link
839 * being queried to be a seen-link.
840 *
841 * @param link the infrastructure link being queried
842 * @return true if another unidirectional link exists in the reverse direction,
843 * has been seen-before and is up
844 */
845 public boolean isBidirectional(Link link) {
846 Link reverseLink = linkService.getLink(link.dst(), link.src());
847 if (reverseLink == null) {
848 return false;
849 }
850 Boolean result = isSeenLinkUp(reverseLink);
851 if (result == null) {
852 return false;
853 }
854 return result.booleanValue();
855 }
856
857 /**
858 * Determines if the given link should be avoided in routing calculations
859 * by policy or design.
860 *
861 * @param link the infrastructure link being queried
862 * @return true if link should be avoided
863 */
864 public boolean avoidLink(Link link) {
865 // XXX currently only avoids all pair-links. In the future can be
866 // extended to avoid any generic link
867 DeviceId src = link.src().deviceId();
868 PortNumber srcPort = link.src().port();
869 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(src)) {
870 log.warn("Device {} not configured..cannot avoid link {}", src, link);
871 return false;
872 }
873 DeviceId pairDev;
874 PortNumber pairLocalPort, pairRemotePort = null;
875 try {
876 pairDev = deviceConfiguration.getPairDeviceId(src);
877 pairLocalPort = deviceConfiguration.getPairLocalPort(src);
878 if (pairDev != null) {
879 pairRemotePort = deviceConfiguration.getPairLocalPort(pairDev);
880 }
881 } catch (DeviceConfigNotFoundException e) {
882 log.warn("Pair dev for dev {} not configured..cannot avoid link {}",
883 src, link);
884 return false;
885 }
886
887 if (srcPort.equals(pairLocalPort) &&
888 link.dst().deviceId().equals(pairDev) &&
889 link.dst().port().equals(pairRemotePort)) {
890 return true;
891 }
892 return false;
893 }
894
sanghob35a6192015-04-01 13:05:26 -0700895 private class InternalPacketProcessor implements PacketProcessor {
sanghob35a6192015-04-01 13:05:26 -0700896 @Override
897 public void process(PacketContext context) {
898
899 if (context.isHandled()) {
900 return;
901 }
902
903 InboundPacket pkt = context.inPacket();
904 Ethernet ethernet = pkt.parsed();
Pier Luigi7dad71c2017-02-01 13:50:04 -0800905
906 if (ethernet == null) {
907 return;
908 }
909
Saurav Das7bcbe702017-06-13 15:35:54 -0700910 log.trace("Rcvd pktin from {}: {}", context.inPacket().receivedFrom(),
911 ethernet);
Pier Ventree0ae7a32016-11-23 09:57:42 -0800912 if (ethernet.getEtherType() == TYPE_ARP) {
Saurav Dasc88d4662017-05-15 15:34:25 -0700913 log.warn("Received unexpected ARP packet on {}",
914 context.inPacket().receivedFrom());
Saurav Das76ae6812017-03-15 15:15:14 -0700915 log.trace("{}", ethernet);
Pier Ventre968da122016-12-09 17:26:04 -0800916 return;
sanghob35a6192015-04-01 13:05:26 -0700917 } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
Pier Ventre735b8c82016-12-02 08:16:05 -0800918 IPv4 ipv4Packet = (IPv4) ethernet.getPayload();
919 //ipHandler.addToPacketBuffer(ipv4Packet);
920 if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) {
921 icmpHandler.processIcmp(ethernet, pkt.receivedFrom());
sanghob35a6192015-04-01 13:05:26 -0700922 } else {
Charles Chan50035632017-01-13 17:20:44 -0800923 // NOTE: We don't support IP learning at this moment so this
924 // is not necessary. Also it causes duplication of DHCP packets.
Pier Ventre968da122016-12-09 17:26:04 -0800925 // ipHandler.processPacketIn(ipv4Packet, pkt.receivedFrom());
sanghob35a6192015-04-01 13:05:26 -0700926 }
Pier Ventre10bd8d12016-11-26 21:05:22 -0800927 } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV6) {
928 IPv6 ipv6Packet = (IPv6) ethernet.getPayload();
Pier Ventre735b8c82016-12-02 08:16:05 -0800929 //ipHandler.addToPacketBuffer(ipv6Packet);
Pier Luigi7dad71c2017-02-01 13:50:04 -0800930 // We deal with the packet only if the packet is a ICMP6 ECHO/REPLY
Pier Ventre735b8c82016-12-02 08:16:05 -0800931 if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_ICMP6) {
932 ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload();
933 if (icmp6Packet.getIcmpType() == ICMP6.ECHO_REQUEST ||
934 icmp6Packet.getIcmpType() == ICMP6.ECHO_REPLY) {
935 icmpHandler.processIcmpv6(ethernet, pkt.receivedFrom());
936 } else {
Saurav Dasc88d4662017-05-15 15:34:25 -0700937 log.trace("Received ICMPv6 0x{} - not handled",
Charles Chan0ed44fb2017-03-13 13:10:30 -0700938 Integer.toHexString(icmp6Packet.getIcmpType() & 0xff));
Pier Ventre735b8c82016-12-02 08:16:05 -0800939 }
940 } else {
941 // NOTE: We don't support IP learning at this moment so this
942 // is not necessary. Also it causes duplication of DHCPv6 packets.
943 // ipHandler.processPacketIn(ipv6Packet, pkt.receivedFrom());
944 }
sanghob35a6192015-04-01 13:05:26 -0700945 }
946 }
947 }
948
949 private class InternalLinkListener implements LinkListener {
950 @Override
951 public void event(LinkEvent event) {
Charles Chanb1f8c762017-03-29 16:39:05 -0700952 if (event.type() == LinkEvent.Type.LINK_ADDED ||
953 event.type() == LinkEvent.Type.LINK_UPDATED ||
954 event.type() == LinkEvent.Type.LINK_REMOVED) {
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -0700955 log.debug("Event {} received from Link Service", event.type());
sanghob35a6192015-04-01 13:05:26 -0700956 scheduleEventHandlerIfNotScheduled(event);
957 }
958 }
959 }
960
961 private class InternalDeviceListener implements DeviceListener {
sanghob35a6192015-04-01 13:05:26 -0700962 @Override
963 public void event(DeviceEvent event) {
sanghob35a6192015-04-01 13:05:26 -0700964 switch (event.type()) {
965 case DEVICE_ADDED:
Saurav Das1a129a02016-11-18 15:21:57 -0800966 case PORT_UPDATED:
967 case PORT_ADDED:
sangho20eff1d2015-04-13 15:15:58 -0700968 case DEVICE_UPDATED:
969 case DEVICE_AVAILABILITY_CHANGED:
Saurav Dasc88d4662017-05-15 15:34:25 -0700970 log.trace("Event {} received from Device Service", event.type());
sanghob35a6192015-04-01 13:05:26 -0700971 scheduleEventHandlerIfNotScheduled(event);
972 break;
973 default:
974 }
975 }
976 }
977
Saurav Das4ce45962015-11-24 23:21:05 -0800978 @SuppressWarnings("rawtypes")
sanghob35a6192015-04-01 13:05:26 -0700979 private void scheduleEventHandlerIfNotScheduled(Event event) {
Charles Chan65238242017-06-22 18:03:14 -0700980 synchronized (THREAD_SCHED_LOCK) {
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700981 eventQueue.add(event);
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -0700982 numOfEventsQueued++;
983
984 if ((numOfHandlerScheduled - numOfHandlerExecution) == 0) {
985 //No pending scheduled event handling threads. So start a new one.
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700986 eventHandlerFuture = executorService
987 .schedule(eventHandler, 100, TimeUnit.MILLISECONDS);
988 numOfHandlerScheduled++;
989 }
Jonathan Hartc19f7c12016-04-12 15:39:44 -0700990 log.trace("numOfEventsQueued {}, numOfEventHandlerScheduled {}",
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -0700991 numOfEventsQueued,
992 numOfHandlerScheduled);
sanghob35a6192015-04-01 13:05:26 -0700993 }
sanghob35a6192015-04-01 13:05:26 -0700994 }
995
996 private class InternalEventHandler implements Runnable {
Srikanth Vavilapalli4db76e32015-04-07 15:12:32 -0700997 @Override
sanghob35a6192015-04-01 13:05:26 -0700998 public void run() {
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700999 try {
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001000 while (true) {
Saurav Das4ce45962015-11-24 23:21:05 -08001001 @SuppressWarnings("rawtypes")
Charles Chan65238242017-06-22 18:03:14 -07001002 Event event;
1003 synchronized (THREAD_SCHED_LOCK) {
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001004 if (!eventQueue.isEmpty()) {
1005 event = eventQueue.poll();
1006 numOfEventsExecuted++;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001007 } else {
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001008 numOfHandlerExecution++;
1009 log.debug("numOfHandlerExecution {} numOfEventsExecuted {}",
1010 numOfHandlerExecution, numOfEventsExecuted);
1011 break;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001012 }
sangho20eff1d2015-04-13 15:15:58 -07001013 }
Charles Chanb1f8c762017-03-29 16:39:05 -07001014 if (event.type() == LinkEvent.Type.LINK_ADDED ||
1015 event.type() == LinkEvent.Type.LINK_UPDATED) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001016 // Note: do not update seenLinks here, otherwise every
1017 // link, even one seen for the first time, will be appear
1018 // to be a previously seen link
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001019 processLinkAdded((Link) event.subject());
1020 } else if (event.type() == LinkEvent.Type.LINK_REMOVED) {
Pier Ventre2c515312016-09-13 21:33:40 -07001021 Link linkRemoved = (Link) event.subject();
Saurav Dasc88d4662017-05-15 15:34:25 -07001022 if (linkRemoved.type() == Link.Type.DIRECT) {
1023 updateSeenLink(linkRemoved, false);
1024 }
1025 // device availability check helps to ensure that
1026 // multiple link-removed events are actually treated as a
1027 // single switch removed event. purgeSeenLink is necessary
1028 // so we do rerouting (instead of rehashing) when switch
1029 // comes back.
Pier Ventre2c515312016-09-13 21:33:40 -07001030 if (linkRemoved.src().elementId() instanceof DeviceId &&
1031 !deviceService.isAvailable(linkRemoved.src().deviceId())) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001032 purgeSeenLink(linkRemoved);
Pier Ventre2c515312016-09-13 21:33:40 -07001033 continue;
1034 }
1035 if (linkRemoved.dst().elementId() instanceof DeviceId &&
1036 !deviceService.isAvailable(linkRemoved.dst().deviceId())) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001037 purgeSeenLink(linkRemoved);
Pier Ventre2c515312016-09-13 21:33:40 -07001038 continue;
1039 }
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001040 processLinkRemoved((Link) event.subject());
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001041 } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED ||
1042 event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
1043 event.type() == DeviceEvent.Type.DEVICE_UPDATED) {
Saurav Das423fe2b2015-12-04 10:52:59 -08001044 DeviceId deviceId = ((Device) event.subject()).id();
1045 if (deviceService.isAvailable(deviceId)) {
Saurav Das837e0bb2015-10-30 17:45:38 -07001046 log.info("Processing device event {} for available device {}",
1047 event.type(), ((Device) event.subject()).id());
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001048 processDeviceAdded((Device) event.subject());
Saurav Das80980c72016-03-23 11:22:49 -07001049 } else {
1050 log.info("Processing device event {} for unavailable device {}",
1051 event.type(), ((Device) event.subject()).id());
1052 processDeviceRemoved((Device) event.subject());
1053 }
Saurav Das1a129a02016-11-18 15:21:57 -08001054 } else if (event.type() == DeviceEvent.Type.PORT_ADDED) {
Saurav Dasd2fded02016-12-02 15:43:47 -08001055 // typically these calls come when device is added first time
1056 // so port filtering rules are handled at the device_added event.
1057 // port added calls represent all ports on the device,
1058 // enabled or not.
Saurav Dasc88d4662017-05-15 15:34:25 -07001059 log.trace("** PORT ADDED {}/{} -> {}",
Saurav Dasd2fded02016-12-02 15:43:47 -08001060 ((DeviceEvent) event).subject().id(),
1061 ((DeviceEvent) event).port().number(),
1062 event.type());
Saurav Das1a129a02016-11-18 15:21:57 -08001063 } else if (event.type() == DeviceEvent.Type.PORT_UPDATED) {
Saurav Dasd2fded02016-12-02 15:43:47 -08001064 // these calls happen for every subsequent event
1065 // ports enabled, disabled, switch goes away, comes back
Saurav Das1a129a02016-11-18 15:21:57 -08001066 log.info("** PORT UPDATED {}/{} -> {}",
1067 event.subject(),
1068 ((DeviceEvent) event).port(),
1069 event.type());
1070 processPortUpdated(((Device) event.subject()),
1071 ((DeviceEvent) event).port());
Srikanth Vavilapalli5428b6c2015-05-14 20:22:47 -07001072 } else {
1073 log.warn("Unhandled event type: {}", event.type());
1074 }
sanghob35a6192015-04-01 13:05:26 -07001075 }
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001076 } catch (Exception e) {
1077 log.error("SegmentRouting event handler "
1078 + "thread thrown an exception: {}", e);
sanghob35a6192015-04-01 13:05:26 -07001079 }
sanghob35a6192015-04-01 13:05:26 -07001080 }
1081 }
1082
sanghob35a6192015-04-01 13:05:26 -07001083 private void processLinkAdded(Link link) {
Saurav Dasb5c236e2016-06-07 10:08:06 -07001084 log.info("** LINK ADDED {}", link.toString());
Charles Chan0b4e6182015-11-03 10:42:14 -08001085 if (!deviceConfiguration.isConfigured(link.src().deviceId())) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001086 log.warn("Source device of this link is not configured..not processing");
Charles Chan0b4e6182015-11-03 10:42:14 -08001087 return;
1088 }
Saurav Dasc88d4662017-05-15 15:34:25 -07001089 if (link.type() != Link.Type.DIRECT) {
1090 // NOTE: A DIRECT link might be transiently marked as INDIRECT
1091 // if BDDP is received before LLDP. We can safely ignore that
1092 // until the LLDP is received and the link is marked as DIRECT.
1093 log.info("Ignore link {}->{}. Link type is {} instead of DIRECT.",
1094 link.src(), link.dst(), link.type());
1095 return;
1096 }
1097
1098 //Irrespective of whether the local is a MASTER or not for this device,
1099 //create group handler instance and push default TTP flow rules if needed,
1100 //as in a multi-instance setup, instances can initiate groups for any device.
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001101 DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src()
1102 .deviceId());
1103 if (groupHandler != null) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001104 groupHandler.portUpForLink(link);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001105 } else {
1106 Device device = deviceService.getDevice(link.src().deviceId());
1107 if (device != null) {
1108 log.warn("processLinkAdded: Link Added "
1109 + "Notification without Device Added "
1110 + "event, still handling it");
1111 processDeviceAdded(device);
1112 groupHandler = groupHandlerMap.get(link.src()
1113 .deviceId());
Saurav Dasc88d4662017-05-15 15:34:25 -07001114 groupHandler.portUpForLink(link);
sanghob35a6192015-04-01 13:05:26 -07001115 }
1116 }
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001117
Saurav Das7bcbe702017-06-13 15:35:54 -07001118 /*// process link only if it is bidirectional
1119 if (!isBidirectional(link)) {
1120 log.debug("Link not bidirectional.. waiting for other direction "
1121 + "src {} --> dst {} ", link.dst(), link.src());
1122 // note that if we are not processing for routing, it should at least
1123 // be considered a seen-link
1124 updateSeenLink(link, true);
1125 return;
1126 }
1127 TO DO this ensure that rehash is still done correctly even if link is
1128 not processed for rerouting - perhaps rehash in both directions when
1129 it ultimately becomes bidi?
1130 */
1131
1132 log.debug("Starting optimized route population process for link "
1133 + "{} --> {}", link.src(), link.dst());
Saurav Dasc88d4662017-05-15 15:34:25 -07001134 boolean seenBefore = isSeenLink(link);
1135 defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(null, link, null);
Saurav Das7bcbe702017-06-13 15:35:54 -07001136
1137 // It's possible that linkUp causes no route-path change as ECMP graph does
1138 // not change if the link is a parallel link (same src-dst as another link.
1139 // However we still need to update ECMP hash groups to include new buckets
1140 // for the link that has come up.
Saurav Dasc88d4662017-05-15 15:34:25 -07001141 if (mastershipService.isLocalMaster(link.src().deviceId())) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001142 if (!seenBefore && isParallelLink(link)) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001143 // if link seen first time, we need to ensure hash-groups have all ports
Saurav Das7bcbe702017-06-13 15:35:54 -07001144 log.debug("Attempting retryHash for paralled first-time link {}", link);
Saurav Dasc88d4662017-05-15 15:34:25 -07001145 groupHandler.retryHash(link, false, true);
1146 } else {
1147 //seen before-link
1148 if (isParallelLink(link)) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001149 log.debug("Attempting retryHash for paralled seen-before "
1150 + "link {}", link);
Saurav Dasc88d4662017-05-15 15:34:25 -07001151 groupHandler.retryHash(link, false, false);
1152 }
1153 }
1154 }
Charles Chan2199c302016-04-23 17:36:10 -07001155
1156 mcastHandler.init();
sanghob35a6192015-04-01 13:05:26 -07001157 }
1158
1159 private void processLinkRemoved(Link link) {
Saurav Dasb5c236e2016-06-07 10:08:06 -07001160 log.info("** LINK REMOVED {}", link.toString());
Saurav Dasc88d4662017-05-15 15:34:25 -07001161 defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(link, null, null);
1162
1163 // update local groupHandler stores
sangho834e4b02015-05-01 09:38:25 -07001164 DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src().deviceId());
1165 if (groupHandler != null) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001166 if (mastershipService.isLocalMaster(link.src().deviceId()) &&
1167 isParallelLink(link)) {
1168 groupHandler.retryHash(link, true, false);
1169 }
1170 // ensure local stores are updated
1171 groupHandler.portDown(link.src().port());
1172 } else {
1173 log.warn("group handler not found for dev:{} when removing link: {}",
1174 link.src().deviceId(), link);
sangho834e4b02015-05-01 09:38:25 -07001175 }
Charles Chan2199c302016-04-23 17:36:10 -07001176
1177 mcastHandler.processLinkDown(link);
sanghob35a6192015-04-01 13:05:26 -07001178 }
1179
1180 private void processDeviceAdded(Device device) {
Saurav Dasb5c236e2016-06-07 10:08:06 -07001181 log.info("** DEVICE ADDED with ID {}", device.id());
Charles Chan91ccbf72017-06-27 18:48:32 -07001182
1183 // NOTE: Punt ARP/NDP even when the device is not configured.
1184 // Host learning without network config is required for CORD config generator.
1185 routingRulePopulator.populateIpPunts(device.id());
1186 routingRulePopulator.populateArpNdpPunts(device.id());
1187
Charles Chan0b4e6182015-11-03 10:42:14 -08001188 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001189 log.warn("Device configuration unavailable. Device {} will be "
1190 + "processed after configuration.", device.id());
Saurav Das2857f382015-11-03 14:39:27 -08001191 return;
1192 }
Charles Chan2199c302016-04-23 17:36:10 -07001193 processDeviceAddedInternal(device.id());
1194 }
1195
1196 private void processDeviceAddedInternal(DeviceId deviceId) {
Saurav Das837e0bb2015-10-30 17:45:38 -07001197 // Irrespective of whether the local is a MASTER or not for this device,
1198 // we need to create a SR-group-handler instance. This is because in a
1199 // multi-instance setup, any instance can initiate forwarding/next-objectives
1200 // for any switch (even if this instance is a SLAVE or not even connected
1201 // to the switch). To handle this, a default-group-handler instance is necessary
1202 // per switch.
Charles Chan2199c302016-04-23 17:36:10 -07001203 log.debug("Current groupHandlerMap devs: {}", groupHandlerMap.keySet());
1204 if (groupHandlerMap.get(deviceId) == null) {
Charles Chan0b4e6182015-11-03 10:42:14 -08001205 DefaultGroupHandler groupHandler;
1206 try {
1207 groupHandler = DefaultGroupHandler.
Charles Chan2199c302016-04-23 17:36:10 -07001208 createGroupHandler(deviceId,
1209 appId,
1210 deviceConfiguration,
1211 linkService,
1212 flowObjectiveService,
1213 this);
Charles Chan0b4e6182015-11-03 10:42:14 -08001214 } catch (DeviceConfigNotFoundException e) {
1215 log.warn(e.getMessage() + " Aborting processDeviceAdded.");
1216 return;
1217 }
Charles Chan2199c302016-04-23 17:36:10 -07001218 log.debug("updating groupHandlerMap with new config for device: {}",
1219 deviceId);
1220 groupHandlerMap.put(deviceId, groupHandler);
Saurav Das2857f382015-11-03 14:39:27 -08001221 }
Saurav Dasb5c236e2016-06-07 10:08:06 -07001222
Charles Chan2199c302016-04-23 17:36:10 -07001223 if (mastershipService.isLocalMaster(deviceId)) {
Saurav Das018605f2017-02-18 14:05:44 -08001224 defaultRoutingHandler.populatePortAddressingRules(deviceId);
Charles Chan03a73e02016-10-24 14:52:01 -07001225 hostHandler.init(deviceId);
Charles Chanfc5c7802016-05-17 13:13:55 -07001226 xConnectHandler.init(deviceId);
Charles Chan2199c302016-04-23 17:36:10 -07001227 DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId);
Charles Chan59cc16d2017-02-02 16:20:42 -08001228 groupHandler.createGroupsFromVlanConfig();
Charles Chan2199c302016-04-23 17:36:10 -07001229 routingRulePopulator.populateSubnetBroadcastRule(deviceId);
Charles Chanc42e84e2015-10-20 16:24:19 -07001230 }
Charles Chan5270ed02016-01-30 23:22:37 -08001231
Charles Chan03a73e02016-10-24 14:52:01 -07001232 appCfgHandler.init(deviceId);
1233 routeHandler.init(deviceId);
sanghob35a6192015-04-01 13:05:26 -07001234 }
1235
Saurav Das80980c72016-03-23 11:22:49 -07001236 private void processDeviceRemoved(Device device) {
Saurav Das7bcbe702017-06-13 15:35:54 -07001237 dsNextObjStore.entrySet().stream()
Saurav Das80980c72016-03-23 11:22:49 -07001238 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
1239 .forEach(entry -> {
Saurav Das7bcbe702017-06-13 15:35:54 -07001240 dsNextObjStore.remove(entry.getKey());
Saurav Das80980c72016-03-23 11:22:49 -07001241 });
Charles Chan59cc16d2017-02-02 16:20:42 -08001242 vlanNextObjStore.entrySet().stream()
Saurav Das80980c72016-03-23 11:22:49 -07001243 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
Charles Chan65238242017-06-22 18:03:14 -07001244 .forEach(entry -> vlanNextObjStore.remove(entry.getKey()));
Saurav Das80980c72016-03-23 11:22:49 -07001245 portNextObjStore.entrySet().stream()
1246 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
Charles Chan65238242017-06-22 18:03:14 -07001247 .forEach(entry -> portNextObjStore.remove(entry.getKey()));
Charles Chaned3742352017-06-15 00:44:51 -07001248
1249 seenLinks.keySet().removeIf(key -> key.src().deviceId().equals(device.id()) ||
1250 key.dst().deviceId().equals(device.id()));
1251
Saurav Das80980c72016-03-23 11:22:49 -07001252 groupHandlerMap.remove(device.id());
Saurav Das80980c72016-03-23 11:22:49 -07001253 defaultRoutingHandler.purgeEcmpGraph(device.id());
Saurav Dasc88d4662017-05-15 15:34:25 -07001254 // Note that a switch going down is associated with all of its links
1255 // going down as well, but it is treated as a single switch down event
1256 // while the link-downs are ignored.
1257 defaultRoutingHandler
1258 .populateRoutingRulesForLinkStatusChange(null, null, device.id());
Charles Chan2199c302016-04-23 17:36:10 -07001259 mcastHandler.removeDevice(device.id());
Charles Chanfc5c7802016-05-17 13:13:55 -07001260 xConnectHandler.removeDevice(device.id());
Saurav Das80980c72016-03-23 11:22:49 -07001261 }
1262
Saurav Das1a129a02016-11-18 15:21:57 -08001263 private void processPortUpdated(Device device, Port port) {
1264 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
1265 log.warn("Device configuration uploading. Not handling port event for"
1266 + "dev: {} port: {}", device.id(), port.number());
1267 return;
1268 }
Saurav Das018605f2017-02-18 14:05:44 -08001269
1270 if (!mastershipService.isLocalMaster(device.id())) {
1271 log.debug("Not master for dev:{} .. not handling port updated event"
1272 + "for port {}", device.id(), port.number());
1273 return;
1274 }
1275
1276 // first we handle filtering rules associated with the port
1277 if (port.isEnabled()) {
1278 log.info("Switchport {}/{} enabled..programming filters",
1279 device.id(), port.number());
Charles Chan7e4f8192017-02-26 22:59:35 -08001280 routingRulePopulator.processSinglePortFilters(device.id(), port.number(), true);
Saurav Das018605f2017-02-18 14:05:44 -08001281 } else {
1282 log.info("Switchport {}/{} disabled..removing filters",
1283 device.id(), port.number());
Charles Chan7e4f8192017-02-26 22:59:35 -08001284 routingRulePopulator.processSinglePortFilters(device.id(), port.number(), false);
Saurav Das018605f2017-02-18 14:05:44 -08001285 }
Saurav Das1a129a02016-11-18 15:21:57 -08001286
1287 // portUpdated calls are for ports that have gone down or up. For switch
1288 // to switch ports, link-events should take care of any re-routing or
1289 // group editing necessary for port up/down. Here we only process edge ports
1290 // that are already configured.
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001291 ConnectPoint cp = new ConnectPoint(device.id(), port.number());
1292 VlanId untaggedVlan = getUntaggedVlanId(cp);
1293 VlanId nativeVlan = getNativeVlanId(cp);
1294 Set<VlanId> taggedVlans = getTaggedVlanId(cp);
Charles Chan59cc16d2017-02-02 16:20:42 -08001295
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001296 if (untaggedVlan == null && nativeVlan == null && taggedVlans.isEmpty()) {
Saurav Dasc88d4662017-05-15 15:34:25 -07001297 log.debug("Not handling port updated event for non-edge port (unconfigured) "
Saurav Das1a129a02016-11-18 15:21:57 -08001298 + "dev/port: {}/{}", device.id(), port.number());
1299 return;
1300 }
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001301 if (untaggedVlan != null) {
1302 processEdgePort(device, port, untaggedVlan, true);
1303 }
1304 if (nativeVlan != null) {
1305 processEdgePort(device, port, nativeVlan, true);
1306 }
1307 if (!taggedVlans.isEmpty()) {
1308 taggedVlans.forEach(tag -> processEdgePort(device, port, tag, false));
1309 }
Saurav Das1a129a02016-11-18 15:21:57 -08001310 }
1311
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001312 private void processEdgePort(Device device, Port port, VlanId vlanId,
1313 boolean popVlan) {
Saurav Das1a129a02016-11-18 15:21:57 -08001314 boolean portUp = port.isEnabled();
1315 if (portUp) {
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001316 log.info("Device:EdgePort {}:{} is enabled in vlan: {}", device.id(),
Charles Chan59cc16d2017-02-02 16:20:42 -08001317 port.number(), vlanId);
Saurav Das1a129a02016-11-18 15:21:57 -08001318 } else {
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001319 log.info("Device:EdgePort {}:{} is disabled in vlan: {}", device.id(),
Charles Chan59cc16d2017-02-02 16:20:42 -08001320 port.number(), vlanId);
Saurav Das1a129a02016-11-18 15:21:57 -08001321 }
1322
Srikanth Vavilapallif5b234a2015-04-21 13:04:13 -07001323 DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id());
sanghob35a6192015-04-01 13:05:26 -07001324 if (groupHandler != null) {
Saurav Dasb0ae6ee2017-03-04 16:08:47 -08001325 groupHandler.processEdgePort(port.number(), vlanId, popVlan, portUp);
Saurav Das1a129a02016-11-18 15:21:57 -08001326 } else {
1327 log.warn("Group handler not found for dev:{}. Not handling edge port"
1328 + " {} event for port:{}", device.id(),
1329 (portUp) ? "UP" : "DOWN", port.number());
sanghob35a6192015-04-01 13:05:26 -07001330 }
1331 }
sangho1e575652015-05-14 00:39:53 -07001332
Pier Ventre10bd8d12016-11-26 21:05:22 -08001333 /**
1334 * Registers the given connect point with the NRS, this is necessary
1335 * to receive the NDP and ARP packets from the NRS.
1336 *
1337 * @param portToRegister connect point to register
1338 */
1339 public void registerConnectPoint(ConnectPoint portToRegister) {
Charles Chan0aa674e2017-02-23 15:44:08 -08001340 neighbourResolutionService.registerNeighbourHandler(
Pier Ventre10bd8d12016-11-26 21:05:22 -08001341 portToRegister,
1342 neighbourHandler,
1343 appId
1344 );
1345 }
1346
Charles Chand6832882015-10-05 17:50:33 -07001347 private class InternalConfigListener implements NetworkConfigListener {
Saurav Das7bcbe702017-06-13 15:35:54 -07001348 private static final long PROGRAM_DELAY = 2;
Charles Chan2c15aca2016-11-09 20:51:44 -08001349 SegmentRoutingManager srManager;
Charles Chan4636be02015-10-07 14:21:45 -07001350
Charles Chane849c192016-01-11 18:28:54 -08001351 /**
1352 * Constructs the internal network config listener.
1353 *
Charles Chan2c15aca2016-11-09 20:51:44 -08001354 * @param srManager segment routing manager
Charles Chane849c192016-01-11 18:28:54 -08001355 */
Charles Chan65238242017-06-22 18:03:14 -07001356 InternalConfigListener(SegmentRoutingManager srManager) {
Charles Chan2c15aca2016-11-09 20:51:44 -08001357 this.srManager = srManager;
Charles Chan4636be02015-10-07 14:21:45 -07001358 }
1359
Charles Chane849c192016-01-11 18:28:54 -08001360 /**
1361 * Reads network config and initializes related data structure accordingly.
1362 */
Charles Chan4636be02015-10-07 14:21:45 -07001363 public void configureNetwork() {
Saurav Das7bcbe702017-06-13 15:35:54 -07001364 if (deviceConfiguration == null) {
1365 deviceConfiguration = new DeviceConfiguration(srManager);
1366 } else {
1367 deviceConfiguration.updateConfig();
1368 }
Charles Chan4636be02015-10-07 14:21:45 -07001369
Charles Chan2c15aca2016-11-09 20:51:44 -08001370 arpHandler = new ArpHandler(srManager);
1371 icmpHandler = new IcmpHandler(srManager);
1372 ipHandler = new IpHandler(srManager);
1373 routingRulePopulator = new RoutingRulePopulator(srManager);
1374 defaultRoutingHandler = new DefaultRoutingHandler(srManager);
Charles Chan4636be02015-10-07 14:21:45 -07001375
1376 tunnelHandler = new TunnelHandler(linkService, deviceConfiguration,
1377 groupHandlerMap, tunnelStore);
1378 policyHandler = new PolicyHandler(appId, deviceConfiguration,
1379 flowObjectiveService,
1380 tunnelHandler, policyStore);
Saurav Das7bcbe702017-06-13 15:35:54 -07001381 // add a small delay to absorb multiple network config added notifications
1382 if (!programmingScheduled.get()) {
1383 programmingScheduled.set(true);
1384 executorService.schedule(new ConfigChange(), PROGRAM_DELAY,
1385 TimeUnit.SECONDS);
Charles Chan4636be02015-10-07 14:21:45 -07001386 }
Charles Chan2199c302016-04-23 17:36:10 -07001387 mcastHandler.init();
Charles Chan4636be02015-10-07 14:21:45 -07001388 }
1389
Charles Chand6832882015-10-05 17:50:33 -07001390 @Override
1391 public void event(NetworkConfigEvent event) {
Charles Chan5270ed02016-01-30 23:22:37 -08001392 // TODO move this part to NetworkConfigEventHandler
1393 if (event.configClass().equals(SegmentRoutingDeviceConfig.class)) {
1394 switch (event.type()) {
1395 case CONFIG_ADDED:
Charles Chan278ce832017-06-26 15:25:09 -07001396 log.info("Segment Routing Device Config added for {}", event.subject());
Charles Chan5270ed02016-01-30 23:22:37 -08001397 configureNetwork();
1398 break;
1399 case CONFIG_UPDATED:
Charles Chan278ce832017-06-26 15:25:09 -07001400 log.info("Segment Routing Config updated for {}", event.subject());
1401 // TODO support dynamic configuration
1402 break;
1403 default:
1404 break;
1405 }
1406 } else if (event.configClass().equals(InterfaceConfig.class)) {
1407 switch (event.type()) {
1408 case CONFIG_ADDED:
1409 log.info("Interface Config added for {}", event.subject());
1410 configureNetwork();
1411 break;
1412 case CONFIG_UPDATED:
1413 log.info("Interface Config updated for {}", event.subject());
Charles Chan5270ed02016-01-30 23:22:37 -08001414 // TODO support dynamic configuration
1415 break;
1416 default:
1417 break;
Charles Chanb8e10c82015-10-14 11:24:40 -07001418 }
Charles Chan5270ed02016-01-30 23:22:37 -08001419 } else if (event.configClass().equals(SegmentRoutingAppConfig.class)) {
Charles Chanfc5c7802016-05-17 13:13:55 -07001420 checkState(appCfgHandler != null, "NetworkConfigEventHandler is not initialized");
Charles Chan5270ed02016-01-30 23:22:37 -08001421 switch (event.type()) {
1422 case CONFIG_ADDED:
Charles Chanfc5c7802016-05-17 13:13:55 -07001423 appCfgHandler.processAppConfigAdded(event);
Charles Chan5270ed02016-01-30 23:22:37 -08001424 break;
1425 case CONFIG_UPDATED:
Charles Chanfc5c7802016-05-17 13:13:55 -07001426 appCfgHandler.processAppConfigUpdated(event);
Charles Chan5270ed02016-01-30 23:22:37 -08001427 break;
1428 case CONFIG_REMOVED:
Charles Chanfc5c7802016-05-17 13:13:55 -07001429 appCfgHandler.processAppConfigRemoved(event);
1430 break;
1431 default:
1432 break;
1433 }
Charles Chan03a73e02016-10-24 14:52:01 -07001434 configureNetwork();
Charles Chanfc5c7802016-05-17 13:13:55 -07001435 } else if (event.configClass().equals(XConnectConfig.class)) {
1436 checkState(xConnectHandler != null, "XConnectHandler is not initialized");
1437 switch (event.type()) {
1438 case CONFIG_ADDED:
1439 xConnectHandler.processXConnectConfigAdded(event);
1440 break;
1441 case CONFIG_UPDATED:
1442 xConnectHandler.processXConnectConfigUpdated(event);
1443 break;
1444 case CONFIG_REMOVED:
1445 xConnectHandler.processXConnectConfigRemoved(event);
Charles Chan5270ed02016-01-30 23:22:37 -08001446 break;
1447 default:
1448 break;
Charles Chanb8e10c82015-10-14 11:24:40 -07001449 }
Pier Ventref34966c2016-11-07 16:21:04 -08001450 } else if (event.configClass().equals(PwaasConfig.class)) {
1451 checkState(l2TunnelHandler != null, "L2TunnelHandler is not initialized");
1452 switch (event.type()) {
1453 case CONFIG_ADDED:
1454 l2TunnelHandler.processPwaasConfigAdded(event);
1455 break;
1456 case CONFIG_UPDATED:
1457 l2TunnelHandler.processPwaasConfigUpdated(event);
1458 break;
1459 case CONFIG_REMOVED:
1460 l2TunnelHandler.processPwaasConfigRemoved(event);
1461 break;
1462 default:
1463 break;
1464 }
Charles Chand6832882015-10-05 17:50:33 -07001465 }
1466 }
Saurav Das7bcbe702017-06-13 15:35:54 -07001467
1468 private final class ConfigChange implements Runnable {
1469 @Override
1470 public void run() {
1471 programmingScheduled.set(false);
1472 for (Device device : deviceService.getDevices()) {
1473 processDeviceAdded(device);
1474 }
1475 defaultRoutingHandler.startPopulationProcess();
1476 }
1477 }
Charles Chand6832882015-10-05 17:50:33 -07001478 }
Charles Chan68aa62d2015-11-09 16:37:23 -08001479
1480 private class InternalHostListener implements HostListener {
Charles Chan68aa62d2015-11-09 16:37:23 -08001481 @Override
1482 public void event(HostEvent event) {
Charles Chan68aa62d2015-11-09 16:37:23 -08001483 switch (event.type()) {
1484 case HOST_ADDED:
Charles Chand2990362016-04-18 13:44:03 -07001485 hostHandler.processHostAddedEvent(event);
Charles Chan68aa62d2015-11-09 16:37:23 -08001486 break;
1487 case HOST_MOVED:
Charles Chand2990362016-04-18 13:44:03 -07001488 hostHandler.processHostMovedEvent(event);
Charles Chan68aa62d2015-11-09 16:37:23 -08001489 break;
1490 case HOST_REMOVED:
Charles Chanf9a52702017-06-16 15:19:24 -07001491 hostHandler.processHostRemovedEvent(event);
Charles Chan68aa62d2015-11-09 16:37:23 -08001492 break;
1493 case HOST_UPDATED:
Charles Chand2990362016-04-18 13:44:03 -07001494 hostHandler.processHostUpdatedEvent(event);
Charles Chan68aa62d2015-11-09 16:37:23 -08001495 break;
1496 default:
1497 log.warn("Unsupported host event type: {}", event.type());
1498 break;
1499 }
1500 }
1501 }
1502
Charles Chand55e84d2016-03-30 17:54:24 -07001503 private class InternalMcastListener implements McastListener {
1504 @Override
1505 public void event(McastEvent event) {
1506 switch (event.type()) {
1507 case SOURCE_ADDED:
Charles Chand2990362016-04-18 13:44:03 -07001508 mcastHandler.processSourceAdded(event);
Charles Chand55e84d2016-03-30 17:54:24 -07001509 break;
1510 case SINK_ADDED:
Charles Chand2990362016-04-18 13:44:03 -07001511 mcastHandler.processSinkAdded(event);
Charles Chand55e84d2016-03-30 17:54:24 -07001512 break;
1513 case SINK_REMOVED:
Charles Chand2990362016-04-18 13:44:03 -07001514 mcastHandler.processSinkRemoved(event);
Charles Chand55e84d2016-03-30 17:54:24 -07001515 break;
1516 case ROUTE_ADDED:
1517 case ROUTE_REMOVED:
1518 default:
1519 break;
1520 }
1521 }
1522 }
Charles Chan35fd1a72016-06-13 18:54:31 -07001523
Charles Chan03a73e02016-10-24 14:52:01 -07001524 private class InternalRouteEventListener implements RouteListener {
1525 @Override
1526 public void event(RouteEvent event) {
1527 switch (event.type()) {
1528 case ROUTE_ADDED:
1529 routeHandler.processRouteAdded(event);
1530 break;
1531 case ROUTE_UPDATED:
1532 routeHandler.processRouteUpdated(event);
1533 break;
1534 case ROUTE_REMOVED:
1535 routeHandler.processRouteRemoved(event);
1536 break;
1537 default:
1538 break;
1539 }
1540 }
1541 }
Saurav Dasc88d4662017-05-15 15:34:25 -07001542
sanghob35a6192015-04-01 13:05:26 -07001543}