blob: 44d66403659fece20536767050964be85ba446f7 [file] [log] [blame]
Jonathan Hartf5829202015-02-12 09:37:02 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.bgprouter;
17
alshabib910aff12015-04-09 16:55:57 -070018import com.google.common.collect.ConcurrentHashMultiset;
19import com.google.common.collect.HashMultimap;
20import com.google.common.collect.Maps;
21import com.google.common.collect.Multimap;
22import com.google.common.collect.Multiset;
Saurav Dasbd7f7422015-04-23 16:31:47 -070023
Jonathan Hartf5829202015-02-12 09:37:02 -080024import org.apache.felix.scr.annotations.Activate;
25import org.apache.felix.scr.annotations.Component;
26import org.apache.felix.scr.annotations.Deactivate;
27import org.apache.felix.scr.annotations.Reference;
28import org.apache.felix.scr.annotations.ReferenceCardinality;
29import org.onlab.packet.Ethernet;
Jonathan Hart7baba072015-02-23 14:27:59 -080030import org.onlab.packet.IpAddress;
31import org.onlab.packet.IpPrefix;
Jonathan Hart54b406b2015-03-06 16:24:14 -080032import org.onosproject.config.NetworkConfigService;
Jonathan Hartf5829202015-02-12 09:37:02 -080033import org.onosproject.core.ApplicationId;
34import org.onosproject.core.CoreService;
35import org.onosproject.net.DeviceId;
Saurav Dasbd7f7422015-04-23 16:31:47 -070036import org.onosproject.net.device.DeviceEvent;
37import org.onosproject.net.device.DeviceListener;
38import org.onosproject.net.device.DeviceService;
Jonathan Hartf5829202015-02-12 09:37:02 -080039import org.onosproject.net.flow.DefaultTrafficSelector;
40import org.onosproject.net.flow.DefaultTrafficTreatment;
Jonathan Hartf5829202015-02-12 09:37:02 -080041import org.onosproject.net.flow.TrafficSelector;
42import org.onosproject.net.flow.TrafficTreatment;
alshabib910aff12015-04-09 16:55:57 -070043import org.onosproject.net.flow.criteria.Criteria;
44import org.onosproject.net.flowobjective.DefaultFilteringObjective;
alshabib2a441c62015-04-13 18:39:38 -070045import org.onosproject.net.flowobjective.DefaultForwardingObjective;
46import org.onosproject.net.flowobjective.DefaultNextObjective;
alshabib910aff12015-04-09 16:55:57 -070047import org.onosproject.net.flowobjective.FilteringObjective;
48import org.onosproject.net.flowobjective.FlowObjectiveService;
alshabib2a441c62015-04-13 18:39:38 -070049import org.onosproject.net.flowobjective.ForwardingObjective;
50import org.onosproject.net.flowobjective.NextObjective;
Saurav Dasbd7f7422015-04-23 16:31:47 -070051import org.onosproject.net.flowobjective.Objective;
52import org.onosproject.net.flowobjective.ObjectiveContext;
53import org.onosproject.net.flowobjective.ObjectiveError;
Jonathan Hartf5829202015-02-12 09:37:02 -080054import org.onosproject.net.packet.PacketService;
Jonathan Hart7baba072015-02-23 14:27:59 -080055import org.onosproject.routing.FibEntry;
Jonathan Hart2da1e602015-02-18 19:09:24 -080056import org.onosproject.routing.FibListener;
57import org.onosproject.routing.FibUpdate;
58import org.onosproject.routing.RoutingService;
Saurav Dasfbe25c52015-03-04 11:12:00 -080059import org.onosproject.routing.config.BgpSpeaker;
Jonathan Hart2da1e602015-02-18 19:09:24 -080060import org.onosproject.routing.config.Interface;
61import org.onosproject.routing.config.RoutingConfigurationService;
Jonathan Hartf5829202015-02-12 09:37:02 -080062import org.slf4j.Logger;
63import org.slf4j.LoggerFactory;
64
alshabib910aff12015-04-09 16:55:57 -070065import java.util.Collection;
alshabib910aff12015-04-09 16:55:57 -070066import java.util.HashMap;
alshabib910aff12015-04-09 16:55:57 -070067import java.util.Map;
68import java.util.Set;
alshabib2a441c62015-04-13 18:39:38 -070069
Jonathan Hartf5829202015-02-12 09:37:02 -080070/**
71 * BgpRouter component.
72 */
73@Component(immediate = true)
74public class BgpRouter {
75
76 private static final Logger log = LoggerFactory.getLogger(BgpRouter.class);
77
78 private static final String BGP_ROUTER_APP = "org.onosproject.bgprouter";
79
Jonathan Hart12ef2052015-03-10 13:58:13 -070080 private static final int PRIORITY_OFFSET = 100;
81 private static final int PRIORITY_MULTIPLIER = 5;
Jonathan Hartf5829202015-02-12 09:37:02 -080082
83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
84 protected CoreService coreService;
85
86 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Jonathan Hartf5829202015-02-12 09:37:02 -080087 protected RoutingService routingService;
88
89 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
90 protected RoutingConfigurationService configService;
91
92 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
93 protected PacketService packetService;
94
Saurav Dasbd7f7422015-04-23 16:31:47 -070095 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
96 protected FlowObjectiveService flowObjectiveService;
97
98 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
99 protected DeviceService deviceService;
100
Saurav Dasfbe25c52015-03-04 11:12:00 -0800101 //
102 // NOTE: Unused reference - needed to guarantee that the
103 // NetworkConfigReader component is activated and the network configuration
104 // is read.
105 //
106 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
107 protected NetworkConfigService networkConfigService;
108
Jonathan Hartf5829202015-02-12 09:37:02 -0800109 private ApplicationId appId;
110
Jonathan Hart7baba072015-02-23 14:27:59 -0800111 // Reference count for how many times a next hop is used by a route
112 private final Multiset<IpAddress> nextHopsCount = ConcurrentHashMultiset.create();
113
114 // Mapping from prefix to its current next hop
115 private final Map<IpPrefix, IpAddress> prefixToNextHop = Maps.newHashMap();
116
117 // Mapping from next hop IP to next hop object containing group info
alshabib2a441c62015-04-13 18:39:38 -0700118 private final Map<IpAddress, Integer> nextHops = Maps.newHashMap();
Jonathan Hart7baba072015-02-23 14:27:59 -0800119
120 // Stores FIB updates that are waiting for groups to be set up
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700121 private final Multimap<NextHopGroupKey, FibEntry> pendingUpdates = HashMultimap.create();
Jonathan Hartf5829202015-02-12 09:37:02 -0800122
Saurav Dasfbe25c52015-03-04 11:12:00 -0800123 // Device id of data-plane switch - should be learned from config
124 private DeviceId deviceId;
125
126 // Device id of control-plane switch (OVS) connected to BGP Speaker - should be
127 // learned from config
128 private DeviceId ctrlDeviceId;
Jonathan Hartf5829202015-02-12 09:37:02 -0800129
Saurav Dasbd7f7422015-04-23 16:31:47 -0700130 // Responsible for handling BGP traffic (encapsulated within OF messages)
131 // between the data-plane switch and the Quagga VM using a control plane OVS.
Jonathan Hartf5829202015-02-12 09:37:02 -0800132 private TunnellingConnectivityManager connectivityManager;
133
Saurav Dasbd7f7422015-04-23 16:31:47 -0700134 private DeviceListener deviceListener;
sangho5eaf0332015-03-09 15:08:12 -0700135 private IcmpHandler icmpHandler;
136
Jonathan Hartf5829202015-02-12 09:37:02 -0800137 @Activate
138 protected void activate() {
Jonathan Hartf5829202015-02-12 09:37:02 -0800139 appId = coreService.registerApplication(BGP_ROUTER_APP);
Saurav Dasfbe25c52015-03-04 11:12:00 -0800140 getDeviceConfiguration(configService.getBgpSpeakers());
Jonathan Hartf5829202015-02-12 09:37:02 -0800141
142 connectivityManager = new TunnellingConnectivityManager(appId,
143 configService,
Jonathan Hart936a7292015-03-06 18:02:57 -0800144 packetService,
Saurav Das3d038262015-04-23 12:36:58 -0700145 flowObjectiveService);
Jonathan Hartf5829202015-02-12 09:37:02 -0800146
sangho5eaf0332015-03-09 15:08:12 -0700147 icmpHandler = new IcmpHandler(configService, packetService);
Saurav Dasbd7f7422015-04-23 16:31:47 -0700148 deviceListener = new InnerDeviceListener();
Pingping Line28ae4c2015-03-13 11:37:03 -0700149 routingService.addFibListener(new InternalFibListener());
150 routingService.start();
Saurav Dasbd7f7422015-04-23 16:31:47 -0700151 deviceService.addListener(deviceListener);
Jonathan Hartf5829202015-02-12 09:37:02 -0800152 connectivityManager.start();
sangho5eaf0332015-03-09 15:08:12 -0700153 icmpHandler.start();
154
Jonathan Hartf5829202015-02-12 09:37:02 -0800155 log.info("BgpRouter started");
156 }
157
158 @Deactivate
159 protected void deactivate() {
160 routingService.stop();
161 connectivityManager.stop();
sangho5eaf0332015-03-09 15:08:12 -0700162 icmpHandler.stop();
Saurav Dasbd7f7422015-04-23 16:31:47 -0700163 deviceService.removeListener(deviceListener);
164 //processIntfFilters(false, configService.getInterfaces()); //TODO necessary?
Jonathan Hartf5829202015-02-12 09:37:02 -0800165 log.info("BgpRouter stopped");
166 }
167
Saurav Dasfbe25c52015-03-04 11:12:00 -0800168 private void getDeviceConfiguration(Map<String, BgpSpeaker> bgps) {
169 if (bgps == null || bgps.values().isEmpty()) {
170 log.error("BGP speakers configuration is missing");
171 return;
172 }
173 for (BgpSpeaker s : bgps.values()) {
174 ctrlDeviceId = s.connectPoint().deviceId();
175 if (s.interfaceAddresses() == null || s.interfaceAddresses().isEmpty()) {
176 log.error("BGP Router must have interfaces configured");
177 return;
178 }
179 deviceId = s.interfaceAddresses().get(0).connectPoint().deviceId();
180 break;
181 }
sangho5eaf0332015-03-09 15:08:12 -0700182
Saurav Dasfbe25c52015-03-04 11:12:00 -0800183 log.info("Router dpid: {}", deviceId);
184 log.info("Control Plane OVS dpid: {}", ctrlDeviceId);
185 }
186
Jonathan Hartf5829202015-02-12 09:37:02 -0800187 private void updateFibEntry(Collection<FibUpdate> updates) {
alshabib2a441c62015-04-13 18:39:38 -0700188 Map<FibEntry, Integer> toInstall = new HashMap<>(updates.size());
Jonathan Hart5b141422015-03-06 12:59:09 -0800189
Jonathan Hartf5829202015-02-12 09:37:02 -0800190 for (FibUpdate update : updates) {
Jonathan Hart7baba072015-02-23 14:27:59 -0800191 FibEntry entry = update.entry();
Jonathan Hartf5829202015-02-12 09:37:02 -0800192
Jonathan Hart7baba072015-02-23 14:27:59 -0800193 addNextHop(entry);
Jonathan Hartf5829202015-02-12 09:37:02 -0800194
alshabib2a441c62015-04-13 18:39:38 -0700195 Integer nextId;
Jonathan Hart7baba072015-02-23 14:27:59 -0800196 synchronized (pendingUpdates) {
alshabib2a441c62015-04-13 18:39:38 -0700197 nextId = nextHops.get(entry.nextHopIp());
Jonathan Hartf5829202015-02-12 09:37:02 -0800198 }
199
alshabib2a441c62015-04-13 18:39:38 -0700200 toInstall.put(update.entry(), nextId);
Jonathan Hartf5829202015-02-12 09:37:02 -0800201 }
Jonathan Hart5b141422015-03-06 12:59:09 -0800202
203 installFlows(toInstall);
Jonathan Hartf5829202015-02-12 09:37:02 -0800204 }
205
alshabib2a441c62015-04-13 18:39:38 -0700206 private void installFlows(Map<FibEntry, Integer> entriesToInstall) {
Jonathan Hart7baba072015-02-23 14:27:59 -0800207
alshabib2a441c62015-04-13 18:39:38 -0700208 for (Map.Entry<FibEntry, Integer> entry : entriesToInstall.entrySet()) {
Jonathan Hart5b141422015-03-06 12:59:09 -0800209 FibEntry fibEntry = entry.getKey();
alshabib2a441c62015-04-13 18:39:38 -0700210 Integer nextId = entry.getValue();
Jonathan Hart5b141422015-03-06 12:59:09 -0800211
alshabib2a441c62015-04-13 18:39:38 -0700212 flowObjectiveService.forward(deviceId,
Saurav Dasbd7f7422015-04-23 16:31:47 -0700213 generateRibForwardingObj(fibEntry.prefix(), nextId).add());
Saurav Das3d038262015-04-23 12:36:58 -0700214 log.trace("Sending forwarding objective {} -> nextId:{}", fibEntry, nextId);
Jonathan Hart5b141422015-03-06 12:59:09 -0800215 }
216
Jonathan Hart7baba072015-02-23 14:27:59 -0800217 }
218
219 private synchronized void deleteFibEntry(Collection<FibUpdate> withdraws) {
Jonathan Hart5b141422015-03-06 12:59:09 -0800220
Jonathan Hart7baba072015-02-23 14:27:59 -0800221 for (FibUpdate update : withdraws) {
222 FibEntry entry = update.entry();
sanghodde53d12015-04-30 10:34:41 -0700223 //Integer nextId = nextHops.get(entry.nextHopIp());
Jonathan Hart7baba072015-02-23 14:27:59 -0800224
Saurav Dasbd7f7422015-04-23 16:31:47 -0700225 /* Group group = deleteNextHop(entry.prefix());
Jonathan Hart37d659c2015-03-08 19:20:38 -0700226 if (group == null) {
227 log.warn("Group not found when deleting {}", entry);
228 return;
alshabib2a441c62015-04-13 18:39:38 -0700229 }*/
Jonathan Hartf5829202015-02-12 09:37:02 -0800230
alshabib2a441c62015-04-13 18:39:38 -0700231 flowObjectiveService.forward(deviceId,
sanghodde53d12015-04-30 10:34:41 -0700232 generateRibForwardingObj(entry.prefix(), null).remove());
Jonathan Hartf5829202015-02-12 09:37:02 -0800233
Jonathan Hartf5829202015-02-12 09:37:02 -0800234 }
Jonathan Hart5b141422015-03-06 12:59:09 -0800235
Jonathan Hartf5829202015-02-12 09:37:02 -0800236 }
237
Saurav Dasbd7f7422015-04-23 16:31:47 -0700238 private ForwardingObjective.Builder generateRibForwardingObj(IpPrefix prefix,
239 Integer nextId) {
Jonathan Hart37d659c2015-03-08 19:20:38 -0700240 TrafficSelector selector = DefaultTrafficSelector.builder()
241 .matchEthType(Ethernet.TYPE_IPV4)
242 .matchIPDst(prefix)
243 .build();
244
Jonathan Hart12ef2052015-03-10 13:58:13 -0700245 int priority = prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET;
246
alshabib2a441c62015-04-13 18:39:38 -0700247 ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective.builder()
248 .fromApp(appId)
249 .makePermanent()
alshabib2a441c62015-04-13 18:39:38 -0700250 .withSelector(selector)
251 .withPriority(priority)
252 .withFlag(ForwardingObjective.Flag.SPECIFIC);
253
sanghodde53d12015-04-30 10:34:41 -0700254 if (nextId == null) {
255 fwdBuilder.withTreatment(DefaultTrafficTreatment.builder().build());
256 } else {
257 fwdBuilder.nextStep(nextId);
258 }
alshabib2a441c62015-04-13 18:39:38 -0700259 return fwdBuilder;
Jonathan Hart37d659c2015-03-08 19:20:38 -0700260 }
261
Jonathan Hart7baba072015-02-23 14:27:59 -0800262 private synchronized void addNextHop(FibEntry entry) {
263 prefixToNextHop.put(entry.prefix(), entry.nextHopIp());
264 if (nextHopsCount.count(entry.nextHopIp()) == 0) {
Jonathan Hartf5829202015-02-12 09:37:02 -0800265 // There was no next hop in the multiset
266
Jonathan Hart7baba072015-02-23 14:27:59 -0800267 Interface egressIntf = configService.getMatchingInterface(entry.nextHopIp());
Jonathan Hartf5829202015-02-12 09:37:02 -0800268 if (egressIntf == null) {
Jonathan Hart7baba072015-02-23 14:27:59 -0800269 log.warn("no egress interface found for {}", entry);
Jonathan Hartf5829202015-02-12 09:37:02 -0800270 return;
271 }
272
Jonathan Hart7baba072015-02-23 14:27:59 -0800273 NextHopGroupKey groupKey = new NextHopGroupKey(entry.nextHopIp());
274
275 NextHop nextHop = new NextHop(entry.nextHopIp(), entry.nextHopMac(), groupKey);
Jonathan Hartf5829202015-02-12 09:37:02 -0800276
277 TrafficTreatment treatment = DefaultTrafficTreatment.builder()
278 .setEthSrc(egressIntf.mac())
279 .setEthDst(nextHop.mac())
Jonathan Hart54b406b2015-03-06 16:24:14 -0800280 .pushVlan()
Jonathan Hartf5829202015-02-12 09:37:02 -0800281 .setVlanId(egressIntf.vlan())
alshabibda1644e2015-03-13 14:01:35 -0700282 .setVlanPcp((byte) 0)
Jonathan Hartf5829202015-02-12 09:37:02 -0800283 .setOutput(egressIntf.connectPoint().port())
284 .build();
285
Saurav Das3ea46622015-04-22 14:01:34 -0700286 int nextId = flowObjectiveService.allocateNextId();
287
alshabib2a441c62015-04-13 18:39:38 -0700288 NextObjective nextObjective = DefaultNextObjective.builder()
Saurav Das3ea46622015-04-22 14:01:34 -0700289 .withId(nextId)
alshabib2a441c62015-04-13 18:39:38 -0700290 .addTreatment(treatment)
291 .withType(NextObjective.Type.SIMPLE)
292 .fromApp(appId)
Saurav Dasbd7f7422015-04-23 16:31:47 -0700293 .add(); // TODO add callbacks
alshabib2a441c62015-04-13 18:39:38 -0700294
295 flowObjectiveService.next(deviceId, nextObjective);
296
Saurav Das3ea46622015-04-22 14:01:34 -0700297 nextHops.put(nextHop.ip(), nextId);
Jonathan Hart7baba072015-02-23 14:27:59 -0800298
Jonathan Hartf5829202015-02-12 09:37:02 -0800299 }
Jonathan Hart7baba072015-02-23 14:27:59 -0800300
301 nextHopsCount.add(entry.nextHopIp());
Jonathan Hartf5829202015-02-12 09:37:02 -0800302 }
303
alshabib2a441c62015-04-13 18:39:38 -0700304 /*private synchronized Group deleteNextHop(IpPrefix prefix) {
Jonathan Hart7baba072015-02-23 14:27:59 -0800305 IpAddress nextHopIp = prefixToNextHop.remove(prefix);
306 NextHop nextHop = nextHops.get(nextHopIp);
307 if (nextHop == null) {
308 log.warn("No next hop found when removing prefix {}", prefix);
Jonathan Hart37d659c2015-03-08 19:20:38 -0700309 return null;
Jonathan Hart7baba072015-02-23 14:27:59 -0800310 }
311
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700312 Group group = groupService.getGroup(deviceId,
313 new DefaultGroupKey(appKryo.
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700314 serialize(nextHop.group())));
Jonathan Hart37d659c2015-03-08 19:20:38 -0700315
Jonathan Hartf9f2cbb2015-03-12 17:44:03 -0700316 // FIXME disabling group deletes for now until we verify the logic is OK
Saurav Dasbd7f7422015-04-23 16:31:47 -0700317 if (nextHopsCount.remove(nextHopIp, 1) <= 1) {
Jonathan Hartf5829202015-02-12 09:37:02 -0800318 // There was one or less next hops, so there are now none
319
Jonathan Hart7baba072015-02-23 14:27:59 -0800320 log.debug("removing group for next hop {}", nextHop);
Jonathan Hartf5829202015-02-12 09:37:02 -0800321
Jonathan Hart7baba072015-02-23 14:27:59 -0800322 nextHops.remove(nextHopIp);
323
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700324 groupService.removeGroup(deviceId,
325 new DefaultGroupKey(appKryo.build().serialize(nextHop.group())),
326 appId);
Saurav Dasbd7f7422015-04-23 16:31:47 -0700327 }
Jonathan Hart37d659c2015-03-08 19:20:38 -0700328
329 return group;
alshabib2a441c62015-04-13 18:39:38 -0700330 }*/
Jonathan Hartf5829202015-02-12 09:37:02 -0800331
332 private class InternalFibListener implements FibListener {
333
334 @Override
335 public void update(Collection<FibUpdate> updates,
336 Collection<FibUpdate> withdraws) {
337 BgpRouter.this.deleteFibEntry(withdraws);
338 BgpRouter.this.updateFibEntry(updates);
339 }
340 }
alshabib10580802015-02-18 18:30:33 -0800341
Saurav Dascfd63d22015-04-13 16:08:24 -0700342 private void processIntfFilters(boolean install, Set<Interface> intfs) {
343 log.info("Processing {} router interfaces", intfs.size());
344 for (Interface intf : intfs) {
345 FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
346 fob.withKey(Criteria.matchInPort(intf.connectPoint().port()))
347 .addCondition(Criteria.matchEthDst(intf.mac()))
348 .addCondition(Criteria.matchVlanId(intf.vlan()));
349 intf.ipAddresses().stream()
350 .forEach(ipaddr -> fob.addCondition(
351 Criteria.matchIPDst(ipaddr.subnetAddress())));
352 fob.permit().fromApp(appId);
Saurav Dasbd7f7422015-04-23 16:31:47 -0700353 flowObjectiveService.filter(
354 deviceId,
355 fob.add(new ObjectiveContext() {
356 @Override
357 public void onSuccess(Objective objective) {
358 log.info("Successfully installed interface based "
359 + "filtering objcetives");
360 }
361
362 @Override
363 public void onError(Objective objective,
364 ObjectiveError error) {
365 log.error("Failed to install interface filters {}: {}",
366 objective, error);
367 // TODO something more than just logging
368 }
369 }));
alshabib10580802015-02-18 18:30:33 -0800370 }
Jonathan Hart7baba072015-02-23 14:27:59 -0800371 }
alshabib10580802015-02-18 18:30:33 -0800372
Saurav Dasbd7f7422015-04-23 16:31:47 -0700373 // Triggers driver setup when a device is (re)detected.
374 private class InnerDeviceListener implements DeviceListener {
Jonathan Hart7baba072015-02-23 14:27:59 -0800375 @Override
Saurav Dasbd7f7422015-04-23 16:31:47 -0700376 public void event(DeviceEvent event) {
377 switch (event.type()) {
378 case DEVICE_ADDED:
379 case DEVICE_AVAILABILITY_CHANGED:
380 if (deviceService.isAvailable(event.subject().id())) {
381 log.info("Device connected {}", event.subject().id());
sanghof22fb402015-04-27 23:55:10 -0700382 if (event.subject().id().equals(deviceId)) {
383 processIntfFilters(true, configService.getInterfaces());
Jonathan Hart7baba072015-02-23 14:27:59 -0800384
sanghodde53d12015-04-30 10:34:41 -0700385 /* For test only - will be removed before Cardinal release
sanghof22fb402015-04-27 23:55:10 -0700386 delay(1000);
387 FibEntry fibEntry = new FibEntry(Ip4Prefix.valueOf("10.1.0.0/16"),
388 Ip4Address.valueOf("192.168.10.1"),
389 MacAddress.valueOf("DE:AD:BE:EF:FE:ED"));
390 FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, fibEntry);
391 updateFibEntry(Collections.singletonList(fibUpdate));
sanghodde53d12015-04-30 10:34:41 -0700392 */
sanghof22fb402015-04-27 23:55:10 -0700393 }
394
395 if (event.subject().id().equals(ctrlDeviceId)) {
396 connectivityManager.notifySwitchAvailable();
397 }
Saurav Dasbd7f7422015-04-23 16:31:47 -0700398 }
399 break;
Jonathan Hart5b141422015-03-06 12:59:09 -0800400
Saurav Dasbd7f7422015-04-23 16:31:47 -0700401 // TODO other cases
402 case DEVICE_UPDATED:
403 break;
404 case DEVICE_REMOVED:
405 break;
406 case DEVICE_SUSPENDED:
407 break;
408 case PORT_ADDED:
409 break;
410 case PORT_UPDATED:
411 break;
412 case PORT_REMOVED:
413 break;
414 default:
415 break;
Jonathan Hart7baba072015-02-23 14:27:59 -0800416 }
417 }
Saurav Dasbd7f7422015-04-23 16:31:47 -0700418 }
Jonathan Hartf5829202015-02-12 09:37:02 -0800419}