blob: eebce8c0c9a04f18c5530587e15abd0779e12f78 [file] [log] [blame]
sangho80f11cb2015-04-01 13:05:26 -07001/*
Brian O'Connor0947d7e2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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
Jonathan Hart61e24e12017-11-30 18:23:42 -080018import com.google.common.collect.HashMultimap;
19import com.google.common.collect.ImmutableMap;
20import com.google.common.collect.Maps;
21import com.google.common.collect.Multimap;
Charles Chanf0ae41e2017-08-23 13:55:39 -070022import com.google.common.collect.Sets;
sangho80f11cb2015-04-01 13:05:26 -070023import org.apache.felix.scr.annotations.Activate;
24import org.apache.felix.scr.annotations.Component;
25import org.apache.felix.scr.annotations.Deactivate;
Charles Chan873661e2017-11-30 15:37:50 -080026import org.apache.felix.scr.annotations.Modified;
27import org.apache.felix.scr.annotations.Property;
sangho80f11cb2015-04-01 13:05:26 -070028import org.apache.felix.scr.annotations.Reference;
29import org.apache.felix.scr.annotations.ReferenceCardinality;
sangho27462c62015-05-14 00:39:53 -070030import org.apache.felix.scr.annotations.Service;
sangho80f11cb2015-04-01 13:05:26 -070031import org.onlab.packet.Ethernet;
Pier Ventreb6b81d52016-12-02 08:16:05 -080032import org.onlab.packet.ICMP6;
Charles Chan77277672015-10-20 16:24:19 -070033import org.onlab.packet.IPv4;
Pier Ventreb6a7f342016-11-26 21:05:22 -080034import org.onlab.packet.IPv6;
Jonghwan Hyune5ef7622017-08-25 17:48:36 -070035import org.onlab.packet.IpAddress;
Charles Chan77277672015-10-20 16:24:19 -070036import org.onlab.packet.IpPrefix;
Jonathan Hart54541d12016-04-12 15:39:44 -070037import org.onlab.packet.VlanId;
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -070038import org.onlab.util.KryoNamespace;
Charles Chan873661e2017-11-30 15:37:50 -080039import org.onlab.util.Tools;
Saurav Dasc3604f12016-03-23 11:22:49 -070040import org.onosproject.cfg.ComponentConfigService;
Pier Luigi580fd8a2018-01-16 10:47:50 +010041import org.onosproject.cluster.ClusterService;
Pierdb27b8d2018-04-17 16:29:56 +020042import org.onosproject.cluster.NodeId;
sangho80f11cb2015-04-01 13:05:26 -070043import org.onosproject.core.ApplicationId;
44import org.onosproject.core.CoreService;
45import org.onosproject.event.Event;
Charles Chanfbcb8812018-04-18 18:41:05 -070046import org.onosproject.mastership.MastershipEvent;
47import org.onosproject.mastership.MastershipListener;
Jonathan Hart54541d12016-04-12 15:39:44 -070048import org.onosproject.mastership.MastershipService;
Pier1f87aca2018-03-14 16:47:32 -070049import org.onosproject.mcast.api.McastEvent;
50import org.onosproject.mcast.api.McastListener;
51import org.onosproject.mcast.api.MulticastRouteService;
Pier Ventreb6a7f342016-11-26 21:05:22 -080052import org.onosproject.net.ConnectPoint;
Jonathan Hart54541d12016-04-12 15:39:44 -070053import org.onosproject.net.Device;
54import org.onosproject.net.DeviceId;
Charles Chanf0ae41e2017-08-23 13:55:39 -070055import org.onosproject.net.Host;
56import org.onosproject.net.HostId;
Jonathan Hart54541d12016-04-12 15:39:44 -070057import org.onosproject.net.Link;
58import org.onosproject.net.Port;
Charles Chanf4586112015-11-09 16:37:23 -080059import org.onosproject.net.PortNumber;
Jonghwan Hyune5ef7622017-08-25 17:48:36 -070060import org.onosproject.net.config.ConfigException;
Charles Chan72f556a2015-10-05 17:50:33 -070061import org.onosproject.net.config.ConfigFactory;
62import org.onosproject.net.config.NetworkConfigEvent;
Charles Chan72f556a2015-10-05 17:50:33 -070063import org.onosproject.net.config.NetworkConfigListener;
Jonathan Hart54541d12016-04-12 15:39:44 -070064import org.onosproject.net.config.NetworkConfigRegistry;
Ray Milkeyae0068a2017-08-15 11:02:29 -070065import org.onosproject.net.config.basics.InterfaceConfig;
66import org.onosproject.net.config.basics.McastConfig;
Charles Chan72f556a2015-10-05 17:50:33 -070067import org.onosproject.net.config.basics.SubjectFactories;
Saurav Dase6c448a2018-01-18 12:07:33 -080068import org.onosproject.net.device.DeviceAdminService;
Jonathan Hart54541d12016-04-12 15:39:44 -070069import org.onosproject.net.device.DeviceEvent;
70import org.onosproject.net.device.DeviceListener;
71import org.onosproject.net.device.DeviceService;
Charles Chanf4586112015-11-09 16:37:23 -080072import org.onosproject.net.flow.TrafficSelector;
73import org.onosproject.net.flow.TrafficTreatment;
Jonathan Hart54541d12016-04-12 15:39:44 -070074import org.onosproject.net.flowobjective.FlowObjectiveService;
Charles Chanf4586112015-11-09 16:37:23 -080075import org.onosproject.net.host.HostEvent;
76import org.onosproject.net.host.HostListener;
Charles Chan873661e2017-11-30 15:37:50 -080077import org.onosproject.net.host.HostLocationProbingService;
Pier Ventreb6a7f342016-11-26 21:05:22 -080078import org.onosproject.net.host.HostService;
Jonghwan Hyune5ef7622017-08-25 17:48:36 -070079import org.onosproject.net.host.InterfaceIpAddress;
Pierdb27b8d2018-04-17 16:29:56 +020080import org.onosproject.net.intent.WorkPartitionService;
Ray Milkeyae0068a2017-08-15 11:02:29 -070081import org.onosproject.net.intf.Interface;
82import org.onosproject.net.intf.InterfaceService;
Pier Ventreb6a7f342016-11-26 21:05:22 -080083import org.onosproject.net.link.LinkEvent;
84import org.onosproject.net.link.LinkListener;
85import org.onosproject.net.link.LinkService;
Ray Milkeyae0068a2017-08-15 11:02:29 -070086import org.onosproject.net.neighbour.NeighbourResolutionService;
Pier Ventreb6a7f342016-11-26 21:05:22 -080087import org.onosproject.net.packet.InboundPacket;
88import org.onosproject.net.packet.PacketContext;
89import org.onosproject.net.packet.PacketProcessor;
90import org.onosproject.net.packet.PacketService;
Pier Luigid8a15162018-02-15 16:33:08 +010091import org.onosproject.net.topology.TopologyEvent;
92import org.onosproject.net.topology.TopologyListener;
Charles Chanc91c8782016-03-30 17:54:24 -070093import org.onosproject.net.topology.TopologyService;
Charles Chanf0ae41e2017-08-23 13:55:39 -070094import org.onosproject.routeservice.ResolvedRoute;
Ray Milkeyae0068a2017-08-15 11:02:29 -070095import org.onosproject.routeservice.RouteEvent;
96import org.onosproject.routeservice.RouteListener;
97import org.onosproject.routeservice.RouteService;
Charles Chanc91c8782016-03-30 17:54:24 -070098import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
99import org.onosproject.segmentrouting.config.DeviceConfiguration;
Pier Ventre6b19e482016-11-07 16:21:04 -0800100import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig;
Ray Milkeyae0068a2017-08-15 11:02:29 -0700101import org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig;
Charles Chan82f19972016-05-17 13:13:55 -0700102import org.onosproject.segmentrouting.config.XConnectConfig;
Charles Chanc91c8782016-03-30 17:54:24 -0700103import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler;
Saurav Das261c3002017-06-13 15:35:54 -0700104import org.onosproject.segmentrouting.grouphandler.DestinationSet;
105import org.onosproject.segmentrouting.grouphandler.NextNeighbors;
Pier Luigi69f774d2018-02-28 12:10:50 +0100106import org.onosproject.segmentrouting.mcast.McastHandler;
107import org.onosproject.segmentrouting.mcast.McastRole;
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700108import org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel;
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700109import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelDescription;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800110import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelHandler;
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700111import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy;
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800112
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800113import org.onosproject.segmentrouting.pwaas.L2Tunnel;
Ray Milkeyae0068a2017-08-15 11:02:29 -0700114import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800115import org.onosproject.segmentrouting.pwaas.L2TunnelPolicy;
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800116import org.onosproject.segmentrouting.pwaas.L2TunnelDescription;
117
Saurav Das261c3002017-06-13 15:35:54 -0700118import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey;
Pier Luigi0f9635b2018-01-15 18:06:43 +0100119import org.onosproject.segmentrouting.storekey.McastStoreKey;
Charles Chan1eaf4802016-04-18 13:44:03 -0700120import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey;
Charles Chan10b0fb72017-02-02 16:20:42 -0800121import org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey;
Charles Chan82f19972016-05-17 13:13:55 -0700122import org.onosproject.segmentrouting.storekey.XConnectStoreKey;
Jonathan Hart54541d12016-04-12 15:39:44 -0700123import org.onosproject.store.serializers.KryoNamespaces;
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700124import org.onosproject.store.service.EventuallyConsistentMap;
125import org.onosproject.store.service.EventuallyConsistentMapBuilder;
126import org.onosproject.store.service.StorageService;
127import org.onosproject.store.service.WallClockTimestamp;
Charles Chan873661e2017-11-30 15:37:50 -0800128import org.osgi.service.component.ComponentContext;
sangho80f11cb2015-04-01 13:05:26 -0700129import org.slf4j.Logger;
130import org.slf4j.LoggerFactory;
131
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700132import java.util.ArrayList;
Jonathan Hart61e24e12017-11-30 18:23:42 -0800133import java.util.Collections;
Charles Chan873661e2017-11-30 15:37:50 -0800134import java.util.Dictionary;
Jonathan Hart61e24e12017-11-30 18:23:42 -0800135import java.util.HashSet;
136import java.util.List;
137import java.util.Map;
Jonathan Hart61e24e12017-11-30 18:23:42 -0800138import java.util.Optional;
139import java.util.Set;
Andrea Campanella060cad82018-04-17 12:09:34 +0200140import java.util.concurrent.CompletableFuture;
Jonathan Hart61e24e12017-11-30 18:23:42 -0800141import java.util.concurrent.ConcurrentHashMap;
Andrea Campanella060cad82018-04-17 12:09:34 +0200142import java.util.concurrent.CopyOnWriteArrayList;
Jonathan Hart61e24e12017-11-30 18:23:42 -0800143import java.util.concurrent.Executors;
144import java.util.concurrent.ScheduledExecutorService;
Jonathan Hart61e24e12017-11-30 18:23:42 -0800145import java.util.concurrent.TimeUnit;
146import java.util.concurrent.atomic.AtomicBoolean;
147import java.util.stream.Collectors;
sangho80f11cb2015-04-01 13:05:26 -0700148
Charles Chand6d25332016-02-26 22:19:52 -0800149import static com.google.common.base.Preconditions.checkState;
Pier Ventreadb4ae62016-11-23 09:57:42 -0800150import static org.onlab.packet.Ethernet.TYPE_ARP;
Yuta HIGUCHIebee2f12016-07-21 16:54:33 -0700151import static org.onlab.util.Tools.groupedThreads;
Saurav Dase321cff2018-02-09 17:26:45 -0800152import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_REGISTERED;
153import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UNREGISTERED;
Charles Chand6d25332016-02-26 22:19:52 -0800154
Charles Chanb7f75ac2016-01-11 18:28:54 -0800155/**
156 * Segment routing manager.
157 */
Jonathan Hart54541d12016-04-12 15:39:44 -0700158@Service
159@Component(immediate = true)
sangho27462c62015-05-14 00:39:53 -0700160public class SegmentRoutingManager implements SegmentRoutingService {
sangho80f11cb2015-04-01 13:05:26 -0700161
Charles Chan46fdfaf2016-11-09 20:51:44 -0800162 private static Logger log = LoggerFactory.getLogger(SegmentRoutingManager.class);
Charles Chan910be6a2017-08-23 14:46:43 -0700163 private static final String NOT_MASTER = "Current instance is not the master of {}. Ignore.";
sangho80f11cb2015-04-01 13:05:26 -0700164
165 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700166 private ComponentConfigService compCfgService;
sangho80f11cb2015-04-01 13:05:26 -0700167
168 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventreb6a7f342016-11-26 21:05:22 -0800169 private NeighbourResolutionService neighbourResolutionService;
170
171 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Luigi69f774d2018-02-28 12:10:50 +0100172 public CoreService coreService;
sangho80f11cb2015-04-01 13:05:26 -0700173
174 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700175 PacketService packetService;
sangho80f11cb2015-04-01 13:05:26 -0700176
177 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700178 HostService hostService;
sangho80f11cb2015-04-01 13:05:26 -0700179
180 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan873661e2017-11-30 15:37:50 -0800181 HostLocationProbingService probingService;
182
183 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Luigi69f774d2018-02-28 12:10:50 +0100184 public DeviceService deviceService;
sangho80f11cb2015-04-01 13:05:26 -0700185
186 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Saurav Dase6c448a2018-01-18 12:07:33 -0800187 DeviceAdminService deviceAdminService;
188
189 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventref3cf5b92016-11-09 14:17:26 -0800190 public FlowObjectiveService flowObjectiveService;
sangho80f11cb2015-04-01 13:05:26 -0700191
192 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Luigi69f774d2018-02-28 12:10:50 +0100193 public LinkService linkService;
sangho27462c62015-05-14 00:39:53 -0700194
Charles Chan82ab1932016-01-30 23:22:37 -0800195 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventref3cf5b92016-11-09 14:17:26 -0800196 public MastershipService mastershipService;
Charles Chandebfea32016-10-24 14:52:01 -0700197
198 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Ventref3cf5b92016-11-09 14:17:26 -0800199 public StorageService storageService;
Charles Chandebfea32016-10-24 14:52:01 -0700200
201 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pier Luigi69f774d2018-02-28 12:10:50 +0100202 public MulticastRouteService multicastRouteService;
Charles Chandebfea32016-10-24 14:52:01 -0700203
204 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan83163812018-01-09 13:45:07 -0800205 public TopologyService topologyService;
Charles Chandebfea32016-10-24 14:52:01 -0700206
207 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chandebfea32016-10-24 14:52:01 -0700208 RouteService routeService;
Charles Chan82ab1932016-01-30 23:22:37 -0800209
210 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan46fdfaf2016-11-09 20:51:44 -0800211 public NetworkConfigRegistry cfgService;
Charles Chan82ab1932016-01-30 23:22:37 -0800212
Saurav Dasc3604f12016-03-23 11:22:49 -0700213 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Charles Chan46fdfaf2016-11-09 20:51:44 -0800214 public InterfaceService interfaceService;
215
Pier Luigi580fd8a2018-01-16 10:47:50 +0100216 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
217 public ClusterService clusterService;
218
219 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Pierdb27b8d2018-04-17 16:29:56 +0200220 public WorkPartitionService workPartitionService;
Pier Luigi580fd8a2018-01-16 10:47:50 +0100221
Charles Chan873661e2017-11-30 15:37:50 -0800222 @Property(name = "activeProbing", boolValue = true,
223 label = "Enable active probing to discover dual-homed hosts.")
224 boolean activeProbing = true;
225
Charles Chandebfea32016-10-24 14:52:01 -0700226 ArpHandler arpHandler = null;
227 IcmpHandler icmpHandler = null;
228 IpHandler ipHandler = null;
229 RoutingRulePopulator routingRulePopulator = null;
Ray Milkeyb85de082017-04-05 09:42:04 -0700230 ApplicationId appId;
231 DeviceConfiguration deviceConfiguration = null;
sangho80f11cb2015-04-01 13:05:26 -0700232
Charles Chandebfea32016-10-24 14:52:01 -0700233 DefaultRoutingHandler defaultRoutingHandler = null;
sangho27462c62015-05-14 00:39:53 -0700234 private TunnelHandler tunnelHandler = null;
235 private PolicyHandler policyHandler = null;
Charles Chan2b078ae2015-10-14 11:24:40 -0700236 private InternalPacketProcessor processor = null;
237 private InternalLinkListener linkListener = null;
238 private InternalDeviceListener deviceListener = null;
Charles Chan82f19972016-05-17 13:13:55 -0700239 private AppConfigHandler appCfgHandler = null;
Pier Luigi69f774d2018-02-28 12:10:50 +0100240 public XConnectHandler xConnectHandler = null;
Saurav Dase6c448a2018-01-18 12:07:33 -0800241 McastHandler mcastHandler = null;
242 HostHandler hostHandler = null;
Pier Ventreb6a7f342016-11-26 21:05:22 -0800243 private RouteHandler routeHandler = null;
Saurav Dase6c448a2018-01-18 12:07:33 -0800244 LinkHandler linkHandler = null;
Pier Ventreb6b81d52016-12-02 08:16:05 -0800245 private SegmentRoutingNeighbourDispatcher neighbourHandler = null;
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800246 private DefaultL2TunnelHandler l2TunnelHandler = null;
Pier Luigid8a15162018-02-15 16:33:08 +0100247 private TopologyHandler topologyHandler = null;
Charles Chan82ab1932016-01-30 23:22:37 -0800248 private final InternalHostListener hostListener = new InternalHostListener();
Charles Chanc91c8782016-03-30 17:54:24 -0700249 private final InternalConfigListener cfgListener = new InternalConfigListener(this);
250 private final InternalMcastListener mcastListener = new InternalMcastListener();
Charles Chandebfea32016-10-24 14:52:01 -0700251 private final InternalRouteEventListener routeListener = new InternalRouteEventListener();
Pier Luigid8a15162018-02-15 16:33:08 +0100252 private final InternalTopologyListener topologyListener = new InternalTopologyListener();
Charles Chanfbcb8812018-04-18 18:41:05 -0700253 private final InternalMastershipListener mastershipListener = new InternalMastershipListener();
Andrea Campanella060cad82018-04-17 12:09:34 +0200254 //Completable future for network configuration process to buffer config events handling during activation
255 private CompletableFuture<Boolean> networkConfigCompletion = null;
Charles Chan39b75522018-04-21 00:44:29 -0700256 private List<Event> queuedEvents = new CopyOnWriteArrayList<>();
sangho80f11cb2015-04-01 13:05:26 -0700257
Charles Chan52003922018-04-05 16:31:15 -0700258 // Handles device, link, topology and network config events
Charles Chanfbcb8812018-04-18 18:41:05 -0700259 private ScheduledExecutorService mainEventExecutor;
sangho80f11cb2015-04-01 13:05:26 -0700260
Charles Chanfbcb8812018-04-18 18:41:05 -0700261 // Handles host, route and mcast events respectively
262 private ScheduledExecutorService hostEventExecutor;
263 private ScheduledExecutorService routeEventExecutor;
264 private ScheduledExecutorService mcastEventExecutor;
Charles Chan52003922018-04-05 16:31:15 -0700265
266 Map<DeviceId, DefaultGroupHandler> groupHandlerMap = new ConcurrentHashMap<>();
Charles Chanb7f75ac2016-01-11 18:28:54 -0800267 /**
Saurav Das261c3002017-06-13 15:35:54 -0700268 * Per device next objective ID store with (device id + destination set) as key.
Charles Chan53de91f2017-08-22 15:07:34 -0700269 * Used to keep track on MPLS group information.
Charles Chanb7f75ac2016-01-11 18:28:54 -0800270 */
Charles Chan873661e2017-11-30 15:37:50 -0800271 private EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey, NextNeighbors>
Saurav Das261c3002017-06-13 15:35:54 -0700272 dsNextObjStore = null;
Charles Chanb7f75ac2016-01-11 18:28:54 -0800273 /**
Charles Chan53de91f2017-08-22 15:07:34 -0700274 * Per device next objective ID store with (device id + vlanid) as key.
275 * Used to keep track on L2 flood group information.
Charles Chanb7f75ac2016-01-11 18:28:54 -0800276 */
Charles Chan873661e2017-11-30 15:37:50 -0800277 private EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer>
Charles Chan10b0fb72017-02-02 16:20:42 -0800278 vlanNextObjStore = null;
Charles Chanb7f75ac2016-01-11 18:28:54 -0800279 /**
Charles Chan53de91f2017-08-22 15:07:34 -0700280 * Per device next objective ID store with (device id + port + treatment + meta) as key.
281 * Used to keep track on L2 interface group and L3 unicast group information.
Charles Chanb7f75ac2016-01-11 18:28:54 -0800282 */
Charles Chan873661e2017-11-30 15:37:50 -0800283 private EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer>
Saurav Das2d94d312015-11-24 23:21:05 -0800284 portNextObjStore = null;
Charles Chan10b0fb72017-02-02 16:20:42 -0800285
Saurav Das2d94d312015-11-24 23:21:05 -0800286 private EventuallyConsistentMap<String, Tunnel> tunnelStore = null;
287 private EventuallyConsistentMap<String, Policy> policyStore = null;
sangho4a5c42a2015-05-20 22:16:38 -0700288
Saurav Das261c3002017-06-13 15:35:54 -0700289 private AtomicBoolean programmingScheduled = new AtomicBoolean();
290
Charles Chanc91c8782016-03-30 17:54:24 -0700291 private final ConfigFactory<DeviceId, SegmentRoutingDeviceConfig> deviceConfigFactory =
Charles Chan82f19972016-05-17 13:13:55 -0700292 new ConfigFactory<DeviceId, SegmentRoutingDeviceConfig>(
293 SubjectFactories.DEVICE_SUBJECT_FACTORY,
Charles Chanc91c8782016-03-30 17:54:24 -0700294 SegmentRoutingDeviceConfig.class, "segmentrouting") {
Charles Chan72f556a2015-10-05 17:50:33 -0700295 @Override
Charles Chan82ab1932016-01-30 23:22:37 -0800296 public SegmentRoutingDeviceConfig createConfig() {
297 return new SegmentRoutingDeviceConfig();
Charles Chan72f556a2015-10-05 17:50:33 -0700298 }
299 };
Pier Ventre6b19e482016-11-07 16:21:04 -0800300
Charles Chanc91c8782016-03-30 17:54:24 -0700301 private final ConfigFactory<ApplicationId, SegmentRoutingAppConfig> appConfigFactory =
Charles Chan82f19972016-05-17 13:13:55 -0700302 new ConfigFactory<ApplicationId, SegmentRoutingAppConfig>(
303 SubjectFactories.APP_SUBJECT_FACTORY,
Charles Chanc91c8782016-03-30 17:54:24 -0700304 SegmentRoutingAppConfig.class, "segmentrouting") {
Charles Chan82ab1932016-01-30 23:22:37 -0800305 @Override
306 public SegmentRoutingAppConfig createConfig() {
307 return new SegmentRoutingAppConfig();
308 }
309 };
Pier Ventre6b19e482016-11-07 16:21:04 -0800310
Charles Chan82f19972016-05-17 13:13:55 -0700311 private final ConfigFactory<ApplicationId, XConnectConfig> xConnectConfigFactory =
312 new ConfigFactory<ApplicationId, XConnectConfig>(
313 SubjectFactories.APP_SUBJECT_FACTORY,
314 XConnectConfig.class, "xconnect") {
315 @Override
316 public XConnectConfig createConfig() {
317 return new XConnectConfig();
318 }
319 };
Pier Ventre6b19e482016-11-07 16:21:04 -0800320
Charles Chanc91c8782016-03-30 17:54:24 -0700321 private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory =
Charles Chan82f19972016-05-17 13:13:55 -0700322 new ConfigFactory<ApplicationId, McastConfig>(
323 SubjectFactories.APP_SUBJECT_FACTORY,
Charles Chanc91c8782016-03-30 17:54:24 -0700324 McastConfig.class, "multicast") {
325 @Override
326 public McastConfig createConfig() {
327 return new McastConfig();
328 }
329 };
330
Charles Chan1963f4f2016-02-18 14:22:42 -0800331 /**
332 * Segment Routing App ID.
333 */
Charles Chan46fdfaf2016-11-09 20:51:44 -0800334 public static final String APP_NAME = "org.onosproject.segmentrouting";
Charles Chan10b0fb72017-02-02 16:20:42 -0800335
Charles Chanb7f75ac2016-01-11 18:28:54 -0800336 /**
337 * The default VLAN ID assigned to the interfaces without subnet config.
338 */
Charles Chan10b0fb72017-02-02 16:20:42 -0800339 public static final VlanId INTERNAL_VLAN = VlanId.vlanId((short) 4094);
Saurav Das7c305372015-10-28 12:39:42 -0700340
sangho80f11cb2015-04-01 13:05:26 -0700341 @Activate
Charles Chan873661e2017-11-30 15:37:50 -0800342 protected void activate(ComponentContext context) {
Charles Chan46fdfaf2016-11-09 20:51:44 -0800343 appId = coreService.registerApplication(APP_NAME);
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700344
Charles Chanfbcb8812018-04-18 18:41:05 -0700345 mainEventExecutor = Executors.newSingleThreadScheduledExecutor(groupedThreads("sr-event-main", "%d", log));
346 hostEventExecutor = Executors.newSingleThreadScheduledExecutor(groupedThreads("sr-event-host", "%d", log));
347 routeEventExecutor = Executors.newSingleThreadScheduledExecutor(groupedThreads("sr-event-route", "%d", log));
348 mcastEventExecutor = Executors.newSingleThreadScheduledExecutor(groupedThreads("sr-event-mcast", "%d", log));
349
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700350 log.debug("Creating EC map nsnextobjectivestore");
Saurav Das261c3002017-06-13 15:35:54 -0700351 EventuallyConsistentMapBuilder<DestinationSetNextObjectiveStoreKey, NextNeighbors>
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700352 nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
Saurav Das261c3002017-06-13 15:35:54 -0700353 dsNextObjStore = nsNextObjMapBuilder
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700354 .withName("nsnextobjectivestore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700355 .withSerializer(createSerializer())
Madan Jampani675ae202015-06-24 19:05:56 -0700356 .withTimestampProvider((k, v) -> new WallClockTimestamp())
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700357 .build();
Saurav Das261c3002017-06-13 15:35:54 -0700358 log.trace("Current size {}", dsNextObjStore.size());
Srikanth Vavilapalli7cd16712015-05-04 09:48:09 -0700359
Charles Chan10b0fb72017-02-02 16:20:42 -0800360 log.debug("Creating EC map vlannextobjectivestore");
361 EventuallyConsistentMapBuilder<VlanNextObjectiveStoreKey, Integer>
362 vlanNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
363 vlanNextObjStore = vlanNextObjMapBuilder
364 .withName("vlannextobjectivestore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700365 .withSerializer(createSerializer())
Charles Chan77277672015-10-20 16:24:19 -0700366 .withTimestampProvider((k, v) -> new WallClockTimestamp())
367 .build();
368
Saurav Das2d94d312015-11-24 23:21:05 -0800369 log.debug("Creating EC map subnetnextobjectivestore");
370 EventuallyConsistentMapBuilder<PortNextObjectiveStoreKey, Integer>
371 portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder();
372 portNextObjStore = portNextObjMapBuilder
373 .withName("portnextobjectivestore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700374 .withSerializer(createSerializer())
Saurav Das2d94d312015-11-24 23:21:05 -0800375 .withTimestampProvider((k, v) -> new WallClockTimestamp())
376 .build();
377
sangho4a5c42a2015-05-20 22:16:38 -0700378 EventuallyConsistentMapBuilder<String, Tunnel> tunnelMapBuilder =
379 storageService.eventuallyConsistentMapBuilder();
sangho4a5c42a2015-05-20 22:16:38 -0700380 tunnelStore = tunnelMapBuilder
381 .withName("tunnelstore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700382 .withSerializer(createSerializer())
Madan Jampani675ae202015-06-24 19:05:56 -0700383 .withTimestampProvider((k, v) -> new WallClockTimestamp())
sangho4a5c42a2015-05-20 22:16:38 -0700384 .build();
385
386 EventuallyConsistentMapBuilder<String, Policy> policyMapBuilder =
387 storageService.eventuallyConsistentMapBuilder();
sangho4a5c42a2015-05-20 22:16:38 -0700388 policyStore = policyMapBuilder
389 .withName("policystore")
Jonathan Hart54541d12016-04-12 15:39:44 -0700390 .withSerializer(createSerializer())
Madan Jampani675ae202015-06-24 19:05:56 -0700391 .withTimestampProvider((k, v) -> new WallClockTimestamp())
sangho4a5c42a2015-05-20 22:16:38 -0700392 .build();
393
Saurav Dasc3604f12016-03-23 11:22:49 -0700394 compCfgService.preSetProperty("org.onosproject.net.group.impl.GroupManager",
Pier Luigib9632ba2017-01-12 18:14:58 -0800395 "purgeOnDisconnection", "true");
Saurav Dasc3604f12016-03-23 11:22:49 -0700396 compCfgService.preSetProperty("org.onosproject.net.flow.impl.FlowRuleManager",
Pier Luigib9632ba2017-01-12 18:14:58 -0800397 "purgeOnDisconnection", "true");
Pier Luigib9632ba2017-01-12 18:14:58 -0800398 compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider",
399 "requestInterceptsEnabled", "false");
Charles Chanc1909e12017-08-08 15:13:37 -0700400 compCfgService.preSetProperty("org.onosproject.net.neighbour.impl.NeighbourResolutionManager",
Pier Luigibc976df2017-01-12 22:46:39 -0800401 "requestInterceptsEnabled", "false");
Charles Chan9597f8d2017-07-24 15:56:10 -0700402 compCfgService.preSetProperty("org.onosproject.dhcprelay.DhcpRelayManager",
Pier Luigibc976df2017-01-12 22:46:39 -0800403 "arpEnabled", "false");
Pier Luigi0ebeb312017-02-02 22:31:34 -0800404 compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager",
405 "greedyLearningIpv6", "true");
Charles Chancf8ea472017-02-28 15:15:17 -0800406 compCfgService.preSetProperty("org.onosproject.routing.cpr.ControlPlaneRedirectManager",
407 "forceUnprovision", "true");
Charles Chanc7b73c72017-08-10 16:57:28 -0700408 compCfgService.preSetProperty("org.onosproject.routeservice.store.RouteStoreImpl",
Charles Chan4c95c0d2017-07-20 16:16:25 -0700409 "distributed", "true");
Charles Chan804772f2017-08-14 11:42:11 -0700410 compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider",
411 "multihomingEnabled", "true");
Charles Chan0c9c19f2017-11-29 19:54:20 -0800412 compCfgService.preSetProperty("org.onosproject.provider.lldp.impl.LldpLinkProvider",
413 "staleLinkAge", "15000");
414 compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager",
415 "allowDuplicateIps", "false");
Charles Chan873661e2017-11-30 15:37:50 -0800416 compCfgService.registerProperties(getClass());
417 modified(context);
Saurav Dasc3604f12016-03-23 11:22:49 -0700418
Charles Chan2b078ae2015-10-14 11:24:40 -0700419 processor = new InternalPacketProcessor();
420 linkListener = new InternalLinkListener();
421 deviceListener = new InternalDeviceListener();
Charles Chan82f19972016-05-17 13:13:55 -0700422 appCfgHandler = new AppConfigHandler(this);
423 xConnectHandler = new XConnectHandler(this);
Charles Chan1eaf4802016-04-18 13:44:03 -0700424 mcastHandler = new McastHandler(this);
425 hostHandler = new HostHandler(this);
Saurav Dase6c448a2018-01-18 12:07:33 -0800426 linkHandler = new LinkHandler(this);
Charles Chandebfea32016-10-24 14:52:01 -0700427 routeHandler = new RouteHandler(this);
Pier Ventreb6b81d52016-12-02 08:16:05 -0800428 neighbourHandler = new SegmentRoutingNeighbourDispatcher(this);
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800429 l2TunnelHandler = new DefaultL2TunnelHandler(this);
Pier Luigid8a15162018-02-15 16:33:08 +0100430 topologyHandler = new TopologyHandler(this);
Charles Chan2b078ae2015-10-14 11:24:40 -0700431
Charles Chand6d25332016-02-26 22:19:52 -0800432 cfgService.addListener(cfgListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700433 cfgService.registerConfigFactory(deviceConfigFactory);
434 cfgService.registerConfigFactory(appConfigFactory);
Charles Chan82f19972016-05-17 13:13:55 -0700435 cfgService.registerConfigFactory(xConnectConfigFactory);
Charles Chanc91c8782016-03-30 17:54:24 -0700436 cfgService.registerConfigFactory(mcastConfigFactory);
Saurav Dase321cff2018-02-09 17:26:45 -0800437 log.info("Configuring network before adding listeners");
Andrea Campanella060cad82018-04-17 12:09:34 +0200438
Charles Chan6961f222018-01-04 14:26:07 -0800439 cfgListener.configureNetwork();
440
Charles Chan82ab1932016-01-30 23:22:37 -0800441 hostService.addListener(hostListener);
Charles Chan2b078ae2015-10-14 11:24:40 -0700442 packetService.addProcessor(processor, PacketProcessor.director(2));
443 linkService.addListener(linkListener);
444 deviceService.addListener(deviceListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700445 multicastRouteService.addListener(mcastListener);
Charles Chanfd48c222017-06-19 00:43:31 -0700446 routeService.addListener(routeListener);
Pier Luigid8a15162018-02-15 16:33:08 +0100447 topologyService.addListener(topologyListener);
Charles Chanfbcb8812018-04-18 18:41:05 -0700448 mastershipService.addListener(mastershipListener);
Charles Chan2b078ae2015-10-14 11:24:40 -0700449
Charles Chanc12c3d02018-03-09 15:53:44 -0800450 linkHandler.init();
Andreas Pantelopoulos75eef062018-01-11 07:53:48 -0800451 l2TunnelHandler.init();
452
Andrea Campanella060cad82018-04-17 12:09:34 +0200453 networkConfigCompletion.whenComplete((value, ex) -> {
454 //setting to null for easier fall through
455 networkConfigCompletion = null;
456 //process all queued events
Charles Chan39b75522018-04-21 00:44:29 -0700457 queuedEvents.forEach(event -> {
Andrea Campanella060cad82018-04-17 12:09:34 +0200458 mainEventExecutor.execute(new InternalEventHandler(event));
459 });
460 });
461
sangho80f11cb2015-04-01 13:05:26 -0700462 log.info("Started");
463 }
464
Saurav Dase6c448a2018-01-18 12:07:33 -0800465 KryoNamespace.Builder createSerializer() {
Jonathan Hart54541d12016-04-12 15:39:44 -0700466 return new KryoNamespace.Builder()
467 .register(KryoNamespaces.API)
Saurav Das261c3002017-06-13 15:35:54 -0700468 .register(DestinationSetNextObjectiveStoreKey.class,
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800469 VlanNextObjectiveStoreKey.class,
470 DestinationSet.class,
471 NextNeighbors.class,
472 Tunnel.class,
473 DefaultTunnel.class,
474 Policy.class,
475 TunnelPolicy.class,
476 Policy.Type.class,
477 PortNextObjectiveStoreKey.class,
478 XConnectStoreKey.class,
479 L2Tunnel.class,
480 L2TunnelPolicy.class,
481 DefaultL2Tunnel.class,
482 DefaultL2TunnelPolicy.class
Jonathan Hart54541d12016-04-12 15:39:44 -0700483 );
484 }
485
sangho80f11cb2015-04-01 13:05:26 -0700486 @Deactivate
487 protected void deactivate() {
Charles Chanfbcb8812018-04-18 18:41:05 -0700488 mainEventExecutor.shutdown();
489 hostEventExecutor.shutdown();
490 routeEventExecutor.shutdown();
491 mcastEventExecutor.shutdown();
492
Charles Chan72f556a2015-10-05 17:50:33 -0700493 cfgService.removeListener(cfgListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700494 cfgService.unregisterConfigFactory(deviceConfigFactory);
495 cfgService.unregisterConfigFactory(appConfigFactory);
Charles Chandebfea32016-10-24 14:52:01 -0700496 cfgService.unregisterConfigFactory(xConnectConfigFactory);
Charles Chanc91c8782016-03-30 17:54:24 -0700497 cfgService.unregisterConfigFactory(mcastConfigFactory);
Charles Chan873661e2017-11-30 15:37:50 -0800498 compCfgService.unregisterProperties(getClass(), false);
Charles Chan72f556a2015-10-05 17:50:33 -0700499
Charles Chanfd48c222017-06-19 00:43:31 -0700500 hostService.removeListener(hostListener);
sangho80f11cb2015-04-01 13:05:26 -0700501 packetService.removeProcessor(processor);
Charles Chan2b078ae2015-10-14 11:24:40 -0700502 linkService.removeListener(linkListener);
503 deviceService.removeListener(deviceListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700504 multicastRouteService.removeListener(mcastListener);
Charles Chandebfea32016-10-24 14:52:01 -0700505 routeService.removeListener(routeListener);
Pier Luigid8a15162018-02-15 16:33:08 +0100506 topologyService.removeListener(topologyListener);
Charles Chanfbcb8812018-04-18 18:41:05 -0700507 mastershipService.removeListener(mastershipListener);
Charles Chanc91c8782016-03-30 17:54:24 -0700508
Charles Chan2e71ef32017-02-23 15:44:08 -0800509 neighbourResolutionService.unregisterNeighbourHandlers(appId);
510
sangho80f11cb2015-04-01 13:05:26 -0700511 processor = null;
Charles Chan2b078ae2015-10-14 11:24:40 -0700512 linkListener = null;
Charles Chanc91c8782016-03-30 17:54:24 -0700513 deviceListener = null;
Charles Chan05bb1702018-04-19 13:10:01 -0700514 groupHandlerMap.forEach((k, v) -> v.shutdown());
Charles Chan2b078ae2015-10-14 11:24:40 -0700515 groupHandlerMap.clear();
516
Saurav Das261c3002017-06-13 15:35:54 -0700517 dsNextObjStore.destroy();
Charles Chan10b0fb72017-02-02 16:20:42 -0800518 vlanNextObjStore.destroy();
Charles Chanc91c8782016-03-30 17:54:24 -0700519 portNextObjStore.destroy();
Charles Chanc91c8782016-03-30 17:54:24 -0700520 tunnelStore.destroy();
521 policyStore.destroy();
Pier Luigi35dab3f2018-01-25 16:16:02 +0100522
523 mcastHandler.terminate();
sangho80f11cb2015-04-01 13:05:26 -0700524 log.info("Stopped");
525 }
526
Charles Chan873661e2017-11-30 15:37:50 -0800527 @Modified
528 private void modified(ComponentContext context) {
529 Dictionary<?, ?> properties = context.getProperties();
530 if (properties == null) {
531 return;
532 }
533
534 String strActiveProving = Tools.get(properties, "activeProbing");
535 boolean expectActiveProbing = Boolean.parseBoolean(strActiveProving);
536
537 if (expectActiveProbing != activeProbing) {
538 activeProbing = expectActiveProbing;
539 log.info("{} active probing", activeProbing ? "Enabling" : "Disabling");
540 }
541 }
542
sangho27462c62015-05-14 00:39:53 -0700543 @Override
544 public List<Tunnel> getTunnels() {
545 return tunnelHandler.getTunnels();
546 }
547
548 @Override
sanghobd812f82015-06-29 14:58:47 -0700549 public TunnelHandler.Result createTunnel(Tunnel tunnel) {
550 return tunnelHandler.createTunnel(tunnel);
sangho27462c62015-05-14 00:39:53 -0700551 }
552
553 @Override
sanghobd812f82015-06-29 14:58:47 -0700554 public TunnelHandler.Result removeTunnel(Tunnel tunnel) {
sangho27462c62015-05-14 00:39:53 -0700555 for (Policy policy: policyHandler.getPolicies()) {
556 if (policy.type() == Policy.Type.TUNNEL_FLOW) {
557 TunnelPolicy tunnelPolicy = (TunnelPolicy) policy;
558 if (tunnelPolicy.tunnelId().equals(tunnel.id())) {
559 log.warn("Cannot remove the tunnel used by a policy");
sanghobd812f82015-06-29 14:58:47 -0700560 return TunnelHandler.Result.TUNNEL_IN_USE;
sangho27462c62015-05-14 00:39:53 -0700561 }
562 }
563 }
sanghobd812f82015-06-29 14:58:47 -0700564 return tunnelHandler.removeTunnel(tunnel);
sangho27462c62015-05-14 00:39:53 -0700565 }
566
567 @Override
sanghobd812f82015-06-29 14:58:47 -0700568 public PolicyHandler.Result removePolicy(Policy policy) {
569 return policyHandler.removePolicy(policy);
sangho27462c62015-05-14 00:39:53 -0700570 }
571
572 @Override
sanghobd812f82015-06-29 14:58:47 -0700573 public PolicyHandler.Result createPolicy(Policy policy) {
574 return policyHandler.createPolicy(policy);
sangho27462c62015-05-14 00:39:53 -0700575 }
576
577 @Override
578 public List<Policy> getPolicies() {
579 return policyHandler.getPolicies();
580 }
581
Saurav Das07c74602016-04-27 18:35:50 -0700582 @Override
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700583 public Set<L2TunnelDescription> getL2TunnelDescriptions(boolean pending) {
584 return l2TunnelHandler.getL2Descriptions(pending);
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700585 }
586
587 @Override
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800588 public List<L2Tunnel> getL2Tunnels() {
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700589 return l2TunnelHandler.getL2Tunnels();
590 }
591
592 @Override
Andreas Pantelopoulos4c7de132018-02-22 12:32:42 -0800593 public List<L2TunnelPolicy> getL2Policies() {
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700594 return l2TunnelHandler.getL2Policies();
595 }
596
Saurav Dasdebcf882018-04-06 20:16:01 -0700597 @Override
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700598 @Deprecated
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700599 public L2TunnelHandler.Result addPseudowiresBulk(List<DefaultL2TunnelDescription> bulkPseudowires) {
600
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700601 // get both added and pending pseudowires
602 List<L2TunnelDescription> pseudowires = new ArrayList<>();
603 pseudowires.addAll(l2TunnelHandler.getL2Descriptions(false));
604 pseudowires.addAll(l2TunnelHandler.getL2Descriptions(true));
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700605 pseudowires.addAll(bulkPseudowires);
Andreas Pantelopoulosd988c1a2018-03-15 16:56:09 -0700606
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700607 Set<L2TunnelDescription> newPseudowires = new HashSet(bulkPseudowires);
608
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700609 L2TunnelHandler.Result retRes = L2TunnelHandler.Result.SUCCESS;
610 L2TunnelHandler.Result res;
611 for (DefaultL2TunnelDescription pw : bulkPseudowires) {
612 res = addPseudowire(pw);
613 if (res != L2TunnelHandler.Result.SUCCESS) {
614 log.error("Pseudowire with id {} can not be instantiated !", res);
615 retRes = res;
616 }
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700617 }
Andreas Pantelopoulos96851252018-03-20 13:58:49 -0700618
619 return retRes;
Andreas Pantelopoulosfc4bc2a2018-03-12 16:30:20 -0700620 }
621
622 @Override
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800623 public L2TunnelHandler.Result addPseudowire(L2TunnelDescription l2TunnelDescription) {
Andreas Pantelopoulos87a06102018-03-21 16:44:18 -0700624 return l2TunnelHandler.deployPseudowire(l2TunnelDescription);
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700625 }
626
627 @Override
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -0800628 public L2TunnelHandler.Result removePseudowire(Integer pwId) {
Andreas Pantelopoulos87a06102018-03-21 16:44:18 -0700629 return l2TunnelHandler.tearDownPseudowire(pwId);
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -0700630 }
631
632 @Override
Saurav Das07c74602016-04-27 18:35:50 -0700633 public void rerouteNetwork() {
634 cfgListener.configureNetwork();
Saurav Das07c74602016-04-27 18:35:50 -0700635 }
636
Charles Chand7844e52016-10-20 17:02:44 -0700637 @Override
Pier Ventreb6a7f342016-11-26 21:05:22 -0800638 public Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap() {
639 Map<DeviceId, Set<IpPrefix>> deviceSubnetMap = Maps.newHashMap();
Jonathan Hart61e24e12017-11-30 18:23:42 -0800640 deviceConfiguration.getRouters().forEach(device ->
641 deviceSubnetMap.put(device, deviceConfiguration.getSubnets(device)));
Charles Chand7844e52016-10-20 17:02:44 -0700642 return deviceSubnetMap;
643 }
644
Saurav Das62ae6792017-05-15 15:34:25 -0700645
646 @Override
647 public ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg() {
648 if (defaultRoutingHandler != null) {
649 return defaultRoutingHandler.getCurrentEmcpSpgMap();
650 } else {
651 return null;
652 }
653 }
654
655 @Override
Saurav Das261c3002017-06-13 15:35:54 -0700656 public ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDestinationSet() {
657 if (dsNextObjStore != null) {
658 return ImmutableMap.copyOf(dsNextObjStore.entrySet());
Saurav Das62ae6792017-05-15 15:34:25 -0700659 } else {
660 return ImmutableMap.of();
661 }
662 }
663
Saurav Dasfbe74572017-08-03 18:30:35 -0700664 @Override
665 public void verifyGroups(DeviceId id) {
666 DefaultGroupHandler gh = groupHandlerMap.get(id);
667 if (gh != null) {
668 gh.triggerBucketCorrector();
669 }
670 }
671
Saurav Das6430f412018-01-25 09:49:01 -0800672 @Override
673 public ImmutableMap<Link, Boolean> getSeenLinks() {
674 return linkHandler.getSeenLinks();
675 }
676
677 @Override
678 public ImmutableMap<DeviceId, Set<PortNumber>> getDownedPortState() {
679 return linkHandler.getDownedPorts();
680 }
681
Pier Luigi0f9635b2018-01-15 18:06:43 +0100682 @Override
683 public Map<McastStoreKey, Integer> getMcastNextIds(IpAddress mcastIp) {
684 return mcastHandler.getMcastNextIds(mcastIp);
685 }
686
687 @Override
Pier Luigi69f774d2018-02-28 12:10:50 +0100688 public Map<McastStoreKey, McastRole> getMcastRoles(IpAddress mcastIp) {
Pier Luigi0f9635b2018-01-15 18:06:43 +0100689 return mcastHandler.getMcastRoles(mcastIp);
690 }
691
692 @Override
693 public Map<ConnectPoint, List<ConnectPoint>> getMcastPaths(IpAddress mcastIp) {
694 return mcastHandler.getMcastPaths(mcastIp);
695 }
696
Pierdb27b8d2018-04-17 16:29:56 +0200697 @Override
Pier71c55772018-04-17 17:25:22 +0200698 public Multimap<ConnectPoint, List<ConnectPoint>> getMcastTrees(IpAddress mcastIp,
699 ConnectPoint sourcecp) {
700 return mcastHandler.getMcastTrees(mcastIp, sourcecp);
701 }
702
703 @Override
Pierdb27b8d2018-04-17 16:29:56 +0200704 public Map<IpAddress, NodeId> getMcastLeaders(IpAddress mcastIp) {
705 return mcastHandler.getMcastLeaders(mcastIp);
706 }
707
Charles Chanb13e0702018-04-17 18:56:53 -0700708 @Override
709 public Map<Set<DeviceId>, NodeId> getShouldProgram() {
710 return defaultRoutingHandler == null ? ImmutableMap.of() :
711 ImmutableMap.copyOf(defaultRoutingHandler.shouldProgram);
712 }
713
714 @Override
715 public Map<DeviceId, Boolean> getShouldProgramCache() {
716 return defaultRoutingHandler == null ? ImmutableMap.of() :
717 ImmutableMap.copyOf(defaultRoutingHandler.shouldProgramCache);
718 }
719
sangho80f1f892015-05-19 11:57:42 -0700720 /**
Ray Milkeyb85de082017-04-05 09:42:04 -0700721 * Extracts the application ID from the manager.
722 *
723 * @return application ID
724 */
725 public ApplicationId appId() {
726 return appId;
727 }
728
729 /**
730 * Returns the device configuration.
731 *
732 * @return device configuration
733 */
734 public DeviceConfiguration deviceConfiguration() {
735 return deviceConfiguration;
736 }
737
738 /**
Saurav Das261c3002017-06-13 15:35:54 -0700739 * Per device next objective ID store with (device id + destination set) as key.
Charles Chan53de91f2017-08-22 15:07:34 -0700740 * Used to keep track on MPLS group information.
Ray Milkeyb85de082017-04-05 09:42:04 -0700741 *
742 * @return next objective ID store
743 */
Saurav Das261c3002017-06-13 15:35:54 -0700744 public EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey, NextNeighbors>
745 dsNextObjStore() {
746 return dsNextObjStore;
Ray Milkeyb85de082017-04-05 09:42:04 -0700747 }
748
749 /**
Charles Chan53de91f2017-08-22 15:07:34 -0700750 * Per device next objective ID store with (device id + vlanid) as key.
751 * Used to keep track on L2 flood group information.
Ray Milkeyb85de082017-04-05 09:42:04 -0700752 *
753 * @return vlan next object store
754 */
755 public EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer> vlanNextObjStore() {
756 return vlanNextObjStore;
757 }
758
759 /**
Charles Chan53de91f2017-08-22 15:07:34 -0700760 * Per device next objective ID store with (device id + port + treatment + meta) as key.
761 * Used to keep track on L2 interface group and L3 unicast group information.
Ray Milkeyb85de082017-04-05 09:42:04 -0700762 *
763 * @return port next object store.
764 */
765 public EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer> portNextObjStore() {
766 return portNextObjStore;
767 }
768
769 /**
Saurav Das261c3002017-06-13 15:35:54 -0700770 * Returns the MPLS-ECMP configuration which indicates whether ECMP on
771 * labeled packets should be programmed or not.
Pier Ventre7a78de22016-10-31 15:00:01 -0700772 *
773 * @return MPLS-ECMP value
774 */
775 public boolean getMplsEcmp() {
776 SegmentRoutingAppConfig segmentRoutingAppConfig = cfgService
777 .getConfig(this.appId, SegmentRoutingAppConfig.class);
778 return segmentRoutingAppConfig != null && segmentRoutingAppConfig.mplsEcmp();
779 }
780
781 /**
sangho80f1f892015-05-19 11:57:42 -0700782 * Returns the tunnel object with the tunnel ID.
783 *
784 * @param tunnelId Tunnel ID
785 * @return Tunnel reference
786 */
sangho27462c62015-05-14 00:39:53 -0700787 public Tunnel getTunnel(String tunnelId) {
788 return tunnelHandler.getTunnel(tunnelId);
789 }
790
Charles Chan90772a72017-02-08 15:52:08 -0800791 // TODO Consider moving these to InterfaceService
sangho80f11cb2015-04-01 13:05:26 -0700792 /**
Charles Chan10b0fb72017-02-02 16:20:42 -0800793 * Returns untagged VLAN configured on given connect point.
Charles Chan90772a72017-02-08 15:52:08 -0800794 * <p>
795 * Only returns the first match if there are multiple untagged VLAN configured
796 * on the connect point.
sangho80f11cb2015-04-01 13:05:26 -0700797 *
Charles Chan10b0fb72017-02-02 16:20:42 -0800798 * @param connectPoint connect point
799 * @return untagged VLAN or null if not configured
sangho80f11cb2015-04-01 13:05:26 -0700800 */
Charles Chan3ed34d82017-06-22 18:03:14 -0700801 VlanId getUntaggedVlanId(ConnectPoint connectPoint) {
Charles Chan10b0fb72017-02-02 16:20:42 -0800802 return interfaceService.getInterfacesByPort(connectPoint).stream()
803 .filter(intf -> !intf.vlanUntagged().equals(VlanId.NONE))
804 .map(Interface::vlanUntagged)
805 .findFirst().orElse(null);
sangho80f11cb2015-04-01 13:05:26 -0700806 }
807
sangho27462c62015-05-14 00:39:53 -0700808 /**
Charles Chan90772a72017-02-08 15:52:08 -0800809 * Returns tagged VLAN configured on given connect point.
810 * <p>
811 * Returns all matches if there are multiple tagged VLAN configured
812 * on the connect point.
813 *
814 * @param connectPoint connect point
815 * @return tagged VLAN or empty set if not configured
816 */
Charles Chan3ed34d82017-06-22 18:03:14 -0700817 Set<VlanId> getTaggedVlanId(ConnectPoint connectPoint) {
Charles Chan90772a72017-02-08 15:52:08 -0800818 Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint);
819 return interfaces.stream()
820 .map(Interface::vlanTagged)
Charles Chan3ed34d82017-06-22 18:03:14 -0700821 .flatMap(Set::stream)
Charles Chan90772a72017-02-08 15:52:08 -0800822 .collect(Collectors.toSet());
823 }
824
825 /**
826 * Returns native VLAN configured on given connect point.
827 * <p>
828 * Only returns the first match if there are multiple native VLAN configured
829 * on the connect point.
830 *
831 * @param connectPoint connect point
832 * @return native VLAN or null if not configured
833 */
Charles Chan3ed34d82017-06-22 18:03:14 -0700834 VlanId getNativeVlanId(ConnectPoint connectPoint) {
Charles Chan90772a72017-02-08 15:52:08 -0800835 Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint);
836 return interfaces.stream()
837 .filter(intf -> !intf.vlanNative().equals(VlanId.NONE))
838 .map(Interface::vlanNative)
839 .findFirst()
840 .orElse(null);
841 }
842
843 /**
Charles Chand9265a32017-06-16 15:19:24 -0700844 * Returns internal VLAN for untagged hosts on given connect point.
845 * <p>
846 * The internal VLAN is either vlan-untagged for an access port,
847 * or vlan-native for a trunk port.
848 *
849 * @param connectPoint connect point
850 * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined
851 */
Pier Luigi69f774d2018-02-28 12:10:50 +0100852 public VlanId getInternalVlanId(ConnectPoint connectPoint) {
Charles Chand9265a32017-06-16 15:19:24 -0700853 VlanId untaggedVlanId = getUntaggedVlanId(connectPoint);
854 VlanId nativeVlanId = getNativeVlanId(connectPoint);
855 return untaggedVlanId != null ? untaggedVlanId : nativeVlanId;
856 }
857
858 /**
Charles Chan3ed34d82017-06-22 18:03:14 -0700859 * Returns optional pair device ID of given device.
860 *
861 * @param deviceId device ID
862 * @return optional pair device ID. Might be empty if pair device is not configured
863 */
864 Optional<DeviceId> getPairDeviceId(DeviceId deviceId) {
865 SegmentRoutingDeviceConfig deviceConfig =
866 cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
867 return Optional.ofNullable(deviceConfig).map(SegmentRoutingDeviceConfig::pairDeviceId);
868 }
869 /**
870 * Returns optional pair device local port of given device.
871 *
872 * @param deviceId device ID
873 * @return optional pair device ID. Might be empty if pair device is not configured
874 */
875 Optional<PortNumber> getPairLocalPorts(DeviceId deviceId) {
876 SegmentRoutingDeviceConfig deviceConfig =
877 cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class);
878 return Optional.ofNullable(deviceConfig).map(SegmentRoutingDeviceConfig::pairLocalPort);
879 }
880
881 /**
Charles Chanf0ae41e2017-08-23 13:55:39 -0700882 * Returns locations of given resolved route.
883 *
884 * @param resolvedRoute resolved route
885 * @return locations of nexthop. Might be empty if next hop is not found
886 */
887 Set<ConnectPoint> nextHopLocations(ResolvedRoute resolvedRoute) {
888 HostId hostId = HostId.hostId(resolvedRoute.nextHopMac(), resolvedRoute.nextHopVlan());
889 return Optional.ofNullable(hostService.getHost(hostId))
890 .map(Host::locations).orElse(Sets.newHashSet())
891 .stream().map(l -> (ConnectPoint) l).collect(Collectors.toSet());
892 }
893
894 /**
Charles Chan90772a72017-02-08 15:52:08 -0800895 * Returns vlan port map of given device.
896 *
897 * @param deviceId device id
898 * @return vlan-port multimap
899 */
900 public Multimap<VlanId, PortNumber> getVlanPortMap(DeviceId deviceId) {
901 HashMultimap<VlanId, PortNumber> vlanPortMap = HashMultimap.create();
902
903 interfaceService.getInterfaces().stream()
904 .filter(intf -> intf.connectPoint().deviceId().equals(deviceId))
905 .forEach(intf -> {
906 vlanPortMap.put(intf.vlanUntagged(), intf.connectPoint().port());
Charles Chan3ed34d82017-06-22 18:03:14 -0700907 intf.vlanTagged().forEach(vlanTagged ->
908 vlanPortMap.put(vlanTagged, intf.connectPoint().port())
909 );
Charles Chan90772a72017-02-08 15:52:08 -0800910 vlanPortMap.put(intf.vlanNative(), intf.connectPoint().port());
911 });
912 vlanPortMap.removeAll(VlanId.NONE);
913
914 return vlanPortMap;
915 }
916
917 /**
Charles Chan10b0fb72017-02-02 16:20:42 -0800918 * Returns the next objective ID for the given vlan id. It is expected
Saurav Das2d94d312015-11-24 23:21:05 -0800919 * that the next-objective has been pre-created from configuration.
Charles Chan77277672015-10-20 16:24:19 -0700920 *
921 * @param deviceId Device ID
Charles Chan10b0fb72017-02-02 16:20:42 -0800922 * @param vlanId VLAN ID
Saurav Das2d94d312015-11-24 23:21:05 -0800923 * @return next objective ID or -1 if it was not found
Charles Chan77277672015-10-20 16:24:19 -0700924 */
Charles Chan3ed34d82017-06-22 18:03:14 -0700925 int getVlanNextObjectiveId(DeviceId deviceId, VlanId vlanId) {
Charles Chan77277672015-10-20 16:24:19 -0700926 if (groupHandlerMap.get(deviceId) != null) {
Charles Chan10b0fb72017-02-02 16:20:42 -0800927 log.trace("getVlanNextObjectiveId query in device {}", deviceId);
928 return groupHandlerMap.get(deviceId).getVlanNextObjectiveId(vlanId);
Charles Chan77277672015-10-20 16:24:19 -0700929 } else {
Charles Chan10b0fb72017-02-02 16:20:42 -0800930 log.warn("getVlanNextObjectiveId query - groupHandler for "
Saurav Das2d94d312015-11-24 23:21:05 -0800931 + "device {} not found", deviceId);
932 return -1;
933 }
934 }
935
936 /**
937 * Returns the next objective ID for the given portNumber, given the treatment.
938 * There could be multiple different treatments to the same outport, which
Saurav Das2cb38292017-03-29 19:09:17 -0700939 * would result in different objectives. If the next object does not exist,
940 * and should be created, a new one is created and its id is returned.
Saurav Das2d94d312015-11-24 23:21:05 -0800941 *
942 * @param deviceId Device ID
943 * @param portNum port number on device for which NextObjective is queried
944 * @param treatment the actions to apply on the packets (should include outport)
945 * @param meta metadata passed into the creation of a Next Objective if necessary
Saurav Das2cb38292017-03-29 19:09:17 -0700946 * @param createIfMissing true if a next object should be created if not found
Saurav Das07c74602016-04-27 18:35:50 -0700947 * @return next objective ID or -1 if an error occurred during retrieval or creation
Saurav Das2d94d312015-11-24 23:21:05 -0800948 */
949 public int getPortNextObjectiveId(DeviceId deviceId, PortNumber portNum,
950 TrafficTreatment treatment,
Saurav Das2cb38292017-03-29 19:09:17 -0700951 TrafficSelector meta,
952 boolean createIfMissing) {
Saurav Das2d94d312015-11-24 23:21:05 -0800953 DefaultGroupHandler ghdlr = groupHandlerMap.get(deviceId);
954 if (ghdlr != null) {
Saurav Das2cb38292017-03-29 19:09:17 -0700955 return ghdlr.getPortNextObjectiveId(portNum, treatment, meta, createIfMissing);
Saurav Das2d94d312015-11-24 23:21:05 -0800956 } else {
Charles Chanb7f75ac2016-01-11 18:28:54 -0800957 log.warn("getPortNextObjectiveId query - groupHandler for device {}"
958 + " not found", deviceId);
959 return -1;
960 }
961 }
962
Saurav Das62ae6792017-05-15 15:34:25 -0700963 /**
964 * Returns the group handler object for the specified device id.
965 *
966 * @param devId the device identifier
967 * @return the groupHandler object for the device id, or null if not found
968 */
Charles Chan3ed34d82017-06-22 18:03:14 -0700969 DefaultGroupHandler getGroupHandler(DeviceId devId) {
Saurav Das62ae6792017-05-15 15:34:25 -0700970 return groupHandlerMap.get(devId);
971 }
972
973 /**
Saurav Dasfbe74572017-08-03 18:30:35 -0700974 * Returns the default routing handler object.
975 *
976 * @return the default routing handler object
977 */
978 public DefaultRoutingHandler getRoutingHandler() {
979 return defaultRoutingHandler;
980 }
981
sangho80f11cb2015-04-01 13:05:26 -0700982 private class InternalPacketProcessor implements PacketProcessor {
sangho80f11cb2015-04-01 13:05:26 -0700983 @Override
984 public void process(PacketContext context) {
985
986 if (context.isHandled()) {
987 return;
988 }
989
990 InboundPacket pkt = context.inPacket();
991 Ethernet ethernet = pkt.parsed();
Pier Luigi37a35432017-02-01 13:50:04 -0800992
993 if (ethernet == null) {
994 return;
995 }
996
Saurav Das261c3002017-06-13 15:35:54 -0700997 log.trace("Rcvd pktin from {}: {}", context.inPacket().receivedFrom(),
998 ethernet);
Pier Ventreadb4ae62016-11-23 09:57:42 -0800999 if (ethernet.getEtherType() == TYPE_ARP) {
Saurav Das62ae6792017-05-15 15:34:25 -07001000 log.warn("Received unexpected ARP packet on {}",
1001 context.inPacket().receivedFrom());
Saurav Das368cf212017-03-15 15:15:14 -07001002 log.trace("{}", ethernet);
Pier Ventre6b2c1b32016-12-09 17:26:04 -08001003 return;
sangho80f11cb2015-04-01 13:05:26 -07001004 } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
Pier Ventreb6b81d52016-12-02 08:16:05 -08001005 IPv4 ipv4Packet = (IPv4) ethernet.getPayload();
1006 //ipHandler.addToPacketBuffer(ipv4Packet);
1007 if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) {
1008 icmpHandler.processIcmp(ethernet, pkt.receivedFrom());
sangho80f11cb2015-04-01 13:05:26 -07001009 } else {
Charles Chand041ad82017-01-13 17:20:44 -08001010 // NOTE: We don't support IP learning at this moment so this
1011 // is not necessary. Also it causes duplication of DHCP packets.
Pier Ventre6b2c1b32016-12-09 17:26:04 -08001012 // ipHandler.processPacketIn(ipv4Packet, pkt.receivedFrom());
sangho80f11cb2015-04-01 13:05:26 -07001013 }
Pier Ventreb6a7f342016-11-26 21:05:22 -08001014 } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV6) {
1015 IPv6 ipv6Packet = (IPv6) ethernet.getPayload();
Pier Ventreb6b81d52016-12-02 08:16:05 -08001016 //ipHandler.addToPacketBuffer(ipv6Packet);
Pier Luigi37a35432017-02-01 13:50:04 -08001017 // We deal with the packet only if the packet is a ICMP6 ECHO/REPLY
Pier Ventreb6b81d52016-12-02 08:16:05 -08001018 if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_ICMP6) {
1019 ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload();
1020 if (icmp6Packet.getIcmpType() == ICMP6.ECHO_REQUEST ||
1021 icmp6Packet.getIcmpType() == ICMP6.ECHO_REPLY) {
1022 icmpHandler.processIcmpv6(ethernet, pkt.receivedFrom());
1023 } else {
Saurav Das62ae6792017-05-15 15:34:25 -07001024 log.trace("Received ICMPv6 0x{} - not handled",
Charles Chand3727b72017-03-13 13:10:30 -07001025 Integer.toHexString(icmp6Packet.getIcmpType() & 0xff));
Pier Ventreb6b81d52016-12-02 08:16:05 -08001026 }
1027 } else {
1028 // NOTE: We don't support IP learning at this moment so this
1029 // is not necessary. Also it causes duplication of DHCPv6 packets.
1030 // ipHandler.processPacketIn(ipv6Packet, pkt.receivedFrom());
1031 }
sangho80f11cb2015-04-01 13:05:26 -07001032 }
1033 }
1034 }
1035
sangho80f11cb2015-04-01 13:05:26 -07001036 private class InternalEventHandler implements Runnable {
Charles Chan52003922018-04-05 16:31:15 -07001037 private Event event;
1038
1039 InternalEventHandler(Event event) {
1040 this.event = event;
1041 }
1042
Srikanth Vavilapalli37a461b2015-04-07 15:12:32 -07001043 @Override
sangho80f11cb2015-04-01 13:05:26 -07001044 public void run() {
Charles Chan52003922018-04-05 16:31:15 -07001045 try {
1046 // TODO We should also change SR routing and PW to listen to TopologyEvents
1047 if (event.type() == LinkEvent.Type.LINK_ADDED ||
1048 event.type() == LinkEvent.Type.LINK_UPDATED) {
1049 linkHandler.processLinkAdded((Link) event.subject());
1050 } else if (event.type() == LinkEvent.Type.LINK_REMOVED) {
1051 linkHandler.processLinkRemoved((Link) event.subject());
1052 } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED ||
1053 event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
1054 event.type() == DeviceEvent.Type.DEVICE_UPDATED) {
1055 DeviceId deviceId = ((Device) event.subject()).id();
1056 if (deviceService.isAvailable(deviceId)) {
1057 log.info("** DEVICE UP Processing device event {} "
1058 + "for available device {}",
1059 event.type(), ((Device) event.subject()).id());
1060 processDeviceAdded((Device) event.subject());
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -07001061 } else {
Charles Chan52003922018-04-05 16:31:15 -07001062 log.info(" ** DEVICE DOWN Processing device event {}"
1063 + " for unavailable device {}",
1064 event.type(), ((Device) event.subject()).id());
1065 processDeviceRemoved((Device) event.subject());
Srikanth Vavilapalli64d96c12015-05-14 20:22:47 -07001066 }
Charles Chan52003922018-04-05 16:31:15 -07001067 } else if (event.type() == DeviceEvent.Type.PORT_ADDED) {
1068 // typically these calls come when device is added first time
1069 // so port filtering rules are handled at the device_added event.
1070 // port added calls represent all ports on the device,
1071 // enabled or not.
1072 log.trace("** PORT ADDED {}/{} -> {}",
1073 ((DeviceEvent) event).subject().id(),
1074 ((DeviceEvent) event).port().number(),
1075 event.type());
1076 } else if (event.type() == DeviceEvent.Type.PORT_UPDATED) {
1077 // these calls happen for every subsequent event
1078 // ports enabled, disabled, switch goes away, comes back
1079 log.info("** PORT UPDATED {}/{} -> {}",
1080 event.subject(),
1081 ((DeviceEvent) event).port(),
1082 event.type());
1083 processPortUpdated(((Device) event.subject()),
1084 ((DeviceEvent) event).port());
1085 } else if (event.type() == TopologyEvent.Type.TOPOLOGY_CHANGED) {
1086 // Process topology event, needed for all modules relying on
1087 // topology service for path computation
1088 TopologyEvent topologyEvent = (TopologyEvent) event;
1089 log.info("Processing topology event {}, topology age {}, reasons {}",
1090 event.type(), topologyEvent.subject().time(),
1091 topologyEvent.reasons().size());
1092 topologyHandler.processTopologyChange(topologyEvent.reasons());
1093 } else if (event.type() == HostEvent.Type.HOST_ADDED) {
1094 hostHandler.processHostAddedEvent((HostEvent) event);
1095 } else if (event.type() == HostEvent.Type.HOST_MOVED) {
1096 hostHandler.processHostMovedEvent((HostEvent) event);
1097 routeHandler.processHostMovedEvent((HostEvent) event);
1098 } else if (event.type() == HostEvent.Type.HOST_REMOVED) {
1099 hostHandler.processHostRemovedEvent((HostEvent) event);
1100 } else if (event.type() == HostEvent.Type.HOST_UPDATED) {
1101 hostHandler.processHostUpdatedEvent((HostEvent) event);
1102 } else if (event.type() == RouteEvent.Type.ROUTE_ADDED) {
1103 routeHandler.processRouteAdded((RouteEvent) event);
1104 } else if (event.type() == RouteEvent.Type.ROUTE_UPDATED) {
1105 routeHandler.processRouteUpdated((RouteEvent) event);
1106 } else if (event.type() == RouteEvent.Type.ROUTE_REMOVED) {
1107 routeHandler.processRouteRemoved((RouteEvent) event);
1108 } else if (event.type() == RouteEvent.Type.ALTERNATIVE_ROUTES_CHANGED) {
1109 routeHandler.processAlternativeRoutesChanged((RouteEvent) event);
1110 } else if (event.type() == McastEvent.Type.SOURCES_ADDED ||
1111 event.type() == McastEvent.Type.SOURCES_REMOVED ||
1112 event.type() == McastEvent.Type.SINKS_ADDED ||
1113 event.type() == McastEvent.Type.SINKS_REMOVED ||
1114 event.type() == McastEvent.Type.ROUTE_ADDED ||
1115 event.type() == McastEvent.Type.ROUTE_REMOVED) {
1116 mcastHandler.processMcastEvent((McastEvent) event);
1117 } else if (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED) {
1118 NetworkConfigEvent netcfgEvent = (NetworkConfigEvent) event;
1119 Class configClass = netcfgEvent.configClass();
1120 if (configClass.equals(SegmentRoutingAppConfig.class)) {
1121 appCfgHandler.processAppConfigAdded(netcfgEvent);
1122 log.info("App config event .. configuring network");
1123 cfgListener.configureNetwork();
1124 } else if (configClass.equals(SegmentRoutingDeviceConfig.class)) {
1125 log.info("Segment Routing Device Config added for {}", event.subject());
1126 cfgListener.configureNetwork();
1127 } else if (configClass.equals(XConnectConfig.class)) {
1128 xConnectHandler.processXConnectConfigAdded(netcfgEvent);
1129 } else if (configClass.equals(InterfaceConfig.class)) {
1130 log.info("Interface Config added for {}", event.subject());
1131 cfgListener.configureNetwork();
1132 } else {
1133 log.error("Unhandled config class: {}", configClass);
1134 }
1135 } else if (event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) {
1136 NetworkConfigEvent netcfgEvent = (NetworkConfigEvent) event;
1137 Class configClass = netcfgEvent.configClass();
1138 if (configClass.equals(SegmentRoutingAppConfig.class)) {
1139 appCfgHandler.processAppConfigUpdated(netcfgEvent);
1140 log.info("App config event .. configuring network");
1141 cfgListener.configureNetwork();
1142 } else if (configClass.equals(SegmentRoutingDeviceConfig.class)) {
1143 log.info("Segment Routing Device Config updated for {}", event.subject());
1144 createOrUpdateDeviceConfiguration();
1145 } else if (configClass.equals(XConnectConfig.class)) {
1146 xConnectHandler.processXConnectConfigUpdated(netcfgEvent);
1147 } else if (configClass.equals(InterfaceConfig.class)) {
1148 log.info("Interface Config updated for {}", event.subject());
1149 createOrUpdateDeviceConfiguration();
1150 updateInterface((InterfaceConfig) netcfgEvent.config().get(),
1151 (InterfaceConfig) netcfgEvent.prevConfig().get());
1152 } else {
1153 log.error("Unhandled config class: {}", configClass);
1154 }
1155 } else if (event.type() == NetworkConfigEvent.Type.CONFIG_REMOVED) {
1156 NetworkConfigEvent netcfgEvent = (NetworkConfigEvent) event;
1157 Class configClass = netcfgEvent.configClass();
1158 if (configClass.equals(SegmentRoutingAppConfig.class)) {
1159 appCfgHandler.processAppConfigRemoved(netcfgEvent);
1160 log.info("App config event .. configuring network");
1161 cfgListener.configureNetwork();
1162 } else if (configClass.equals(SegmentRoutingDeviceConfig.class)) {
1163 // TODO Handle sr device config removal
1164 log.info("SegmentRoutingDeviceConfig removal is not handled in current implementation");
1165 } else if (configClass.equals(XConnectConfig.class)) {
1166 xConnectHandler.processXConnectConfigRemoved(netcfgEvent);
1167 } else if (configClass.equals(InterfaceConfig.class)) {
1168 // TODO Handle interface removal
1169 log.info("InterfaceConfig removal is not handled in current implementation");
1170 } else {
1171 log.error("Unhandled config class: {}", configClass);
1172 }
1173 } else {
1174 log.warn("Unhandled event type: {}", event.type());
sangho80f11cb2015-04-01 13:05:26 -07001175 }
Charles Chan52003922018-04-05 16:31:15 -07001176 } catch (Exception e) {
1177 log.error("SegmentRouting event handler thread thrown an exception: {}",
1178 e.getMessage(), e);
sangho80f11cb2015-04-01 13:05:26 -07001179 }
sangho80f11cb2015-04-01 13:05:26 -07001180 }
1181 }
1182
Saurav Dase6c448a2018-01-18 12:07:33 -08001183 void processDeviceAdded(Device device) {
Saurav Dasb149be12016-06-07 10:08:06 -07001184 log.info("** DEVICE ADDED with ID {}", device.id());
Charles Chan9bd6aea2017-06-27 18:48:32 -07001185
1186 // NOTE: Punt ARP/NDP even when the device is not configured.
1187 // Host learning without network config is required for CORD config generator.
1188 routingRulePopulator.populateIpPunts(device.id());
1189 routingRulePopulator.populateArpNdpPunts(device.id());
1190
Charles Chan319d1a22015-11-03 10:42:14 -08001191 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
Saurav Das261c3002017-06-13 15:35:54 -07001192 log.warn("Device configuration unavailable. Device {} will be "
1193 + "processed after configuration.", device.id());
Saurav Das8ec0ec42015-11-03 14:39:27 -08001194 return;
1195 }
Charles Chan72779502016-04-23 17:36:10 -07001196 processDeviceAddedInternal(device.id());
1197 }
1198
1199 private void processDeviceAddedInternal(DeviceId deviceId) {
Saurav Dasc28b3432015-10-30 17:45:38 -07001200 // Irrespective of whether the local is a MASTER or not for this device,
1201 // we need to create a SR-group-handler instance. This is because in a
1202 // multi-instance setup, any instance can initiate forwarding/next-objectives
1203 // for any switch (even if this instance is a SLAVE or not even connected
1204 // to the switch). To handle this, a default-group-handler instance is necessary
1205 // per switch.
Charles Chan72779502016-04-23 17:36:10 -07001206 log.debug("Current groupHandlerMap devs: {}", groupHandlerMap.keySet());
1207 if (groupHandlerMap.get(deviceId) == null) {
Charles Chan319d1a22015-11-03 10:42:14 -08001208 DefaultGroupHandler groupHandler;
1209 try {
1210 groupHandler = DefaultGroupHandler.
Charles Chan72779502016-04-23 17:36:10 -07001211 createGroupHandler(deviceId,
1212 appId,
1213 deviceConfiguration,
1214 linkService,
1215 flowObjectiveService,
1216 this);
Charles Chan319d1a22015-11-03 10:42:14 -08001217 } catch (DeviceConfigNotFoundException e) {
1218 log.warn(e.getMessage() + " Aborting processDeviceAdded.");
1219 return;
1220 }
Saurav Das2b6a00f2017-12-05 15:00:23 -08001221 log.debug("updating groupHandlerMap with new grpHdlr for device: {}",
Charles Chan72779502016-04-23 17:36:10 -07001222 deviceId);
1223 groupHandlerMap.put(deviceId, groupHandler);
Saurav Das8ec0ec42015-11-03 14:39:27 -08001224 }
Saurav Dasb149be12016-06-07 10:08:06 -07001225
Charles Chan72779502016-04-23 17:36:10 -07001226 if (mastershipService.isLocalMaster(deviceId)) {
Saurav Dasf9332192017-02-18 14:05:44 -08001227 defaultRoutingHandler.populatePortAddressingRules(deviceId);
Charles Chan82f19972016-05-17 13:13:55 -07001228 xConnectHandler.init(deviceId);
Charles Chan72779502016-04-23 17:36:10 -07001229 DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId);
Charles Chan10b0fb72017-02-02 16:20:42 -08001230 groupHandler.createGroupsFromVlanConfig();
Charles Chan72779502016-04-23 17:36:10 -07001231 routingRulePopulator.populateSubnetBroadcastRule(deviceId);
Charles Chan77277672015-10-20 16:24:19 -07001232 }
Charles Chan82ab1932016-01-30 23:22:37 -08001233
Charles Chandebfea32016-10-24 14:52:01 -07001234 appCfgHandler.init(deviceId);
Charles Chand66d6712018-03-29 16:03:41 -07001235 hostHandler.init(deviceId);
Charles Chandebfea32016-10-24 14:52:01 -07001236 routeHandler.init(deviceId);
sangho80f11cb2015-04-01 13:05:26 -07001237 }
1238
Saurav Dasc3604f12016-03-23 11:22:49 -07001239 private void processDeviceRemoved(Device device) {
Saurav Das261c3002017-06-13 15:35:54 -07001240 dsNextObjStore.entrySet().stream()
Saurav Dasc3604f12016-03-23 11:22:49 -07001241 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
Charles Chan873661e2017-11-30 15:37:50 -08001242 .forEach(entry -> dsNextObjStore.remove(entry.getKey()));
Charles Chan10b0fb72017-02-02 16:20:42 -08001243 vlanNextObjStore.entrySet().stream()
Saurav Dasc3604f12016-03-23 11:22:49 -07001244 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
Charles Chan3ed34d82017-06-22 18:03:14 -07001245 .forEach(entry -> vlanNextObjStore.remove(entry.getKey()));
Saurav Dasc3604f12016-03-23 11:22:49 -07001246 portNextObjStore.entrySet().stream()
1247 .filter(entry -> entry.getKey().deviceId().equals(device.id()))
Charles Chan3ed34d82017-06-22 18:03:14 -07001248 .forEach(entry -> portNextObjStore.remove(entry.getKey()));
Saurav Dase6c448a2018-01-18 12:07:33 -08001249 linkHandler.processDeviceRemoved(device);
Charles Chan17d75d82017-06-15 00:44:51 -07001250
Saurav Dasfbe74572017-08-03 18:30:35 -07001251 DefaultGroupHandler gh = groupHandlerMap.remove(device.id());
1252 if (gh != null) {
1253 gh.shutdown();
1254 }
Saurav Das62ae6792017-05-15 15:34:25 -07001255 // Note that a switch going down is associated with all of its links
1256 // going down as well, but it is treated as a single switch down event
Saurav Dasdebcf882018-04-06 20:16:01 -07001257 // while the link-downs are ignored. We cannot rely on the ordering of
1258 // events - i.e we cannot expect all link-downs to come before the
1259 // switch down - so we purge all seen-links for the switch before
1260 // handling route-path changes for the switch-down
Saurav Das62ae6792017-05-15 15:34:25 -07001261 defaultRoutingHandler
Saurav Dasdc7f2752018-03-18 21:28:15 -07001262 .populateRoutingRulesForLinkStatusChange(null, null, device.id(), true);
Saurav Das6430f412018-01-25 09:49:01 -08001263 defaultRoutingHandler.purgeEcmpGraph(device.id());
Charles Chan82f19972016-05-17 13:13:55 -07001264 xConnectHandler.removeDevice(device.id());
Saurav Das97241862018-02-14 14:14:54 -08001265
1266 // Cleanup all internal groupHandler stores for this device. Should be
1267 // done after all rerouting or rehashing has been completed
1268 groupHandlerMap.entrySet()
1269 .forEach(entry -> entry.getValue().cleanUpForNeighborDown(device.id()));
Saurav Dasc3604f12016-03-23 11:22:49 -07001270 }
1271
Saurav Dasf0f592d2016-11-18 15:21:57 -08001272 private void processPortUpdated(Device device, Port port) {
1273 if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
1274 log.warn("Device configuration uploading. Not handling port event for"
1275 + "dev: {} port: {}", device.id(), port.number());
1276 return;
1277 }
Saurav Dasf9332192017-02-18 14:05:44 -08001278
1279 if (!mastershipService.isLocalMaster(device.id())) {
1280 log.debug("Not master for dev:{} .. not handling port updated event"
1281 + "for port {}", device.id(), port.number());
1282 return;
1283 }
1284
1285 // first we handle filtering rules associated with the port
1286 if (port.isEnabled()) {
1287 log.info("Switchport {}/{} enabled..programming filters",
1288 device.id(), port.number());
Charles Chan43be46b2017-02-26 22:59:35 -08001289 routingRulePopulator.processSinglePortFilters(device.id(), port.number(), true);
Saurav Dasf9332192017-02-18 14:05:44 -08001290 } else {
1291 log.info("Switchport {}/{} disabled..removing filters",
1292 device.id(), port.number());
Charles Chan43be46b2017-02-26 22:59:35 -08001293 routingRulePopulator.processSinglePortFilters(device.id(), port.number(), false);
Saurav Dasf9332192017-02-18 14:05:44 -08001294 }
Saurav Dasf0f592d2016-11-18 15:21:57 -08001295
1296 // portUpdated calls are for ports that have gone down or up. For switch
1297 // to switch ports, link-events should take care of any re-routing or
1298 // group editing necessary for port up/down. Here we only process edge ports
1299 // that are already configured.
Saurav Das3fb28272017-03-04 16:08:47 -08001300 ConnectPoint cp = new ConnectPoint(device.id(), port.number());
1301 VlanId untaggedVlan = getUntaggedVlanId(cp);
1302 VlanId nativeVlan = getNativeVlanId(cp);
1303 Set<VlanId> taggedVlans = getTaggedVlanId(cp);
Charles Chan10b0fb72017-02-02 16:20:42 -08001304
Saurav Das3fb28272017-03-04 16:08:47 -08001305 if (untaggedVlan == null && nativeVlan == null && taggedVlans.isEmpty()) {
Saurav Das62ae6792017-05-15 15:34:25 -07001306 log.debug("Not handling port updated event for non-edge port (unconfigured) "
Saurav Dasf0f592d2016-11-18 15:21:57 -08001307 + "dev/port: {}/{}", device.id(), port.number());
1308 return;
1309 }
Saurav Das3fb28272017-03-04 16:08:47 -08001310 if (untaggedVlan != null) {
1311 processEdgePort(device, port, untaggedVlan, true);
1312 }
1313 if (nativeVlan != null) {
1314 processEdgePort(device, port, nativeVlan, true);
1315 }
1316 if (!taggedVlans.isEmpty()) {
1317 taggedVlans.forEach(tag -> processEdgePort(device, port, tag, false));
1318 }
Saurav Dasf0f592d2016-11-18 15:21:57 -08001319 }
1320
Saurav Das3fb28272017-03-04 16:08:47 -08001321 private void processEdgePort(Device device, Port port, VlanId vlanId,
1322 boolean popVlan) {
Saurav Dasf0f592d2016-11-18 15:21:57 -08001323 boolean portUp = port.isEnabled();
1324 if (portUp) {
Saurav Das3fb28272017-03-04 16:08:47 -08001325 log.info("Device:EdgePort {}:{} is enabled in vlan: {}", device.id(),
Charles Chan10b0fb72017-02-02 16:20:42 -08001326 port.number(), vlanId);
Charles Chan873661e2017-11-30 15:37:50 -08001327 hostHandler.processPortUp(new ConnectPoint(device.id(), port.number()));
Saurav Dasf0f592d2016-11-18 15:21:57 -08001328 } else {
Saurav Das3fb28272017-03-04 16:08:47 -08001329 log.info("Device:EdgePort {}:{} is disabled in vlan: {}", device.id(),
Charles Chan10b0fb72017-02-02 16:20:42 -08001330 port.number(), vlanId);
Saurav Dasf0f592d2016-11-18 15:21:57 -08001331 }
1332
Srikanth Vavilapalli64505482015-04-21 13:04:13 -07001333 DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id());
sangho80f11cb2015-04-01 13:05:26 -07001334 if (groupHandler != null) {
Saurav Das3fb28272017-03-04 16:08:47 -08001335 groupHandler.processEdgePort(port.number(), vlanId, popVlan, portUp);
Saurav Dasf0f592d2016-11-18 15:21:57 -08001336 } else {
1337 log.warn("Group handler not found for dev:{}. Not handling edge port"
1338 + " {} event for port:{}", device.id(),
1339 (portUp) ? "UP" : "DOWN", port.number());
sangho80f11cb2015-04-01 13:05:26 -07001340 }
1341 }
sangho27462c62015-05-14 00:39:53 -07001342
Charles Chan8ca5a122017-10-20 16:06:55 -07001343 private void createOrUpdateDeviceConfiguration() {
1344 if (deviceConfiguration == null) {
Saurav Dase321cff2018-02-09 17:26:45 -08001345 log.info("Creating new DeviceConfiguration");
Charles Chan8ca5a122017-10-20 16:06:55 -07001346 deviceConfiguration = new DeviceConfiguration(this);
1347 } else {
Saurav Dase321cff2018-02-09 17:26:45 -08001348 log.info("Updating DeviceConfiguration");
Charles Chan8ca5a122017-10-20 16:06:55 -07001349 deviceConfiguration.updateConfig();
1350 }
1351 }
1352
Charles Chanfbcb8812018-04-18 18:41:05 -07001353 private void createOrUpdateDefaultRoutingHandler() {
1354 if (defaultRoutingHandler == null) {
1355 log.info("Creating new DefaultRoutingHandler");
1356 defaultRoutingHandler = new DefaultRoutingHandler(this);
1357 } else {
1358 log.info("Updating DefaultRoutingHandler");
1359 defaultRoutingHandler.update(this);
1360 }
1361 }
1362
Pier Ventreb6a7f342016-11-26 21:05:22 -08001363 /**
1364 * Registers the given connect point with the NRS, this is necessary
1365 * to receive the NDP and ARP packets from the NRS.
1366 *
1367 * @param portToRegister connect point to register
1368 */
1369 public void registerConnectPoint(ConnectPoint portToRegister) {
Charles Chan2e71ef32017-02-23 15:44:08 -08001370 neighbourResolutionService.registerNeighbourHandler(
Pier Ventreb6a7f342016-11-26 21:05:22 -08001371 portToRegister,
1372 neighbourHandler,
1373 appId
1374 );
1375 }
1376
Charles Chan72f556a2015-10-05 17:50:33 -07001377 private class InternalConfigListener implements NetworkConfigListener {
Saurav Das261c3002017-06-13 15:35:54 -07001378 private static final long PROGRAM_DELAY = 2;
Charles Chan46fdfaf2016-11-09 20:51:44 -08001379 SegmentRoutingManager srManager;
Charles Chane7c61022015-10-07 14:21:45 -07001380
Charles Chanb7f75ac2016-01-11 18:28:54 -08001381 /**
1382 * Constructs the internal network config listener.
1383 *
Charles Chan46fdfaf2016-11-09 20:51:44 -08001384 * @param srManager segment routing manager
Charles Chanb7f75ac2016-01-11 18:28:54 -08001385 */
Charles Chan3ed34d82017-06-22 18:03:14 -07001386 InternalConfigListener(SegmentRoutingManager srManager) {
Charles Chan46fdfaf2016-11-09 20:51:44 -08001387 this.srManager = srManager;
Charles Chane7c61022015-10-07 14:21:45 -07001388 }
1389
Charles Chanb7f75ac2016-01-11 18:28:54 -08001390 /**
1391 * Reads network config and initializes related data structure accordingly.
1392 */
Charles Chan873661e2017-11-30 15:37:50 -08001393 void configureNetwork() {
Saurav Dase321cff2018-02-09 17:26:45 -08001394 log.info("Configuring network ...");
Andrea Campanella060cad82018-04-17 12:09:34 +02001395
1396 // Setting handling of network configuration events completable future
1397 // The completable future is needed because of the async behaviour of the configureNetwork,
1398 // listener registration and event arrival
1399 // Enables us to buffer the events and execute them when the configure network is done.
1400 networkConfigCompletion = new CompletableFuture<>();
1401
1402 // add a small delay to absorb multiple network config added notifications
1403 if (!programmingScheduled.get()) {
1404 log.info("Buffering config calls for {} secs", PROGRAM_DELAY);
1405 programmingScheduled.set(true);
1406 mainEventExecutor.schedule(new ConfigChange(), PROGRAM_DELAY, TimeUnit.SECONDS);
1407 }
1408
Charles Chan8ca5a122017-10-20 16:06:55 -07001409 createOrUpdateDeviceConfiguration();
Charles Chane7c61022015-10-07 14:21:45 -07001410
Charles Chan46fdfaf2016-11-09 20:51:44 -08001411 arpHandler = new ArpHandler(srManager);
1412 icmpHandler = new IcmpHandler(srManager);
1413 ipHandler = new IpHandler(srManager);
1414 routingRulePopulator = new RoutingRulePopulator(srManager);
Charles Chanfbcb8812018-04-18 18:41:05 -07001415 createOrUpdateDefaultRoutingHandler();
Charles Chane7c61022015-10-07 14:21:45 -07001416
1417 tunnelHandler = new TunnelHandler(linkService, deviceConfiguration,
1418 groupHandlerMap, tunnelStore);
1419 policyHandler = new PolicyHandler(appId, deviceConfiguration,
1420 flowObjectiveService,
1421 tunnelHandler, policyStore);
Andrea Campanella060cad82018-04-17 12:09:34 +02001422 networkConfigCompletion.complete(true);
1423
Charles Chan72779502016-04-23 17:36:10 -07001424 mcastHandler.init();
Andrea Campanella060cad82018-04-17 12:09:34 +02001425
Charles Chane7c61022015-10-07 14:21:45 -07001426 }
1427
Charles Chan72f556a2015-10-05 17:50:33 -07001428 @Override
1429 public void event(NetworkConfigEvent event) {
Charles Chan3f4aca62018-03-21 16:57:47 -07001430 checkState(appCfgHandler != null, "NetworkConfigEventHandler is not initialized");
1431 checkState(xConnectHandler != null, "XConnectHandler is not initialized");
1432 switch (event.type()) {
1433 case CONFIG_ADDED:
1434 case CONFIG_UPDATED:
1435 case CONFIG_REMOVED:
1436 log.trace("Schedule Network Config event {}", event);
Andrea Campanella060cad82018-04-17 12:09:34 +02001437 if (networkConfigCompletion == null || networkConfigCompletion.isDone()) {
1438 mainEventExecutor.execute(new InternalEventHandler(event));
1439 } else {
Charles Chan39b75522018-04-21 00:44:29 -07001440 queuedEvents.add(event);
Andrea Campanella060cad82018-04-17 12:09:34 +02001441 }
Charles Chan3f4aca62018-03-21 16:57:47 -07001442 break;
1443 default:
1444 break;
Charles Chan72f556a2015-10-05 17:50:33 -07001445 }
1446 }
Saurav Das261c3002017-06-13 15:35:54 -07001447
Charles Chanc4a68c32018-01-03 16:26:32 -08001448 @Override
1449 public boolean isRelevant(NetworkConfigEvent event) {
Saurav Dase321cff2018-02-09 17:26:45 -08001450 if (event.type() == CONFIG_REGISTERED ||
1451 event.type() == CONFIG_UNREGISTERED) {
1452 log.debug("Ignore event {} due to type mismatch", event);
1453 return false;
Charles Chanc4a68c32018-01-03 16:26:32 -08001454 }
Saurav Dase321cff2018-02-09 17:26:45 -08001455
1456 if (!event.configClass().equals(SegmentRoutingDeviceConfig.class) &&
1457 !event.configClass().equals(SegmentRoutingAppConfig.class) &&
1458 !event.configClass().equals(InterfaceConfig.class) &&
Andreas Pantelopouloscdbb22c2018-02-23 14:18:00 -08001459 !event.configClass().equals(XConnectConfig.class)) {
Saurav Dase321cff2018-02-09 17:26:45 -08001460 log.debug("Ignore event {} due to class mismatch", event);
1461 return false;
1462 }
1463
1464 return true;
Charles Chanc4a68c32018-01-03 16:26:32 -08001465 }
1466
Saurav Das261c3002017-06-13 15:35:54 -07001467 private final class ConfigChange implements Runnable {
1468 @Override
1469 public void run() {
1470 programmingScheduled.set(false);
Saurav Dase321cff2018-02-09 17:26:45 -08001471 log.info("Reacting to config changes after buffer delay");
Saurav Das261c3002017-06-13 15:35:54 -07001472 for (Device device : deviceService.getDevices()) {
1473 processDeviceAdded(device);
1474 }
1475 defaultRoutingHandler.startPopulationProcess();
1476 }
1477 }
Charles Chan72f556a2015-10-05 17:50:33 -07001478 }
Charles Chanf4586112015-11-09 16:37:23 -08001479
Charles Chan3f4aca62018-03-21 16:57:47 -07001480 private class InternalLinkListener implements LinkListener {
1481 @Override
1482 public void event(LinkEvent event) {
1483 if (event.type() == LinkEvent.Type.LINK_ADDED ||
1484 event.type() == LinkEvent.Type.LINK_UPDATED ||
1485 event.type() == LinkEvent.Type.LINK_REMOVED) {
1486 log.trace("Schedule Link event {}", event);
Andrea Campanella060cad82018-04-17 12:09:34 +02001487 if (networkConfigCompletion == null || networkConfigCompletion.isDone()) {
1488 mainEventExecutor.execute(new InternalEventHandler(event));
1489 } else {
Charles Chan39b75522018-04-21 00:44:29 -07001490 queuedEvents.add(event);
Andrea Campanella060cad82018-04-17 12:09:34 +02001491 }
Charles Chan3f4aca62018-03-21 16:57:47 -07001492 }
1493 }
1494 }
1495
1496 private class InternalDeviceListener implements DeviceListener {
1497 @Override
1498 public void event(DeviceEvent event) {
1499 switch (event.type()) {
1500 case DEVICE_ADDED:
1501 case PORT_UPDATED:
1502 case PORT_ADDED:
1503 case DEVICE_UPDATED:
1504 case DEVICE_AVAILABILITY_CHANGED:
1505 log.trace("Schedule Device event {}", event);
Andrea Campanella060cad82018-04-17 12:09:34 +02001506 if (networkConfigCompletion == null || networkConfigCompletion.isDone()) {
1507 mainEventExecutor.execute(new InternalEventHandler(event));
1508 } else {
Charles Chan39b75522018-04-21 00:44:29 -07001509 queuedEvents.add(event);
Andrea Campanella060cad82018-04-17 12:09:34 +02001510 }
Charles Chan3f4aca62018-03-21 16:57:47 -07001511 break;
1512 default:
1513 }
1514 }
1515 }
1516
1517 private class InternalTopologyListener implements TopologyListener {
1518 @Override
1519 public void event(TopologyEvent event) {
1520 switch (event.type()) {
1521 case TOPOLOGY_CHANGED:
1522 log.trace("Schedule Topology event {}", event);
Andrea Campanella060cad82018-04-17 12:09:34 +02001523 if (networkConfigCompletion == null || networkConfigCompletion.isDone()) {
1524 mainEventExecutor.execute(new InternalEventHandler(event));
1525 } else {
Charles Chan39b75522018-04-21 00:44:29 -07001526 queuedEvents.add(event);
Andrea Campanella060cad82018-04-17 12:09:34 +02001527 }
Charles Chan3f4aca62018-03-21 16:57:47 -07001528 break;
1529 default:
1530 }
1531 }
1532 }
1533
Charles Chanf4586112015-11-09 16:37:23 -08001534 private class InternalHostListener implements HostListener {
Charles Chanf4586112015-11-09 16:37:23 -08001535 @Override
1536 public void event(HostEvent event) {
Charles Chanf4586112015-11-09 16:37:23 -08001537 switch (event.type()) {
1538 case HOST_ADDED:
Charles Chanf4586112015-11-09 16:37:23 -08001539 case HOST_MOVED:
Charles Chanf4586112015-11-09 16:37:23 -08001540 case HOST_REMOVED:
Charles Chanf4586112015-11-09 16:37:23 -08001541 case HOST_UPDATED:
Charles Chan3f4aca62018-03-21 16:57:47 -07001542 log.trace("Schedule Host event {}", event);
Charles Chandbbbb8a2018-04-07 11:35:08 -07001543 hostEventExecutor.execute(new InternalEventHandler(event));
Charles Chanf4586112015-11-09 16:37:23 -08001544 break;
1545 default:
1546 log.warn("Unsupported host event type: {}", event.type());
1547 break;
1548 }
1549 }
1550 }
1551
Charles Chanc91c8782016-03-30 17:54:24 -07001552 private class InternalMcastListener implements McastListener {
1553 @Override
1554 public void event(McastEvent event) {
1555 switch (event.type()) {
Pier1f87aca2018-03-14 16:47:32 -07001556 case SOURCES_ADDED:
1557 case SOURCES_REMOVED:
1558 case SINKS_ADDED:
1559 case SINKS_REMOVED:
Charles Chanc91c8782016-03-30 17:54:24 -07001560 case ROUTE_REMOVED:
Pierdb27b8d2018-04-17 16:29:56 +02001561 case ROUTE_ADDED:
Charles Chan3f4aca62018-03-21 16:57:47 -07001562 log.trace("Schedule Mcast event {}", event);
Charles Chandbbbb8a2018-04-07 11:35:08 -07001563 mcastEventExecutor.execute(new InternalEventHandler(event));
Pier Luigi6786b922018-02-02 16:19:11 +01001564 break;
Charles Chanc91c8782016-03-30 17:54:24 -07001565 default:
Charles Chan3f4aca62018-03-21 16:57:47 -07001566 log.warn("Unsupported mcast event type: {}", event.type());
Charles Chanc91c8782016-03-30 17:54:24 -07001567 break;
1568 }
1569 }
1570 }
Charles Chan41f5ec02016-06-13 18:54:31 -07001571
Charles Chandebfea32016-10-24 14:52:01 -07001572 private class InternalRouteEventListener implements RouteListener {
1573 @Override
1574 public void event(RouteEvent event) {
1575 switch (event.type()) {
1576 case ROUTE_ADDED:
Charles Chandebfea32016-10-24 14:52:01 -07001577 case ROUTE_UPDATED:
Charles Chandebfea32016-10-24 14:52:01 -07001578 case ROUTE_REMOVED:
Charles Chan910be6a2017-08-23 14:46:43 -07001579 case ALTERNATIVE_ROUTES_CHANGED:
Charles Chan3f4aca62018-03-21 16:57:47 -07001580 log.trace("Schedule Route event {}", event);
Charles Chandbbbb8a2018-04-07 11:35:08 -07001581 routeEventExecutor.execute(new InternalEventHandler(event));
Charles Chan910be6a2017-08-23 14:46:43 -07001582 break;
Charles Chandebfea32016-10-24 14:52:01 -07001583 default:
Charles Chan3f4aca62018-03-21 16:57:47 -07001584 log.warn("Unsupported route event type: {}", event.type());
Charles Chandebfea32016-10-24 14:52:01 -07001585 break;
1586 }
1587 }
1588 }
Saurav Das62ae6792017-05-15 15:34:25 -07001589
Charles Chanfbcb8812018-04-18 18:41:05 -07001590 private class InternalMastershipListener implements MastershipListener {
1591 @Override
1592 public void event(MastershipEvent event) {
1593 DeviceId deviceId = event.subject();
1594 Optional<DeviceId> pairDeviceId = getPairDeviceId(deviceId);
1595
1596 switch (event.type()) {
1597 case MASTER_CHANGED:
1598 log.info("Invalidating shouldProgram cache for {}/pair={} due to mastership change",
1599 deviceId, pairDeviceId);
1600 defaultRoutingHandler.invalidateShouldProgramCache(deviceId);
1601 pairDeviceId.ifPresent(defaultRoutingHandler::invalidateShouldProgramCache);
1602 break;
1603 case BACKUPS_CHANGED:
1604 case SUSPENDED:
1605 default:
1606 break;
1607 }
1608 }
1609 }
1610
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001611 private void updateInterface(InterfaceConfig conf, InterfaceConfig prevConf) {
1612 try {
1613 Set<Interface> intfs = conf.getInterfaces();
1614 Set<Interface> prevIntfs = prevConf.getInterfaces();
1615
1616 // Now we only handle one interface config at each port.
1617 if (intfs.size() != 1 || prevIntfs.size() != 1) {
1618 log.warn("Interface update aborted - one at a time is allowed, " +
1619 "but {} / {}(prev) received.", intfs.size(), prevIntfs.size());
1620 return;
1621 }
1622
Andrea Campanella060cad82018-04-17 12:09:34 +02001623 //The system is in an incoherent state, abort
1624 if (defaultRoutingHandler == null) {
1625 log.warn("Interface update aborted, defaultRoutingHandler is null");
1626 return;
1627 }
1628
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001629 Interface intf = intfs.stream().findFirst().get();
1630 Interface prevIntf = prevIntfs.stream().findFirst().get();
1631
1632 DeviceId deviceId = intf.connectPoint().deviceId();
1633 PortNumber portNum = intf.connectPoint().port();
1634
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001635 removeSubnetConfig(prevIntf.connectPoint(),
1636 Sets.difference(new HashSet<>(prevIntf.ipAddressesList()),
1637 new HashSet<>(intf.ipAddressesList())));
1638
Jonghwan Hyuna4ce0aa2018-02-12 16:43:45 +09001639 if (!prevIntf.vlanNative().equals(VlanId.NONE)
1640 && !prevIntf.vlanNative().equals(intf.vlanUntagged())
1641 && !prevIntf.vlanNative().equals(intf.vlanNative())) {
1642 if (intf.vlanTagged().contains(prevIntf.vlanNative())) {
1643 // Update filtering objective and L2IG group bucket
1644 updatePortVlanTreatment(deviceId, portNum, prevIntf.vlanNative(), false);
1645 } else {
1646 // RemoveVlanNative
1647 updateVlanConfigInternal(deviceId, portNum, prevIntf.vlanNative(), true, false);
1648 }
1649 }
1650
1651 if (!prevIntf.vlanUntagged().equals(VlanId.NONE)
1652 && !prevIntf.vlanUntagged().equals(intf.vlanUntagged())
1653 && !prevIntf.vlanUntagged().equals(intf.vlanNative())) {
1654 if (intf.vlanTagged().contains(prevIntf.vlanUntagged())) {
1655 // Update filtering objective and L2IG group bucket
1656 updatePortVlanTreatment(deviceId, portNum, prevIntf.vlanUntagged(), false);
1657 } else {
1658 // RemoveVlanUntagged
1659 updateVlanConfigInternal(deviceId, portNum, prevIntf.vlanUntagged(), true, false);
1660 }
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001661 }
1662
1663 if (!prevIntf.vlanTagged().isEmpty() && !intf.vlanTagged().equals(prevIntf.vlanTagged())) {
1664 // RemoveVlanTagged
Jonghwan Hyuna4ce0aa2018-02-12 16:43:45 +09001665 Sets.difference(prevIntf.vlanTagged(), intf.vlanTagged()).stream()
1666 .filter(i -> !intf.vlanUntagged().equals(i))
1667 .filter(i -> !intf.vlanNative().equals(i))
1668 .forEach(vlanId -> updateVlanConfigInternal(
1669 deviceId, portNum, vlanId, false, false));
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001670 }
1671
Jonghwan Hyuna4ce0aa2018-02-12 16:43:45 +09001672 if (!intf.vlanNative().equals(VlanId.NONE)
1673 && !prevIntf.vlanNative().equals(intf.vlanNative())
1674 && !prevIntf.vlanUntagged().equals(intf.vlanNative())) {
1675 if (prevIntf.vlanTagged().contains(intf.vlanNative())) {
1676 // Update filtering objective and L2IG group bucket
1677 updatePortVlanTreatment(deviceId, portNum, intf.vlanNative(), true);
1678 } else {
1679 // AddVlanNative
1680 updateVlanConfigInternal(deviceId, portNum, intf.vlanNative(), true, true);
1681 }
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001682 }
1683
1684 if (!intf.vlanTagged().isEmpty() && !intf.vlanTagged().equals(prevIntf.vlanTagged())) {
1685 // AddVlanTagged
Jonghwan Hyuna4ce0aa2018-02-12 16:43:45 +09001686 Sets.difference(intf.vlanTagged(), prevIntf.vlanTagged()).stream()
1687 .filter(i -> !prevIntf.vlanUntagged().equals(i))
1688 .filter(i -> !prevIntf.vlanNative().equals(i))
1689 .forEach(vlanId -> updateVlanConfigInternal(
1690 deviceId, portNum, vlanId, false, true)
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001691 );
1692 }
1693
Jonghwan Hyuna4ce0aa2018-02-12 16:43:45 +09001694 if (!intf.vlanUntagged().equals(VlanId.NONE)
1695 && !prevIntf.vlanUntagged().equals(intf.vlanUntagged())
1696 && !prevIntf.vlanNative().equals(intf.vlanUntagged())) {
1697 if (prevIntf.vlanTagged().contains(intf.vlanUntagged())) {
1698 // Update filtering objective and L2IG group bucket
1699 updatePortVlanTreatment(deviceId, portNum, intf.vlanUntagged(), true);
1700 } else {
1701 // AddVlanUntagged
1702 updateVlanConfigInternal(deviceId, portNum, intf.vlanUntagged(), true, true);
1703 }
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001704 }
1705 addSubnetConfig(prevIntf.connectPoint(),
1706 Sets.difference(new HashSet<>(intf.ipAddressesList()),
1707 new HashSet<>(prevIntf.ipAddressesList())));
1708 } catch (ConfigException e) {
1709 log.error("Error in configuration");
1710 }
1711 }
1712
Jonghwan Hyuna4ce0aa2018-02-12 16:43:45 +09001713 private void updatePortVlanTreatment(DeviceId deviceId, PortNumber portNum,
1714 VlanId vlanId, boolean pushVlan) {
1715 DefaultGroupHandler grpHandler = getGroupHandler(deviceId);
1716 if (grpHandler == null) {
1717 log.warn("Failed to retrieve group handler for device {}", deviceId);
1718 return;
1719 }
1720
1721 // Update filtering objective for a single port
1722 routingRulePopulator.updateSinglePortFilters(deviceId, portNum, !pushVlan, vlanId, false);
1723 routingRulePopulator.updateSinglePortFilters(deviceId, portNum, pushVlan, vlanId, true);
1724
1725 if (getVlanNextObjectiveId(deviceId, vlanId) != -1) {
1726 // Update L2IG bucket of the port
1727 grpHandler.updateL2InterfaceGroupBucket(portNum, vlanId, pushVlan);
1728 } else {
1729 log.warn("Failed to retrieve next objective for vlan {} in device {}:{}", vlanId, deviceId, portNum);
1730 }
1731 }
1732
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001733 private void updateVlanConfigInternal(DeviceId deviceId, PortNumber portNum,
1734 VlanId vlanId, boolean pushVlan, boolean install) {
1735 DefaultGroupHandler grpHandler = getGroupHandler(deviceId);
1736 if (grpHandler == null) {
1737 log.warn("Failed to retrieve group handler for device {}", deviceId);
1738 return;
1739 }
1740
1741 // Update filtering objective for a single port
1742 routingRulePopulator.updateSinglePortFilters(deviceId, portNum, pushVlan, vlanId, install);
1743
1744 // Update filtering objective for multicast ingress port
1745 mcastHandler.updateFilterToDevice(deviceId, portNum, vlanId, install);
1746
1747 int nextId = getVlanNextObjectiveId(deviceId, vlanId);
1748
1749 if (nextId != -1 && !install) {
1750 // Update next objective for a single port as an output port
1751 // Remove a single port from L2FG
Jonghwan Hyuna4ce0aa2018-02-12 16:43:45 +09001752 grpHandler.updateGroupFromVlanConfiguration(vlanId, portNum, nextId, install);
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001753 // Remove L2 Bridging rule and L3 Unicast rule to the host
1754 hostHandler.processIntfVlanUpdatedEvent(deviceId, portNum, vlanId, pushVlan, install);
1755 // Remove broadcast forwarding rule and corresponding L2FG for VLAN
1756 // only if there is no port configured on that VLAN ID
1757 if (!getVlanPortMap(deviceId).containsKey(vlanId)) {
1758 // Remove broadcast forwarding rule for the VLAN
1759 routingRulePopulator.updateSubnetBroadcastRule(deviceId, vlanId, install);
1760 // Remove L2FG for VLAN
1761 grpHandler.removeBcastGroupFromVlan(deviceId, portNum, vlanId, pushVlan);
1762 } else {
1763 // Remove L2IG of the port
1764 grpHandler.removePortNextObjective(deviceId, portNum, vlanId, pushVlan);
1765 }
1766 } else if (install) {
1767 if (nextId != -1) {
1768 // Add a single port to L2FG
Jonghwan Hyuna4ce0aa2018-02-12 16:43:45 +09001769 grpHandler.updateGroupFromVlanConfiguration(vlanId, portNum, nextId, install);
Jonghwan Hyune5ef7622017-08-25 17:48:36 -07001770 } else {
1771 // Create L2FG for VLAN
1772 grpHandler.createBcastGroupFromVlan(vlanId, Collections.singleton(portNum));
1773 routingRulePopulator.updateSubnetBroadcastRule(deviceId, vlanId, install);
1774 }
1775 hostHandler.processIntfVlanUpdatedEvent(deviceId, portNum, vlanId, pushVlan, install);
1776 } else {
1777 log.warn("Failed to retrieve next objective for vlan {} in device {}:{}", vlanId, deviceId, portNum);
1778 }
1779 }
1780
1781 private void removeSubnetConfig(ConnectPoint cp, Set<InterfaceIpAddress> ipAddressSet) {
1782 Set<IpPrefix> ipPrefixSet = ipAddressSet.stream().
1783 map(InterfaceIpAddress::subnetAddress).collect(Collectors.toSet());
1784
1785 Set<InterfaceIpAddress> deviceIntfIpAddrs = interfaceService.getInterfaces().stream()
1786 .filter(intf -> intf.connectPoint().deviceId().equals(cp.deviceId()))
1787 .filter(intf -> !intf.connectPoint().equals(cp))
1788 .flatMap(intf -> intf.ipAddressesList().stream())
1789 .collect(Collectors.toSet());
1790 // 1. Partial subnet population
1791 // Remove routing rules for removed subnet from previous configuration,
1792 // which does not also exist in other interfaces in the same device
1793 Set<IpPrefix> deviceIpPrefixSet = deviceIntfIpAddrs.stream()
1794 .map(InterfaceIpAddress::subnetAddress)
1795 .collect(Collectors.toSet());
1796
1797 defaultRoutingHandler.revokeSubnet(
1798 ipPrefixSet.stream()
1799 .filter(ipPrefix -> !deviceIpPrefixSet.contains(ipPrefix))
1800 .collect(Collectors.toSet()));
1801
1802 // 2. Interface IP punts
1803 // Remove IP punts for old Intf address
1804 Set<IpAddress> deviceIpAddrs = deviceIntfIpAddrs.stream()
1805 .map(InterfaceIpAddress::ipAddress)
1806 .collect(Collectors.toSet());
1807 ipAddressSet.stream()
1808 .map(InterfaceIpAddress::ipAddress)
1809 .filter(interfaceIpAddress -> !deviceIpAddrs.contains(interfaceIpAddress))
1810 .forEach(interfaceIpAddress ->
1811 routingRulePopulator.revokeSingleIpPunts(
1812 cp.deviceId(), interfaceIpAddress));
1813
1814 // 3. Host unicast routing rule
1815 // Remove unicast routing rule
1816 hostHandler.processIntfIpUpdatedEvent(cp, ipPrefixSet, false);
1817 }
1818
1819 private void addSubnetConfig(ConnectPoint cp, Set<InterfaceIpAddress> ipAddressSet) {
1820 Set<IpPrefix> ipPrefixSet = ipAddressSet.stream().
1821 map(InterfaceIpAddress::subnetAddress).collect(Collectors.toSet());
1822
1823 Set<InterfaceIpAddress> deviceIntfIpAddrs = interfaceService.getInterfaces().stream()
1824 .filter(intf -> intf.connectPoint().deviceId().equals(cp.deviceId()))
1825 .filter(intf -> !intf.connectPoint().equals(cp))
1826 .flatMap(intf -> intf.ipAddressesList().stream())
1827 .collect(Collectors.toSet());
1828 // 1. Partial subnet population
1829 // Add routing rules for newly added subnet, which does not also exist in
1830 // other interfaces in the same device
1831 Set<IpPrefix> deviceIpPrefixSet = deviceIntfIpAddrs.stream()
1832 .map(InterfaceIpAddress::subnetAddress)
1833 .collect(Collectors.toSet());
1834
1835 defaultRoutingHandler.populateSubnet(
1836 Collections.singleton(cp),
1837 ipPrefixSet.stream()
1838 .filter(ipPrefix -> !deviceIpPrefixSet.contains(ipPrefix))
1839 .collect(Collectors.toSet()));
1840
1841 // 2. Interface IP punts
1842 // Add IP punts for new Intf address
1843 Set<IpAddress> deviceIpAddrs = deviceIntfIpAddrs.stream()
1844 .map(InterfaceIpAddress::ipAddress)
1845 .collect(Collectors.toSet());
1846 ipAddressSet.stream()
1847 .map(InterfaceIpAddress::ipAddress)
1848 .filter(interfaceIpAddress -> !deviceIpAddrs.contains(interfaceIpAddress))
1849 .forEach(interfaceIpAddress ->
1850 routingRulePopulator.populateSingleIpPunts(
1851 cp.deviceId(), interfaceIpAddress));
1852
1853 // 3. Host unicast routing rule
1854 // Add unicast routing rule
1855 hostHandler.processIntfIpUpdatedEvent(cp, ipPrefixSet, true);
1856 }
sangho80f11cb2015-04-01 13:05:26 -07001857}