sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 43b5354 | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.segmentrouting; |
| 17 | |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 18 | import com.google.common.collect.HashMultimap; |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableMap; |
Charles Chan | d7844e5 | 2016-10-20 17:02:44 -0700 | [diff] [blame] | 20 | import com.google.common.collect.Maps; |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 21 | import com.google.common.collect.Multimap; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 22 | import org.apache.felix.scr.annotations.Activate; |
| 23 | import org.apache.felix.scr.annotations.Component; |
| 24 | import org.apache.felix.scr.annotations.Deactivate; |
| 25 | import org.apache.felix.scr.annotations.Reference; |
| 26 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 27 | import org.apache.felix.scr.annotations.Service; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 28 | import org.onlab.packet.Ethernet; |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 29 | import org.onlab.packet.ICMP6; |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 30 | import org.onlab.packet.IPv4; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 31 | import org.onlab.packet.IPv6; |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 32 | import org.onlab.packet.IpPrefix; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 33 | import org.onlab.packet.VlanId; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 34 | import org.onlab.util.KryoNamespace; |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 35 | import org.onosproject.cfg.ComponentConfigService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 36 | import org.onosproject.core.ApplicationId; |
| 37 | import org.onosproject.core.CoreService; |
| 38 | import org.onosproject.event.Event; |
Charles Chan | 68363b1 | 2017-06-26 15:25:09 -0700 | [diff] [blame] | 39 | import org.onosproject.incubator.net.config.basics.InterfaceConfig; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 40 | import org.onosproject.incubator.net.config.basics.McastConfig; |
Pier Luigi | ad0a67f | 2017-02-03 13:34:21 -0800 | [diff] [blame] | 41 | import org.onosproject.incubator.net.intf.Interface; |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 42 | import org.onosproject.incubator.net.intf.InterfaceService; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 43 | import org.onosproject.incubator.net.routing.RouteEvent; |
| 44 | import org.onosproject.incubator.net.routing.RouteListener; |
| 45 | import org.onosproject.incubator.net.routing.RouteService; |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 46 | import org.onosproject.incubator.net.neighbour.NeighbourResolutionService; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 47 | import org.onosproject.mastership.MastershipService; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 48 | import org.onosproject.net.ConnectPoint; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 49 | import org.onosproject.net.Device; |
| 50 | import org.onosproject.net.DeviceId; |
| 51 | import org.onosproject.net.Link; |
| 52 | import org.onosproject.net.Port; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 53 | import org.onosproject.net.PortNumber; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 54 | import org.onosproject.net.config.ConfigFactory; |
| 55 | import org.onosproject.net.config.NetworkConfigEvent; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 56 | import org.onosproject.net.config.NetworkConfigListener; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 57 | import org.onosproject.net.config.NetworkConfigRegistry; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 58 | import org.onosproject.net.config.basics.SubjectFactories; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 59 | import org.onosproject.net.device.DeviceEvent; |
| 60 | import org.onosproject.net.device.DeviceListener; |
| 61 | import org.onosproject.net.device.DeviceService; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 62 | import org.onosproject.net.flow.TrafficSelector; |
| 63 | import org.onosproject.net.flow.TrafficTreatment; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 64 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 65 | import org.onosproject.net.host.HostEvent; |
| 66 | import org.onosproject.net.host.HostListener; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 67 | import org.onosproject.net.host.HostService; |
| 68 | import org.onosproject.net.link.LinkEvent; |
| 69 | import org.onosproject.net.link.LinkListener; |
| 70 | import org.onosproject.net.link.LinkService; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 71 | import org.onosproject.net.mcast.McastEvent; |
| 72 | import org.onosproject.net.mcast.McastListener; |
| 73 | import org.onosproject.net.mcast.MulticastRouteService; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 74 | import org.onosproject.net.packet.InboundPacket; |
| 75 | import org.onosproject.net.packet.PacketContext; |
| 76 | import org.onosproject.net.packet.PacketProcessor; |
| 77 | import org.onosproject.net.packet.PacketService; |
Pier Ventre | f3cf5b9 | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 78 | import org.onosproject.net.topology.PathService; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 79 | import org.onosproject.net.topology.TopologyService; |
| 80 | import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; |
| 81 | import org.onosproject.segmentrouting.config.DeviceConfiguration; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 82 | import org.onosproject.segmentrouting.config.PwaasConfig; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 83 | import org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 84 | import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig; |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 85 | import org.onosproject.segmentrouting.config.XConnectConfig; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 86 | import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; |
| 87 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 88 | import org.onosproject.segmentrouting.storekey.NeighborSetNextObjectiveStoreKey; |
| 89 | import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey; |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 90 | import org.onosproject.segmentrouting.storekey.SubnetAssignedVidStoreKey; |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 91 | import org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey; |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 92 | import org.onosproject.segmentrouting.storekey.XConnectStoreKey; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 93 | import org.onosproject.segmentrouting.pwaas.L2TunnelHandler; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 94 | import org.onosproject.store.serializers.KryoNamespaces; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 95 | import org.onosproject.store.service.EventuallyConsistentMap; |
| 96 | import org.onosproject.store.service.EventuallyConsistentMapBuilder; |
| 97 | import org.onosproject.store.service.StorageService; |
| 98 | import org.onosproject.store.service.WallClockTimestamp; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 99 | import org.slf4j.Logger; |
| 100 | import org.slf4j.LoggerFactory; |
| 101 | |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 102 | import java.util.List; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 103 | import java.util.Map; |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 104 | import java.util.Map.Entry; |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 105 | import java.util.Set; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 106 | import java.util.concurrent.ConcurrentHashMap; |
| 107 | import java.util.concurrent.ConcurrentLinkedQueue; |
| 108 | import java.util.concurrent.Executors; |
| 109 | import java.util.concurrent.ScheduledExecutorService; |
| 110 | import java.util.concurrent.ScheduledFuture; |
| 111 | import java.util.concurrent.TimeUnit; |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 112 | import java.util.stream.Collectors; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 113 | |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 114 | import static com.google.common.base.Preconditions.checkState; |
Pier Ventre | adb4ae6 | 2016-11-23 09:57:42 -0800 | [diff] [blame] | 115 | import static org.onlab.packet.Ethernet.TYPE_ARP; |
Yuta HIGUCHI | ebee2f1 | 2016-07-21 16:54:33 -0700 | [diff] [blame] | 116 | import static org.onlab.util.Tools.groupedThreads; |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 117 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 118 | /** |
| 119 | * Segment routing manager. |
| 120 | */ |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 121 | @Service |
| 122 | @Component(immediate = true) |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 123 | public class SegmentRoutingManager implements SegmentRoutingService { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 124 | |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 125 | private static Logger log = LoggerFactory.getLogger(SegmentRoutingManager.class); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 126 | |
| 127 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 128 | private ComponentConfigService compCfgService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 129 | |
| 130 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 131 | private NeighbourResolutionService neighbourResolutionService; |
| 132 | |
| 133 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | f3cf5b9 | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 134 | public PathService pathService; |
| 135 | |
| 136 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 137 | CoreService coreService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 138 | |
| 139 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 140 | PacketService packetService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 141 | |
| 142 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 143 | HostService hostService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 144 | |
| 145 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 146 | DeviceService deviceService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 147 | |
| 148 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | f3cf5b9 | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 149 | public FlowObjectiveService flowObjectiveService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 150 | |
| 151 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 152 | LinkService linkService; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 153 | |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 154 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | f3cf5b9 | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 155 | public MastershipService mastershipService; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 156 | |
| 157 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | f3cf5b9 | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 158 | public StorageService storageService; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 159 | |
| 160 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 161 | MulticastRouteService multicastRouteService; |
| 162 | |
| 163 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 164 | TopologyService topologyService; |
| 165 | |
| 166 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 167 | RouteService routeService; |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 168 | |
| 169 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 170 | public NetworkConfigRegistry cfgService; |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 171 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 172 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 173 | public InterfaceService interfaceService; |
| 174 | |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 175 | ArpHandler arpHandler = null; |
| 176 | IcmpHandler icmpHandler = null; |
| 177 | IpHandler ipHandler = null; |
| 178 | RoutingRulePopulator routingRulePopulator = null; |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 179 | ApplicationId appId; |
| 180 | DeviceConfiguration deviceConfiguration = null; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 181 | |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 182 | DefaultRoutingHandler defaultRoutingHandler = null; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 183 | private TunnelHandler tunnelHandler = null; |
| 184 | private PolicyHandler policyHandler = null; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 185 | private InternalPacketProcessor processor = null; |
| 186 | private InternalLinkListener linkListener = null; |
| 187 | private InternalDeviceListener deviceListener = null; |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 188 | private AppConfigHandler appCfgHandler = null; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 189 | XConnectHandler xConnectHandler = null; |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 190 | private McastHandler mcastHandler = null; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 191 | HostHandler hostHandler = null; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 192 | private RouteHandler routeHandler = null; |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 193 | private SegmentRoutingNeighbourDispatcher neighbourHandler = null; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 194 | private L2TunnelHandler l2TunnelHandler = null; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 195 | private InternalEventHandler eventHandler = new InternalEventHandler(); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 196 | private final InternalHostListener hostListener = new InternalHostListener(); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 197 | private final InternalConfigListener cfgListener = new InternalConfigListener(this); |
| 198 | private final InternalMcastListener mcastListener = new InternalMcastListener(); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 199 | private final InternalRouteEventListener routeListener = new InternalRouteEventListener(); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 200 | |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 201 | private ScheduledExecutorService executorService = Executors |
Yuta HIGUCHI | ebee2f1 | 2016-07-21 16:54:33 -0700 | [diff] [blame] | 202 | .newScheduledThreadPool(1, groupedThreads("SegmentRoutingManager", "event-%d", log)); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 203 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 204 | @SuppressWarnings("unused") |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 205 | private static ScheduledFuture<?> eventHandlerFuture = null; |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 206 | @SuppressWarnings("rawtypes") |
Yuta HIGUCHI | ebee2f1 | 2016-07-21 16:54:33 -0700 | [diff] [blame] | 207 | private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<>(); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 208 | private Map<DeviceId, DefaultGroupHandler> groupHandlerMap = |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 209 | new ConcurrentHashMap<>(); |
| 210 | /** |
| 211 | * Per device next objective ID store with (device id + neighbor set) as key. |
| 212 | */ |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 213 | EventuallyConsistentMap<NeighborSetNextObjectiveStoreKey, Integer> |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 214 | nsNextObjStore = null; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 215 | /** |
| 216 | * Per device next objective ID store with (device id + subnet) as key. |
| 217 | */ |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 218 | EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer> |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 219 | vlanNextObjStore = null; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 220 | /** |
| 221 | * Per device next objective ID store with (device id + port) as key. |
| 222 | */ |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 223 | EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer> |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 224 | portNextObjStore = null; |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 225 | |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 226 | // Local store for all links seen and their present status, used for |
| 227 | // optimized routing. The existence of the link in the keys is enough to know |
| 228 | // if the link has been "seen-before" by this instance of the controller. |
| 229 | // The boolean value indicates if the link is currently up or not. |
| 230 | // XXX Currently the optimized routing logic depends on "forgetting" a link |
| 231 | // when a switch goes down, but "remembering" it when only the link goes down. |
| 232 | // Consider changing this logic so we can use the Link Service instead of |
| 233 | // a local cache. |
| 234 | private Map<Link, Boolean> seenLinks = new ConcurrentHashMap<>(); |
| 235 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 236 | private EventuallyConsistentMap<String, Tunnel> tunnelStore = null; |
| 237 | private EventuallyConsistentMap<String, Policy> policyStore = null; |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 238 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 239 | private final ConfigFactory<DeviceId, SegmentRoutingDeviceConfig> deviceConfigFactory = |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 240 | new ConfigFactory<DeviceId, SegmentRoutingDeviceConfig>( |
| 241 | SubjectFactories.DEVICE_SUBJECT_FACTORY, |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 242 | SegmentRoutingDeviceConfig.class, "segmentrouting") { |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 243 | @Override |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 244 | public SegmentRoutingDeviceConfig createConfig() { |
| 245 | return new SegmentRoutingDeviceConfig(); |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 246 | } |
| 247 | }; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 248 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 249 | private final ConfigFactory<ApplicationId, SegmentRoutingAppConfig> appConfigFactory = |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 250 | new ConfigFactory<ApplicationId, SegmentRoutingAppConfig>( |
| 251 | SubjectFactories.APP_SUBJECT_FACTORY, |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 252 | SegmentRoutingAppConfig.class, "segmentrouting") { |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 253 | @Override |
| 254 | public SegmentRoutingAppConfig createConfig() { |
| 255 | return new SegmentRoutingAppConfig(); |
| 256 | } |
| 257 | }; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 258 | |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 259 | private final ConfigFactory<ApplicationId, XConnectConfig> xConnectConfigFactory = |
| 260 | new ConfigFactory<ApplicationId, XConnectConfig>( |
| 261 | SubjectFactories.APP_SUBJECT_FACTORY, |
| 262 | XConnectConfig.class, "xconnect") { |
| 263 | @Override |
| 264 | public XConnectConfig createConfig() { |
| 265 | return new XConnectConfig(); |
| 266 | } |
| 267 | }; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 268 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 269 | private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory = |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 270 | new ConfigFactory<ApplicationId, McastConfig>( |
| 271 | SubjectFactories.APP_SUBJECT_FACTORY, |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 272 | McastConfig.class, "multicast") { |
| 273 | @Override |
| 274 | public McastConfig createConfig() { |
| 275 | return new McastConfig(); |
| 276 | } |
| 277 | }; |
| 278 | |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 279 | private final ConfigFactory<ApplicationId, PwaasConfig> pwaasConfigFactory = |
| 280 | new ConfigFactory<ApplicationId, PwaasConfig>( |
| 281 | SubjectFactories.APP_SUBJECT_FACTORY, |
| 282 | PwaasConfig.class, "pwaas") { |
| 283 | @Override |
| 284 | public PwaasConfig createConfig() { |
| 285 | return new PwaasConfig(); |
| 286 | } |
| 287 | }; |
| 288 | |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 289 | private Object threadSchedulerLock = new Object(); |
| 290 | private static int numOfEventsQueued = 0; |
| 291 | private static int numOfEventsExecuted = 0; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 292 | private static int numOfHandlerExecution = 0; |
| 293 | private static int numOfHandlerScheduled = 0; |
| 294 | |
Charles Chan | 1963f4f | 2016-02-18 14:22:42 -0800 | [diff] [blame] | 295 | /** |
| 296 | * Segment Routing App ID. |
| 297 | */ |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 298 | public static final String APP_NAME = "org.onosproject.segmentrouting"; |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 299 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 300 | /** |
| 301 | * The default VLAN ID assigned to the interfaces without subnet config. |
| 302 | */ |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 303 | public static final VlanId INTERNAL_VLAN = VlanId.vlanId((short) 4094); |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 304 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 305 | @Activate |
| 306 | protected void activate() { |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 307 | appId = coreService.registerApplication(APP_NAME); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 308 | |
| 309 | log.debug("Creating EC map nsnextobjectivestore"); |
| 310 | EventuallyConsistentMapBuilder<NeighborSetNextObjectiveStoreKey, Integer> |
| 311 | nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 312 | nsNextObjStore = nsNextObjMapBuilder |
| 313 | .withName("nsnextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 314 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 315 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 316 | .build(); |
| 317 | log.trace("Current size {}", nsNextObjStore.size()); |
| 318 | |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 319 | log.debug("Creating EC map vlannextobjectivestore"); |
| 320 | EventuallyConsistentMapBuilder<VlanNextObjectiveStoreKey, Integer> |
| 321 | vlanNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
| 322 | vlanNextObjStore = vlanNextObjMapBuilder |
| 323 | .withName("vlannextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 324 | .withSerializer(createSerializer()) |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 325 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 326 | .build(); |
| 327 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 328 | log.debug("Creating EC map subnetnextobjectivestore"); |
| 329 | EventuallyConsistentMapBuilder<PortNextObjectiveStoreKey, Integer> |
| 330 | portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
| 331 | portNextObjStore = portNextObjMapBuilder |
| 332 | .withName("portnextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 333 | .withSerializer(createSerializer()) |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 334 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 335 | .build(); |
| 336 | |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 337 | EventuallyConsistentMapBuilder<String, Tunnel> tunnelMapBuilder = |
| 338 | storageService.eventuallyConsistentMapBuilder(); |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 339 | tunnelStore = tunnelMapBuilder |
| 340 | .withName("tunnelstore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 341 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 342 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 343 | .build(); |
| 344 | |
| 345 | EventuallyConsistentMapBuilder<String, Policy> policyMapBuilder = |
| 346 | storageService.eventuallyConsistentMapBuilder(); |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 347 | policyStore = policyMapBuilder |
| 348 | .withName("policystore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 349 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 350 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 351 | .build(); |
| 352 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 353 | compCfgService.preSetProperty("org.onosproject.net.group.impl.GroupManager", |
Pier Luigi | b9632ba | 2017-01-12 18:14:58 -0800 | [diff] [blame] | 354 | "purgeOnDisconnection", "true"); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 355 | compCfgService.preSetProperty("org.onosproject.net.flow.impl.FlowRuleManager", |
Pier Luigi | b9632ba | 2017-01-12 18:14:58 -0800 | [diff] [blame] | 356 | "purgeOnDisconnection", "true"); |
Pier Luigi | b9632ba | 2017-01-12 18:14:58 -0800 | [diff] [blame] | 357 | compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider", |
| 358 | "requestInterceptsEnabled", "false"); |
Pier Luigi | bc976df | 2017-01-12 22:46:39 -0800 | [diff] [blame] | 359 | compCfgService.preSetProperty("org.onosproject.incubator.net.neighbour.impl.NeighbourResolutionManager", |
| 360 | "requestInterceptsEnabled", "false"); |
| 361 | compCfgService.preSetProperty("org.onosproject.dhcprelay.DhcpRelay", |
| 362 | "arpEnabled", "false"); |
Pier Luigi | 0ebeb31 | 2017-02-02 22:31:34 -0800 | [diff] [blame] | 363 | compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager", |
| 364 | "greedyLearningIpv6", "true"); |
Charles Chan | cf8ea47 | 2017-02-28 15:15:17 -0800 | [diff] [blame] | 365 | compCfgService.preSetProperty("org.onosproject.routing.cpr.ControlPlaneRedirectManager", |
| 366 | "forceUnprovision", "true"); |
Charles Chan | 4c95c0d | 2017-07-20 16:16:25 -0700 | [diff] [blame^] | 367 | compCfgService.preSetProperty("org.onosproject.incubator.store.routing.impl.RouteStoreImpl", |
| 368 | "distributed", "true"); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 369 | |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 370 | processor = new InternalPacketProcessor(); |
| 371 | linkListener = new InternalLinkListener(); |
| 372 | deviceListener = new InternalDeviceListener(); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 373 | appCfgHandler = new AppConfigHandler(this); |
| 374 | xConnectHandler = new XConnectHandler(this); |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 375 | mcastHandler = new McastHandler(this); |
| 376 | hostHandler = new HostHandler(this); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 377 | routeHandler = new RouteHandler(this); |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 378 | neighbourHandler = new SegmentRoutingNeighbourDispatcher(this); |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 379 | l2TunnelHandler = new L2TunnelHandler(this); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 380 | |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 381 | cfgService.addListener(cfgListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 382 | cfgService.registerConfigFactory(deviceConfigFactory); |
| 383 | cfgService.registerConfigFactory(appConfigFactory); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 384 | cfgService.registerConfigFactory(xConnectConfigFactory); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 385 | cfgService.registerConfigFactory(mcastConfigFactory); |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 386 | cfgService.registerConfigFactory(pwaasConfigFactory); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 387 | hostService.addListener(hostListener); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 388 | packetService.addProcessor(processor, PacketProcessor.director(2)); |
| 389 | linkService.addListener(linkListener); |
| 390 | deviceService.addListener(deviceListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 391 | multicastRouteService.addListener(mcastListener); |
Charles Chan | fd48c22 | 2017-06-19 00:43:31 -0700 | [diff] [blame] | 392 | routeService.addListener(routeListener); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 393 | |
| 394 | cfgListener.configureNetwork(); |
| 395 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 396 | log.info("Started"); |
| 397 | } |
| 398 | |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 399 | private KryoNamespace.Builder createSerializer() { |
| 400 | return new KryoNamespace.Builder() |
| 401 | .register(KryoNamespaces.API) |
| 402 | .register(NeighborSetNextObjectiveStoreKey.class, |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 403 | VlanNextObjectiveStoreKey.class, |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 404 | SubnetAssignedVidStoreKey.class, |
| 405 | NeighborSet.class, |
| 406 | Tunnel.class, |
| 407 | DefaultTunnel.class, |
| 408 | Policy.class, |
| 409 | TunnelPolicy.class, |
| 410 | Policy.Type.class, |
| 411 | PortNextObjectiveStoreKey.class, |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 412 | XConnectStoreKey.class |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 413 | ); |
| 414 | } |
| 415 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 416 | @Deactivate |
| 417 | protected void deactivate() { |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 418 | cfgService.removeListener(cfgListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 419 | cfgService.unregisterConfigFactory(deviceConfigFactory); |
| 420 | cfgService.unregisterConfigFactory(appConfigFactory); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 421 | cfgService.unregisterConfigFactory(xConnectConfigFactory); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 422 | cfgService.unregisterConfigFactory(mcastConfigFactory); |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 423 | cfgService.unregisterConfigFactory(pwaasConfigFactory); |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 424 | |
Charles Chan | fd48c22 | 2017-06-19 00:43:31 -0700 | [diff] [blame] | 425 | hostService.removeListener(hostListener); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 426 | packetService.removeProcessor(processor); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 427 | linkService.removeListener(linkListener); |
| 428 | deviceService.removeListener(deviceListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 429 | multicastRouteService.removeListener(mcastListener); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 430 | routeService.removeListener(routeListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 431 | |
Charles Chan | 2e71ef3 | 2017-02-23 15:44:08 -0800 | [diff] [blame] | 432 | neighbourResolutionService.unregisterNeighbourHandlers(appId); |
| 433 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 434 | processor = null; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 435 | linkListener = null; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 436 | deviceListener = null; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 437 | groupHandlerMap.clear(); |
| 438 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 439 | nsNextObjStore.destroy(); |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 440 | vlanNextObjStore.destroy(); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 441 | portNextObjStore.destroy(); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 442 | tunnelStore.destroy(); |
| 443 | policyStore.destroy(); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 444 | log.info("Stopped"); |
| 445 | } |
| 446 | |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 447 | @Override |
| 448 | public List<Tunnel> getTunnels() { |
| 449 | return tunnelHandler.getTunnels(); |
| 450 | } |
| 451 | |
| 452 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 453 | public TunnelHandler.Result createTunnel(Tunnel tunnel) { |
| 454 | return tunnelHandler.createTunnel(tunnel); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 458 | public TunnelHandler.Result removeTunnel(Tunnel tunnel) { |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 459 | for (Policy policy: policyHandler.getPolicies()) { |
| 460 | if (policy.type() == Policy.Type.TUNNEL_FLOW) { |
| 461 | TunnelPolicy tunnelPolicy = (TunnelPolicy) policy; |
| 462 | if (tunnelPolicy.tunnelId().equals(tunnel.id())) { |
| 463 | log.warn("Cannot remove the tunnel used by a policy"); |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 464 | return TunnelHandler.Result.TUNNEL_IN_USE; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 465 | } |
| 466 | } |
| 467 | } |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 468 | return tunnelHandler.removeTunnel(tunnel); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 472 | public PolicyHandler.Result removePolicy(Policy policy) { |
| 473 | return policyHandler.removePolicy(policy); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 477 | public PolicyHandler.Result createPolicy(Policy policy) { |
| 478 | return policyHandler.createPolicy(policy); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | @Override |
| 482 | public List<Policy> getPolicies() { |
| 483 | return policyHandler.getPolicies(); |
| 484 | } |
| 485 | |
Saurav Das | 07c7460 | 2016-04-27 18:35:50 -0700 | [diff] [blame] | 486 | @Override |
| 487 | public void rerouteNetwork() { |
| 488 | cfgListener.configureNetwork(); |
| 489 | for (Device device : deviceService.getDevices()) { |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 490 | if (mastershipService.isLocalMaster(device.id())) { |
| 491 | defaultRoutingHandler.populatePortAddressingRules(device.id()); |
| 492 | } |
Saurav Das | 07c7460 | 2016-04-27 18:35:50 -0700 | [diff] [blame] | 493 | } |
| 494 | defaultRoutingHandler.startPopulationProcess(); |
| 495 | } |
| 496 | |
Charles Chan | d7844e5 | 2016-10-20 17:02:44 -0700 | [diff] [blame] | 497 | @Override |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 498 | public Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap() { |
| 499 | Map<DeviceId, Set<IpPrefix>> deviceSubnetMap = Maps.newHashMap(); |
Charles Chan | d7844e5 | 2016-10-20 17:02:44 -0700 | [diff] [blame] | 500 | deviceService.getAvailableDevices().forEach(device -> { |
| 501 | deviceSubnetMap.put(device.id(), deviceConfiguration.getSubnets(device.id())); |
| 502 | }); |
| 503 | return deviceSubnetMap; |
| 504 | } |
| 505 | |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 506 | |
| 507 | @Override |
| 508 | public ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg() { |
| 509 | if (defaultRoutingHandler != null) { |
| 510 | return defaultRoutingHandler.getCurrentEmcpSpgMap(); |
| 511 | } else { |
| 512 | return null; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | @Override |
| 517 | public ImmutableMap<NeighborSetNextObjectiveStoreKey, Integer> getNeighborSet() { |
| 518 | if (nsNextObjStore != null) { |
| 519 | return ImmutableMap.copyOf(nsNextObjStore.entrySet()); |
| 520 | } else { |
| 521 | return ImmutableMap.of(); |
| 522 | } |
| 523 | } |
| 524 | |
sangho | 80f1f89 | 2015-05-19 11:57:42 -0700 | [diff] [blame] | 525 | /** |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 526 | * Extracts the application ID from the manager. |
| 527 | * |
| 528 | * @return application ID |
| 529 | */ |
| 530 | public ApplicationId appId() { |
| 531 | return appId; |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * Returns the device configuration. |
| 536 | * |
| 537 | * @return device configuration |
| 538 | */ |
| 539 | public DeviceConfiguration deviceConfiguration() { |
| 540 | return deviceConfiguration; |
| 541 | } |
| 542 | |
| 543 | /** |
| 544 | * Per device next objective ID store with (device id + neighbor set) as key. |
| 545 | * |
| 546 | * @return next objective ID store |
| 547 | */ |
| 548 | public EventuallyConsistentMap<NeighborSetNextObjectiveStoreKey, Integer> nsNextObjStore() { |
| 549 | return nsNextObjStore; |
| 550 | } |
| 551 | |
| 552 | /** |
| 553 | * Per device next objective ID store with (device id + subnet) as key. |
| 554 | * |
| 555 | * @return vlan next object store |
| 556 | */ |
| 557 | public EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer> vlanNextObjStore() { |
| 558 | return vlanNextObjStore; |
| 559 | } |
| 560 | |
| 561 | /** |
| 562 | * Per device next objective ID store with (device id + port) as key. |
| 563 | * |
| 564 | * @return port next object store. |
| 565 | */ |
| 566 | public EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer> portNextObjStore() { |
| 567 | return portNextObjStore; |
| 568 | } |
| 569 | |
| 570 | /** |
Pier Ventre | 7a78de2 | 2016-10-31 15:00:01 -0700 | [diff] [blame] | 571 | * Returns the MPLS-ECMP configuration. |
| 572 | * |
| 573 | * @return MPLS-ECMP value |
| 574 | */ |
| 575 | public boolean getMplsEcmp() { |
| 576 | SegmentRoutingAppConfig segmentRoutingAppConfig = cfgService |
| 577 | .getConfig(this.appId, SegmentRoutingAppConfig.class); |
| 578 | return segmentRoutingAppConfig != null && segmentRoutingAppConfig.mplsEcmp(); |
| 579 | } |
| 580 | |
| 581 | /** |
sangho | 80f1f89 | 2015-05-19 11:57:42 -0700 | [diff] [blame] | 582 | * Returns the tunnel object with the tunnel ID. |
| 583 | * |
| 584 | * @param tunnelId Tunnel ID |
| 585 | * @return Tunnel reference |
| 586 | */ |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 587 | public Tunnel getTunnel(String tunnelId) { |
| 588 | return tunnelHandler.getTunnel(tunnelId); |
| 589 | } |
| 590 | |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 591 | // TODO Consider moving these to InterfaceService |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 592 | /** |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 593 | * Returns untagged VLAN configured on given connect point. |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 594 | * <p> |
| 595 | * Only returns the first match if there are multiple untagged VLAN configured |
| 596 | * on the connect point. |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 597 | * |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 598 | * @param connectPoint connect point |
| 599 | * @return untagged VLAN or null if not configured |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 600 | */ |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 601 | public VlanId getUntaggedVlanId(ConnectPoint connectPoint) { |
| 602 | return interfaceService.getInterfacesByPort(connectPoint).stream() |
| 603 | .filter(intf -> !intf.vlanUntagged().equals(VlanId.NONE)) |
| 604 | .map(Interface::vlanUntagged) |
| 605 | .findFirst().orElse(null); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 606 | } |
| 607 | |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 608 | /** |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 609 | * Returns tagged VLAN configured on given connect point. |
| 610 | * <p> |
| 611 | * Returns all matches if there are multiple tagged VLAN configured |
| 612 | * on the connect point. |
| 613 | * |
| 614 | * @param connectPoint connect point |
| 615 | * @return tagged VLAN or empty set if not configured |
| 616 | */ |
| 617 | public Set<VlanId> getTaggedVlanId(ConnectPoint connectPoint) { |
| 618 | Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint); |
| 619 | return interfaces.stream() |
| 620 | .map(Interface::vlanTagged) |
| 621 | .flatMap(vlanIds -> vlanIds.stream()) |
| 622 | .collect(Collectors.toSet()); |
| 623 | } |
| 624 | |
| 625 | /** |
| 626 | * Returns native VLAN configured on given connect point. |
| 627 | * <p> |
| 628 | * Only returns the first match if there are multiple native VLAN configured |
| 629 | * on the connect point. |
| 630 | * |
| 631 | * @param connectPoint connect point |
| 632 | * @return native VLAN or null if not configured |
| 633 | */ |
| 634 | public VlanId getNativeVlanId(ConnectPoint connectPoint) { |
| 635 | Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint); |
| 636 | return interfaces.stream() |
| 637 | .filter(intf -> !intf.vlanNative().equals(VlanId.NONE)) |
| 638 | .map(Interface::vlanNative) |
| 639 | .findFirst() |
| 640 | .orElse(null); |
| 641 | } |
| 642 | |
| 643 | /** |
| 644 | * Returns vlan port map of given device. |
| 645 | * |
| 646 | * @param deviceId device id |
| 647 | * @return vlan-port multimap |
| 648 | */ |
| 649 | public Multimap<VlanId, PortNumber> getVlanPortMap(DeviceId deviceId) { |
| 650 | HashMultimap<VlanId, PortNumber> vlanPortMap = HashMultimap.create(); |
| 651 | |
| 652 | interfaceService.getInterfaces().stream() |
| 653 | .filter(intf -> intf.connectPoint().deviceId().equals(deviceId)) |
| 654 | .forEach(intf -> { |
| 655 | vlanPortMap.put(intf.vlanUntagged(), intf.connectPoint().port()); |
| 656 | intf.vlanTagged().forEach(vlanTagged -> { |
| 657 | vlanPortMap.put(vlanTagged, intf.connectPoint().port()); |
| 658 | }); |
| 659 | vlanPortMap.put(intf.vlanNative(), intf.connectPoint().port()); |
| 660 | }); |
| 661 | vlanPortMap.removeAll(VlanId.NONE); |
| 662 | |
| 663 | return vlanPortMap; |
| 664 | } |
| 665 | |
| 666 | /** |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 667 | * Returns the next objective ID for the given subnet prefix. It is expected |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 668 | * Returns the next objective ID for the given vlan id. It is expected |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 669 | * that the next-objective has been pre-created from configuration. |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 670 | * |
| 671 | * @param deviceId Device ID |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 672 | * @param vlanId VLAN ID |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 673 | * @return next objective ID or -1 if it was not found |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 674 | */ |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 675 | public int getVlanNextObjectiveId(DeviceId deviceId, VlanId vlanId) { |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 676 | if (groupHandlerMap.get(deviceId) != null) { |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 677 | log.trace("getVlanNextObjectiveId query in device {}", deviceId); |
| 678 | return groupHandlerMap.get(deviceId).getVlanNextObjectiveId(vlanId); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 679 | } else { |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 680 | log.warn("getVlanNextObjectiveId query - groupHandler for " |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 681 | + "device {} not found", deviceId); |
| 682 | return -1; |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | /** |
| 687 | * Returns the next objective ID for the given portNumber, given the treatment. |
| 688 | * There could be multiple different treatments to the same outport, which |
Saurav Das | 2cb3829 | 2017-03-29 19:09:17 -0700 | [diff] [blame] | 689 | * would result in different objectives. If the next object does not exist, |
| 690 | * and should be created, a new one is created and its id is returned. |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 691 | * |
| 692 | * @param deviceId Device ID |
| 693 | * @param portNum port number on device for which NextObjective is queried |
| 694 | * @param treatment the actions to apply on the packets (should include outport) |
| 695 | * @param meta metadata passed into the creation of a Next Objective if necessary |
Saurav Das | 2cb3829 | 2017-03-29 19:09:17 -0700 | [diff] [blame] | 696 | * @param createIfMissing true if a next object should be created if not found |
Saurav Das | 07c7460 | 2016-04-27 18:35:50 -0700 | [diff] [blame] | 697 | * @return next objective ID or -1 if an error occurred during retrieval or creation |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 698 | */ |
| 699 | public int getPortNextObjectiveId(DeviceId deviceId, PortNumber portNum, |
| 700 | TrafficTreatment treatment, |
Saurav Das | 2cb3829 | 2017-03-29 19:09:17 -0700 | [diff] [blame] | 701 | TrafficSelector meta, |
| 702 | boolean createIfMissing) { |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 703 | DefaultGroupHandler ghdlr = groupHandlerMap.get(deviceId); |
| 704 | if (ghdlr != null) { |
Saurav Das | 2cb3829 | 2017-03-29 19:09:17 -0700 | [diff] [blame] | 705 | return ghdlr.getPortNextObjectiveId(portNum, treatment, meta, createIfMissing); |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 706 | } else { |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 707 | log.warn("getPortNextObjectiveId query - groupHandler for device {}" |
| 708 | + " not found", deviceId); |
| 709 | return -1; |
| 710 | } |
| 711 | } |
| 712 | |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 713 | /** |
| 714 | * Returns the group handler object for the specified device id. |
| 715 | * |
| 716 | * @param devId the device identifier |
| 717 | * @return the groupHandler object for the device id, or null if not found |
| 718 | */ |
| 719 | public DefaultGroupHandler getGroupHandler(DeviceId devId) { |
| 720 | return groupHandlerMap.get(devId); |
| 721 | } |
| 722 | |
| 723 | /** |
| 724 | * Returns true if this controller instance has seen this link before. The |
| 725 | * link may not be currently up, but as long as the link had been seen before |
| 726 | * this method will return true. The one exception is when the link was |
| 727 | * indeed seen before, but this controller instance was forced to forget it |
| 728 | * by a call to purgeSeenLink method. |
| 729 | * |
| 730 | * @param link the infrastructure link being queried |
| 731 | * @return true if this controller instance has seen this link before |
| 732 | */ |
| 733 | public boolean isSeenLink(Link link) { |
| 734 | return seenLinks.containsKey(link); |
| 735 | } |
| 736 | |
| 737 | /** |
| 738 | * Updates the seen link store. Updates can be for links that are currently |
| 739 | * available or not. |
| 740 | * |
| 741 | * @param link the link to update in the seen-link local store |
| 742 | * @param up the status of the link, true if up, false if down |
| 743 | */ |
| 744 | public void updateSeenLink(Link link, boolean up) { |
| 745 | seenLinks.put(link, up); |
| 746 | } |
| 747 | |
| 748 | /** |
| 749 | * Returns the status of a seen-link (up or down). If the link has not |
| 750 | * been seen-before, a null object is returned. |
| 751 | * |
| 752 | * @param link the infrastructure link being queried |
| 753 | * @return null if the link was not seen-before; |
| 754 | * true if the seen-link is up; |
| 755 | * false if the seen-link is down |
| 756 | */ |
| 757 | public Boolean isSeenLinkUp(Link link) { |
| 758 | return seenLinks.get(link); |
| 759 | } |
| 760 | |
| 761 | /** |
| 762 | * Makes this controller instance forget a previously seen before link. |
| 763 | * |
| 764 | * @param link the infrastructure link to purge |
| 765 | */ |
| 766 | public void purgeSeenLink(Link link) { |
| 767 | seenLinks.remove(link); |
| 768 | } |
| 769 | |
| 770 | /** |
| 771 | * Returns the status of a link as parallel link. A parallel link |
| 772 | * is defined as a link which has common src and dst switches as another |
| 773 | * seen-link that is currently enabled. It is not necessary for the link being |
| 774 | * queried to be a seen-link. |
| 775 | * |
| 776 | * @param link the infrastructure link being queried |
| 777 | * @return true if a seen-link exists that is up, and shares the |
| 778 | * same src and dst switches as the link being queried |
| 779 | */ |
| 780 | public boolean isParallelLink(Link link) { |
| 781 | for (Entry<Link, Boolean> seen : seenLinks.entrySet()) { |
| 782 | Link seenLink = seen.getKey(); |
| 783 | if (seenLink.equals(link)) { |
| 784 | continue; |
| 785 | } |
| 786 | if (seenLink.src().deviceId().equals(link.src().deviceId()) && |
| 787 | seenLink.dst().deviceId().equals(link.dst().deviceId()) && |
| 788 | seen.getValue()) { |
| 789 | return true; |
| 790 | } |
| 791 | } |
| 792 | return false; |
| 793 | } |
| 794 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 795 | private class InternalPacketProcessor implements PacketProcessor { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 796 | @Override |
| 797 | public void process(PacketContext context) { |
| 798 | |
| 799 | if (context.isHandled()) { |
| 800 | return; |
| 801 | } |
| 802 | |
| 803 | InboundPacket pkt = context.inPacket(); |
| 804 | Ethernet ethernet = pkt.parsed(); |
Pier Luigi | 37a3543 | 2017-02-01 13:50:04 -0800 | [diff] [blame] | 805 | |
| 806 | if (ethernet == null) { |
| 807 | return; |
| 808 | } |
| 809 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 810 | log.trace("Rcvd pktin: {}", ethernet); |
Pier Ventre | adb4ae6 | 2016-11-23 09:57:42 -0800 | [diff] [blame] | 811 | if (ethernet.getEtherType() == TYPE_ARP) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 812 | log.warn("Received unexpected ARP packet on {}", |
| 813 | context.inPacket().receivedFrom()); |
Saurav Das | 368cf21 | 2017-03-15 15:15:14 -0700 | [diff] [blame] | 814 | log.trace("{}", ethernet); |
Pier Ventre | 6b2c1b3 | 2016-12-09 17:26:04 -0800 | [diff] [blame] | 815 | return; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 816 | } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) { |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 817 | IPv4 ipv4Packet = (IPv4) ethernet.getPayload(); |
| 818 | //ipHandler.addToPacketBuffer(ipv4Packet); |
| 819 | if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) { |
| 820 | icmpHandler.processIcmp(ethernet, pkt.receivedFrom()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 821 | } else { |
Charles Chan | d041ad8 | 2017-01-13 17:20:44 -0800 | [diff] [blame] | 822 | // NOTE: We don't support IP learning at this moment so this |
| 823 | // is not necessary. Also it causes duplication of DHCP packets. |
Pier Ventre | 6b2c1b3 | 2016-12-09 17:26:04 -0800 | [diff] [blame] | 824 | // ipHandler.processPacketIn(ipv4Packet, pkt.receivedFrom()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 825 | } |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 826 | } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV6) { |
| 827 | IPv6 ipv6Packet = (IPv6) ethernet.getPayload(); |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 828 | //ipHandler.addToPacketBuffer(ipv6Packet); |
Pier Luigi | 37a3543 | 2017-02-01 13:50:04 -0800 | [diff] [blame] | 829 | // We deal with the packet only if the packet is a ICMP6 ECHO/REPLY |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 830 | if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_ICMP6) { |
| 831 | ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload(); |
| 832 | if (icmp6Packet.getIcmpType() == ICMP6.ECHO_REQUEST || |
| 833 | icmp6Packet.getIcmpType() == ICMP6.ECHO_REPLY) { |
| 834 | icmpHandler.processIcmpv6(ethernet, pkt.receivedFrom()); |
| 835 | } else { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 836 | log.trace("Received ICMPv6 0x{} - not handled", |
Charles Chan | d3727b7 | 2017-03-13 13:10:30 -0700 | [diff] [blame] | 837 | Integer.toHexString(icmp6Packet.getIcmpType() & 0xff)); |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 838 | } |
| 839 | } else { |
| 840 | // NOTE: We don't support IP learning at this moment so this |
| 841 | // is not necessary. Also it causes duplication of DHCPv6 packets. |
| 842 | // ipHandler.processPacketIn(ipv6Packet, pkt.receivedFrom()); |
| 843 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 844 | } |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | private class InternalLinkListener implements LinkListener { |
| 849 | @Override |
| 850 | public void event(LinkEvent event) { |
Charles Chan | 0cff8aa | 2017-03-29 16:39:05 -0700 | [diff] [blame] | 851 | if (event.type() == LinkEvent.Type.LINK_ADDED || |
| 852 | event.type() == LinkEvent.Type.LINK_UPDATED || |
| 853 | event.type() == LinkEvent.Type.LINK_REMOVED) { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 854 | log.debug("Event {} received from Link Service", event.type()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 855 | scheduleEventHandlerIfNotScheduled(event); |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | private class InternalDeviceListener implements DeviceListener { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 861 | @Override |
| 862 | public void event(DeviceEvent event) { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 863 | switch (event.type()) { |
| 864 | case DEVICE_ADDED: |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 865 | case PORT_UPDATED: |
| 866 | case PORT_ADDED: |
sangho | fb7c729 | 2015-04-13 15:15:58 -0700 | [diff] [blame] | 867 | case DEVICE_UPDATED: |
| 868 | case DEVICE_AVAILABILITY_CHANGED: |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 869 | log.trace("Event {} received from Device Service", event.type()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 870 | scheduleEventHandlerIfNotScheduled(event); |
| 871 | break; |
| 872 | default: |
| 873 | } |
| 874 | } |
| 875 | } |
| 876 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 877 | @SuppressWarnings("rawtypes") |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 878 | private void scheduleEventHandlerIfNotScheduled(Event event) { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 879 | synchronized (threadSchedulerLock) { |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 880 | eventQueue.add(event); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 881 | numOfEventsQueued++; |
| 882 | |
| 883 | if ((numOfHandlerScheduled - numOfHandlerExecution) == 0) { |
| 884 | //No pending scheduled event handling threads. So start a new one. |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 885 | eventHandlerFuture = executorService |
| 886 | .schedule(eventHandler, 100, TimeUnit.MILLISECONDS); |
| 887 | numOfHandlerScheduled++; |
| 888 | } |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 889 | log.trace("numOfEventsQueued {}, numOfEventHandlerScheduled {}", |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 890 | numOfEventsQueued, |
| 891 | numOfHandlerScheduled); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 892 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 893 | } |
| 894 | |
| 895 | private class InternalEventHandler implements Runnable { |
Srikanth Vavilapalli | 37a461b | 2015-04-07 15:12:32 -0700 | [diff] [blame] | 896 | @Override |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 897 | public void run() { |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 898 | try { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 899 | while (true) { |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 900 | @SuppressWarnings("rawtypes") |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 901 | Event event = null; |
| 902 | synchronized (threadSchedulerLock) { |
| 903 | if (!eventQueue.isEmpty()) { |
| 904 | event = eventQueue.poll(); |
| 905 | numOfEventsExecuted++; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 906 | } else { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 907 | numOfHandlerExecution++; |
| 908 | log.debug("numOfHandlerExecution {} numOfEventsExecuted {}", |
| 909 | numOfHandlerExecution, numOfEventsExecuted); |
| 910 | break; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 911 | } |
sangho | fb7c729 | 2015-04-13 15:15:58 -0700 | [diff] [blame] | 912 | } |
Charles Chan | 0cff8aa | 2017-03-29 16:39:05 -0700 | [diff] [blame] | 913 | if (event.type() == LinkEvent.Type.LINK_ADDED || |
| 914 | event.type() == LinkEvent.Type.LINK_UPDATED) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 915 | // Note: do not update seenLinks here, otherwise every |
| 916 | // link, even one seen for the first time, will be appear |
| 917 | // to be a previously seen link |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 918 | processLinkAdded((Link) event.subject()); |
| 919 | } else if (event.type() == LinkEvent.Type.LINK_REMOVED) { |
Pier Ventre | 6d59389 | 2016-09-13 21:33:40 -0700 | [diff] [blame] | 920 | Link linkRemoved = (Link) event.subject(); |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 921 | if (linkRemoved.type() == Link.Type.DIRECT) { |
| 922 | updateSeenLink(linkRemoved, false); |
| 923 | } |
| 924 | // device availability check helps to ensure that |
| 925 | // multiple link-removed events are actually treated as a |
| 926 | // single switch removed event. purgeSeenLink is necessary |
| 927 | // so we do rerouting (instead of rehashing) when switch |
| 928 | // comes back. |
Pier Ventre | 6d59389 | 2016-09-13 21:33:40 -0700 | [diff] [blame] | 929 | if (linkRemoved.src().elementId() instanceof DeviceId && |
| 930 | !deviceService.isAvailable(linkRemoved.src().deviceId())) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 931 | purgeSeenLink(linkRemoved); |
Pier Ventre | 6d59389 | 2016-09-13 21:33:40 -0700 | [diff] [blame] | 932 | continue; |
| 933 | } |
| 934 | if (linkRemoved.dst().elementId() instanceof DeviceId && |
| 935 | !deviceService.isAvailable(linkRemoved.dst().deviceId())) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 936 | purgeSeenLink(linkRemoved); |
Pier Ventre | 6d59389 | 2016-09-13 21:33:40 -0700 | [diff] [blame] | 937 | continue; |
| 938 | } |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 939 | processLinkRemoved((Link) event.subject()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 940 | } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED || |
| 941 | event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED || |
| 942 | event.type() == DeviceEvent.Type.DEVICE_UPDATED) { |
Saurav Das | 62af880 | 2015-12-04 10:52:59 -0800 | [diff] [blame] | 943 | DeviceId deviceId = ((Device) event.subject()).id(); |
| 944 | if (deviceService.isAvailable(deviceId)) { |
Saurav Das | c28b343 | 2015-10-30 17:45:38 -0700 | [diff] [blame] | 945 | log.info("Processing device event {} for available device {}", |
| 946 | event.type(), ((Device) event.subject()).id()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 947 | processDeviceAdded((Device) event.subject()); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 948 | } else { |
| 949 | log.info("Processing device event {} for unavailable device {}", |
| 950 | event.type(), ((Device) event.subject()).id()); |
| 951 | processDeviceRemoved((Device) event.subject()); |
| 952 | } |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 953 | } else if (event.type() == DeviceEvent.Type.PORT_ADDED) { |
Saurav Das | d1872b0 | 2016-12-02 15:43:47 -0800 | [diff] [blame] | 954 | // typically these calls come when device is added first time |
| 955 | // so port filtering rules are handled at the device_added event. |
| 956 | // port added calls represent all ports on the device, |
| 957 | // enabled or not. |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 958 | log.trace("** PORT ADDED {}/{} -> {}", |
Saurav Das | d1872b0 | 2016-12-02 15:43:47 -0800 | [diff] [blame] | 959 | ((DeviceEvent) event).subject().id(), |
| 960 | ((DeviceEvent) event).port().number(), |
| 961 | event.type()); |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 962 | } else if (event.type() == DeviceEvent.Type.PORT_UPDATED) { |
Saurav Das | d1872b0 | 2016-12-02 15:43:47 -0800 | [diff] [blame] | 963 | // these calls happen for every subsequent event |
| 964 | // ports enabled, disabled, switch goes away, comes back |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 965 | log.info("** PORT UPDATED {}/{} -> {}", |
| 966 | event.subject(), |
| 967 | ((DeviceEvent) event).port(), |
| 968 | event.type()); |
| 969 | processPortUpdated(((Device) event.subject()), |
| 970 | ((DeviceEvent) event).port()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 971 | } else { |
| 972 | log.warn("Unhandled event type: {}", event.type()); |
| 973 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 974 | } |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 975 | } catch (Exception e) { |
| 976 | log.error("SegmentRouting event handler " |
| 977 | + "thread thrown an exception: {}", e); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 978 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 979 | } |
| 980 | } |
| 981 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 982 | private void processLinkAdded(Link link) { |
Saurav Das | b149be1 | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 983 | log.info("** LINK ADDED {}", link.toString()); |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 984 | if (!deviceConfiguration.isConfigured(link.src().deviceId())) { |
| 985 | log.warn("Source device of this link is not configured."); |
| 986 | return; |
| 987 | } |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 988 | if (link.type() != Link.Type.DIRECT) { |
| 989 | // NOTE: A DIRECT link might be transiently marked as INDIRECT |
| 990 | // if BDDP is received before LLDP. We can safely ignore that |
| 991 | // until the LLDP is received and the link is marked as DIRECT. |
| 992 | log.info("Ignore link {}->{}. Link type is {} instead of DIRECT.", |
| 993 | link.src(), link.dst(), link.type()); |
| 994 | return; |
| 995 | } |
| 996 | |
| 997 | //Irrespective of whether the local is a MASTER or not for this device, |
| 998 | //create group handler instance and push default TTP flow rules if needed, |
| 999 | //as in a multi-instance setup, instances can initiate groups for any device. |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1000 | DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src() |
| 1001 | .deviceId()); |
| 1002 | if (groupHandler != null) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1003 | groupHandler.portUpForLink(link); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1004 | } else { |
| 1005 | Device device = deviceService.getDevice(link.src().deviceId()); |
| 1006 | if (device != null) { |
| 1007 | log.warn("processLinkAdded: Link Added " |
| 1008 | + "Notification without Device Added " |
| 1009 | + "event, still handling it"); |
| 1010 | processDeviceAdded(device); |
| 1011 | groupHandler = groupHandlerMap.get(link.src() |
| 1012 | .deviceId()); |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1013 | groupHandler.portUpForLink(link); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1014 | } |
| 1015 | } |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1016 | |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1017 | log.trace("Starting optimized route population process"); |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1018 | boolean seenBefore = isSeenLink(link); |
| 1019 | defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(null, link, null); |
| 1020 | if (mastershipService.isLocalMaster(link.src().deviceId())) { |
| 1021 | if (!seenBefore) { |
| 1022 | // if link seen first time, we need to ensure hash-groups have all ports |
| 1023 | groupHandler.retryHash(link, false, true); |
| 1024 | } else { |
| 1025 | //seen before-link |
| 1026 | if (isParallelLink(link)) { |
| 1027 | groupHandler.retryHash(link, false, false); |
| 1028 | } |
| 1029 | } |
| 1030 | } |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1031 | |
| 1032 | mcastHandler.init(); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1033 | } |
| 1034 | |
| 1035 | private void processLinkRemoved(Link link) { |
Saurav Das | b149be1 | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 1036 | log.info("** LINK REMOVED {}", link.toString()); |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1037 | defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(link, null, null); |
| 1038 | |
| 1039 | // update local groupHandler stores |
sangho | 2165d22 | 2015-05-01 09:38:25 -0700 | [diff] [blame] | 1040 | DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src().deviceId()); |
| 1041 | if (groupHandler != null) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1042 | if (mastershipService.isLocalMaster(link.src().deviceId()) && |
| 1043 | isParallelLink(link)) { |
| 1044 | groupHandler.retryHash(link, true, false); |
| 1045 | } |
| 1046 | // ensure local stores are updated |
| 1047 | groupHandler.portDown(link.src().port()); |
| 1048 | } else { |
| 1049 | log.warn("group handler not found for dev:{} when removing link: {}", |
| 1050 | link.src().deviceId(), link); |
sangho | 2165d22 | 2015-05-01 09:38:25 -0700 | [diff] [blame] | 1051 | } |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1052 | |
| 1053 | mcastHandler.processLinkDown(link); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | private void processDeviceAdded(Device device) { |
Saurav Das | b149be1 | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 1057 | log.info("** DEVICE ADDED with ID {}", device.id()); |
Charles Chan | 9bd6aea | 2017-06-27 18:48:32 -0700 | [diff] [blame] | 1058 | |
| 1059 | // NOTE: Punt ARP/NDP even when the device is not configured. |
| 1060 | // Host learning without network config is required for CORD config generator. |
| 1061 | routingRulePopulator.populateIpPunts(device.id()); |
| 1062 | routingRulePopulator.populateArpNdpPunts(device.id()); |
| 1063 | |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 1064 | if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) { |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 1065 | log.warn("Device configuration uploading. Device {} will be " |
| 1066 | + "processed after config completes.", device.id()); |
| 1067 | return; |
| 1068 | } |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1069 | processDeviceAddedInternal(device.id()); |
| 1070 | } |
| 1071 | |
| 1072 | private void processDeviceAddedInternal(DeviceId deviceId) { |
Saurav Das | c28b343 | 2015-10-30 17:45:38 -0700 | [diff] [blame] | 1073 | // Irrespective of whether the local is a MASTER or not for this device, |
| 1074 | // we need to create a SR-group-handler instance. This is because in a |
| 1075 | // multi-instance setup, any instance can initiate forwarding/next-objectives |
| 1076 | // for any switch (even if this instance is a SLAVE or not even connected |
| 1077 | // to the switch). To handle this, a default-group-handler instance is necessary |
| 1078 | // per switch. |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1079 | log.debug("Current groupHandlerMap devs: {}", groupHandlerMap.keySet()); |
| 1080 | if (groupHandlerMap.get(deviceId) == null) { |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 1081 | DefaultGroupHandler groupHandler; |
| 1082 | try { |
| 1083 | groupHandler = DefaultGroupHandler. |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1084 | createGroupHandler(deviceId, |
| 1085 | appId, |
| 1086 | deviceConfiguration, |
| 1087 | linkService, |
| 1088 | flowObjectiveService, |
| 1089 | this); |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 1090 | } catch (DeviceConfigNotFoundException e) { |
| 1091 | log.warn(e.getMessage() + " Aborting processDeviceAdded."); |
| 1092 | return; |
| 1093 | } |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1094 | log.debug("updating groupHandlerMap with new config for device: {}", |
| 1095 | deviceId); |
| 1096 | groupHandlerMap.put(deviceId, groupHandler); |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 1097 | } |
Saurav Das | b149be1 | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 1098 | |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1099 | if (mastershipService.isLocalMaster(deviceId)) { |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 1100 | defaultRoutingHandler.populatePortAddressingRules(deviceId); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1101 | hostHandler.init(deviceId); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1102 | xConnectHandler.init(deviceId); |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1103 | DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId); |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1104 | groupHandler.createGroupsFromVlanConfig(); |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1105 | routingRulePopulator.populateSubnetBroadcastRule(deviceId); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 1106 | } |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1107 | |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1108 | appCfgHandler.init(deviceId); |
| 1109 | routeHandler.init(deviceId); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1110 | } |
| 1111 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1112 | private void processDeviceRemoved(Device device) { |
| 1113 | nsNextObjStore.entrySet().stream() |
| 1114 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
| 1115 | .forEach(entry -> { |
| 1116 | nsNextObjStore.remove(entry.getKey()); |
| 1117 | }); |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1118 | vlanNextObjStore.entrySet().stream() |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1119 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
| 1120 | .forEach(entry -> { |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1121 | vlanNextObjStore.remove(entry.getKey()); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1122 | }); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1123 | portNextObjStore.entrySet().stream() |
| 1124 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
| 1125 | .forEach(entry -> { |
| 1126 | portNextObjStore.remove(entry.getKey()); |
| 1127 | }); |
Charles Chan | 17d75d8 | 2017-06-15 00:44:51 -0700 | [diff] [blame] | 1128 | |
| 1129 | seenLinks.keySet().removeIf(key -> key.src().deviceId().equals(device.id()) || |
| 1130 | key.dst().deviceId().equals(device.id())); |
| 1131 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1132 | groupHandlerMap.remove(device.id()); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1133 | defaultRoutingHandler.purgeEcmpGraph(device.id()); |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1134 | // Note that a switch going down is associated with all of its links |
| 1135 | // going down as well, but it is treated as a single switch down event |
| 1136 | // while the link-downs are ignored. |
| 1137 | defaultRoutingHandler |
| 1138 | .populateRoutingRulesForLinkStatusChange(null, null, device.id()); |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1139 | mcastHandler.removeDevice(device.id()); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1140 | xConnectHandler.removeDevice(device.id()); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1143 | private void processPortUpdated(Device device, Port port) { |
| 1144 | if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) { |
| 1145 | log.warn("Device configuration uploading. Not handling port event for" |
| 1146 | + "dev: {} port: {}", device.id(), port.number()); |
| 1147 | return; |
| 1148 | } |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 1149 | |
| 1150 | if (!mastershipService.isLocalMaster(device.id())) { |
| 1151 | log.debug("Not master for dev:{} .. not handling port updated event" |
| 1152 | + "for port {}", device.id(), port.number()); |
| 1153 | return; |
| 1154 | } |
| 1155 | |
| 1156 | // first we handle filtering rules associated with the port |
| 1157 | if (port.isEnabled()) { |
| 1158 | log.info("Switchport {}/{} enabled..programming filters", |
| 1159 | device.id(), port.number()); |
Charles Chan | 43be46b | 2017-02-26 22:59:35 -0800 | [diff] [blame] | 1160 | routingRulePopulator.processSinglePortFilters(device.id(), port.number(), true); |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 1161 | } else { |
| 1162 | log.info("Switchport {}/{} disabled..removing filters", |
| 1163 | device.id(), port.number()); |
Charles Chan | 43be46b | 2017-02-26 22:59:35 -0800 | [diff] [blame] | 1164 | routingRulePopulator.processSinglePortFilters(device.id(), port.number(), false); |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 1165 | } |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1166 | |
| 1167 | // portUpdated calls are for ports that have gone down or up. For switch |
| 1168 | // to switch ports, link-events should take care of any re-routing or |
| 1169 | // group editing necessary for port up/down. Here we only process edge ports |
| 1170 | // that are already configured. |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1171 | ConnectPoint cp = new ConnectPoint(device.id(), port.number()); |
| 1172 | VlanId untaggedVlan = getUntaggedVlanId(cp); |
| 1173 | VlanId nativeVlan = getNativeVlanId(cp); |
| 1174 | Set<VlanId> taggedVlans = getTaggedVlanId(cp); |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1175 | |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1176 | if (untaggedVlan == null && nativeVlan == null && taggedVlans.isEmpty()) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1177 | log.debug("Not handling port updated event for non-edge port (unconfigured) " |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1178 | + "dev/port: {}/{}", device.id(), port.number()); |
| 1179 | return; |
| 1180 | } |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1181 | if (untaggedVlan != null) { |
| 1182 | processEdgePort(device, port, untaggedVlan, true); |
| 1183 | } |
| 1184 | if (nativeVlan != null) { |
| 1185 | processEdgePort(device, port, nativeVlan, true); |
| 1186 | } |
| 1187 | if (!taggedVlans.isEmpty()) { |
| 1188 | taggedVlans.forEach(tag -> processEdgePort(device, port, tag, false)); |
| 1189 | } |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1190 | } |
| 1191 | |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1192 | private void processEdgePort(Device device, Port port, VlanId vlanId, |
| 1193 | boolean popVlan) { |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1194 | boolean portUp = port.isEnabled(); |
| 1195 | if (portUp) { |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1196 | log.info("Device:EdgePort {}:{} is enabled in vlan: {}", device.id(), |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1197 | port.number(), vlanId); |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1198 | } else { |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1199 | log.info("Device:EdgePort {}:{} is disabled in vlan: {}", device.id(), |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1200 | port.number(), vlanId); |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1201 | } |
| 1202 | |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 1203 | DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1204 | if (groupHandler != null) { |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1205 | groupHandler.processEdgePort(port.number(), vlanId, popVlan, portUp); |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1206 | } else { |
| 1207 | log.warn("Group handler not found for dev:{}. Not handling edge port" |
| 1208 | + " {} event for port:{}", device.id(), |
| 1209 | (portUp) ? "UP" : "DOWN", port.number()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1210 | } |
| 1211 | } |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 1212 | |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 1213 | /** |
| 1214 | * Registers the given connect point with the NRS, this is necessary |
| 1215 | * to receive the NDP and ARP packets from the NRS. |
| 1216 | * |
| 1217 | * @param portToRegister connect point to register |
| 1218 | */ |
| 1219 | public void registerConnectPoint(ConnectPoint portToRegister) { |
Charles Chan | 2e71ef3 | 2017-02-23 15:44:08 -0800 | [diff] [blame] | 1220 | neighbourResolutionService.registerNeighbourHandler( |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 1221 | portToRegister, |
| 1222 | neighbourHandler, |
| 1223 | appId |
| 1224 | ); |
| 1225 | } |
| 1226 | |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 1227 | private class InternalConfigListener implements NetworkConfigListener { |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1228 | SegmentRoutingManager srManager; |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1229 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 1230 | /** |
| 1231 | * Constructs the internal network config listener. |
| 1232 | * |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1233 | * @param srManager segment routing manager |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 1234 | */ |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1235 | public InternalConfigListener(SegmentRoutingManager srManager) { |
| 1236 | this.srManager = srManager; |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1237 | } |
| 1238 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 1239 | /** |
| 1240 | * Reads network config and initializes related data structure accordingly. |
| 1241 | */ |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1242 | public void configureNetwork() { |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 1243 | |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1244 | deviceConfiguration = new DeviceConfiguration(srManager); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1245 | |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1246 | arpHandler = new ArpHandler(srManager); |
| 1247 | icmpHandler = new IcmpHandler(srManager); |
| 1248 | ipHandler = new IpHandler(srManager); |
| 1249 | routingRulePopulator = new RoutingRulePopulator(srManager); |
| 1250 | defaultRoutingHandler = new DefaultRoutingHandler(srManager); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1251 | |
| 1252 | tunnelHandler = new TunnelHandler(linkService, deviceConfiguration, |
| 1253 | groupHandlerMap, tunnelStore); |
| 1254 | policyHandler = new PolicyHandler(appId, deviceConfiguration, |
| 1255 | flowObjectiveService, |
| 1256 | tunnelHandler, policyStore); |
| 1257 | |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1258 | for (Device device : deviceService.getDevices()) { |
Charles Chan | a275efd | 2017-07-12 18:47:58 -0700 | [diff] [blame] | 1259 | processDeviceAdded(device); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | defaultRoutingHandler.startPopulationProcess(); |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1263 | mcastHandler.init(); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1264 | } |
| 1265 | |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 1266 | @Override |
| 1267 | public void event(NetworkConfigEvent event) { |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1268 | // TODO move this part to NetworkConfigEventHandler |
| 1269 | if (event.configClass().equals(SegmentRoutingDeviceConfig.class)) { |
| 1270 | switch (event.type()) { |
| 1271 | case CONFIG_ADDED: |
Charles Chan | 68363b1 | 2017-06-26 15:25:09 -0700 | [diff] [blame] | 1272 | log.info("Segment Routing Device Config added for {}", event.subject()); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1273 | configureNetwork(); |
| 1274 | break; |
| 1275 | case CONFIG_UPDATED: |
Charles Chan | 68363b1 | 2017-06-26 15:25:09 -0700 | [diff] [blame] | 1276 | log.info("Segment Routing Config updated for {}", event.subject()); |
| 1277 | // TODO support dynamic configuration |
| 1278 | break; |
| 1279 | default: |
| 1280 | break; |
| 1281 | } |
| 1282 | } else if (event.configClass().equals(InterfaceConfig.class)) { |
| 1283 | switch (event.type()) { |
| 1284 | case CONFIG_ADDED: |
| 1285 | log.info("Interface Config added for {}", event.subject()); |
| 1286 | configureNetwork(); |
| 1287 | break; |
| 1288 | case CONFIG_UPDATED: |
| 1289 | log.info("Interface Config updated for {}", event.subject()); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1290 | // TODO support dynamic configuration |
| 1291 | break; |
| 1292 | default: |
| 1293 | break; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 1294 | } |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1295 | } else if (event.configClass().equals(SegmentRoutingAppConfig.class)) { |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1296 | checkState(appCfgHandler != null, "NetworkConfigEventHandler is not initialized"); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1297 | switch (event.type()) { |
| 1298 | case CONFIG_ADDED: |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1299 | appCfgHandler.processAppConfigAdded(event); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1300 | break; |
| 1301 | case CONFIG_UPDATED: |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1302 | appCfgHandler.processAppConfigUpdated(event); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1303 | break; |
| 1304 | case CONFIG_REMOVED: |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1305 | appCfgHandler.processAppConfigRemoved(event); |
| 1306 | break; |
| 1307 | default: |
| 1308 | break; |
| 1309 | } |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1310 | configureNetwork(); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1311 | } else if (event.configClass().equals(XConnectConfig.class)) { |
| 1312 | checkState(xConnectHandler != null, "XConnectHandler is not initialized"); |
| 1313 | switch (event.type()) { |
| 1314 | case CONFIG_ADDED: |
| 1315 | xConnectHandler.processXConnectConfigAdded(event); |
| 1316 | break; |
| 1317 | case CONFIG_UPDATED: |
| 1318 | xConnectHandler.processXConnectConfigUpdated(event); |
| 1319 | break; |
| 1320 | case CONFIG_REMOVED: |
| 1321 | xConnectHandler.processXConnectConfigRemoved(event); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1322 | break; |
| 1323 | default: |
| 1324 | break; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 1325 | } |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 1326 | } else if (event.configClass().equals(PwaasConfig.class)) { |
| 1327 | checkState(l2TunnelHandler != null, "L2TunnelHandler is not initialized"); |
| 1328 | switch (event.type()) { |
| 1329 | case CONFIG_ADDED: |
| 1330 | l2TunnelHandler.processPwaasConfigAdded(event); |
| 1331 | break; |
| 1332 | case CONFIG_UPDATED: |
| 1333 | l2TunnelHandler.processPwaasConfigUpdated(event); |
| 1334 | break; |
| 1335 | case CONFIG_REMOVED: |
| 1336 | l2TunnelHandler.processPwaasConfigRemoved(event); |
| 1337 | break; |
| 1338 | default: |
| 1339 | break; |
| 1340 | } |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 1341 | } |
| 1342 | } |
| 1343 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1344 | |
| 1345 | private class InternalHostListener implements HostListener { |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1346 | @Override |
| 1347 | public void event(HostEvent event) { |
| 1348 | // Do not proceed without mastership |
| 1349 | DeviceId deviceId = event.subject().location().deviceId(); |
| 1350 | if (!mastershipService.isLocalMaster(deviceId)) { |
| 1351 | return; |
| 1352 | } |
| 1353 | |
| 1354 | switch (event.type()) { |
| 1355 | case HOST_ADDED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1356 | hostHandler.processHostAddedEvent(event); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1357 | break; |
| 1358 | case HOST_MOVED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1359 | hostHandler.processHostMovedEvent(event); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1360 | break; |
| 1361 | case HOST_REMOVED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1362 | hostHandler.processHostRemoveEvent(event); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1363 | break; |
| 1364 | case HOST_UPDATED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1365 | hostHandler.processHostUpdatedEvent(event); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1366 | break; |
| 1367 | default: |
| 1368 | log.warn("Unsupported host event type: {}", event.type()); |
| 1369 | break; |
| 1370 | } |
| 1371 | } |
| 1372 | } |
| 1373 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 1374 | private class InternalMcastListener implements McastListener { |
| 1375 | @Override |
| 1376 | public void event(McastEvent event) { |
| 1377 | switch (event.type()) { |
| 1378 | case SOURCE_ADDED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1379 | mcastHandler.processSourceAdded(event); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 1380 | break; |
| 1381 | case SINK_ADDED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1382 | mcastHandler.processSinkAdded(event); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 1383 | break; |
| 1384 | case SINK_REMOVED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1385 | mcastHandler.processSinkRemoved(event); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 1386 | break; |
| 1387 | case ROUTE_ADDED: |
| 1388 | case ROUTE_REMOVED: |
| 1389 | default: |
| 1390 | break; |
| 1391 | } |
| 1392 | } |
| 1393 | } |
Charles Chan | 41f5ec0 | 2016-06-13 18:54:31 -0700 | [diff] [blame] | 1394 | |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1395 | private class InternalRouteEventListener implements RouteListener { |
| 1396 | @Override |
| 1397 | public void event(RouteEvent event) { |
| 1398 | switch (event.type()) { |
| 1399 | case ROUTE_ADDED: |
| 1400 | routeHandler.processRouteAdded(event); |
| 1401 | break; |
| 1402 | case ROUTE_UPDATED: |
| 1403 | routeHandler.processRouteUpdated(event); |
| 1404 | break; |
| 1405 | case ROUTE_REMOVED: |
| 1406 | routeHandler.processRouteRemoved(event); |
| 1407 | break; |
| 1408 | default: |
| 1409 | break; |
| 1410 | } |
| 1411 | } |
| 1412 | } |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1413 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1414 | } |