sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 43b5354 | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.segmentrouting; |
| 17 | |
| 18 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; |
| 21 | import org.apache.felix.scr.annotations.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 23 | import org.apache.felix.scr.annotations.Service; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 24 | import org.onlab.packet.Ethernet; |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 25 | import org.onlab.packet.IPv4; |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 26 | import org.onlab.packet.Ip4Prefix; |
| 27 | import org.onlab.packet.IpAddress; |
| 28 | import org.onlab.packet.IpPrefix; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 29 | import org.onlab.packet.MacAddress; |
| 30 | import org.onlab.packet.VlanId; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 31 | import org.onlab.util.KryoNamespace; |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 32 | import org.onosproject.cfg.ComponentConfigService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 33 | import org.onosproject.core.ApplicationId; |
| 34 | import org.onosproject.core.CoreService; |
| 35 | import org.onosproject.event.Event; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 36 | import org.onosproject.mastership.MastershipService; |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 37 | import org.onosproject.net.ConnectPoint; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 38 | import org.onosproject.net.Device; |
| 39 | import org.onosproject.net.DeviceId; |
| 40 | import org.onosproject.net.Link; |
| 41 | import org.onosproject.net.Port; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 42 | import org.onosproject.net.PortNumber; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 43 | import org.onosproject.net.config.ConfigFactory; |
| 44 | import org.onosproject.net.config.NetworkConfigEvent; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 45 | import org.onosproject.net.config.NetworkConfigListener; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 46 | import org.onosproject.net.config.NetworkConfigRegistry; |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 47 | import org.onosproject.net.config.basics.SubjectFactories; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 48 | import org.onosproject.net.device.DeviceEvent; |
| 49 | import org.onosproject.net.device.DeviceListener; |
| 50 | import org.onosproject.net.device.DeviceService; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 51 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 52 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 53 | import org.onosproject.net.flow.TrafficSelector; |
| 54 | import org.onosproject.net.flow.TrafficTreatment; |
| 55 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 56 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 57 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 58 | import org.onosproject.net.flowobjective.Objective; |
| 59 | import org.onosproject.net.flowobjective.ObjectiveContext; |
| 60 | import org.onosproject.net.flowobjective.ObjectiveError; |
| 61 | import org.onosproject.net.host.HostEvent; |
| 62 | import org.onosproject.net.host.HostListener; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 63 | import org.onosproject.net.host.HostService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 64 | import org.onosproject.net.link.LinkEvent; |
| 65 | import org.onosproject.net.link.LinkListener; |
| 66 | import org.onosproject.net.link.LinkService; |
| 67 | import org.onosproject.net.packet.InboundPacket; |
| 68 | import org.onosproject.net.packet.PacketContext; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 69 | import org.onosproject.net.packet.PacketPriority; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 70 | import org.onosproject.net.packet.PacketProcessor; |
| 71 | import org.onosproject.net.packet.PacketService; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 72 | import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; |
| 73 | import org.onosproject.segmentrouting.config.DeviceConfiguration; |
| 74 | import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig; |
| 75 | import org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig; |
| 76 | import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; |
| 77 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; |
| 78 | import org.onosproject.segmentrouting.grouphandler.NeighborSetNextObjectiveStoreKey; |
| 79 | import org.onosproject.segmentrouting.grouphandler.PortNextObjectiveStoreKey; |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 80 | import org.onosproject.segmentrouting.grouphandler.SubnetNextObjectiveStoreKey; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 81 | import org.onosproject.segmentrouting.grouphandler.XConnectNextObjectiveStoreKey; |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 82 | import org.onosproject.store.serializers.KryoNamespaces; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 83 | import org.onosproject.store.service.EventuallyConsistentMap; |
| 84 | import org.onosproject.store.service.EventuallyConsistentMapBuilder; |
| 85 | import org.onosproject.store.service.StorageService; |
| 86 | import org.onosproject.store.service.WallClockTimestamp; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 87 | import org.slf4j.Logger; |
| 88 | import org.slf4j.LoggerFactory; |
| 89 | |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 90 | import java.util.Collections; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 91 | import java.util.HashSet; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 92 | import java.util.List; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 93 | import java.util.Map; |
Charles Chan | de6655c | 2015-12-23 00:15:11 -0800 | [diff] [blame] | 94 | import java.util.Optional; |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 95 | import java.util.Set; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 96 | import java.util.concurrent.ConcurrentHashMap; |
| 97 | import java.util.concurrent.ConcurrentLinkedQueue; |
| 98 | import java.util.concurrent.Executors; |
| 99 | import java.util.concurrent.ScheduledExecutorService; |
| 100 | import java.util.concurrent.ScheduledFuture; |
| 101 | import java.util.concurrent.TimeUnit; |
| 102 | |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 103 | import static com.google.common.base.Preconditions.checkState; |
| 104 | |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 105 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 106 | /** |
| 107 | * Segment routing manager. |
| 108 | */ |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 109 | @Service |
| 110 | @Component(immediate = true) |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 111 | public class SegmentRoutingManager implements SegmentRoutingService { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 112 | |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 113 | private static Logger log = LoggerFactory |
| 114 | .getLogger(SegmentRoutingManager.class); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 115 | |
| 116 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 117 | protected CoreService coreService; |
| 118 | |
| 119 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 120 | protected PacketService packetService; |
| 121 | |
| 122 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 123 | protected HostService hostService; |
| 124 | |
| 125 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 126 | protected DeviceService deviceService; |
| 127 | |
| 128 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 129 | protected FlowObjectiveService flowObjectiveService; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 130 | |
| 131 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 132 | protected LinkService linkService; |
| 133 | |
| 134 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 135 | protected MastershipService mastershipService; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 136 | |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 137 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 138 | protected StorageService storageService; |
| 139 | |
| 140 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 141 | protected NetworkConfigRegistry cfgService; |
| 142 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 143 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 144 | protected ComponentConfigService compCfgService; |
| 145 | |
Srikanth Vavilapalli | 37a461b | 2015-04-07 15:12:32 -0700 | [diff] [blame] | 146 | protected ArpHandler arpHandler = null; |
| 147 | protected IcmpHandler icmpHandler = null; |
| 148 | protected IpHandler ipHandler = null; |
| 149 | protected RoutingRulePopulator routingRulePopulator = null; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 150 | protected ApplicationId appId; |
sangho | 9b169e3 | 2015-04-14 16:27:13 -0700 | [diff] [blame] | 151 | protected DeviceConfiguration deviceConfiguration = null; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 152 | |
Srikanth Vavilapalli | 37a461b | 2015-04-07 15:12:32 -0700 | [diff] [blame] | 153 | private DefaultRoutingHandler defaultRoutingHandler = null; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 154 | private TunnelHandler tunnelHandler = null; |
| 155 | private PolicyHandler policyHandler = null; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 156 | private InternalPacketProcessor processor = null; |
| 157 | private InternalLinkListener linkListener = null; |
| 158 | private InternalDeviceListener deviceListener = null; |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 159 | private NetworkConfigEventHandler netcfgHandler = null; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 160 | private InternalEventHandler eventHandler = new InternalEventHandler(); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 161 | private final InternalHostListener hostListener = new InternalHostListener(); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 162 | |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 163 | private ScheduledExecutorService executorService = Executors |
| 164 | .newScheduledThreadPool(1); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 165 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 166 | @SuppressWarnings("unused") |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 167 | private static ScheduledFuture<?> eventHandlerFuture = null; |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 168 | @SuppressWarnings("rawtypes") |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 169 | private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<Event>(); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 170 | private Map<DeviceId, DefaultGroupHandler> groupHandlerMap = |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 171 | new ConcurrentHashMap<>(); |
| 172 | /** |
| 173 | * Per device next objective ID store with (device id + neighbor set) as key. |
| 174 | */ |
| 175 | public EventuallyConsistentMap<NeighborSetNextObjectiveStoreKey, Integer> |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 176 | nsNextObjStore = null; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 177 | /** |
| 178 | * Per device next objective ID store with (device id + subnet) as key. |
| 179 | */ |
| 180 | public EventuallyConsistentMap<SubnetNextObjectiveStoreKey, Integer> |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 181 | subnetNextObjStore = null; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 182 | /** |
| 183 | * Per device next objective ID store with (device id + port) as key. |
| 184 | */ |
| 185 | public EventuallyConsistentMap<PortNextObjectiveStoreKey, Integer> |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 186 | portNextObjStore = null; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 187 | /** |
| 188 | * Per cross-connect objective ID store with VLAN ID as key. |
| 189 | */ |
| 190 | public EventuallyConsistentMap<XConnectNextObjectiveStoreKey, Integer> |
| 191 | xConnectNextObjStore = null; |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 192 | // Per device, per-subnet assigned-vlans store, with (device id + subnet |
| 193 | // IPv4 prefix) as key |
| 194 | private EventuallyConsistentMap<SubnetAssignedVidStoreKey, VlanId> |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 195 | subnetVidStore = null; |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 196 | private EventuallyConsistentMap<String, Tunnel> tunnelStore = null; |
| 197 | private EventuallyConsistentMap<String, Policy> policyStore = null; |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 198 | |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 199 | private final InternalConfigListener cfgListener = |
| 200 | new InternalConfigListener(this); |
| 201 | |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 202 | private final ConfigFactory<DeviceId, SegmentRoutingDeviceConfig> cfgDeviceFactory = |
| 203 | new ConfigFactory<DeviceId, SegmentRoutingDeviceConfig>(SubjectFactories.DEVICE_SUBJECT_FACTORY, |
| 204 | SegmentRoutingDeviceConfig.class, |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 205 | "segmentrouting") { |
| 206 | @Override |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 207 | public SegmentRoutingDeviceConfig createConfig() { |
| 208 | return new SegmentRoutingDeviceConfig(); |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 209 | } |
| 210 | }; |
Srikanth Vavilapalli | 37a461b | 2015-04-07 15:12:32 -0700 | [diff] [blame] | 211 | |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 212 | private final ConfigFactory<ApplicationId, SegmentRoutingAppConfig> cfgAppFactory = |
| 213 | new ConfigFactory<ApplicationId, SegmentRoutingAppConfig>(SubjectFactories.APP_SUBJECT_FACTORY, |
| 214 | SegmentRoutingAppConfig.class, |
| 215 | "segmentrouting") { |
| 216 | @Override |
| 217 | public SegmentRoutingAppConfig createConfig() { |
| 218 | return new SegmentRoutingAppConfig(); |
| 219 | } |
| 220 | }; |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 221 | |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 222 | private Object threadSchedulerLock = new Object(); |
| 223 | private static int numOfEventsQueued = 0; |
| 224 | private static int numOfEventsExecuted = 0; |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 225 | private static int numOfHandlerExecution = 0; |
| 226 | private static int numOfHandlerScheduled = 0; |
| 227 | |
Charles Chan | 1963f4f | 2016-02-18 14:22:42 -0800 | [diff] [blame] | 228 | /** |
| 229 | * Segment Routing App ID. |
| 230 | */ |
| 231 | public static final String SR_APP_ID = "org.onosproject.segmentrouting"; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 232 | /** |
| 233 | * The starting value of per-subnet VLAN ID assignment. |
| 234 | */ |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 235 | private static final short ASSIGNED_VLAN_START = 4093; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 236 | /** |
| 237 | * The default VLAN ID assigned to the interfaces without subnet config. |
| 238 | */ |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 239 | public static final short ASSIGNED_VLAN_NO_SUBNET = 4094; |
| 240 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 241 | @Activate |
| 242 | protected void activate() { |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 243 | appId = coreService.registerApplication(SR_APP_ID); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 244 | |
| 245 | log.debug("Creating EC map nsnextobjectivestore"); |
| 246 | EventuallyConsistentMapBuilder<NeighborSetNextObjectiveStoreKey, Integer> |
| 247 | nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 248 | nsNextObjStore = nsNextObjMapBuilder |
| 249 | .withName("nsnextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 250 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 251 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 252 | .build(); |
| 253 | log.trace("Current size {}", nsNextObjStore.size()); |
| 254 | |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 255 | log.debug("Creating EC map subnetnextobjectivestore"); |
| 256 | EventuallyConsistentMapBuilder<SubnetNextObjectiveStoreKey, Integer> |
| 257 | subnetNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 258 | subnetNextObjStore = subnetNextObjMapBuilder |
| 259 | .withName("subnetnextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 260 | .withSerializer(createSerializer()) |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 261 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 262 | .build(); |
| 263 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 264 | log.debug("Creating EC map subnetnextobjectivestore"); |
| 265 | EventuallyConsistentMapBuilder<PortNextObjectiveStoreKey, Integer> |
| 266 | portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
| 267 | portNextObjStore = portNextObjMapBuilder |
| 268 | .withName("portnextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 269 | .withSerializer(createSerializer()) |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 270 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 271 | .build(); |
| 272 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 273 | log.debug("Creating EC map xconnectnextobjectivestore"); |
| 274 | EventuallyConsistentMapBuilder<XConnectNextObjectiveStoreKey, Integer> |
| 275 | xConnectNextObjStoreBuilder = storageService.eventuallyConsistentMapBuilder(); |
| 276 | xConnectNextObjStore = xConnectNextObjStoreBuilder |
| 277 | .withName("xconnectnextobjectivestore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 278 | .withSerializer(createSerializer()) |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 279 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 280 | .build(); |
| 281 | |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 282 | EventuallyConsistentMapBuilder<String, Tunnel> tunnelMapBuilder = |
| 283 | storageService.eventuallyConsistentMapBuilder(); |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 284 | tunnelStore = tunnelMapBuilder |
| 285 | .withName("tunnelstore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 286 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 287 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 288 | .build(); |
| 289 | |
| 290 | EventuallyConsistentMapBuilder<String, Policy> policyMapBuilder = |
| 291 | storageService.eventuallyConsistentMapBuilder(); |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 292 | policyStore = policyMapBuilder |
| 293 | .withName("policystore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 294 | .withSerializer(createSerializer()) |
Madan Jampani | 675ae20 | 2015-06-24 19:05:56 -0700 | [diff] [blame] | 295 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
sangho | 4a5c42a | 2015-05-20 22:16:38 -0700 | [diff] [blame] | 296 | .build(); |
| 297 | |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 298 | EventuallyConsistentMapBuilder<SubnetAssignedVidStoreKey, VlanId> |
| 299 | subnetVidStoreMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 300 | subnetVidStore = subnetVidStoreMapBuilder |
| 301 | .withName("subnetvidstore") |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 302 | .withSerializer(createSerializer()) |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 303 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 304 | .build(); |
| 305 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 306 | compCfgService.preSetProperty("org.onosproject.net.group.impl.GroupManager", |
| 307 | "purgeOnDisconnection", "true"); |
| 308 | compCfgService.preSetProperty("org.onosproject.net.flow.impl.FlowRuleManager", |
| 309 | "purgeOnDisconnection", "true"); |
| 310 | |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 311 | processor = new InternalPacketProcessor(); |
| 312 | linkListener = new InternalLinkListener(); |
| 313 | deviceListener = new InternalDeviceListener(); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 314 | netcfgHandler = new NetworkConfigEventHandler(this); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 315 | |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 316 | cfgService.addListener(cfgListener); |
| 317 | cfgService.registerConfigFactory(cfgDeviceFactory); |
| 318 | cfgService.registerConfigFactory(cfgAppFactory); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 319 | hostService.addListener(hostListener); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 320 | packetService.addProcessor(processor, PacketProcessor.director(2)); |
| 321 | linkService.addListener(linkListener); |
| 322 | deviceService.addListener(deviceListener); |
| 323 | |
Charles Chan | de6655c | 2015-12-23 00:15:11 -0800 | [diff] [blame] | 324 | // Request ARP packet-in |
| 325 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 326 | selector.matchEthType(Ethernet.TYPE_ARP); |
| 327 | packetService.requestPackets(selector.build(), PacketPriority.CONTROL, appId, Optional.empty()); |
| 328 | |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 329 | cfgListener.configureNetwork(); |
| 330 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 331 | log.info("Started"); |
| 332 | } |
| 333 | |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 334 | private KryoNamespace.Builder createSerializer() { |
| 335 | return new KryoNamespace.Builder() |
| 336 | .register(KryoNamespaces.API) |
| 337 | .register(NeighborSetNextObjectiveStoreKey.class, |
| 338 | SubnetNextObjectiveStoreKey.class, |
| 339 | SubnetAssignedVidStoreKey.class, |
| 340 | NeighborSet.class, |
| 341 | Tunnel.class, |
| 342 | DefaultTunnel.class, |
| 343 | Policy.class, |
| 344 | TunnelPolicy.class, |
| 345 | Policy.Type.class, |
| 346 | PortNextObjectiveStoreKey.class, |
| 347 | XConnectNextObjectiveStoreKey.class |
| 348 | ); |
| 349 | } |
| 350 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 351 | @Deactivate |
| 352 | protected void deactivate() { |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 353 | cfgService.removeListener(cfgListener); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 354 | cfgService.unregisterConfigFactory(cfgDeviceFactory); |
| 355 | cfgService.unregisterConfigFactory(cfgAppFactory); |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 356 | |
Charles Chan | de6655c | 2015-12-23 00:15:11 -0800 | [diff] [blame] | 357 | // Withdraw ARP packet-in |
| 358 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 359 | selector.matchEthType(Ethernet.TYPE_ARP); |
| 360 | packetService.cancelPackets(selector.build(), PacketPriority.CONTROL, appId, Optional.empty()); |
| 361 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 362 | packetService.removeProcessor(processor); |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 363 | linkService.removeListener(linkListener); |
| 364 | deviceService.removeListener(deviceListener); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 365 | processor = null; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 366 | linkListener = null; |
| 367 | deviceService = null; |
| 368 | |
| 369 | groupHandlerMap.clear(); |
| 370 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 371 | log.info("Stopped"); |
| 372 | } |
| 373 | |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 374 | |
| 375 | @Override |
| 376 | public List<Tunnel> getTunnels() { |
| 377 | return tunnelHandler.getTunnels(); |
| 378 | } |
| 379 | |
| 380 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 381 | public TunnelHandler.Result createTunnel(Tunnel tunnel) { |
| 382 | return tunnelHandler.createTunnel(tunnel); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 386 | public TunnelHandler.Result removeTunnel(Tunnel tunnel) { |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 387 | for (Policy policy: policyHandler.getPolicies()) { |
| 388 | if (policy.type() == Policy.Type.TUNNEL_FLOW) { |
| 389 | TunnelPolicy tunnelPolicy = (TunnelPolicy) policy; |
| 390 | if (tunnelPolicy.tunnelId().equals(tunnel.id())) { |
| 391 | log.warn("Cannot remove the tunnel used by a policy"); |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 392 | return TunnelHandler.Result.TUNNEL_IN_USE; |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | } |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 396 | return tunnelHandler.removeTunnel(tunnel); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 400 | public PolicyHandler.Result removePolicy(Policy policy) { |
| 401 | return policyHandler.removePolicy(policy); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | @Override |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 405 | public PolicyHandler.Result createPolicy(Policy policy) { |
| 406 | return policyHandler.createPolicy(policy); |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | @Override |
| 410 | public List<Policy> getPolicies() { |
| 411 | return policyHandler.getPolicies(); |
| 412 | } |
| 413 | |
sangho | 80f1f89 | 2015-05-19 11:57:42 -0700 | [diff] [blame] | 414 | /** |
| 415 | * Returns the tunnel object with the tunnel ID. |
| 416 | * |
| 417 | * @param tunnelId Tunnel ID |
| 418 | * @return Tunnel reference |
| 419 | */ |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 420 | public Tunnel getTunnel(String tunnelId) { |
| 421 | return tunnelHandler.getTunnel(tunnelId); |
| 422 | } |
| 423 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 424 | /** |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 425 | * Returns the vlan-id assigned to the subnet configured for a device. |
| 426 | * If no vlan-id has been assigned, a new one is assigned out of a pool of ids, |
| 427 | * if and only if this controller instance is the master for the device. |
| 428 | * <p> |
| 429 | * USAGE: The assigned vlans are meant to be applied to untagged packets on those |
| 430 | * switches/pipelines that need this functionality. These vids are meant |
| 431 | * to be used internally within a switch, and thus need to be unique only |
| 432 | * on a switch level. Note that packets never go out on the wire with these |
| 433 | * vlans. Currently, vlan ids are assigned from value 4093 down. |
| 434 | * Vlan id 4094 expected to be used for all ports that are not assigned subnets. |
| 435 | * Vlan id 4095 is reserved and unused. Only a single vlan id is assigned |
| 436 | * per subnet. |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 437 | * |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 438 | * @param deviceId switch dpid |
| 439 | * @param subnet IPv4 prefix for which assigned vlan is desired |
| 440 | * @return VlanId assigned for the subnet on the device, or |
| 441 | * null if no vlan assignment was found and this instance is not |
| 442 | * the master for the device. |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 443 | */ |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 444 | // TODO: We should avoid assigning VLAN IDs that are used by VLAN cross-connection. |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 445 | public VlanId getSubnetAssignedVlanId(DeviceId deviceId, Ip4Prefix subnet) { |
| 446 | VlanId assignedVid = subnetVidStore.get(new SubnetAssignedVidStoreKey( |
| 447 | deviceId, subnet)); |
| 448 | if (assignedVid != null) { |
| 449 | log.debug("Query for subnet:{} on device:{} returned assigned-vlan " |
| 450 | + "{}", subnet, deviceId, assignedVid); |
| 451 | return assignedVid; |
| 452 | } |
| 453 | //check mastership for the right to assign a vlan |
| 454 | if (!mastershipService.isLocalMaster(deviceId)) { |
| 455 | log.warn("This controller instance is not the master for device {}. " |
| 456 | + "Cannot assign vlan-id for subnet {}", deviceId, subnet); |
| 457 | return null; |
| 458 | } |
| 459 | // vlan assignment is expensive but done only once |
Charles Chan | c6ad775 | 2015-10-29 14:58:10 -0700 | [diff] [blame] | 460 | Set<Ip4Prefix> configuredSubnets = deviceConfiguration.getSubnets(deviceId); |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 461 | Set<Short> assignedVlans = new HashSet<>(); |
| 462 | Set<Ip4Prefix> unassignedSubnets = new HashSet<>(); |
| 463 | for (Ip4Prefix sub : configuredSubnets) { |
| 464 | VlanId v = subnetVidStore.get(new SubnetAssignedVidStoreKey(deviceId, |
| 465 | sub)); |
| 466 | if (v != null) { |
| 467 | assignedVlans.add(v.toShort()); |
| 468 | } else { |
| 469 | unassignedSubnets.add(sub); |
| 470 | } |
| 471 | } |
| 472 | short nextAssignedVlan = ASSIGNED_VLAN_START; |
| 473 | if (!assignedVlans.isEmpty()) { |
| 474 | nextAssignedVlan = (short) (Collections.min(assignedVlans) - 1); |
| 475 | } |
| 476 | for (Ip4Prefix unsub : unassignedSubnets) { |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 477 | // Special case for default route. Assign default VLAN ID to /32 and /0 subnets |
| 478 | if (unsub.prefixLength() == IpPrefix.MAX_INET_MASK_LENGTH || |
| 479 | unsub.prefixLength() == 0) { |
| 480 | subnetVidStore.put(new SubnetAssignedVidStoreKey(deviceId, unsub), |
| 481 | VlanId.vlanId(ASSIGNED_VLAN_NO_SUBNET)); |
| 482 | } else { |
| 483 | subnetVidStore.put(new SubnetAssignedVidStoreKey(deviceId, unsub), |
| 484 | VlanId.vlanId(nextAssignedVlan--)); |
| 485 | log.info("Assigned vlan: {} to subnet: {} on device: {}", |
| 486 | nextAssignedVlan + 1, unsub, deviceId); |
| 487 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 488 | } |
| 489 | |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 490 | return subnetVidStore.get(new SubnetAssignedVidStoreKey(deviceId, subnet)); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 491 | } |
| 492 | |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 493 | /** |
Saurav Das | 7c30537 | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 494 | * Returns the next objective ID for the given NeighborSet. |
Saurav Das | 4c35fc4 | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 495 | * If the nextObjective does not exist, a new one is created and |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 496 | * its id is returned. |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 497 | * |
sangho | 80f1f89 | 2015-05-19 11:57:42 -0700 | [diff] [blame] | 498 | * @param deviceId Device ID |
| 499 | * @param ns NegighborSet |
Saurav Das | 4c35fc4 | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 500 | * @param meta metadata passed into the creation of a Next Objective |
| 501 | * @return next objective ID or -1 if an error was encountered during the |
| 502 | * creation of the nextObjective |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 503 | */ |
Saurav Das | 4c35fc4 | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 504 | public int getNextObjectiveId(DeviceId deviceId, NeighborSet ns, |
| 505 | TrafficSelector meta) { |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 506 | if (groupHandlerMap.get(deviceId) != null) { |
| 507 | log.trace("getNextObjectiveId query in device {}", deviceId); |
| 508 | return groupHandlerMap |
Saurav Das | 4c35fc4 | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 509 | .get(deviceId).getNextObjectiveId(ns, meta); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 510 | } else { |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 511 | log.warn("getNextObjectiveId query - groupHandler for device {} " |
| 512 | + "not found", deviceId); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 513 | return -1; |
| 514 | } |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 515 | } |
| 516 | |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 517 | /** |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 518 | * Returns the next objective ID for the given subnet prefix. It is expected |
| 519 | * that the next-objective has been pre-created from configuration. |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 520 | * |
| 521 | * @param deviceId Device ID |
| 522 | * @param prefix Subnet |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 523 | * @return next objective ID or -1 if it was not found |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 524 | */ |
| 525 | public int getSubnetNextObjectiveId(DeviceId deviceId, IpPrefix prefix) { |
| 526 | if (groupHandlerMap.get(deviceId) != null) { |
| 527 | log.trace("getSubnetNextObjectiveId query in device {}", deviceId); |
| 528 | return groupHandlerMap |
| 529 | .get(deviceId).getSubnetNextObjectiveId(prefix); |
| 530 | } else { |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 531 | log.warn("getSubnetNextObjectiveId query - groupHandler for " |
| 532 | + "device {} not found", deviceId); |
| 533 | return -1; |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | /** |
| 538 | * Returns the next objective ID for the given portNumber, given the treatment. |
| 539 | * There could be multiple different treatments to the same outport, which |
| 540 | * would result in different objectives. If the next object |
| 541 | * does not exist, a new one is created and its id is returned. |
| 542 | * |
| 543 | * @param deviceId Device ID |
| 544 | * @param portNum port number on device for which NextObjective is queried |
| 545 | * @param treatment the actions to apply on the packets (should include outport) |
| 546 | * @param meta metadata passed into the creation of a Next Objective if necessary |
| 547 | * @return next objective ID or -1 if it was not found |
| 548 | */ |
| 549 | public int getPortNextObjectiveId(DeviceId deviceId, PortNumber portNum, |
| 550 | TrafficTreatment treatment, |
| 551 | TrafficSelector meta) { |
| 552 | DefaultGroupHandler ghdlr = groupHandlerMap.get(deviceId); |
| 553 | if (ghdlr != null) { |
| 554 | return ghdlr.getPortNextObjectiveId(portNum, treatment, meta); |
| 555 | } else { |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 556 | log.warn("getPortNextObjectiveId query - groupHandler for device {}" |
| 557 | + " not found", deviceId); |
| 558 | return -1; |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * Returns the next objective ID of type broadcast associated with the VLAN |
| 564 | * cross-connection. |
| 565 | * |
| 566 | * @param deviceId Device ID for the cross-connection |
| 567 | * @param vlanId VLAN ID for the cross-connection |
| 568 | * @return next objective ID or -1 if it was not found |
| 569 | */ |
| 570 | public int getXConnectNextObjectiveId(DeviceId deviceId, VlanId vlanId) { |
| 571 | DefaultGroupHandler ghdlr = groupHandlerMap.get(deviceId); |
| 572 | if (ghdlr != null) { |
| 573 | return ghdlr.getXConnectNextObjectiveId(vlanId); |
| 574 | } else { |
| 575 | log.warn("getPortNextObjectiveId query - groupHandler for device {}" |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 576 | + " not found", deviceId); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 577 | return -1; |
| 578 | } |
| 579 | } |
| 580 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 581 | private class InternalPacketProcessor implements PacketProcessor { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 582 | @Override |
| 583 | public void process(PacketContext context) { |
| 584 | |
| 585 | if (context.isHandled()) { |
| 586 | return; |
| 587 | } |
| 588 | |
| 589 | InboundPacket pkt = context.inPacket(); |
| 590 | Ethernet ethernet = pkt.parsed(); |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 591 | log.trace("Rcvd pktin: {}", ethernet); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 592 | if (ethernet.getEtherType() == Ethernet.TYPE_ARP) { |
| 593 | arpHandler.processPacketIn(pkt); |
| 594 | } else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) { |
| 595 | IPv4 ipPacket = (IPv4) ethernet.getPayload(); |
| 596 | ipHandler.addToPacketBuffer(ipPacket); |
| 597 | if (ipPacket.getProtocol() == IPv4.PROTOCOL_ICMP) { |
| 598 | icmpHandler.processPacketIn(pkt); |
| 599 | } else { |
| 600 | ipHandler.processPacketIn(pkt); |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | private class InternalLinkListener implements LinkListener { |
| 607 | @Override |
| 608 | public void event(LinkEvent event) { |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 609 | if (event.type() == LinkEvent.Type.LINK_ADDED |
| 610 | || event.type() == LinkEvent.Type.LINK_REMOVED) { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 611 | log.debug("Event {} received from Link Service", event.type()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 612 | scheduleEventHandlerIfNotScheduled(event); |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | private class InternalDeviceListener implements DeviceListener { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 618 | @Override |
| 619 | public void event(DeviceEvent event) { |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 620 | switch (event.type()) { |
| 621 | case DEVICE_ADDED: |
| 622 | case PORT_REMOVED: |
sangho | fb7c729 | 2015-04-13 15:15:58 -0700 | [diff] [blame] | 623 | case DEVICE_UPDATED: |
| 624 | case DEVICE_AVAILABILITY_CHANGED: |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 625 | log.debug("Event {} received from Device Service", event.type()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 626 | scheduleEventHandlerIfNotScheduled(event); |
| 627 | break; |
| 628 | default: |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 633 | @SuppressWarnings("rawtypes") |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 634 | private void scheduleEventHandlerIfNotScheduled(Event event) { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 635 | synchronized (threadSchedulerLock) { |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 636 | eventQueue.add(event); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 637 | numOfEventsQueued++; |
| 638 | |
| 639 | if ((numOfHandlerScheduled - numOfHandlerExecution) == 0) { |
| 640 | //No pending scheduled event handling threads. So start a new one. |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 641 | eventHandlerFuture = executorService |
| 642 | .schedule(eventHandler, 100, TimeUnit.MILLISECONDS); |
| 643 | numOfHandlerScheduled++; |
| 644 | } |
Jonathan Hart | 54541d1 | 2016-04-12 15:39:44 -0700 | [diff] [blame^] | 645 | log.trace("numOfEventsQueued {}, numOfEventHandlerScheduled {}", |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 646 | numOfEventsQueued, |
| 647 | numOfHandlerScheduled); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 648 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | private class InternalEventHandler implements Runnable { |
Srikanth Vavilapalli | 37a461b | 2015-04-07 15:12:32 -0700 | [diff] [blame] | 652 | @Override |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 653 | public void run() { |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 654 | try { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 655 | while (true) { |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 656 | @SuppressWarnings("rawtypes") |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 657 | Event event = null; |
| 658 | synchronized (threadSchedulerLock) { |
| 659 | if (!eventQueue.isEmpty()) { |
| 660 | event = eventQueue.poll(); |
| 661 | numOfEventsExecuted++; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 662 | } else { |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 663 | numOfHandlerExecution++; |
| 664 | log.debug("numOfHandlerExecution {} numOfEventsExecuted {}", |
| 665 | numOfHandlerExecution, numOfEventsExecuted); |
| 666 | break; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 667 | } |
sangho | fb7c729 | 2015-04-13 15:15:58 -0700 | [diff] [blame] | 668 | } |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 669 | if (event.type() == LinkEvent.Type.LINK_ADDED) { |
| 670 | processLinkAdded((Link) event.subject()); |
| 671 | } else if (event.type() == LinkEvent.Type.LINK_REMOVED) { |
| 672 | processLinkRemoved((Link) event.subject()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 673 | } else if (event.type() == DeviceEvent.Type.DEVICE_ADDED || |
| 674 | event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED || |
| 675 | event.type() == DeviceEvent.Type.DEVICE_UPDATED) { |
Saurav Das | 62af880 | 2015-12-04 10:52:59 -0800 | [diff] [blame] | 676 | DeviceId deviceId = ((Device) event.subject()).id(); |
| 677 | if (deviceService.isAvailable(deviceId)) { |
Saurav Das | c28b343 | 2015-10-30 17:45:38 -0700 | [diff] [blame] | 678 | log.info("Processing device event {} for available device {}", |
| 679 | event.type(), ((Device) event.subject()).id()); |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 680 | processDeviceAdded((Device) event.subject()); |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 681 | } else { |
| 682 | log.info("Processing device event {} for unavailable device {}", |
| 683 | event.type(), ((Device) event.subject()).id()); |
| 684 | processDeviceRemoved((Device) event.subject()); |
| 685 | } |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 686 | } else if (event.type() == DeviceEvent.Type.PORT_REMOVED) { |
| 687 | processPortRemoved((Device) event.subject(), |
| 688 | ((DeviceEvent) event).port()); |
| 689 | } else { |
| 690 | log.warn("Unhandled event type: {}", event.type()); |
| 691 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 692 | } |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 693 | } catch (Exception e) { |
| 694 | log.error("SegmentRouting event handler " |
| 695 | + "thread thrown an exception: {}", e); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 696 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 697 | } |
| 698 | } |
| 699 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 700 | private void processLinkAdded(Link link) { |
| 701 | log.debug("A new link {} was added", link.toString()); |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 702 | if (!deviceConfiguration.isConfigured(link.src().deviceId())) { |
| 703 | log.warn("Source device of this link is not configured."); |
| 704 | return; |
| 705 | } |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 706 | //Irrespective whether the local is a MASTER or not for this device, |
| 707 | //create group handler instance and push default TTP flow rules. |
| 708 | //Because in a multi-instance setup, instances can initiate |
| 709 | //groups for any devices. Also the default TTP rules are needed |
| 710 | //to be pushed before inserting any IP table entries for any device |
| 711 | DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src() |
| 712 | .deviceId()); |
| 713 | if (groupHandler != null) { |
Saurav Das | 4c35fc4 | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 714 | groupHandler.linkUp(link, mastershipService.isLocalMaster( |
| 715 | link.src().deviceId())); |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 716 | } else { |
| 717 | Device device = deviceService.getDevice(link.src().deviceId()); |
| 718 | if (device != null) { |
| 719 | log.warn("processLinkAdded: Link Added " |
| 720 | + "Notification without Device Added " |
| 721 | + "event, still handling it"); |
| 722 | processDeviceAdded(device); |
| 723 | groupHandler = groupHandlerMap.get(link.src() |
| 724 | .deviceId()); |
Saurav Das | 4c35fc4 | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 725 | groupHandler.linkUp(link, mastershipService.isLocalMaster(device.id())); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 726 | } |
| 727 | } |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 728 | |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 729 | log.trace("Starting optimized route population process"); |
| 730 | defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(null); |
| 731 | //log.trace("processLinkAdded: re-starting route population process"); |
| 732 | //defaultRoutingHandler.startPopulationProcess(); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | private void processLinkRemoved(Link link) { |
| 736 | log.debug("A link {} was removed", link.toString()); |
sangho | 2165d22 | 2015-05-01 09:38:25 -0700 | [diff] [blame] | 737 | DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src().deviceId()); |
| 738 | if (groupHandler != null) { |
Saurav Das | 62af880 | 2015-12-04 10:52:59 -0800 | [diff] [blame] | 739 | groupHandler.portDown(link.src().port(), |
| 740 | mastershipService.isLocalMaster(link.src().deviceId())); |
sangho | 2165d22 | 2015-05-01 09:38:25 -0700 | [diff] [blame] | 741 | } |
Srikanth Vavilapalli | 64d96c1 | 2015-05-14 20:22:47 -0700 | [diff] [blame] | 742 | log.trace("Starting optimized route population process"); |
| 743 | defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(link); |
| 744 | //log.trace("processLinkRemoved: re-starting route population process"); |
| 745 | //defaultRoutingHandler.startPopulationProcess(); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | private void processDeviceAdded(Device device) { |
| 749 | log.debug("A new device with ID {} was added", device.id()); |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 750 | if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) { |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 751 | log.warn("Device configuration uploading. Device {} will be " |
| 752 | + "processed after config completes.", device.id()); |
| 753 | return; |
| 754 | } |
Saurav Das | c28b343 | 2015-10-30 17:45:38 -0700 | [diff] [blame] | 755 | // Irrespective of whether the local is a MASTER or not for this device, |
| 756 | // we need to create a SR-group-handler instance. This is because in a |
| 757 | // multi-instance setup, any instance can initiate forwarding/next-objectives |
| 758 | // for any switch (even if this instance is a SLAVE or not even connected |
| 759 | // to the switch). To handle this, a default-group-handler instance is necessary |
| 760 | // per switch. |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 761 | if (groupHandlerMap.get(device.id()) == null) { |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 762 | DefaultGroupHandler groupHandler; |
| 763 | try { |
| 764 | groupHandler = DefaultGroupHandler. |
| 765 | createGroupHandler(device.id(), |
| 766 | appId, |
| 767 | deviceConfiguration, |
| 768 | linkService, |
| 769 | flowObjectiveService, |
Charles Chan | de6655c | 2015-12-23 00:15:11 -0800 | [diff] [blame] | 770 | this); |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 771 | } catch (DeviceConfigNotFoundException e) { |
| 772 | log.warn(e.getMessage() + " Aborting processDeviceAdded."); |
| 773 | return; |
| 774 | } |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 775 | groupHandlerMap.put(device.id(), groupHandler); |
| 776 | // Also, in some cases, drivers may need extra |
| 777 | // information to process rules (eg. Router IP/MAC); and so, we send |
| 778 | // port addressing rules to the driver as well irrespective of whether |
| 779 | // this instance is the master or not. |
| 780 | defaultRoutingHandler.populatePortAddressingRules(device.id()); |
Charles Chan | d4a99c5 | 2015-11-18 16:51:08 -0800 | [diff] [blame] | 781 | hostListener.readInitialHosts(); |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 782 | } |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 783 | if (mastershipService.isLocalMaster(device.id())) { |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 784 | DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id()); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 785 | groupHandler.createGroupsFromSubnetConfig(); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 786 | routingRulePopulator.populateSubnetBroadcastRule(device.id()); |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 787 | groupHandler.createGroupsForXConnect(device.id()); |
| 788 | routingRulePopulator.populateXConnectBroadcastRule(device.id()); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 789 | } |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 790 | |
| 791 | netcfgHandler.initVRouters(device.id()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 792 | } |
| 793 | |
Saurav Das | c3604f1 | 2016-03-23 11:22:49 -0700 | [diff] [blame] | 794 | private void processDeviceRemoved(Device device) { |
| 795 | nsNextObjStore.entrySet().stream() |
| 796 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
| 797 | .forEach(entry -> { |
| 798 | nsNextObjStore.remove(entry.getKey()); |
| 799 | }); |
| 800 | |
| 801 | subnetNextObjStore.entrySet().stream() |
| 802 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
| 803 | .forEach(entry -> { |
| 804 | subnetNextObjStore.remove(entry.getKey()); |
| 805 | }); |
| 806 | |
| 807 | portNextObjStore.entrySet().stream() |
| 808 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
| 809 | .forEach(entry -> { |
| 810 | portNextObjStore.remove(entry.getKey()); |
| 811 | }); |
| 812 | |
| 813 | xConnectNextObjStore.entrySet().stream() |
| 814 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
| 815 | .forEach(entry -> { |
| 816 | xConnectNextObjStore.remove(entry.getKey()); |
| 817 | }); |
| 818 | |
| 819 | subnetVidStore.entrySet().stream() |
| 820 | .filter(entry -> entry.getKey().deviceId().equals(device.id())) |
| 821 | .forEach(entry -> { |
| 822 | subnetVidStore.remove(entry.getKey()); |
| 823 | }); |
| 824 | |
| 825 | groupHandlerMap.remove(device.id()); |
| 826 | |
| 827 | defaultRoutingHandler.purgeEcmpGraph(device.id()); |
| 828 | } |
| 829 | |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 830 | private void processPortRemoved(Device device, Port port) { |
| 831 | log.debug("Port {} was removed", port.toString()); |
Srikanth Vavilapalli | 6450548 | 2015-04-21 13:04:13 -0700 | [diff] [blame] | 832 | DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id()); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 833 | if (groupHandler != null) { |
Saurav Das | 62af880 | 2015-12-04 10:52:59 -0800 | [diff] [blame] | 834 | groupHandler.portDown(port.number(), |
| 835 | mastershipService.isLocalMaster(device.id())); |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 836 | } |
| 837 | } |
sangho | 27462c6 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 838 | |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 839 | private class InternalConfigListener implements NetworkConfigListener { |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 840 | SegmentRoutingManager segmentRoutingManager; |
| 841 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 842 | /** |
| 843 | * Constructs the internal network config listener. |
| 844 | * |
| 845 | * @param srMgr segment routing manager |
| 846 | */ |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 847 | public InternalConfigListener(SegmentRoutingManager srMgr) { |
| 848 | this.segmentRoutingManager = srMgr; |
| 849 | } |
| 850 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 851 | /** |
| 852 | * Reads network config and initializes related data structure accordingly. |
| 853 | */ |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 854 | public void configureNetwork() { |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 855 | deviceConfiguration = new DeviceConfiguration(appId, |
| 856 | segmentRoutingManager.cfgService); |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 857 | |
| 858 | arpHandler = new ArpHandler(segmentRoutingManager); |
| 859 | icmpHandler = new IcmpHandler(segmentRoutingManager); |
| 860 | ipHandler = new IpHandler(segmentRoutingManager); |
| 861 | routingRulePopulator = new RoutingRulePopulator(segmentRoutingManager); |
| 862 | defaultRoutingHandler = new DefaultRoutingHandler(segmentRoutingManager); |
| 863 | |
| 864 | tunnelHandler = new TunnelHandler(linkService, deviceConfiguration, |
| 865 | groupHandlerMap, tunnelStore); |
| 866 | policyHandler = new PolicyHandler(appId, deviceConfiguration, |
| 867 | flowObjectiveService, |
| 868 | tunnelHandler, policyStore); |
| 869 | |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 870 | for (Device device : deviceService.getDevices()) { |
Saurav Das | c28b343 | 2015-10-30 17:45:38 -0700 | [diff] [blame] | 871 | // Irrespective of whether the local is a MASTER or not for this device, |
| 872 | // we need to create a SR-group-handler instance. This is because in a |
| 873 | // multi-instance setup, any instance can initiate forwarding/next-objectives |
| 874 | // for any switch (even if this instance is a SLAVE or not even connected |
| 875 | // to the switch). To handle this, a default-group-handler instance is necessary |
| 876 | // per switch. |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 877 | if (groupHandlerMap.get(device.id()) == null) { |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 878 | DefaultGroupHandler groupHandler; |
| 879 | try { |
| 880 | groupHandler = DefaultGroupHandler. |
| 881 | createGroupHandler(device.id(), |
| 882 | appId, |
| 883 | deviceConfiguration, |
| 884 | linkService, |
| 885 | flowObjectiveService, |
Charles Chan | de6655c | 2015-12-23 00:15:11 -0800 | [diff] [blame] | 886 | segmentRoutingManager); |
Charles Chan | 319d1a2 | 2015-11-03 10:42:14 -0800 | [diff] [blame] | 887 | } catch (DeviceConfigNotFoundException e) { |
| 888 | log.warn(e.getMessage() + " Aborting configureNetwork."); |
| 889 | return; |
| 890 | } |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 891 | groupHandlerMap.put(device.id(), groupHandler); |
Saurav Das | c28b343 | 2015-10-30 17:45:38 -0700 | [diff] [blame] | 892 | |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 893 | // Also, in some cases, drivers may need extra |
| 894 | // information to process rules (eg. Router IP/MAC); and so, we send |
| 895 | // port addressing rules to the driver as well, irrespective of whether |
| 896 | // this instance is the master or not. |
| 897 | defaultRoutingHandler.populatePortAddressingRules(device.id()); |
Charles Chan | d4a99c5 | 2015-11-18 16:51:08 -0800 | [diff] [blame] | 898 | hostListener.readInitialHosts(); |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 899 | } |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 900 | if (mastershipService.isLocalMaster(device.id())) { |
Saurav Das | 8ec0ec4 | 2015-11-03 14:39:27 -0800 | [diff] [blame] | 901 | DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id()); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 902 | groupHandler.createGroupsFromSubnetConfig(); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 903 | routingRulePopulator.populateSubnetBroadcastRule(device.id()); |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 904 | groupHandler.createGroupsForXConnect(device.id()); |
| 905 | routingRulePopulator.populateXConnectBroadcastRule(device.id()); |
Charles Chan | 7727767 | 2015-10-20 16:24:19 -0700 | [diff] [blame] | 906 | } |
Charles Chan | e7c6102 | 2015-10-07 14:21:45 -0700 | [diff] [blame] | 907 | } |
| 908 | |
| 909 | defaultRoutingHandler.startPopulationProcess(); |
| 910 | } |
| 911 | |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 912 | @Override |
| 913 | public void event(NetworkConfigEvent event) { |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 914 | // TODO move this part to NetworkConfigEventHandler |
| 915 | if (event.configClass().equals(SegmentRoutingDeviceConfig.class)) { |
| 916 | switch (event.type()) { |
| 917 | case CONFIG_ADDED: |
| 918 | log.info("Segment Routing Config added."); |
| 919 | configureNetwork(); |
| 920 | break; |
| 921 | case CONFIG_UPDATED: |
| 922 | log.info("Segment Routing Config updated."); |
| 923 | // TODO support dynamic configuration |
| 924 | break; |
| 925 | default: |
| 926 | break; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 927 | } |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 928 | } else if (event.configClass().equals(SegmentRoutingAppConfig.class)) { |
Charles Chan | d6d2533 | 2016-02-26 22:19:52 -0800 | [diff] [blame] | 929 | checkState(netcfgHandler != null, "NetworkConfigEventHandler is not initialized"); |
Charles Chan | 82ab193 | 2016-01-30 23:22:37 -0800 | [diff] [blame] | 930 | switch (event.type()) { |
| 931 | case CONFIG_ADDED: |
| 932 | netcfgHandler.processVRouterConfigAdded(event); |
| 933 | break; |
| 934 | case CONFIG_UPDATED: |
| 935 | netcfgHandler.processVRouterConfigUpdated(event); |
| 936 | break; |
| 937 | case CONFIG_REMOVED: |
| 938 | netcfgHandler.processVRouterConfigRemoved(event); |
| 939 | break; |
| 940 | default: |
| 941 | break; |
Charles Chan | 2b078ae | 2015-10-14 11:24:40 -0700 | [diff] [blame] | 942 | } |
Charles Chan | 72f556a | 2015-10-05 17:50:33 -0700 | [diff] [blame] | 943 | } |
| 944 | } |
| 945 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 946 | |
Charles Chan | d4a99c5 | 2015-11-18 16:51:08 -0800 | [diff] [blame] | 947 | // TODO Move bridging table population to a separate class |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 948 | private class InternalHostListener implements HostListener { |
Charles Chan | d4a99c5 | 2015-11-18 16:51:08 -0800 | [diff] [blame] | 949 | private void readInitialHosts() { |
| 950 | hostService.getHosts().forEach(host -> { |
| 951 | MacAddress mac = host.mac(); |
| 952 | VlanId vlanId = host.vlan(); |
| 953 | DeviceId deviceId = host.location().deviceId(); |
| 954 | PortNumber port = host.location().port(); |
| 955 | Set<IpAddress> ips = host.ipAddresses(); |
| 956 | log.debug("Host {}/{} is added at {}:{}", mac, vlanId, deviceId, port); |
| 957 | |
| 958 | // Populate bridging table entry |
| 959 | ForwardingObjective.Builder fob = |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 960 | getForwardingObjectiveBuilder(deviceId, mac, vlanId, port); |
Charles Chan | d4a99c5 | 2015-11-18 16:51:08 -0800 | [diff] [blame] | 961 | flowObjectiveService.forward(deviceId, fob.add( |
| 962 | new BridgingTableObjectiveContext(mac, vlanId) |
| 963 | )); |
| 964 | |
| 965 | // Populate IP table entry |
| 966 | ips.forEach(ip -> { |
| 967 | if (ip.isIp4()) { |
| 968 | routingRulePopulator.populateIpRuleForHost( |
| 969 | deviceId, ip.getIp4Address(), mac, port); |
| 970 | } |
| 971 | }); |
| 972 | }); |
| 973 | } |
| 974 | |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 975 | private ForwardingObjective.Builder getForwardingObjectiveBuilder( |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 976 | DeviceId deviceId, MacAddress mac, VlanId vlanId, |
| 977 | PortNumber outport) { |
Charles Chan | de6655c | 2015-12-23 00:15:11 -0800 | [diff] [blame] | 978 | // Get assigned VLAN for the subnet |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 979 | VlanId outvlan = null; |
| 980 | Ip4Prefix subnet = deviceConfiguration.getPortSubnet(deviceId, outport); |
| 981 | if (subnet == null) { |
| 982 | outvlan = VlanId.vlanId(ASSIGNED_VLAN_NO_SUBNET); |
| 983 | } else { |
| 984 | outvlan = getSubnetAssignedVlanId(deviceId, subnet); |
| 985 | } |
Charles Chan | de6655c | 2015-12-23 00:15:11 -0800 | [diff] [blame] | 986 | |
| 987 | // match rule |
| 988 | TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); |
| 989 | sbuilder.matchEthDst(mac); |
| 990 | /* |
| 991 | * Note: for untagged packets, match on the assigned VLAN. |
| 992 | * for tagged packets, match on its incoming VLAN. |
| 993 | */ |
| 994 | if (vlanId.equals(VlanId.NONE)) { |
| 995 | sbuilder.matchVlanId(outvlan); |
| 996 | } else { |
| 997 | sbuilder.matchVlanId(vlanId); |
| 998 | } |
| 999 | |
| 1000 | TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); |
| 1001 | tbuilder.immediate().popVlan(); |
| 1002 | tbuilder.immediate().setOutput(outport); |
| 1003 | |
| 1004 | // for switch pipelines that need it, provide outgoing vlan as metadata |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 1005 | TrafficSelector meta = DefaultTrafficSelector.builder() |
| 1006 | .matchVlanId(outvlan).build(); |
| 1007 | |
| 1008 | // All forwarding is via Groups. Drivers can re-purpose to flow-actions if needed. |
| 1009 | int portNextObjId = getPortNextObjectiveId(deviceId, outport, |
| 1010 | tbuilder.build(), |
| 1011 | meta); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1012 | |
| 1013 | return DefaultForwardingObjective.builder() |
| 1014 | .withFlag(ForwardingObjective.Flag.SPECIFIC) |
| 1015 | .withSelector(sbuilder.build()) |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 1016 | .nextStep(portNextObjId) |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1017 | .withPriority(100) |
| 1018 | .fromApp(appId) |
| 1019 | .makePermanent(); |
| 1020 | } |
| 1021 | |
| 1022 | private void processHostAddedEvent(HostEvent event) { |
| 1023 | MacAddress mac = event.subject().mac(); |
| 1024 | VlanId vlanId = event.subject().vlan(); |
| 1025 | DeviceId deviceId = event.subject().location().deviceId(); |
| 1026 | PortNumber port = event.subject().location().port(); |
| 1027 | Set<IpAddress> ips = event.subject().ipAddresses(); |
Saurav Das | 2d94d31 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 1028 | log.info("Host {}/{} is added at {}:{}", mac, vlanId, deviceId, port); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1029 | |
Charles Chan | 57bd98c | 2016-02-22 19:27:29 -0800 | [diff] [blame] | 1030 | if (!deviceConfiguration.suppressHost() |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1031 | .contains(new ConnectPoint(deviceId, port))) { |
| 1032 | // Populate bridging table entry |
| 1033 | log.debug("Populate L2 table entry for host {} at {}:{}", |
| 1034 | mac, deviceId, port); |
| 1035 | ForwardingObjective.Builder fob = |
| 1036 | getForwardingObjectiveBuilder(deviceId, mac, vlanId, port); |
| 1037 | flowObjectiveService.forward(deviceId, fob.add( |
| 1038 | new BridgingTableObjectiveContext(mac, vlanId) |
| 1039 | )); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1040 | |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1041 | // Populate IP table entry |
| 1042 | ips.forEach(ip -> { |
| 1043 | if (ip.isIp4()) { |
| 1044 | routingRulePopulator.populateIpRuleForHost( |
| 1045 | deviceId, ip.getIp4Address(), mac, port); |
| 1046 | } |
| 1047 | }); |
| 1048 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | private void processHostRemoveEvent(HostEvent event) { |
| 1052 | MacAddress mac = event.subject().mac(); |
| 1053 | VlanId vlanId = event.subject().vlan(); |
| 1054 | DeviceId deviceId = event.subject().location().deviceId(); |
| 1055 | PortNumber port = event.subject().location().port(); |
| 1056 | Set<IpAddress> ips = event.subject().ipAddresses(); |
| 1057 | log.debug("Host {}/{} is removed from {}:{}", mac, vlanId, deviceId, port); |
| 1058 | |
Charles Chan | 57bd98c | 2016-02-22 19:27:29 -0800 | [diff] [blame] | 1059 | if (!deviceConfiguration.suppressHost() |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1060 | .contains(new ConnectPoint(deviceId, port))) { |
| 1061 | // Revoke bridging table entry |
| 1062 | ForwardingObjective.Builder fob = |
| 1063 | getForwardingObjectiveBuilder(deviceId, mac, vlanId, port); |
| 1064 | flowObjectiveService.forward(deviceId, fob.remove( |
| 1065 | new BridgingTableObjectiveContext(mac, vlanId) |
| 1066 | )); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1067 | |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1068 | // Revoke IP table entry |
| 1069 | ips.forEach(ip -> { |
| 1070 | if (ip.isIp4()) { |
| 1071 | routingRulePopulator.revokeIpRuleForHost( |
| 1072 | deviceId, ip.getIp4Address(), mac, port); |
| 1073 | } |
| 1074 | }); |
| 1075 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1076 | } |
| 1077 | |
| 1078 | private void processHostMovedEvent(HostEvent event) { |
| 1079 | MacAddress mac = event.subject().mac(); |
| 1080 | VlanId vlanId = event.subject().vlan(); |
| 1081 | DeviceId prevDeviceId = event.prevSubject().location().deviceId(); |
| 1082 | PortNumber prevPort = event.prevSubject().location().port(); |
| 1083 | Set<IpAddress> prevIps = event.prevSubject().ipAddresses(); |
| 1084 | DeviceId newDeviceId = event.subject().location().deviceId(); |
| 1085 | PortNumber newPort = event.subject().location().port(); |
| 1086 | Set<IpAddress> newIps = event.subject().ipAddresses(); |
| 1087 | log.debug("Host {}/{} is moved from {}:{} to {}:{}", |
| 1088 | mac, vlanId, prevDeviceId, prevPort, newDeviceId, newPort); |
| 1089 | |
Charles Chan | 57bd98c | 2016-02-22 19:27:29 -0800 | [diff] [blame] | 1090 | if (!deviceConfiguration.suppressHost() |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1091 | .contains(new ConnectPoint(prevDeviceId, prevPort))) { |
| 1092 | // Revoke previous bridging table entry |
| 1093 | ForwardingObjective.Builder prevFob = |
| 1094 | getForwardingObjectiveBuilder(prevDeviceId, mac, vlanId, prevPort); |
| 1095 | flowObjectiveService.forward(prevDeviceId, prevFob.remove( |
| 1096 | new BridgingTableObjectiveContext(mac, vlanId) |
| 1097 | )); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1098 | |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1099 | // Revoke previous IP table entry |
| 1100 | prevIps.forEach(ip -> { |
| 1101 | if (ip.isIp4()) { |
| 1102 | routingRulePopulator.revokeIpRuleForHost( |
| 1103 | prevDeviceId, ip.getIp4Address(), mac, prevPort); |
| 1104 | } |
| 1105 | }); |
| 1106 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1107 | |
Charles Chan | 57bd98c | 2016-02-22 19:27:29 -0800 | [diff] [blame] | 1108 | if (!deviceConfiguration.suppressHost() |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1109 | .contains(new ConnectPoint(newDeviceId, newPort))) { |
| 1110 | // Populate new bridging table entry |
| 1111 | ForwardingObjective.Builder newFob = |
| 1112 | getForwardingObjectiveBuilder(newDeviceId, mac, vlanId, newPort); |
| 1113 | flowObjectiveService.forward(newDeviceId, newFob.add( |
| 1114 | new BridgingTableObjectiveContext(mac, vlanId) |
| 1115 | )); |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1116 | |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1117 | // Populate new IP table entry |
| 1118 | newIps.forEach(ip -> { |
| 1119 | if (ip.isIp4()) { |
| 1120 | routingRulePopulator.populateIpRuleForHost( |
| 1121 | newDeviceId, ip.getIp4Address(), mac, newPort); |
| 1122 | } |
| 1123 | }); |
| 1124 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1125 | } |
| 1126 | |
| 1127 | private void processHostUpdatedEvent(HostEvent event) { |
| 1128 | MacAddress mac = event.subject().mac(); |
| 1129 | VlanId vlanId = event.subject().vlan(); |
| 1130 | DeviceId prevDeviceId = event.prevSubject().location().deviceId(); |
| 1131 | PortNumber prevPort = event.prevSubject().location().port(); |
| 1132 | Set<IpAddress> prevIps = event.prevSubject().ipAddresses(); |
| 1133 | DeviceId newDeviceId = event.subject().location().deviceId(); |
| 1134 | PortNumber newPort = event.subject().location().port(); |
| 1135 | Set<IpAddress> newIps = event.subject().ipAddresses(); |
| 1136 | log.debug("Host {}/{} is updated", mac, vlanId); |
| 1137 | |
Charles Chan | 57bd98c | 2016-02-22 19:27:29 -0800 | [diff] [blame] | 1138 | if (!deviceConfiguration.suppressHost() |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1139 | .contains(new ConnectPoint(prevDeviceId, prevPort))) { |
| 1140 | // Revoke previous IP table entry |
| 1141 | prevIps.forEach(ip -> { |
| 1142 | if (ip.isIp4()) { |
| 1143 | routingRulePopulator.revokeIpRuleForHost( |
| 1144 | prevDeviceId, ip.getIp4Address(), mac, prevPort); |
| 1145 | } |
| 1146 | }); |
| 1147 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1148 | |
Charles Chan | 57bd98c | 2016-02-22 19:27:29 -0800 | [diff] [blame] | 1149 | if (!deviceConfiguration.suppressHost() |
Charles Chan | 43547ca | 2016-02-10 20:46:58 -0800 | [diff] [blame] | 1150 | .contains(new ConnectPoint(newDeviceId, newPort))) { |
| 1151 | // Populate new IP table entry |
| 1152 | newIps.forEach(ip -> { |
| 1153 | if (ip.isIp4()) { |
| 1154 | routingRulePopulator.populateIpRuleForHost( |
| 1155 | newDeviceId, ip.getIp4Address(), mac, newPort); |
| 1156 | } |
| 1157 | }); |
| 1158 | } |
Charles Chan | f458611 | 2015-11-09 16:37:23 -0800 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | @Override |
| 1162 | public void event(HostEvent event) { |
| 1163 | // Do not proceed without mastership |
| 1164 | DeviceId deviceId = event.subject().location().deviceId(); |
| 1165 | if (!mastershipService.isLocalMaster(deviceId)) { |
| 1166 | return; |
| 1167 | } |
| 1168 | |
| 1169 | switch (event.type()) { |
| 1170 | case HOST_ADDED: |
| 1171 | processHostAddedEvent(event); |
| 1172 | break; |
| 1173 | case HOST_MOVED: |
| 1174 | processHostMovedEvent(event); |
| 1175 | break; |
| 1176 | case HOST_REMOVED: |
| 1177 | processHostRemoveEvent(event); |
| 1178 | break; |
| 1179 | case HOST_UPDATED: |
| 1180 | processHostUpdatedEvent(event); |
| 1181 | break; |
| 1182 | default: |
| 1183 | log.warn("Unsupported host event type: {}", event.type()); |
| 1184 | break; |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | private static class BridgingTableObjectiveContext implements ObjectiveContext { |
| 1190 | final MacAddress mac; |
| 1191 | final VlanId vlanId; |
| 1192 | |
| 1193 | BridgingTableObjectiveContext(MacAddress mac, VlanId vlanId) { |
| 1194 | this.mac = mac; |
| 1195 | this.vlanId = vlanId; |
| 1196 | } |
| 1197 | |
| 1198 | @Override |
| 1199 | public void onSuccess(Objective objective) { |
| 1200 | if (objective.op() == Objective.Operation.ADD) { |
| 1201 | log.debug("Successfully populate bridging table entry for {}/{}", |
| 1202 | mac, vlanId); |
| 1203 | } else { |
| 1204 | log.debug("Successfully revoke bridging table entry for {}/{}", |
| 1205 | mac, vlanId); |
| 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | @Override |
| 1210 | public void onError(Objective objective, ObjectiveError error) { |
| 1211 | if (objective.op() == Objective.Operation.ADD) { |
| 1212 | log.debug("Fail to populate bridging table entry for {}/{}. {}", |
| 1213 | mac, vlanId, error); |
| 1214 | } else { |
| 1215 | log.debug("Fail to revoke bridging table entry for {}/{}. {}", |
| 1216 | mac, vlanId, error); |
| 1217 | } |
| 1218 | } |
| 1219 | } |
sangho | 80f11cb | 2015-04-01 13:05:26 -0700 | [diff] [blame] | 1220 | } |