sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0947d7e | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
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 | |
Andreas Pantelopoulos | afc637f | 2017-12-20 18:04:27 -0800 | [diff] [blame] | 18 | import com.fasterxml.jackson.databind.ObjectMapper; |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 19 | import com.fasterxml.jackson.databind.node.ObjectNode; |
Jonathan Hart | 61e24e1 | 2017-11-30 18:23:42 -0800 | [diff] [blame] | 20 | import com.google.common.collect.HashMultimap; |
| 21 | import com.google.common.collect.ImmutableMap; |
| 22 | import com.google.common.collect.Maps; |
| 23 | import com.google.common.collect.Multimap; |
Charles Chan | f0ae41e | 2017-08-23 13:55:39 -0700 | [diff] [blame] | 24 | import com.google.common.collect.Sets; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 25 | import org.apache.felix.scr.annotations.Activate; |
| 26 | import org.apache.felix.scr.annotations.Component; |
| 27 | import org.apache.felix.scr.annotations.Deactivate; |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 28 | import org.apache.felix.scr.annotations.Modified; |
| 29 | import org.apache.felix.scr.annotations.Property; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 30 | import org.apache.felix.scr.annotations.Reference; |
| 31 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 32 | import org.apache.felix.scr.annotations.Service; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 33 | import org.onlab.packet.Ethernet; |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 34 | import org.onlab.packet.ICMP6; |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 35 | import org.onlab.packet.IPv4; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 36 | import org.onlab.packet.IPv6; |
Jonghwan Hyun | e5ef762 | 2017-08-25 17:48:36 -0700 | [diff] [blame] | 37 | import org.onlab.packet.IpAddress; |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 38 | import org.onlab.packet.IpPrefix; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 39 | import org.onlab.packet.VlanId; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 40 | import org.onlab.util.KryoNamespace; |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 41 | import org.onlab.util.Tools; |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 42 | import org.onosproject.cfg.ComponentConfigService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 43 | import org.onosproject.core.ApplicationId; |
| 44 | import org.onosproject.core.CoreService; |
| 45 | import org.onosproject.event.Event; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 46 | import org.onosproject.mastership.MastershipService; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 47 | import org.onosproject.net.ConnectPoint; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 48 | import org.onosproject.net.Device; |
| 49 | import org.onosproject.net.DeviceId; |
Charles Chan | f0ae41e | 2017-08-23 13:55:39 -0700 | [diff] [blame] | 50 | import org.onosproject.net.Host; |
| 51 | import org.onosproject.net.HostId; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 52 | import org.onosproject.net.Link; |
| 53 | import org.onosproject.net.Port; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 54 | import org.onosproject.net.PortNumber; |
Jonghwan Hyun | e5ef762 | 2017-08-25 17:48:36 -0700 | [diff] [blame] | 55 | import org.onosproject.net.config.ConfigException; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 56 | import org.onosproject.net.config.ConfigFactory; |
| 57 | import org.onosproject.net.config.NetworkConfigEvent; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 58 | import org.onosproject.net.config.NetworkConfigListener; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 59 | import org.onosproject.net.config.NetworkConfigRegistry; |
Ray Milkey | ae0068a | 2017-08-15 11:02:29 -0700 | [diff] [blame] | 60 | import org.onosproject.net.config.basics.InterfaceConfig; |
| 61 | import org.onosproject.net.config.basics.McastConfig; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 62 | import org.onosproject.net.config.basics.SubjectFactories; |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 63 | import org.onosproject.net.device.DeviceAdminService; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 64 | import org.onosproject.net.device.DeviceEvent; |
| 65 | import org.onosproject.net.device.DeviceListener; |
| 66 | import org.onosproject.net.device.DeviceService; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 67 | import org.onosproject.net.flow.TrafficSelector; |
| 68 | import org.onosproject.net.flow.TrafficTreatment; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 69 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 70 | import org.onosproject.net.host.HostEvent; |
| 71 | import org.onosproject.net.host.HostListener; |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 72 | import org.onosproject.net.host.HostLocationProbingService; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 73 | import org.onosproject.net.host.HostService; |
Jonghwan Hyun | e5ef762 | 2017-08-25 17:48:36 -0700 | [diff] [blame] | 74 | import org.onosproject.net.host.InterfaceIpAddress; |
Ray Milkey | ae0068a | 2017-08-15 11:02:29 -0700 | [diff] [blame] | 75 | import org.onosproject.net.intf.Interface; |
| 76 | import org.onosproject.net.intf.InterfaceService; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 77 | import org.onosproject.net.link.LinkEvent; |
| 78 | import org.onosproject.net.link.LinkListener; |
| 79 | import org.onosproject.net.link.LinkService; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 80 | import org.onosproject.net.mcast.McastEvent; |
| 81 | import org.onosproject.net.mcast.McastListener; |
| 82 | import org.onosproject.net.mcast.MulticastRouteService; |
Ray Milkey | ae0068a | 2017-08-15 11:02:29 -0700 | [diff] [blame] | 83 | import org.onosproject.net.neighbour.NeighbourResolutionService; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 84 | import org.onosproject.net.packet.InboundPacket; |
| 85 | import org.onosproject.net.packet.PacketContext; |
| 86 | import org.onosproject.net.packet.PacketProcessor; |
| 87 | import org.onosproject.net.packet.PacketService; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 88 | import org.onosproject.net.topology.TopologyService; |
Charles Chan | f0ae41e | 2017-08-23 13:55:39 -0700 | [diff] [blame] | 89 | import org.onosproject.routeservice.ResolvedRoute; |
Ray Milkey | ae0068a | 2017-08-15 11:02:29 -0700 | [diff] [blame] | 90 | import org.onosproject.routeservice.RouteEvent; |
| 91 | import org.onosproject.routeservice.RouteListener; |
| 92 | import org.onosproject.routeservice.RouteService; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 93 | import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; |
| 94 | import org.onosproject.segmentrouting.config.DeviceConfiguration; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 95 | import org.onosproject.segmentrouting.config.PwaasConfig; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 96 | import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig; |
Ray Milkey | ae0068a | 2017-08-15 11:02:29 -0700 | [diff] [blame] | 97 | import org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig; |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 98 | import org.onosproject.segmentrouting.config.XConnectConfig; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 99 | import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 100 | import org.onosproject.segmentrouting.grouphandler.DestinationSet; |
| 101 | import org.onosproject.segmentrouting.grouphandler.NextNeighbors; |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 102 | import org.onosproject.segmentrouting.pwaas.DefaultL2Tunnel; |
| 103 | import org.onosproject.segmentrouting.pwaas.DefaultL2TunnelPolicy; |
Ray Milkey | ae0068a | 2017-08-15 11:02:29 -0700 | [diff] [blame] | 104 | import org.onosproject.segmentrouting.pwaas.L2TunnelHandler; |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 105 | import org.onosproject.segmentrouting.storekey.DestinationSetNextObjectiveStoreKey; |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 106 | import org.onosproject.segmentrouting.storekey.PortNextObjectiveStoreKey; |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 107 | import org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey; |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 108 | import org.onosproject.segmentrouting.storekey.XConnectStoreKey; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 109 | import org.onosproject.store.serializers.KryoNamespaces; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 110 | import org.onosproject.store.service.EventuallyConsistentMap; |
| 111 | import org.onosproject.store.service.EventuallyConsistentMapBuilder; |
| 112 | import org.onosproject.store.service.StorageService; |
| 113 | import org.onosproject.store.service.WallClockTimestamp; |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 114 | import org.osgi.service.component.ComponentContext; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 115 | import org.slf4j.Logger; |
| 116 | import org.slf4j.LoggerFactory; |
| 117 | |
Jonathan Hart | 61e24e1 | 2017-11-30 18:23:42 -0800 | [diff] [blame] | 118 | import java.util.Collections; |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 119 | import java.util.Dictionary; |
Jonathan Hart | 61e24e1 | 2017-11-30 18:23:42 -0800 | [diff] [blame] | 120 | import java.util.HashSet; |
| 121 | import java.util.List; |
| 122 | import java.util.Map; |
Jonathan Hart | 61e24e1 | 2017-11-30 18:23:42 -0800 | [diff] [blame] | 123 | import java.util.Optional; |
| 124 | import java.util.Set; |
| 125 | import java.util.concurrent.ConcurrentHashMap; |
| 126 | import java.util.concurrent.ConcurrentLinkedQueue; |
| 127 | import java.util.concurrent.Executors; |
| 128 | import java.util.concurrent.ScheduledExecutorService; |
| 129 | import java.util.concurrent.ScheduledFuture; |
| 130 | import java.util.concurrent.TimeUnit; |
| 131 | import java.util.concurrent.atomic.AtomicBoolean; |
| 132 | import java.util.stream.Collectors; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 133 | |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 134 | import static com.google.common.base.Preconditions.checkState; |
Pier Ventre | adb4ae6 | 2016-11-23 09:57:42 -0800 | [diff] [blame] | 135 | import static org.onlab.packet.Ethernet.TYPE_ARP; |
Yuta HIGUCHI | ebee2f1 | 2016-07-21 16:54:33 -0700 | [diff] [blame] | 136 | import static org.onlab.util.Tools.groupedThreads; |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 137 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 138 | /** |
| 139 | * Segment routing manager. |
| 140 | */ |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 141 | @Service |
| 142 | @Component(immediate = true) |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 143 | public class SegmentRoutingManager implements SegmentRoutingService { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 144 | |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 145 | private static Logger log = LoggerFactory.getLogger(SegmentRoutingManager.class); |
Charles Chan | 910be6a | 2017-08-23 14:46:43 -0700 | [diff] [blame] | 146 | private static final String NOT_MASTER = "Current instance is not the master of {}. Ignore."; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 147 | |
| 148 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 149 | private ComponentConfigService compCfgService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 150 | |
| 151 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 152 | private NeighbourResolutionService neighbourResolutionService; |
| 153 | |
| 154 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 155 | CoreService coreService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 156 | |
| 157 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 158 | PacketService packetService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 159 | |
| 160 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 161 | HostService hostService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 162 | |
| 163 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 164 | HostLocationProbingService probingService; |
| 165 | |
| 166 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 167 | DeviceService deviceService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 168 | |
| 169 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 170 | DeviceAdminService deviceAdminService; |
| 171 | |
| 172 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | f3cf5b9 | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 173 | public FlowObjectiveService flowObjectiveService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 174 | |
| 175 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 176 | LinkService linkService; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 177 | |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 178 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | f3cf5b9 | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 179 | public MastershipService mastershipService; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 180 | |
| 181 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Pier Ventre | f3cf5b9 | 2016-11-09 14:17:26 -0800 | [diff] [blame] | 182 | public StorageService storageService; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 183 | |
| 184 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 185 | MulticastRouteService multicastRouteService; |
| 186 | |
| 187 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | 8316381 | 2018-01-09 13:45:07 -0800 | [diff] [blame] | 188 | public TopologyService topologyService; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 189 | |
| 190 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 191 | RouteService routeService; |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 192 | |
| 193 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 194 | public NetworkConfigRegistry cfgService; |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 195 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 196 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 197 | public InterfaceService interfaceService; |
| 198 | |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 199 | @Property(name = "activeProbing", boolValue = true, |
| 200 | label = "Enable active probing to discover dual-homed hosts.") |
| 201 | boolean activeProbing = true; |
| 202 | |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 203 | ArpHandler arpHandler = null; |
| 204 | IcmpHandler icmpHandler = null; |
| 205 | IpHandler ipHandler = null; |
| 206 | RoutingRulePopulator routingRulePopulator = null; |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 207 | ApplicationId appId; |
| 208 | DeviceConfiguration deviceConfiguration = null; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 209 | |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 210 | DefaultRoutingHandler defaultRoutingHandler = null; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 211 | private TunnelHandler tunnelHandler = null; |
| 212 | private PolicyHandler policyHandler = null; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 213 | private InternalPacketProcessor processor = null; |
| 214 | private InternalLinkListener linkListener = null; |
| 215 | private InternalDeviceListener deviceListener = null; |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 216 | private AppConfigHandler appCfgHandler = null; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 217 | XConnectHandler xConnectHandler = null; |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 218 | McastHandler mcastHandler = null; |
| 219 | HostHandler hostHandler = null; |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 220 | private RouteHandler routeHandler = null; |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 221 | LinkHandler linkHandler = null; |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 222 | private SegmentRoutingNeighbourDispatcher neighbourHandler = null; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 223 | private L2TunnelHandler l2TunnelHandler = null; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 224 | private InternalEventHandler eventHandler = new InternalEventHandler(); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 225 | private final InternalHostListener hostListener = new InternalHostListener(); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 226 | private final InternalConfigListener cfgListener = new InternalConfigListener(this); |
| 227 | private final InternalMcastListener mcastListener = new InternalMcastListener(); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 228 | private final InternalRouteEventListener routeListener = new InternalRouteEventListener(); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 229 | |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 230 | private ScheduledExecutorService executorService = Executors |
Yuta HIGUCHI | ebee2f1 | 2016-07-21 16:54:33 -0700 | [diff] [blame] | 231 | .newScheduledThreadPool(1, groupedThreads("SegmentRoutingManager", "event-%d", log)); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 232 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 233 | @SuppressWarnings("unused") |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 234 | private static ScheduledFuture<?> eventHandlerFuture = null; |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 235 | @SuppressWarnings("rawtypes") |
Yuta HIGUCHI | ebee2f1 | 2016-07-21 16:54:33 -0700 | [diff] [blame] | 236 | private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<>(); |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 237 | Map<DeviceId, DefaultGroupHandler> groupHandlerMap = |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 238 | new ConcurrentHashMap<>(); |
| 239 | /** |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 240 | * Per device next objective ID store with (device id + destination set) as key. |
Charles Chan | 53de91f | 2017-08-22 15:07:34 -0700 | [diff] [blame] | 241 | * Used to keep track on MPLS group information. |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 242 | */ |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 243 | private EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 244 | dsNextObjStore = null; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 245 | /** |
Charles Chan | 53de91f | 2017-08-22 15:07:34 -0700 | [diff] [blame] | 246 | * Per device next objective ID store with (device id + vlanid) as key. |
| 247 | * Used to keep track on L2 flood group information. |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 248 | */ |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 249 | private EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer> |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 250 | vlanNextObjStore = null; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 251 | /** |
Charles Chan | 53de91f | 2017-08-22 15:07:34 -0700 | [diff] [blame] | 252 | * Per device next objective ID store with (device id + port + treatment + meta) as key. |
| 253 | * Used to keep track on L2 interface group and L3 unicast group information. |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 254 | */ |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 255 | private EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer> |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 256 | portNextObjStore = null; |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 257 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 258 | private EventuallyConsistentMap<String, Tunnel> tunnelStore = null; |
| 259 | private EventuallyConsistentMap<String, Policy> policyStore = null; |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 260 | |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 261 | private AtomicBoolean programmingScheduled = new AtomicBoolean(); |
| 262 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 263 | private final ConfigFactory<DeviceId, SegmentRoutingDeviceConfig> deviceConfigFactory = |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 264 | new ConfigFactory<DeviceId, SegmentRoutingDeviceConfig>( |
| 265 | SubjectFactories.DEVICE_SUBJECT_FACTORY, |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 266 | SegmentRoutingDeviceConfig.class, "segmentrouting") { |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 267 | @Override |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 268 | public SegmentRoutingDeviceConfig createConfig() { |
| 269 | return new SegmentRoutingDeviceConfig(); |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 270 | } |
| 271 | }; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 272 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 273 | private final ConfigFactory<ApplicationId, SegmentRoutingAppConfig> appConfigFactory = |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 274 | new ConfigFactory<ApplicationId, SegmentRoutingAppConfig>( |
| 275 | SubjectFactories.APP_SUBJECT_FACTORY, |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 276 | SegmentRoutingAppConfig.class, "segmentrouting") { |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 277 | @Override |
| 278 | public SegmentRoutingAppConfig createConfig() { |
| 279 | return new SegmentRoutingAppConfig(); |
| 280 | } |
| 281 | }; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 282 | |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 283 | private final ConfigFactory<ApplicationId, XConnectConfig> xConnectConfigFactory = |
| 284 | new ConfigFactory<ApplicationId, XConnectConfig>( |
| 285 | SubjectFactories.APP_SUBJECT_FACTORY, |
| 286 | XConnectConfig.class, "xconnect") { |
| 287 | @Override |
| 288 | public XConnectConfig createConfig() { |
| 289 | return new XConnectConfig(); |
| 290 | } |
| 291 | }; |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 292 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 293 | private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory = |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 294 | new ConfigFactory<ApplicationId, McastConfig>( |
| 295 | SubjectFactories.APP_SUBJECT_FACTORY, |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 296 | McastConfig.class, "multicast") { |
| 297 | @Override |
| 298 | public McastConfig createConfig() { |
| 299 | return new McastConfig(); |
| 300 | } |
| 301 | }; |
| 302 | |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 303 | private final ConfigFactory<ApplicationId, PwaasConfig> pwaasConfigFactory = |
| 304 | new ConfigFactory<ApplicationId, PwaasConfig>( |
| 305 | SubjectFactories.APP_SUBJECT_FACTORY, |
| 306 | PwaasConfig.class, "pwaas") { |
| 307 | @Override |
| 308 | public PwaasConfig createConfig() { |
| 309 | return new PwaasConfig(); |
| 310 | } |
| 311 | }; |
| 312 | |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 313 | private static final Object THREAD_SCHED_LOCK = new Object(); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 314 | private static int numOfEventsQueued = 0; |
| 315 | private static int numOfEventsExecuted = 0; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 316 | private static int numOfHandlerExecution = 0; |
| 317 | private static int numOfHandlerScheduled = 0; |
| 318 | |
Charles Chan | 1963f4f | 2016-02-18 14:22:42 -0800 | [diff] [blame] | 319 | /** |
| 320 | * Segment Routing App ID. |
| 321 | */ |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 322 | public static final String APP_NAME = "org.onosproject.segmentrouting"; |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 323 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 324 | /** |
| 325 | * The default VLAN ID assigned to the interfaces without subnet config. |
| 326 | */ |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 327 | public static final VlanId INTERNAL_VLAN = VlanId.vlanId((short) 4094); |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 328 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 329 | @Activate |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 330 | protected void activate(ComponentContext context) { |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 331 | appId = coreService.registerApplication(APP_NAME); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 332 | |
| 333 | log.debug("Creating EC map nsnextobjectivestore"); |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 334 | EventuallyConsistentMapBuilder<DestinationSetNextObjectiveStoreKey, NextNeighbors> |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 335 | nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 336 | dsNextObjStore = nsNextObjMapBuilder |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 337 | .withName("nsnextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 338 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 339 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 340 | .build(); |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 341 | log.trace("Current size {}", dsNextObjStore.size()); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 342 | |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 343 | log.debug("Creating EC map vlannextobjectivestore"); |
| 344 | EventuallyConsistentMapBuilder<VlanNextObjectiveStoreKey, Integer> |
| 345 | vlanNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
| 346 | vlanNextObjStore = vlanNextObjMapBuilder |
| 347 | .withName("vlannextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 348 | .withSerializer(createSerializer()) |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 349 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 350 | .build(); |
| 351 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 352 | log.debug("Creating EC map subnetnextobjectivestore"); |
| 353 | EventuallyConsistentMapBuilder<PortNextObjectiveStoreKey, Integer> |
| 354 | portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
| 355 | portNextObjStore = portNextObjMapBuilder |
| 356 | .withName("portnextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 357 | .withSerializer(createSerializer()) |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 358 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 359 | .build(); |
| 360 | |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 361 | EventuallyConsistentMapBuilder<String, Tunnel> tunnelMapBuilder = |
| 362 | storageService.eventuallyConsistentMapBuilder(); |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 363 | tunnelStore = tunnelMapBuilder |
| 364 | .withName("tunnelstore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 365 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 366 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 367 | .build(); |
| 368 | |
| 369 | EventuallyConsistentMapBuilder<String, Policy> policyMapBuilder = |
| 370 | storageService.eventuallyConsistentMapBuilder(); |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 371 | policyStore = policyMapBuilder |
| 372 | .withName("policystore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 373 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 374 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 375 | .build(); |
| 376 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 377 | compCfgService.preSetProperty("org.onosproject.net.group.impl.GroupManager", |
Pier Luigi | b9632ba | 2017-01-12 18:14:58 -0800 | [diff] [blame] | 378 | "purgeOnDisconnection", "true"); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 379 | compCfgService.preSetProperty("org.onosproject.net.flow.impl.FlowRuleManager", |
Pier Luigi | b9632ba | 2017-01-12 18:14:58 -0800 | [diff] [blame] | 380 | "purgeOnDisconnection", "true"); |
Pier Luigi | b9632ba | 2017-01-12 18:14:58 -0800 | [diff] [blame] | 381 | compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider", |
| 382 | "requestInterceptsEnabled", "false"); |
Charles Chan | c1909e1 | 2017-08-08 15:13:37 -0700 | [diff] [blame] | 383 | compCfgService.preSetProperty("org.onosproject.net.neighbour.impl.NeighbourResolutionManager", |
Pier Luigi | bc976df | 2017-01-12 22:46:39 -0800 | [diff] [blame] | 384 | "requestInterceptsEnabled", "false"); |
Charles Chan | 9597f8d | 2017-07-24 15:56:10 -0700 | [diff] [blame] | 385 | compCfgService.preSetProperty("org.onosproject.dhcprelay.DhcpRelayManager", |
Pier Luigi | bc976df | 2017-01-12 22:46:39 -0800 | [diff] [blame] | 386 | "arpEnabled", "false"); |
Pier Luigi | 0ebeb31 | 2017-02-02 22:31:34 -0800 | [diff] [blame] | 387 | compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager", |
| 388 | "greedyLearningIpv6", "true"); |
Charles Chan | cf8ea47 | 2017-02-28 15:15:17 -0800 | [diff] [blame] | 389 | compCfgService.preSetProperty("org.onosproject.routing.cpr.ControlPlaneRedirectManager", |
| 390 | "forceUnprovision", "true"); |
Charles Chan | c7b73c7 | 2017-08-10 16:57:28 -0700 | [diff] [blame] | 391 | compCfgService.preSetProperty("org.onosproject.routeservice.store.RouteStoreImpl", |
Charles Chan | 4c95c0d | 2017-07-20 16:16:25 -0700 | [diff] [blame] | 392 | "distributed", "true"); |
Charles Chan | 804772f | 2017-08-14 11:42:11 -0700 | [diff] [blame] | 393 | compCfgService.preSetProperty("org.onosproject.provider.host.impl.HostLocationProvider", |
| 394 | "multihomingEnabled", "true"); |
Charles Chan | 0c9c19f | 2017-11-29 19:54:20 -0800 | [diff] [blame] | 395 | compCfgService.preSetProperty("org.onosproject.provider.lldp.impl.LldpLinkProvider", |
| 396 | "staleLinkAge", "15000"); |
| 397 | compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager", |
| 398 | "allowDuplicateIps", "false"); |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 399 | compCfgService.registerProperties(getClass()); |
| 400 | modified(context); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 401 | |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 402 | processor = new InternalPacketProcessor(); |
| 403 | linkListener = new InternalLinkListener(); |
| 404 | deviceListener = new InternalDeviceListener(); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 405 | appCfgHandler = new AppConfigHandler(this); |
| 406 | xConnectHandler = new XConnectHandler(this); |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 407 | mcastHandler = new McastHandler(this); |
| 408 | hostHandler = new HostHandler(this); |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 409 | linkHandler = new LinkHandler(this); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 410 | routeHandler = new RouteHandler(this); |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 411 | neighbourHandler = new SegmentRoutingNeighbourDispatcher(this); |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 412 | l2TunnelHandler = new L2TunnelHandler(this); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 413 | |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 414 | cfgService.addListener(cfgListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 415 | cfgService.registerConfigFactory(deviceConfigFactory); |
| 416 | cfgService.registerConfigFactory(appConfigFactory); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 417 | cfgService.registerConfigFactory(xConnectConfigFactory); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 418 | cfgService.registerConfigFactory(mcastConfigFactory); |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 419 | cfgService.registerConfigFactory(pwaasConfigFactory); |
Charles Chan | 6961f22 | 2018-01-04 14:26:07 -0800 | [diff] [blame] | 420 | |
| 421 | cfgListener.configureNetwork(); |
| 422 | |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 423 | hostService.addListener(hostListener); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 424 | packetService.addProcessor(processor, PacketProcessor.director(2)); |
| 425 | linkService.addListener(linkListener); |
| 426 | deviceService.addListener(deviceListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 427 | multicastRouteService.addListener(mcastListener); |
Charles Chan | fd48c22 | 2017-06-19 00:43:31 -0700 | [diff] [blame] | 428 | routeService.addListener(routeListener); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 429 | |
Andreas Pantelopoulos | 75eef06 | 2018-01-11 07:53:48 -0800 | [diff] [blame] | 430 | l2TunnelHandler.init(); |
| 431 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 432 | log.info("Started"); |
| 433 | } |
| 434 | |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 435 | KryoNamespace.Builder createSerializer() { |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 436 | return new KryoNamespace.Builder() |
| 437 | .register(KryoNamespaces.API) |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 438 | .register(DestinationSetNextObjectiveStoreKey.class, |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 439 | VlanNextObjectiveStoreKey.class, |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 440 | DestinationSet.class, |
| 441 | NextNeighbors.class, |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 442 | Tunnel.class, |
| 443 | DefaultTunnel.class, |
| 444 | Policy.class, |
| 445 | TunnelPolicy.class, |
| 446 | Policy.Type.class, |
| 447 | PortNextObjectiveStoreKey.class, |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 448 | XConnectStoreKey.class, |
| 449 | DefaultL2Tunnel.class, |
| 450 | DefaultL2TunnelPolicy.class |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 451 | ); |
| 452 | } |
| 453 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 454 | @Deactivate |
| 455 | protected void deactivate() { |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 456 | cfgService.removeListener(cfgListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 457 | cfgService.unregisterConfigFactory(deviceConfigFactory); |
| 458 | cfgService.unregisterConfigFactory(appConfigFactory); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 459 | cfgService.unregisterConfigFactory(xConnectConfigFactory); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 460 | cfgService.unregisterConfigFactory(mcastConfigFactory); |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 461 | cfgService.unregisterConfigFactory(pwaasConfigFactory); |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 462 | compCfgService.unregisterProperties(getClass(), false); |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 463 | |
Charles Chan | fd48c22 | 2017-06-19 00:43:31 -0700 | [diff] [blame] | 464 | hostService.removeListener(hostListener); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 465 | packetService.removeProcessor(processor); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 466 | linkService.removeListener(linkListener); |
| 467 | deviceService.removeListener(deviceListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 468 | multicastRouteService.removeListener(mcastListener); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 469 | routeService.removeListener(routeListener); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 470 | |
Charles Chan | 2e71ef3 | 2017-02-23 15:44:08 -0800 | [diff] [blame] | 471 | neighbourResolutionService.unregisterNeighbourHandlers(appId); |
| 472 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 473 | processor = null; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 474 | linkListener = null; |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 475 | deviceListener = null; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 476 | groupHandlerMap.clear(); |
| 477 | |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 478 | dsNextObjStore.destroy(); |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 479 | vlanNextObjStore.destroy(); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 480 | portNextObjStore.destroy(); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 481 | tunnelStore.destroy(); |
| 482 | policyStore.destroy(); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 483 | log.info("Stopped"); |
| 484 | } |
| 485 | |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 486 | @Modified |
| 487 | private void modified(ComponentContext context) { |
| 488 | Dictionary<?, ?> properties = context.getProperties(); |
| 489 | if (properties == null) { |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | String strActiveProving = Tools.get(properties, "activeProbing"); |
| 494 | boolean expectActiveProbing = Boolean.parseBoolean(strActiveProving); |
| 495 | |
| 496 | if (expectActiveProbing != activeProbing) { |
| 497 | activeProbing = expectActiveProbing; |
| 498 | log.info("{} active probing", activeProbing ? "Enabling" : "Disabling"); |
| 499 | } |
| 500 | } |
| 501 | |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 502 | @Override |
| 503 | public List<Tunnel> getTunnels() { |
| 504 | return tunnelHandler.getTunnels(); |
| 505 | } |
| 506 | |
| 507 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 508 | public TunnelHandler.Result createTunnel(Tunnel tunnel) { |
| 509 | return tunnelHandler.createTunnel(tunnel); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 513 | public TunnelHandler.Result removeTunnel(Tunnel tunnel) { |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 514 | for (Policy policy: policyHandler.getPolicies()) { |
| 515 | if (policy.type() == Policy.Type.TUNNEL_FLOW) { |
| 516 | TunnelPolicy tunnelPolicy = (TunnelPolicy) policy; |
| 517 | if (tunnelPolicy.tunnelId().equals(tunnel.id())) { |
| 518 | log.warn("Cannot remove the tunnel used by a policy"); |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 519 | return TunnelHandler.Result.TUNNEL_IN_USE; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 520 | } |
| 521 | } |
| 522 | } |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 523 | return tunnelHandler.removeTunnel(tunnel); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 527 | public PolicyHandler.Result removePolicy(Policy policy) { |
| 528 | return policyHandler.removePolicy(policy); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 532 | public PolicyHandler.Result createPolicy(Policy policy) { |
| 533 | return policyHandler.createPolicy(policy); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | @Override |
| 537 | public List<Policy> getPolicies() { |
| 538 | return policyHandler.getPolicies(); |
| 539 | } |
| 540 | |
Saurav Das | 07c7460 | 2016-04-27 18:35:50 -0700 | [diff] [blame] | 541 | @Override |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 542 | public List<DefaultL2Tunnel> getL2Tunnels() { |
| 543 | return l2TunnelHandler.getL2Tunnels(); |
| 544 | } |
| 545 | |
| 546 | @Override |
| 547 | public List<DefaultL2TunnelPolicy> getL2Policies() { |
| 548 | return l2TunnelHandler.getL2Policies(); |
| 549 | } |
| 550 | |
| 551 | @Override |
| 552 | public L2TunnelHandler.Result addPseudowire(String tunnelId, String pwLabel, String cP1, |
| 553 | String cP1InnerVlan, String cP1OuterVlan, String cP2, |
| 554 | String cP2InnerVlan, String cP2OuterVlan, |
| 555 | String mode, String sdTag) { |
Andreas Pantelopoulos | afc637f | 2017-12-20 18:04:27 -0800 | [diff] [blame] | 556 | // Try to inject an empty Pwaas config if it is not found for the first time |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 557 | PwaasConfig config = cfgService.getConfig(appId(), PwaasConfig.class); |
| 558 | if (config == null) { |
Andreas Pantelopoulos | afc637f | 2017-12-20 18:04:27 -0800 | [diff] [blame] | 559 | log.debug("Pwaas config not found. Try to create an empty one."); |
| 560 | cfgService.applyConfig(appId(), PwaasConfig.class, new ObjectMapper().createObjectNode()); |
| 561 | config = cfgService.getConfig(appId(), PwaasConfig.class); |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | ObjectNode object = config.addPseudowire(tunnelId, pwLabel, |
| 565 | cP1, cP1InnerVlan, cP1OuterVlan, |
| 566 | cP2, cP2InnerVlan, cP2OuterVlan, |
| 567 | mode, sdTag); |
| 568 | if (object == null) { |
| 569 | log.warn("Could not add pseudowire to the configuration!"); |
| 570 | return L2TunnelHandler.Result.ADDITION_ERROR; |
| 571 | } |
| 572 | |
| 573 | // inform everyone about the valid change in the pw configuration |
| 574 | cfgService.applyConfig(appId(), PwaasConfig.class, object); |
| 575 | return L2TunnelHandler.Result.SUCCESS; |
| 576 | } |
| 577 | |
| 578 | @Override |
| 579 | public L2TunnelHandler.Result removePseudowire(String pwId) { |
| 580 | |
| 581 | PwaasConfig config = cfgService.getConfig(appId(), PwaasConfig.class); |
| 582 | if (config == null) { |
| 583 | log.warn("Configuration for Pwaas class could not be found!"); |
| 584 | return L2TunnelHandler.Result.CONFIG_NOT_FOUND; |
| 585 | } |
| 586 | |
| 587 | ObjectNode object = config.removePseudowire(pwId); |
| 588 | if (object == null) { |
| 589 | log.warn("Could not delete pseudowire from configuration!"); |
| 590 | return L2TunnelHandler.Result.REMOVAL_ERROR; |
| 591 | } |
| 592 | |
| 593 | // sanity check, this should never fail since we removed a pw |
| 594 | // and we always check when we update the configuration |
| 595 | config.isValid(); |
| 596 | |
| 597 | // inform everyone |
| 598 | cfgService.applyConfig(appId(), PwaasConfig.class, object); |
| 599 | |
| 600 | return L2TunnelHandler.Result.SUCCESS; |
| 601 | } |
| 602 | |
| 603 | @Override |
Saurav Das | 07c7460 | 2016-04-27 18:35:50 -0700 | [diff] [blame] | 604 | public void rerouteNetwork() { |
| 605 | cfgListener.configureNetwork(); |
Saurav Das | 07c7460 | 2016-04-27 18:35:50 -0700 | [diff] [blame] | 606 | } |
| 607 | |
Charles Chan | d7844e5 | 2016-10-20 17:02:44 -0700 | [diff] [blame] | 608 | @Override |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 609 | public Map<DeviceId, Set<IpPrefix>> getDeviceSubnetMap() { |
| 610 | Map<DeviceId, Set<IpPrefix>> deviceSubnetMap = Maps.newHashMap(); |
Jonathan Hart | 61e24e1 | 2017-11-30 18:23:42 -0800 | [diff] [blame] | 611 | deviceConfiguration.getRouters().forEach(device -> |
| 612 | deviceSubnetMap.put(device, deviceConfiguration.getSubnets(device))); |
Charles Chan | d7844e5 | 2016-10-20 17:02:44 -0700 | [diff] [blame] | 613 | return deviceSubnetMap; |
| 614 | } |
| 615 | |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 616 | |
| 617 | @Override |
| 618 | public ImmutableMap<DeviceId, EcmpShortestPathGraph> getCurrentEcmpSpg() { |
| 619 | if (defaultRoutingHandler != null) { |
| 620 | return defaultRoutingHandler.getCurrentEmcpSpgMap(); |
| 621 | } else { |
| 622 | return null; |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | @Override |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 627 | public ImmutableMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> getDestinationSet() { |
| 628 | if (dsNextObjStore != null) { |
| 629 | return ImmutableMap.copyOf(dsNextObjStore.entrySet()); |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 630 | } else { |
| 631 | return ImmutableMap.of(); |
| 632 | } |
| 633 | } |
| 634 | |
Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 635 | @Override |
| 636 | public void verifyGroups(DeviceId id) { |
| 637 | DefaultGroupHandler gh = groupHandlerMap.get(id); |
| 638 | if (gh != null) { |
| 639 | gh.triggerBucketCorrector(); |
| 640 | } |
| 641 | } |
| 642 | |
sangho | 80f1f89 | 2015-05-19 11:57:42 -0700 | [diff] [blame] | 643 | /** |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 644 | * Extracts the application ID from the manager. |
| 645 | * |
| 646 | * @return application ID |
| 647 | */ |
| 648 | public ApplicationId appId() { |
| 649 | return appId; |
| 650 | } |
| 651 | |
| 652 | /** |
| 653 | * Returns the device configuration. |
| 654 | * |
| 655 | * @return device configuration |
| 656 | */ |
| 657 | public DeviceConfiguration deviceConfiguration() { |
| 658 | return deviceConfiguration; |
| 659 | } |
| 660 | |
| 661 | /** |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 662 | * Per device next objective ID store with (device id + destination set) as key. |
Charles Chan | 53de91f | 2017-08-22 15:07:34 -0700 | [diff] [blame] | 663 | * Used to keep track on MPLS group information. |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 664 | * |
| 665 | * @return next objective ID store |
| 666 | */ |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 667 | public EventuallyConsistentMap<DestinationSetNextObjectiveStoreKey, NextNeighbors> |
| 668 | dsNextObjStore() { |
| 669 | return dsNextObjStore; |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | /** |
Charles Chan | 53de91f | 2017-08-22 15:07:34 -0700 | [diff] [blame] | 673 | * Per device next objective ID store with (device id + vlanid) as key. |
| 674 | * Used to keep track on L2 flood group information. |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 675 | * |
| 676 | * @return vlan next object store |
| 677 | */ |
| 678 | public EventuallyConsistentMap<VlanNextObjectiveStoreKey, Integer> vlanNextObjStore() { |
| 679 | return vlanNextObjStore; |
| 680 | } |
| 681 | |
| 682 | /** |
Charles Chan | 53de91f | 2017-08-22 15:07:34 -0700 | [diff] [blame] | 683 | * Per device next objective ID store with (device id + port + treatment + meta) as key. |
| 684 | * Used to keep track on L2 interface group and L3 unicast group information. |
Ray Milkey | b85de08 | 2017-04-05 09:42:04 -0700 | [diff] [blame] | 685 | * |
| 686 | * @return port next object store. |
| 687 | */ |
| 688 | public EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer> portNextObjStore() { |
| 689 | return portNextObjStore; |
| 690 | } |
| 691 | |
| 692 | /** |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 693 | * Returns the MPLS-ECMP configuration which indicates whether ECMP on |
| 694 | * labeled packets should be programmed or not. |
Pier Ventre | 7a78de2 | 2016-10-31 15:00:01 -0700 | [diff] [blame] | 695 | * |
| 696 | * @return MPLS-ECMP value |
| 697 | */ |
| 698 | public boolean getMplsEcmp() { |
| 699 | SegmentRoutingAppConfig segmentRoutingAppConfig = cfgService |
| 700 | .getConfig(this.appId, SegmentRoutingAppConfig.class); |
| 701 | return segmentRoutingAppConfig != null && segmentRoutingAppConfig.mplsEcmp(); |
| 702 | } |
| 703 | |
| 704 | /** |
sangho | 80f1f89 | 2015-05-19 11:57:42 -0700 | [diff] [blame] | 705 | * Returns the tunnel object with the tunnel ID. |
| 706 | * |
| 707 | * @param tunnelId Tunnel ID |
| 708 | * @return Tunnel reference |
| 709 | */ |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 710 | public Tunnel getTunnel(String tunnelId) { |
| 711 | return tunnelHandler.getTunnel(tunnelId); |
| 712 | } |
| 713 | |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 714 | // TODO Consider moving these to InterfaceService |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 715 | /** |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 716 | * Returns untagged VLAN configured on given connect point. |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 717 | * <p> |
| 718 | * Only returns the first match if there are multiple untagged VLAN configured |
| 719 | * on the connect point. |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 720 | * |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 721 | * @param connectPoint connect point |
| 722 | * @return untagged VLAN or null if not configured |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 723 | */ |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 724 | VlanId getUntaggedVlanId(ConnectPoint connectPoint) { |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 725 | return interfaceService.getInterfacesByPort(connectPoint).stream() |
| 726 | .filter(intf -> !intf.vlanUntagged().equals(VlanId.NONE)) |
| 727 | .map(Interface::vlanUntagged) |
| 728 | .findFirst().orElse(null); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 729 | } |
| 730 | |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 731 | /** |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 732 | * Returns tagged VLAN configured on given connect point. |
| 733 | * <p> |
| 734 | * Returns all matches if there are multiple tagged VLAN configured |
| 735 | * on the connect point. |
| 736 | * |
| 737 | * @param connectPoint connect point |
| 738 | * @return tagged VLAN or empty set if not configured |
| 739 | */ |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 740 | Set<VlanId> getTaggedVlanId(ConnectPoint connectPoint) { |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 741 | Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint); |
| 742 | return interfaces.stream() |
| 743 | .map(Interface::vlanTagged) |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 744 | .flatMap(Set::stream) |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 745 | .collect(Collectors.toSet()); |
| 746 | } |
| 747 | |
| 748 | /** |
| 749 | * Returns native VLAN configured on given connect point. |
| 750 | * <p> |
| 751 | * Only returns the first match if there are multiple native VLAN configured |
| 752 | * on the connect point. |
| 753 | * |
| 754 | * @param connectPoint connect point |
| 755 | * @return native VLAN or null if not configured |
| 756 | */ |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 757 | VlanId getNativeVlanId(ConnectPoint connectPoint) { |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 758 | Set<Interface> interfaces = interfaceService.getInterfacesByPort(connectPoint); |
| 759 | return interfaces.stream() |
| 760 | .filter(intf -> !intf.vlanNative().equals(VlanId.NONE)) |
| 761 | .map(Interface::vlanNative) |
| 762 | .findFirst() |
| 763 | .orElse(null); |
| 764 | } |
| 765 | |
| 766 | /** |
Charles Chan | d9265a3 | 2017-06-16 15:19:24 -0700 | [diff] [blame] | 767 | * Returns internal VLAN for untagged hosts on given connect point. |
| 768 | * <p> |
| 769 | * The internal VLAN is either vlan-untagged for an access port, |
| 770 | * or vlan-native for a trunk port. |
| 771 | * |
| 772 | * @param connectPoint connect point |
| 773 | * @return internal VLAN or null if both vlan-untagged and vlan-native are undefined |
| 774 | */ |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 775 | VlanId getInternalVlanId(ConnectPoint connectPoint) { |
Charles Chan | d9265a3 | 2017-06-16 15:19:24 -0700 | [diff] [blame] | 776 | VlanId untaggedVlanId = getUntaggedVlanId(connectPoint); |
| 777 | VlanId nativeVlanId = getNativeVlanId(connectPoint); |
| 778 | return untaggedVlanId != null ? untaggedVlanId : nativeVlanId; |
| 779 | } |
| 780 | |
| 781 | /** |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 782 | * Returns optional pair device ID of given device. |
| 783 | * |
| 784 | * @param deviceId device ID |
| 785 | * @return optional pair device ID. Might be empty if pair device is not configured |
| 786 | */ |
| 787 | Optional<DeviceId> getPairDeviceId(DeviceId deviceId) { |
| 788 | SegmentRoutingDeviceConfig deviceConfig = |
| 789 | cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class); |
| 790 | return Optional.ofNullable(deviceConfig).map(SegmentRoutingDeviceConfig::pairDeviceId); |
| 791 | } |
| 792 | /** |
| 793 | * Returns optional pair device local port of given device. |
| 794 | * |
| 795 | * @param deviceId device ID |
| 796 | * @return optional pair device ID. Might be empty if pair device is not configured |
| 797 | */ |
| 798 | Optional<PortNumber> getPairLocalPorts(DeviceId deviceId) { |
| 799 | SegmentRoutingDeviceConfig deviceConfig = |
| 800 | cfgService.getConfig(deviceId, SegmentRoutingDeviceConfig.class); |
| 801 | return Optional.ofNullable(deviceConfig).map(SegmentRoutingDeviceConfig::pairLocalPort); |
| 802 | } |
| 803 | |
| 804 | /** |
Charles Chan | 910be6a | 2017-08-23 14:46:43 -0700 | [diff] [blame] | 805 | * Determine if current instance is the master of given connect point. |
| 806 | * |
| 807 | * @param cp connect point |
| 808 | * @return true if current instance is the master of given connect point |
| 809 | */ |
Andreas Pantelopoulos | 5e7be3d | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 810 | public boolean isMasterOf(ConnectPoint cp) { |
Charles Chan | 910be6a | 2017-08-23 14:46:43 -0700 | [diff] [blame] | 811 | boolean isMaster = mastershipService.isLocalMaster(cp.deviceId()); |
| 812 | if (!isMaster) { |
| 813 | log.debug(NOT_MASTER, cp); |
| 814 | } |
| 815 | return isMaster; |
| 816 | } |
| 817 | |
| 818 | /** |
Charles Chan | f0ae41e | 2017-08-23 13:55:39 -0700 | [diff] [blame] | 819 | * Returns locations of given resolved route. |
| 820 | * |
| 821 | * @param resolvedRoute resolved route |
| 822 | * @return locations of nexthop. Might be empty if next hop is not found |
| 823 | */ |
| 824 | Set<ConnectPoint> nextHopLocations(ResolvedRoute resolvedRoute) { |
| 825 | HostId hostId = HostId.hostId(resolvedRoute.nextHopMac(), resolvedRoute.nextHopVlan()); |
| 826 | return Optional.ofNullable(hostService.getHost(hostId)) |
| 827 | .map(Host::locations).orElse(Sets.newHashSet()) |
| 828 | .stream().map(l -> (ConnectPoint) l).collect(Collectors.toSet()); |
| 829 | } |
| 830 | |
| 831 | /** |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 832 | * Returns vlan port map of given device. |
| 833 | * |
| 834 | * @param deviceId device id |
| 835 | * @return vlan-port multimap |
| 836 | */ |
| 837 | public Multimap<VlanId, PortNumber> getVlanPortMap(DeviceId deviceId) { |
| 838 | HashMultimap<VlanId, PortNumber> vlanPortMap = HashMultimap.create(); |
| 839 | |
| 840 | interfaceService.getInterfaces().stream() |
| 841 | .filter(intf -> intf.connectPoint().deviceId().equals(deviceId)) |
| 842 | .forEach(intf -> { |
| 843 | vlanPortMap.put(intf.vlanUntagged(), intf.connectPoint().port()); |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 844 | intf.vlanTagged().forEach(vlanTagged -> |
| 845 | vlanPortMap.put(vlanTagged, intf.connectPoint().port()) |
| 846 | ); |
Charles Chan | 90772a7 | 2017-02-08 15:52:08 -0800 | [diff] [blame] | 847 | vlanPortMap.put(intf.vlanNative(), intf.connectPoint().port()); |
| 848 | }); |
| 849 | vlanPortMap.removeAll(VlanId.NONE); |
| 850 | |
| 851 | return vlanPortMap; |
| 852 | } |
| 853 | |
| 854 | /** |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 855 | * 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] | 856 | * that the next-objective has been pre-created from configuration. |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 857 | * |
| 858 | * @param deviceId Device ID |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 859 | * @param vlanId VLAN ID |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 860 | * @return next objective ID or -1 if it was not found |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 861 | */ |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 862 | int getVlanNextObjectiveId(DeviceId deviceId, VlanId vlanId) { |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 863 | if (groupHandlerMap.get(deviceId) != null) { |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 864 | log.trace("getVlanNextObjectiveId query in device {}", deviceId); |
| 865 | return groupHandlerMap.get(deviceId).getVlanNextObjectiveId(vlanId); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 866 | } else { |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 867 | log.warn("getVlanNextObjectiveId query - groupHandler for " |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 868 | + "device {} not found", deviceId); |
| 869 | return -1; |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | /** |
| 874 | * Returns the next objective ID for the given portNumber, given the treatment. |
| 875 | * There could be multiple different treatments to the same outport, which |
Saurav Das | 2cb3829 | 2017-03-29 19:09:17 -0700 | [diff] [blame] | 876 | * would result in different objectives. If the next object does not exist, |
| 877 | * 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] | 878 | * |
| 879 | * @param deviceId Device ID |
| 880 | * @param portNum port number on device for which NextObjective is queried |
| 881 | * @param treatment the actions to apply on the packets (should include outport) |
| 882 | * @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] | 883 | * @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] | 884 | * @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] | 885 | */ |
| 886 | public int getPortNextObjectiveId(DeviceId deviceId, PortNumber portNum, |
| 887 | TrafficTreatment treatment, |
Saurav Das | 2cb3829 | 2017-03-29 19:09:17 -0700 | [diff] [blame] | 888 | TrafficSelector meta, |
| 889 | boolean createIfMissing) { |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 890 | DefaultGroupHandler ghdlr = groupHandlerMap.get(deviceId); |
| 891 | if (ghdlr != null) { |
Saurav Das | 2cb3829 | 2017-03-29 19:09:17 -0700 | [diff] [blame] | 892 | return ghdlr.getPortNextObjectiveId(portNum, treatment, meta, createIfMissing); |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 893 | } else { |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 894 | log.warn("getPortNextObjectiveId query - groupHandler for device {}" |
| 895 | + " not found", deviceId); |
| 896 | return -1; |
| 897 | } |
| 898 | } |
| 899 | |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 900 | /** |
| 901 | * Returns the group handler object for the specified device id. |
| 902 | * |
| 903 | * @param devId the device identifier |
| 904 | * @return the groupHandler object for the device id, or null if not found |
| 905 | */ |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 906 | DefaultGroupHandler getGroupHandler(DeviceId devId) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 907 | return groupHandlerMap.get(devId); |
| 908 | } |
| 909 | |
| 910 | /** |
Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 911 | * Returns the default routing handler object. |
| 912 | * |
| 913 | * @return the default routing handler object |
| 914 | */ |
| 915 | public DefaultRoutingHandler getRoutingHandler() { |
| 916 | return defaultRoutingHandler; |
| 917 | } |
| 918 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 919 | private class InternalPacketProcessor implements PacketProcessor { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 920 | @Override |
| 921 | public void process(PacketContext context) { |
| 922 | |
| 923 | if (context.isHandled()) { |
| 924 | return; |
| 925 | } |
| 926 | |
| 927 | InboundPacket pkt = context.inPacket(); |
| 928 | Ethernet ethernet = pkt.parsed(); |
Pier Luigi | 37a3543 | 2017-02-01 13:50:04 -0800 | [diff] [blame] | 929 | |
| 930 | if (ethernet == null) { |
| 931 | return; |
| 932 | } |
| 933 | |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 934 | log.trace("Rcvd pktin from {}: {}", context.inPacket().receivedFrom(), |
| 935 | ethernet); |
Pier Ventre | adb4ae6 | 2016-11-23 09:57:42 -0800 | [diff] [blame] | 936 | if (ethernet.getEtherType() == TYPE_ARP) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 937 | log.warn("Received unexpected ARP packet on {}", |
| 938 | context.inPacket().receivedFrom()); |
Saurav Das | 368cf21 | 2017-03-15 15:15:14 -0700 | [diff] [blame] | 939 | log.trace("{}", ethernet); |
Pier Ventre | 6b2c1b3 | 2016-12-09 17:26:04 -0800 | [diff] [blame] | 940 | return; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 941 | } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) { |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 942 | IPv4 ipv4Packet = (IPv4) ethernet.getPayload(); |
| 943 | //ipHandler.addToPacketBuffer(ipv4Packet); |
| 944 | if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_ICMP) { |
| 945 | icmpHandler.processIcmp(ethernet, pkt.receivedFrom()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 946 | } else { |
Charles Chan | d041ad8 | 2017-01-13 17:20:44 -0800 | [diff] [blame] | 947 | // NOTE: We don't support IP learning at this moment so this |
| 948 | // is not necessary. Also it causes duplication of DHCP packets. |
Pier Ventre | 6b2c1b3 | 2016-12-09 17:26:04 -0800 | [diff] [blame] | 949 | // ipHandler.processPacketIn(ipv4Packet, pkt.receivedFrom()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 950 | } |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 951 | } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV6) { |
| 952 | IPv6 ipv6Packet = (IPv6) ethernet.getPayload(); |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 953 | //ipHandler.addToPacketBuffer(ipv6Packet); |
Pier Luigi | 37a3543 | 2017-02-01 13:50:04 -0800 | [diff] [blame] | 954 | // 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] | 955 | if (ipv6Packet.getNextHeader() == IPv6.PROTOCOL_ICMP6) { |
| 956 | ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload(); |
| 957 | if (icmp6Packet.getIcmpType() == ICMP6.ECHO_REQUEST || |
| 958 | icmp6Packet.getIcmpType() == ICMP6.ECHO_REPLY) { |
| 959 | icmpHandler.processIcmpv6(ethernet, pkt.receivedFrom()); |
| 960 | } else { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 961 | log.trace("Received ICMPv6 0x{} - not handled", |
Charles Chan | d3727b7 | 2017-03-13 13:10:30 -0700 | [diff] [blame] | 962 | Integer.toHexString(icmp6Packet.getIcmpType() & 0xff)); |
Pier Ventre | b6b81d5 | 2016-12-02 08:16:05 -0800 | [diff] [blame] | 963 | } |
| 964 | } else { |
| 965 | // NOTE: We don't support IP learning at this moment so this |
| 966 | // is not necessary. Also it causes duplication of DHCPv6 packets. |
| 967 | // ipHandler.processPacketIn(ipv6Packet, pkt.receivedFrom()); |
| 968 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 969 | } |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | private class InternalLinkListener implements LinkListener { |
| 974 | @Override |
| 975 | public void event(LinkEvent event) { |
Charles Chan | 0cff8aa | 2017-03-29 16:39:05 -0700 | [diff] [blame] | 976 | if (event.type() == LinkEvent.Type.LINK_ADDED || |
| 977 | event.type() == LinkEvent.Type.LINK_UPDATED || |
| 978 | event.type() == LinkEvent.Type.LINK_REMOVED) { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 979 | log.debug("Event {} received from Link Service", event.type()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 980 | scheduleEventHandlerIfNotScheduled(event); |
| 981 | } |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | private class InternalDeviceListener implements DeviceListener { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 986 | @Override |
| 987 | public void event(DeviceEvent event) { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 988 | switch (event.type()) { |
| 989 | case DEVICE_ADDED: |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 990 | case PORT_UPDATED: |
| 991 | case PORT_ADDED: |
sangho | fb7c729 | 2015-04-13 15:15:58 -0700 | [diff] [blame] | 992 | case DEVICE_UPDATED: |
| 993 | case DEVICE_AVAILABILITY_CHANGED: |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 994 | log.trace("Event {} received from Device Service", event.type()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 995 | scheduleEventHandlerIfNotScheduled(event); |
| 996 | break; |
| 997 | default: |
| 998 | } |
| 999 | } |
| 1000 | } |
| 1001 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 1002 | @SuppressWarnings("rawtypes") |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1003 | private void scheduleEventHandlerIfNotScheduled(Event event) { |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 1004 | synchronized (THREAD_SCHED_LOCK) { |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1005 | eventQueue.add(event); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1006 | numOfEventsQueued++; |
| 1007 | |
| 1008 | if ((numOfHandlerScheduled - numOfHandlerExecution) == 0) { |
| 1009 | //No pending scheduled event handling threads. So start a new one. |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1010 | eventHandlerFuture = executorService |
| 1011 | .schedule(eventHandler, 100, TimeUnit.MILLISECONDS); |
| 1012 | numOfHandlerScheduled++; |
| 1013 | } |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame] | 1014 | log.trace("numOfEventsQueued {}, numOfEventHandlerScheduled {}", |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1015 | numOfEventsQueued, |
| 1016 | numOfHandlerScheduled); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1017 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1018 | } |
| 1019 | |
| 1020 | private class InternalEventHandler implements Runnable { |
Srikanth Vavilapalli | 37a461b | 2015-04-07 15:12:32 -0700 | [diff] [blame] | 1021 | @Override |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1022 | public void run() { |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1023 | try { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1024 | while (true) { |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 1025 | @SuppressWarnings("rawtypes") |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 1026 | Event event; |
| 1027 | synchronized (THREAD_SCHED_LOCK) { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1028 | if (!eventQueue.isEmpty()) { |
| 1029 | event = eventQueue.poll(); |
| 1030 | numOfEventsExecuted++; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1031 | } else { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1032 | numOfHandlerExecution++; |
| 1033 | log.debug("numOfHandlerExecution {} numOfEventsExecuted {}", |
| 1034 | numOfHandlerExecution, numOfEventsExecuted); |
| 1035 | break; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1036 | } |
sangho | fb7c729 | 2015-04-13 15:15:58 -0700 | [diff] [blame] | 1037 | } |
Charles Chan | 0cff8aa | 2017-03-29 16:39:05 -0700 | [diff] [blame] | 1038 | if (event.type() == LinkEvent.Type.LINK_ADDED || |
| 1039 | event.type() == LinkEvent.Type.LINK_UPDATED) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1040 | // Note: do not update seenLinks here, otherwise every |
| 1041 | // link, even one seen for the first time, will be appear |
| 1042 | // to be a previously seen link |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 1043 | linkHandler.processLinkAdded((Link) event.subject()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1044 | } else if (event.type() == LinkEvent.Type.LINK_REMOVED) { |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 1045 | linkHandler.processLinkRemoved((Link) event.subject()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1046 | } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED || |
| 1047 | event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED || |
| 1048 | event.type() == DeviceEvent.Type.DEVICE_UPDATED) { |
Saurav Das | 62af880 | 2015-12-04 10:52:59 -0800 | [diff] [blame] | 1049 | DeviceId deviceId = ((Device) event.subject()).id(); |
| 1050 | if (deviceService.isAvailable(deviceId)) { |
Saurav Das | c28b343 | 2015-10-30 17:45:38 -0700 | [diff] [blame] | 1051 | log.info("Processing device event {} for available device {}", |
| 1052 | event.type(), ((Device) event.subject()).id()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1053 | processDeviceAdded((Device) event.subject()); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1054 | } else { |
| 1055 | log.info("Processing device event {} for unavailable device {}", |
| 1056 | event.type(), ((Device) event.subject()).id()); |
| 1057 | processDeviceRemoved((Device) event.subject()); |
| 1058 | } |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1059 | } else if (event.type() == DeviceEvent.Type.PORT_ADDED) { |
Saurav Das | d1872b0 | 2016-12-02 15:43:47 -0800 | [diff] [blame] | 1060 | // typically these calls come when device is added first time |
| 1061 | // so port filtering rules are handled at the device_added event. |
| 1062 | // port added calls represent all ports on the device, |
| 1063 | // enabled or not. |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1064 | log.trace("** PORT ADDED {}/{} -> {}", |
Saurav Das | d1872b0 | 2016-12-02 15:43:47 -0800 | [diff] [blame] | 1065 | ((DeviceEvent) event).subject().id(), |
| 1066 | ((DeviceEvent) event).port().number(), |
| 1067 | event.type()); |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1068 | } else if (event.type() == DeviceEvent.Type.PORT_UPDATED) { |
Saurav Das | d1872b0 | 2016-12-02 15:43:47 -0800 | [diff] [blame] | 1069 | // these calls happen for every subsequent event |
| 1070 | // ports enabled, disabled, switch goes away, comes back |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1071 | log.info("** PORT UPDATED {}/{} -> {}", |
| 1072 | event.subject(), |
| 1073 | ((DeviceEvent) event).port(), |
| 1074 | event.type()); |
| 1075 | processPortUpdated(((Device) event.subject()), |
| 1076 | ((DeviceEvent) event).port()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 1077 | } else { |
| 1078 | log.warn("Unhandled event type: {}", event.type()); |
| 1079 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1080 | } |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1081 | } catch (Exception e) { |
| 1082 | log.error("SegmentRouting event handler " |
| 1083 | + "thread thrown an exception: {}", e); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1084 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1085 | } |
| 1086 | } |
| 1087 | |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 1088 | void processDeviceAdded(Device device) { |
Saurav Das | b149be1 | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 1089 | log.info("** DEVICE ADDED with ID {}", device.id()); |
Charles Chan | 9bd6aea | 2017-06-27 18:48:32 -0700 | [diff] [blame] | 1090 | |
| 1091 | // NOTE: Punt ARP/NDP even when the device is not configured. |
| 1092 | // Host learning without network config is required for CORD config generator. |
| 1093 | routingRulePopulator.populateIpPunts(device.id()); |
| 1094 | routingRulePopulator.populateArpNdpPunts(device.id()); |
| 1095 | |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 1096 | if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) { |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 1097 | log.warn("Device configuration unavailable. Device {} will be " |
| 1098 | + "processed after configuration.", device.id()); |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 1099 | return; |
| 1100 | } |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1101 | processDeviceAddedInternal(device.id()); |
| 1102 | } |
| 1103 | |
| 1104 | private void processDeviceAddedInternal(DeviceId deviceId) { |
Saurav Das | c28b343 | 2015-10-30 17:45:38 -0700 | [diff] [blame] | 1105 | // Irrespective of whether the local is a MASTER or not for this device, |
| 1106 | // we need to create a SR-group-handler instance. This is because in a |
| 1107 | // multi-instance setup, any instance can initiate forwarding/next-objectives |
| 1108 | // for any switch (even if this instance is a SLAVE or not even connected |
| 1109 | // to the switch). To handle this, a default-group-handler instance is necessary |
| 1110 | // per switch. |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1111 | log.debug("Current groupHandlerMap devs: {}", groupHandlerMap.keySet()); |
| 1112 | if (groupHandlerMap.get(deviceId) == null) { |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 1113 | DefaultGroupHandler groupHandler; |
| 1114 | try { |
| 1115 | groupHandler = DefaultGroupHandler. |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1116 | createGroupHandler(deviceId, |
| 1117 | appId, |
| 1118 | deviceConfiguration, |
| 1119 | linkService, |
| 1120 | flowObjectiveService, |
| 1121 | this); |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 1122 | } catch (DeviceConfigNotFoundException e) { |
| 1123 | log.warn(e.getMessage() + " Aborting processDeviceAdded."); |
| 1124 | return; |
| 1125 | } |
Saurav Das | 2b6a00f | 2017-12-05 15:00:23 -0800 | [diff] [blame] | 1126 | log.debug("updating groupHandlerMap with new grpHdlr for device: {}", |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1127 | deviceId); |
| 1128 | groupHandlerMap.put(deviceId, groupHandler); |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 1129 | } |
Saurav Das | b149be1 | 2016-06-07 10:08:06 -0700 | [diff] [blame] | 1130 | |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1131 | if (mastershipService.isLocalMaster(deviceId)) { |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 1132 | defaultRoutingHandler.populatePortAddressingRules(deviceId); |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1133 | hostHandler.init(deviceId); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1134 | xConnectHandler.init(deviceId); |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1135 | DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId); |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1136 | groupHandler.createGroupsFromVlanConfig(); |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1137 | routingRulePopulator.populateSubnetBroadcastRule(deviceId); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 1138 | } |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1139 | |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1140 | appCfgHandler.init(deviceId); |
| 1141 | routeHandler.init(deviceId); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1142 | } |
| 1143 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1144 | private void processDeviceRemoved(Device device) { |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 1145 | dsNextObjStore.entrySet().stream() |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1146 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 1147 | .forEach(entry -> dsNextObjStore.remove(entry.getKey())); |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1148 | vlanNextObjStore.entrySet().stream() |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1149 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 1150 | .forEach(entry -> vlanNextObjStore.remove(entry.getKey())); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1151 | portNextObjStore.entrySet().stream() |
| 1152 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 1153 | .forEach(entry -> portNextObjStore.remove(entry.getKey())); |
Saurav Das | e6c448a | 2018-01-18 12:07:33 -0800 | [diff] [blame] | 1154 | linkHandler.processDeviceRemoved(device); |
Charles Chan | 17d75d8 | 2017-06-15 00:44:51 -0700 | [diff] [blame] | 1155 | |
Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 1156 | DefaultGroupHandler gh = groupHandlerMap.remove(device.id()); |
| 1157 | if (gh != null) { |
| 1158 | gh.shutdown(); |
| 1159 | } |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1160 | defaultRoutingHandler.purgeEcmpGraph(device.id()); |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1161 | // Note that a switch going down is associated with all of its links |
| 1162 | // going down as well, but it is treated as a single switch down event |
| 1163 | // while the link-downs are ignored. |
| 1164 | defaultRoutingHandler |
| 1165 | .populateRoutingRulesForLinkStatusChange(null, null, device.id()); |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1166 | mcastHandler.removeDevice(device.id()); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1167 | xConnectHandler.removeDevice(device.id()); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 1168 | } |
| 1169 | |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1170 | private void processPortUpdated(Device device, Port port) { |
| 1171 | if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) { |
| 1172 | log.warn("Device configuration uploading. Not handling port event for" |
| 1173 | + "dev: {} port: {}", device.id(), port.number()); |
| 1174 | return; |
| 1175 | } |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 1176 | |
| 1177 | if (!mastershipService.isLocalMaster(device.id())) { |
| 1178 | log.debug("Not master for dev:{} .. not handling port updated event" |
| 1179 | + "for port {}", device.id(), port.number()); |
| 1180 | return; |
| 1181 | } |
| 1182 | |
| 1183 | // first we handle filtering rules associated with the port |
| 1184 | if (port.isEnabled()) { |
| 1185 | log.info("Switchport {}/{} enabled..programming filters", |
| 1186 | device.id(), port.number()); |
Charles Chan | 43be46b | 2017-02-26 22:59:35 -0800 | [diff] [blame] | 1187 | routingRulePopulator.processSinglePortFilters(device.id(), port.number(), true); |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 1188 | } else { |
| 1189 | log.info("Switchport {}/{} disabled..removing filters", |
| 1190 | device.id(), port.number()); |
Charles Chan | 43be46b | 2017-02-26 22:59:35 -0800 | [diff] [blame] | 1191 | routingRulePopulator.processSinglePortFilters(device.id(), port.number(), false); |
Saurav Das | f933219 | 2017-02-18 14:05:44 -0800 | [diff] [blame] | 1192 | } |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1193 | |
| 1194 | // portUpdated calls are for ports that have gone down or up. For switch |
| 1195 | // to switch ports, link-events should take care of any re-routing or |
| 1196 | // group editing necessary for port up/down. Here we only process edge ports |
| 1197 | // that are already configured. |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1198 | ConnectPoint cp = new ConnectPoint(device.id(), port.number()); |
| 1199 | VlanId untaggedVlan = getUntaggedVlanId(cp); |
| 1200 | VlanId nativeVlan = getNativeVlanId(cp); |
| 1201 | Set<VlanId> taggedVlans = getTaggedVlanId(cp); |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1202 | |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1203 | if (untaggedVlan == null && nativeVlan == null && taggedVlans.isEmpty()) { |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1204 | log.debug("Not handling port updated event for non-edge port (unconfigured) " |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1205 | + "dev/port: {}/{}", device.id(), port.number()); |
| 1206 | return; |
| 1207 | } |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1208 | if (untaggedVlan != null) { |
| 1209 | processEdgePort(device, port, untaggedVlan, true); |
| 1210 | } |
| 1211 | if (nativeVlan != null) { |
| 1212 | processEdgePort(device, port, nativeVlan, true); |
| 1213 | } |
| 1214 | if (!taggedVlans.isEmpty()) { |
| 1215 | taggedVlans.forEach(tag -> processEdgePort(device, port, tag, false)); |
| 1216 | } |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1217 | } |
| 1218 | |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1219 | private void processEdgePort(Device device, Port port, VlanId vlanId, |
| 1220 | boolean popVlan) { |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1221 | boolean portUp = port.isEnabled(); |
| 1222 | if (portUp) { |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1223 | log.info("Device:EdgePort {}:{} is enabled in vlan: {}", device.id(), |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1224 | port.number(), vlanId); |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 1225 | hostHandler.processPortUp(new ConnectPoint(device.id(), port.number())); |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1226 | } else { |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1227 | log.info("Device:EdgePort {}:{} is disabled in vlan: {}", device.id(), |
Charles Chan | 10b0fb7 | 2017-02-02 16:20:42 -0800 | [diff] [blame] | 1228 | port.number(), vlanId); |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1229 | } |
| 1230 | |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 1231 | DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1232 | if (groupHandler != null) { |
Saurav Das | 3fb2827 | 2017-03-04 16:08:47 -0800 | [diff] [blame] | 1233 | groupHandler.processEdgePort(port.number(), vlanId, popVlan, portUp); |
Saurav Das | f0f592d | 2016-11-18 15:21:57 -0800 | [diff] [blame] | 1234 | } else { |
| 1235 | log.warn("Group handler not found for dev:{}. Not handling edge port" |
| 1236 | + " {} event for port:{}", device.id(), |
| 1237 | (portUp) ? "UP" : "DOWN", port.number()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1238 | } |
| 1239 | } |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 1240 | |
Charles Chan | 8ca5a12 | 2017-10-20 16:06:55 -0700 | [diff] [blame] | 1241 | private void createOrUpdateDeviceConfiguration() { |
| 1242 | if (deviceConfiguration == null) { |
| 1243 | deviceConfiguration = new DeviceConfiguration(this); |
| 1244 | } else { |
| 1245 | deviceConfiguration.updateConfig(); |
| 1246 | } |
| 1247 | } |
| 1248 | |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 1249 | /** |
| 1250 | * Registers the given connect point with the NRS, this is necessary |
| 1251 | * to receive the NDP and ARP packets from the NRS. |
| 1252 | * |
| 1253 | * @param portToRegister connect point to register |
| 1254 | */ |
| 1255 | public void registerConnectPoint(ConnectPoint portToRegister) { |
Charles Chan | 2e71ef3 | 2017-02-23 15:44:08 -0800 | [diff] [blame] | 1256 | neighbourResolutionService.registerNeighbourHandler( |
Pier Ventre | b6a7f34 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 1257 | portToRegister, |
| 1258 | neighbourHandler, |
| 1259 | appId |
| 1260 | ); |
| 1261 | } |
| 1262 | |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 1263 | private class InternalConfigListener implements NetworkConfigListener { |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 1264 | private static final long PROGRAM_DELAY = 2; |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1265 | SegmentRoutingManager srManager; |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1266 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 1267 | /** |
| 1268 | * Constructs the internal network config listener. |
| 1269 | * |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1270 | * @param srManager segment routing manager |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 1271 | */ |
Charles Chan | 3ed34d8 | 2017-06-22 18:03:14 -0700 | [diff] [blame] | 1272 | InternalConfigListener(SegmentRoutingManager srManager) { |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1273 | this.srManager = srManager; |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1274 | } |
| 1275 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 1276 | /** |
| 1277 | * Reads network config and initializes related data structure accordingly. |
| 1278 | */ |
Charles Chan | 873661e | 2017-11-30 15:37:50 -0800 | [diff] [blame] | 1279 | void configureNetwork() { |
Charles Chan | 8ca5a12 | 2017-10-20 16:06:55 -0700 | [diff] [blame] | 1280 | createOrUpdateDeviceConfiguration(); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1281 | |
Charles Chan | 46fdfaf | 2016-11-09 20:51:44 -0800 | [diff] [blame] | 1282 | arpHandler = new ArpHandler(srManager); |
| 1283 | icmpHandler = new IcmpHandler(srManager); |
| 1284 | ipHandler = new IpHandler(srManager); |
| 1285 | routingRulePopulator = new RoutingRulePopulator(srManager); |
| 1286 | defaultRoutingHandler = new DefaultRoutingHandler(srManager); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1287 | |
| 1288 | tunnelHandler = new TunnelHandler(linkService, deviceConfiguration, |
| 1289 | groupHandlerMap, tunnelStore); |
| 1290 | policyHandler = new PolicyHandler(appId, deviceConfiguration, |
| 1291 | flowObjectiveService, |
| 1292 | tunnelHandler, policyStore); |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 1293 | // add a small delay to absorb multiple network config added notifications |
| 1294 | if (!programmingScheduled.get()) { |
| 1295 | programmingScheduled.set(true); |
| 1296 | executorService.schedule(new ConfigChange(), PROGRAM_DELAY, |
| 1297 | TimeUnit.SECONDS); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1298 | } |
Charles Chan | 7277950 | 2016-04-23 17:36:10 -0700 | [diff] [blame] | 1299 | mcastHandler.init(); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 1300 | } |
| 1301 | |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 1302 | @Override |
| 1303 | public void event(NetworkConfigEvent event) { |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1304 | // TODO move this part to NetworkConfigEventHandler |
| 1305 | if (event.configClass().equals(SegmentRoutingDeviceConfig.class)) { |
| 1306 | switch (event.type()) { |
| 1307 | case CONFIG_ADDED: |
Charles Chan | 68363b1 | 2017-06-26 15:25:09 -0700 | [diff] [blame] | 1308 | log.info("Segment Routing Device Config added for {}", event.subject()); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1309 | configureNetwork(); |
| 1310 | break; |
| 1311 | case CONFIG_UPDATED: |
Charles Chan | 68363b1 | 2017-06-26 15:25:09 -0700 | [diff] [blame] | 1312 | log.info("Segment Routing Config updated for {}", event.subject()); |
Charles Chan | 8ca5a12 | 2017-10-20 16:06:55 -0700 | [diff] [blame] | 1313 | createOrUpdateDeviceConfiguration(); |
Charles Chan | 68363b1 | 2017-06-26 15:25:09 -0700 | [diff] [blame] | 1314 | // TODO support dynamic configuration |
| 1315 | break; |
| 1316 | default: |
| 1317 | break; |
| 1318 | } |
| 1319 | } else if (event.configClass().equals(InterfaceConfig.class)) { |
| 1320 | switch (event.type()) { |
| 1321 | case CONFIG_ADDED: |
| 1322 | log.info("Interface Config added for {}", event.subject()); |
| 1323 | configureNetwork(); |
| 1324 | break; |
| 1325 | case CONFIG_UPDATED: |
| 1326 | log.info("Interface Config updated for {}", event.subject()); |
Charles Chan | 8ca5a12 | 2017-10-20 16:06:55 -0700 | [diff] [blame] | 1327 | createOrUpdateDeviceConfiguration(); |
Jonghwan Hyun | e5ef762 | 2017-08-25 17:48:36 -0700 | [diff] [blame] | 1328 | |
| 1329 | // Following code will be uncommented when [CORD-634] is fully implemented. |
| 1330 | // [CORD-634] Add dynamic config support for interfaces |
| 1331 | updateInterface((InterfaceConfig) event.config().get(), |
| 1332 | (InterfaceConfig) event.prevConfig().get()); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1333 | // TODO support dynamic configuration |
| 1334 | break; |
| 1335 | default: |
| 1336 | break; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 1337 | } |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1338 | } else if (event.configClass().equals(SegmentRoutingAppConfig.class)) { |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1339 | checkState(appCfgHandler != null, "NetworkConfigEventHandler is not initialized"); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1340 | switch (event.type()) { |
| 1341 | case CONFIG_ADDED: |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1342 | appCfgHandler.processAppConfigAdded(event); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1343 | break; |
| 1344 | case CONFIG_UPDATED: |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1345 | appCfgHandler.processAppConfigUpdated(event); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1346 | break; |
| 1347 | case CONFIG_REMOVED: |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1348 | appCfgHandler.processAppConfigRemoved(event); |
| 1349 | break; |
| 1350 | default: |
| 1351 | break; |
| 1352 | } |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1353 | configureNetwork(); |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 1354 | } else if (event.configClass().equals(XConnectConfig.class)) { |
| 1355 | checkState(xConnectHandler != null, "XConnectHandler is not initialized"); |
| 1356 | switch (event.type()) { |
| 1357 | case CONFIG_ADDED: |
| 1358 | xConnectHandler.processXConnectConfigAdded(event); |
| 1359 | break; |
| 1360 | case CONFIG_UPDATED: |
| 1361 | xConnectHandler.processXConnectConfigUpdated(event); |
| 1362 | break; |
| 1363 | case CONFIG_REMOVED: |
| 1364 | xConnectHandler.processXConnectConfigRemoved(event); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 1365 | break; |
| 1366 | default: |
| 1367 | break; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 1368 | } |
Pier Ventre | 6b19e48 | 2016-11-07 16:21:04 -0800 | [diff] [blame] | 1369 | } else if (event.configClass().equals(PwaasConfig.class)) { |
| 1370 | checkState(l2TunnelHandler != null, "L2TunnelHandler is not initialized"); |
| 1371 | switch (event.type()) { |
| 1372 | case CONFIG_ADDED: |
| 1373 | l2TunnelHandler.processPwaasConfigAdded(event); |
| 1374 | break; |
| 1375 | case CONFIG_UPDATED: |
| 1376 | l2TunnelHandler.processPwaasConfigUpdated(event); |
| 1377 | break; |
| 1378 | case CONFIG_REMOVED: |
| 1379 | l2TunnelHandler.processPwaasConfigRemoved(event); |
| 1380 | break; |
| 1381 | default: |
| 1382 | break; |
| 1383 | } |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 1384 | } |
| 1385 | } |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 1386 | |
Charles Chan | c4a68c3 | 2018-01-03 16:26:32 -0800 | [diff] [blame] | 1387 | @Override |
| 1388 | public boolean isRelevant(NetworkConfigEvent event) { |
| 1389 | if (event.configClass().equals(SegmentRoutingDeviceConfig.class) || |
| 1390 | event.configClass().equals(SegmentRoutingAppConfig.class) || |
| 1391 | event.configClass().equals(InterfaceConfig.class) || |
| 1392 | event.configClass().equals(XConnectConfig.class) || |
| 1393 | event.configClass().equals(PwaasConfig.class)) { |
| 1394 | return true; |
| 1395 | } |
| 1396 | log.debug("Ignore irrelevant event class {}", event.configClass().getName()); |
| 1397 | return false; |
| 1398 | } |
| 1399 | |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 1400 | private final class ConfigChange implements Runnable { |
| 1401 | @Override |
| 1402 | public void run() { |
| 1403 | programmingScheduled.set(false); |
| 1404 | for (Device device : deviceService.getDevices()) { |
| 1405 | processDeviceAdded(device); |
| 1406 | } |
| 1407 | defaultRoutingHandler.startPopulationProcess(); |
| 1408 | } |
| 1409 | } |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 1410 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1411 | |
| 1412 | private class InternalHostListener implements HostListener { |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1413 | @Override |
| 1414 | public void event(HostEvent event) { |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1415 | switch (event.type()) { |
| 1416 | case HOST_ADDED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1417 | hostHandler.processHostAddedEvent(event); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1418 | break; |
| 1419 | case HOST_MOVED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1420 | hostHandler.processHostMovedEvent(event); |
Charles Chan | 910be6a | 2017-08-23 14:46:43 -0700 | [diff] [blame] | 1421 | routeHandler.processHostMovedEvent(event); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1422 | break; |
| 1423 | case HOST_REMOVED: |
Charles Chan | d9265a3 | 2017-06-16 15:19:24 -0700 | [diff] [blame] | 1424 | hostHandler.processHostRemovedEvent(event); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1425 | break; |
| 1426 | case HOST_UPDATED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1427 | hostHandler.processHostUpdatedEvent(event); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1428 | break; |
| 1429 | default: |
| 1430 | log.warn("Unsupported host event type: {}", event.type()); |
| 1431 | break; |
| 1432 | } |
| 1433 | } |
| 1434 | } |
| 1435 | |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 1436 | private class InternalMcastListener implements McastListener { |
| 1437 | @Override |
| 1438 | public void event(McastEvent event) { |
| 1439 | switch (event.type()) { |
| 1440 | case SOURCE_ADDED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1441 | mcastHandler.processSourceAdded(event); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 1442 | break; |
| 1443 | case SINK_ADDED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1444 | mcastHandler.processSinkAdded(event); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 1445 | break; |
| 1446 | case SINK_REMOVED: |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 1447 | mcastHandler.processSinkRemoved(event); |
Charles Chan | c91c878 | 2016-03-30 17:54:24 -0700 | [diff] [blame] | 1448 | break; |
| 1449 | case ROUTE_ADDED: |
| 1450 | case ROUTE_REMOVED: |
| 1451 | default: |
| 1452 | break; |
| 1453 | } |
| 1454 | } |
| 1455 | } |
Charles Chan | 41f5ec0 | 2016-06-13 18:54:31 -0700 | [diff] [blame] | 1456 | |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1457 | private class InternalRouteEventListener implements RouteListener { |
| 1458 | @Override |
| 1459 | public void event(RouteEvent event) { |
| 1460 | switch (event.type()) { |
| 1461 | case ROUTE_ADDED: |
| 1462 | routeHandler.processRouteAdded(event); |
| 1463 | break; |
| 1464 | case ROUTE_UPDATED: |
| 1465 | routeHandler.processRouteUpdated(event); |
| 1466 | break; |
| 1467 | case ROUTE_REMOVED: |
| 1468 | routeHandler.processRouteRemoved(event); |
| 1469 | break; |
Charles Chan | 910be6a | 2017-08-23 14:46:43 -0700 | [diff] [blame] | 1470 | case ALTERNATIVE_ROUTES_CHANGED: |
| 1471 | routeHandler.processAlternativeRoutesChanged(event); |
| 1472 | break; |
Charles Chan | debfea3 | 2016-10-24 14:52:01 -0700 | [diff] [blame] | 1473 | default: |
| 1474 | break; |
| 1475 | } |
| 1476 | } |
| 1477 | } |
Saurav Das | 62ae679 | 2017-05-15 15:34:25 -0700 | [diff] [blame] | 1478 | |
Jonghwan Hyun | e5ef762 | 2017-08-25 17:48:36 -0700 | [diff] [blame] | 1479 | private void updateInterface(InterfaceConfig conf, InterfaceConfig prevConf) { |
| 1480 | try { |
| 1481 | Set<Interface> intfs = conf.getInterfaces(); |
| 1482 | Set<Interface> prevIntfs = prevConf.getInterfaces(); |
| 1483 | |
| 1484 | // Now we only handle one interface config at each port. |
| 1485 | if (intfs.size() != 1 || prevIntfs.size() != 1) { |
| 1486 | log.warn("Interface update aborted - one at a time is allowed, " + |
| 1487 | "but {} / {}(prev) received.", intfs.size(), prevIntfs.size()); |
| 1488 | return; |
| 1489 | } |
| 1490 | |
| 1491 | Interface intf = intfs.stream().findFirst().get(); |
| 1492 | Interface prevIntf = prevIntfs.stream().findFirst().get(); |
| 1493 | |
| 1494 | DeviceId deviceId = intf.connectPoint().deviceId(); |
| 1495 | PortNumber portNum = intf.connectPoint().port(); |
| 1496 | |
| 1497 | if (!mastershipService.isLocalMaster(deviceId)) { |
| 1498 | log.debug("CONFIG_UPDATED event for interfaces should be " + |
| 1499 | "handled by master node for device {}", deviceId); |
| 1500 | return; |
| 1501 | } |
| 1502 | |
| 1503 | removeSubnetConfig(prevIntf.connectPoint(), |
| 1504 | Sets.difference(new HashSet<>(prevIntf.ipAddressesList()), |
| 1505 | new HashSet<>(intf.ipAddressesList()))); |
| 1506 | |
| 1507 | if (prevIntf.vlanNative() != VlanId.NONE && !intf.vlanNative().equals(prevIntf.vlanNative())) { |
| 1508 | // RemoveVlanNative |
| 1509 | updateVlanConfigInternal(deviceId, portNum, prevIntf.vlanNative(), true, false); |
| 1510 | } |
| 1511 | |
| 1512 | if (!prevIntf.vlanTagged().isEmpty() && !intf.vlanTagged().equals(prevIntf.vlanTagged())) { |
| 1513 | // RemoveVlanTagged |
| 1514 | prevIntf.vlanTagged().stream().filter(i -> !intf.vlanTagged().contains(i)).forEach( |
| 1515 | vlanId -> updateVlanConfigInternal(deviceId, portNum, vlanId, false, false) |
| 1516 | ); |
| 1517 | } |
| 1518 | |
| 1519 | if (prevIntf.vlanUntagged() != VlanId.NONE && !intf.vlanUntagged().equals(prevIntf.vlanUntagged())) { |
| 1520 | // RemoveVlanUntagged |
| 1521 | updateVlanConfigInternal(deviceId, portNum, prevIntf.vlanUntagged(), true, false); |
| 1522 | } |
| 1523 | |
| 1524 | if (intf.vlanNative() != VlanId.NONE && !prevIntf.vlanNative().equals(intf.vlanNative())) { |
| 1525 | // AddVlanNative |
| 1526 | updateVlanConfigInternal(deviceId, portNum, intf.vlanNative(), true, true); |
| 1527 | } |
| 1528 | |
| 1529 | if (!intf.vlanTagged().isEmpty() && !intf.vlanTagged().equals(prevIntf.vlanTagged())) { |
| 1530 | // AddVlanTagged |
| 1531 | intf.vlanTagged().stream().filter(i -> !prevIntf.vlanTagged().contains(i)).forEach( |
| 1532 | vlanId -> updateVlanConfigInternal(deviceId, portNum, vlanId, false, true) |
| 1533 | ); |
| 1534 | } |
| 1535 | |
| 1536 | if (intf.vlanUntagged() != VlanId.NONE && !prevIntf.vlanUntagged().equals(intf.vlanUntagged())) { |
| 1537 | // AddVlanUntagged |
| 1538 | updateVlanConfigInternal(deviceId, portNum, intf.vlanUntagged(), true, true); |
| 1539 | } |
| 1540 | addSubnetConfig(prevIntf.connectPoint(), |
| 1541 | Sets.difference(new HashSet<>(intf.ipAddressesList()), |
| 1542 | new HashSet<>(prevIntf.ipAddressesList()))); |
| 1543 | } catch (ConfigException e) { |
| 1544 | log.error("Error in configuration"); |
| 1545 | } |
| 1546 | } |
| 1547 | |
| 1548 | private void updateVlanConfigInternal(DeviceId deviceId, PortNumber portNum, |
| 1549 | VlanId vlanId, boolean pushVlan, boolean install) { |
| 1550 | DefaultGroupHandler grpHandler = getGroupHandler(deviceId); |
| 1551 | if (grpHandler == null) { |
| 1552 | log.warn("Failed to retrieve group handler for device {}", deviceId); |
| 1553 | return; |
| 1554 | } |
| 1555 | |
| 1556 | // Update filtering objective for a single port |
| 1557 | routingRulePopulator.updateSinglePortFilters(deviceId, portNum, pushVlan, vlanId, install); |
| 1558 | |
| 1559 | // Update filtering objective for multicast ingress port |
| 1560 | mcastHandler.updateFilterToDevice(deviceId, portNum, vlanId, install); |
| 1561 | |
| 1562 | int nextId = getVlanNextObjectiveId(deviceId, vlanId); |
| 1563 | |
| 1564 | if (nextId != -1 && !install) { |
| 1565 | // Update next objective for a single port as an output port |
| 1566 | // Remove a single port from L2FG |
| 1567 | grpHandler.updateGroupFromVlanConfiguration(portNum, Collections.singleton(vlanId), nextId, install); |
| 1568 | // Remove L2 Bridging rule and L3 Unicast rule to the host |
| 1569 | hostHandler.processIntfVlanUpdatedEvent(deviceId, portNum, vlanId, pushVlan, install); |
| 1570 | // Remove broadcast forwarding rule and corresponding L2FG for VLAN |
| 1571 | // only if there is no port configured on that VLAN ID |
| 1572 | if (!getVlanPortMap(deviceId).containsKey(vlanId)) { |
| 1573 | // Remove broadcast forwarding rule for the VLAN |
| 1574 | routingRulePopulator.updateSubnetBroadcastRule(deviceId, vlanId, install); |
| 1575 | // Remove L2FG for VLAN |
| 1576 | grpHandler.removeBcastGroupFromVlan(deviceId, portNum, vlanId, pushVlan); |
| 1577 | } else { |
| 1578 | // Remove L2IG of the port |
| 1579 | grpHandler.removePortNextObjective(deviceId, portNum, vlanId, pushVlan); |
| 1580 | } |
| 1581 | } else if (install) { |
| 1582 | if (nextId != -1) { |
| 1583 | // Add a single port to L2FG |
| 1584 | grpHandler.updateGroupFromVlanConfiguration(portNum, Collections.singleton(vlanId), nextId, install); |
| 1585 | } else { |
| 1586 | // Create L2FG for VLAN |
| 1587 | grpHandler.createBcastGroupFromVlan(vlanId, Collections.singleton(portNum)); |
| 1588 | routingRulePopulator.updateSubnetBroadcastRule(deviceId, vlanId, install); |
| 1589 | } |
| 1590 | hostHandler.processIntfVlanUpdatedEvent(deviceId, portNum, vlanId, pushVlan, install); |
| 1591 | } else { |
| 1592 | log.warn("Failed to retrieve next objective for vlan {} in device {}:{}", vlanId, deviceId, portNum); |
| 1593 | } |
| 1594 | } |
| 1595 | |
| 1596 | private void removeSubnetConfig(ConnectPoint cp, Set<InterfaceIpAddress> ipAddressSet) { |
| 1597 | Set<IpPrefix> ipPrefixSet = ipAddressSet.stream(). |
| 1598 | map(InterfaceIpAddress::subnetAddress).collect(Collectors.toSet()); |
| 1599 | |
| 1600 | Set<InterfaceIpAddress> deviceIntfIpAddrs = interfaceService.getInterfaces().stream() |
| 1601 | .filter(intf -> intf.connectPoint().deviceId().equals(cp.deviceId())) |
| 1602 | .filter(intf -> !intf.connectPoint().equals(cp)) |
| 1603 | .flatMap(intf -> intf.ipAddressesList().stream()) |
| 1604 | .collect(Collectors.toSet()); |
| 1605 | // 1. Partial subnet population |
| 1606 | // Remove routing rules for removed subnet from previous configuration, |
| 1607 | // which does not also exist in other interfaces in the same device |
| 1608 | Set<IpPrefix> deviceIpPrefixSet = deviceIntfIpAddrs.stream() |
| 1609 | .map(InterfaceIpAddress::subnetAddress) |
| 1610 | .collect(Collectors.toSet()); |
| 1611 | |
| 1612 | defaultRoutingHandler.revokeSubnet( |
| 1613 | ipPrefixSet.stream() |
| 1614 | .filter(ipPrefix -> !deviceIpPrefixSet.contains(ipPrefix)) |
| 1615 | .collect(Collectors.toSet())); |
| 1616 | |
| 1617 | // 2. Interface IP punts |
| 1618 | // Remove IP punts for old Intf address |
| 1619 | Set<IpAddress> deviceIpAddrs = deviceIntfIpAddrs.stream() |
| 1620 | .map(InterfaceIpAddress::ipAddress) |
| 1621 | .collect(Collectors.toSet()); |
| 1622 | ipAddressSet.stream() |
| 1623 | .map(InterfaceIpAddress::ipAddress) |
| 1624 | .filter(interfaceIpAddress -> !deviceIpAddrs.contains(interfaceIpAddress)) |
| 1625 | .forEach(interfaceIpAddress -> |
| 1626 | routingRulePopulator.revokeSingleIpPunts( |
| 1627 | cp.deviceId(), interfaceIpAddress)); |
| 1628 | |
| 1629 | // 3. Host unicast routing rule |
| 1630 | // Remove unicast routing rule |
| 1631 | hostHandler.processIntfIpUpdatedEvent(cp, ipPrefixSet, false); |
| 1632 | } |
| 1633 | |
| 1634 | private void addSubnetConfig(ConnectPoint cp, Set<InterfaceIpAddress> ipAddressSet) { |
| 1635 | Set<IpPrefix> ipPrefixSet = ipAddressSet.stream(). |
| 1636 | map(InterfaceIpAddress::subnetAddress).collect(Collectors.toSet()); |
| 1637 | |
| 1638 | Set<InterfaceIpAddress> deviceIntfIpAddrs = interfaceService.getInterfaces().stream() |
| 1639 | .filter(intf -> intf.connectPoint().deviceId().equals(cp.deviceId())) |
| 1640 | .filter(intf -> !intf.connectPoint().equals(cp)) |
| 1641 | .flatMap(intf -> intf.ipAddressesList().stream()) |
| 1642 | .collect(Collectors.toSet()); |
| 1643 | // 1. Partial subnet population |
| 1644 | // Add routing rules for newly added subnet, which does not also exist in |
| 1645 | // other interfaces in the same device |
| 1646 | Set<IpPrefix> deviceIpPrefixSet = deviceIntfIpAddrs.stream() |
| 1647 | .map(InterfaceIpAddress::subnetAddress) |
| 1648 | .collect(Collectors.toSet()); |
| 1649 | |
| 1650 | defaultRoutingHandler.populateSubnet( |
| 1651 | Collections.singleton(cp), |
| 1652 | ipPrefixSet.stream() |
| 1653 | .filter(ipPrefix -> !deviceIpPrefixSet.contains(ipPrefix)) |
| 1654 | .collect(Collectors.toSet())); |
| 1655 | |
| 1656 | // 2. Interface IP punts |
| 1657 | // Add IP punts for new Intf address |
| 1658 | Set<IpAddress> deviceIpAddrs = deviceIntfIpAddrs.stream() |
| 1659 | .map(InterfaceIpAddress::ipAddress) |
| 1660 | .collect(Collectors.toSet()); |
| 1661 | ipAddressSet.stream() |
| 1662 | .map(InterfaceIpAddress::ipAddress) |
| 1663 | .filter(interfaceIpAddress -> !deviceIpAddrs.contains(interfaceIpAddress)) |
| 1664 | .forEach(interfaceIpAddress -> |
| 1665 | routingRulePopulator.populateSingleIpPunts( |
| 1666 | cp.deviceId(), interfaceIpAddress)); |
| 1667 | |
| 1668 | // 3. Host unicast routing rule |
| 1669 | // Add unicast routing rule |
| 1670 | hostHandler.processIntfIpUpdatedEvent(cp, ipPrefixSet, true); |
| 1671 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1672 | } |