blob: 0d564f195db3d71e61a4e72ba2df7fe19b008f37 [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;
Srikanth Vavilapalli89ad3772015-03-25 18:00:38 -070030import org.onlab.packet.Ip4Address;
alshabib2a441c62015-04-13 18:39:38 -070031import org.onlab.packet.Ip4Prefix;
Jonathan Hart7baba072015-02-23 14:27:59 -080032import org.onlab.packet.IpAddress;
33import org.onlab.packet.IpPrefix;
alshabib2a441c62015-04-13 18:39:38 -070034import org.onlab.packet.MacAddress;
Jonathan Hart54b406b2015-03-06 16:24:14 -080035import org.onosproject.config.NetworkConfigService;
Jonathan Hartf5829202015-02-12 09:37:02 -080036import org.onosproject.core.ApplicationId;
37import org.onosproject.core.CoreService;
38import org.onosproject.net.DeviceId;
Saurav Dasbd7f7422015-04-23 16:31:47 -070039import org.onosproject.net.device.DeviceEvent;
40import org.onosproject.net.device.DeviceListener;
41import org.onosproject.net.device.DeviceService;
Jonathan Hartf5829202015-02-12 09:37:02 -080042import org.onosproject.net.flow.DefaultTrafficSelector;
43import org.onosproject.net.flow.DefaultTrafficTreatment;
Jonathan Hartf5829202015-02-12 09:37:02 -080044import org.onosproject.net.flow.TrafficSelector;
45import org.onosproject.net.flow.TrafficTreatment;
alshabib910aff12015-04-09 16:55:57 -070046import org.onosproject.net.flow.criteria.Criteria;
47import org.onosproject.net.flowobjective.DefaultFilteringObjective;
alshabib2a441c62015-04-13 18:39:38 -070048import org.onosproject.net.flowobjective.DefaultForwardingObjective;
49import org.onosproject.net.flowobjective.DefaultNextObjective;
alshabib910aff12015-04-09 16:55:57 -070050import org.onosproject.net.flowobjective.FilteringObjective;
51import org.onosproject.net.flowobjective.FlowObjectiveService;
alshabib2a441c62015-04-13 18:39:38 -070052import org.onosproject.net.flowobjective.ForwardingObjective;
53import org.onosproject.net.flowobjective.NextObjective;
Saurav Dasbd7f7422015-04-23 16:31:47 -070054import org.onosproject.net.flowobjective.Objective;
55import org.onosproject.net.flowobjective.ObjectiveContext;
56import org.onosproject.net.flowobjective.ObjectiveError;
Jonathan Hartf5829202015-02-12 09:37:02 -080057import org.onosproject.net.packet.PacketService;
Jonathan Hart7baba072015-02-23 14:27:59 -080058import org.onosproject.routing.FibEntry;
Jonathan Hart2da1e602015-02-18 19:09:24 -080059import org.onosproject.routing.FibListener;
60import org.onosproject.routing.FibUpdate;
61import org.onosproject.routing.RoutingService;
Saurav Dasfbe25c52015-03-04 11:12:00 -080062import org.onosproject.routing.config.BgpSpeaker;
Jonathan Hart2da1e602015-02-18 19:09:24 -080063import org.onosproject.routing.config.Interface;
64import org.onosproject.routing.config.RoutingConfigurationService;
Jonathan Hartf5829202015-02-12 09:37:02 -080065import org.slf4j.Logger;
66import org.slf4j.LoggerFactory;
67
alshabib910aff12015-04-09 16:55:57 -070068import java.util.Collection;
69import java.util.Collections;
70import java.util.HashMap;
alshabib910aff12015-04-09 16:55:57 -070071import java.util.Map;
72import java.util.Set;
alshabib2a441c62015-04-13 18:39:38 -070073
74import static org.onlab.util.Tools.delay;
Jonathan Hartf5829202015-02-12 09:37:02 -080075
76/**
77 * BgpRouter component.
78 */
79@Component(immediate = true)
80public class BgpRouter {
81
82 private static final Logger log = LoggerFactory.getLogger(BgpRouter.class);
83
84 private static final String BGP_ROUTER_APP = "org.onosproject.bgprouter";
85
Jonathan Hart12ef2052015-03-10 13:58:13 -070086 private static final int PRIORITY_OFFSET = 100;
87 private static final int PRIORITY_MULTIPLIER = 5;
Jonathan Hartf5829202015-02-12 09:37:02 -080088
89 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
90 protected CoreService coreService;
91
92 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Jonathan Hartf5829202015-02-12 09:37:02 -080093 protected RoutingService routingService;
94
95 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
96 protected RoutingConfigurationService configService;
97
98 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
99 protected PacketService packetService;
100
Saurav Dasbd7f7422015-04-23 16:31:47 -0700101 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
102 protected FlowObjectiveService flowObjectiveService;
103
104 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
105 protected DeviceService deviceService;
106
Saurav Dasfbe25c52015-03-04 11:12:00 -0800107 //
108 // NOTE: Unused reference - needed to guarantee that the
109 // NetworkConfigReader component is activated and the network configuration
110 // is read.
111 //
112 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
113 protected NetworkConfigService networkConfigService;
114
Jonathan Hartf5829202015-02-12 09:37:02 -0800115 private ApplicationId appId;
116
Jonathan Hart7baba072015-02-23 14:27:59 -0800117 // Reference count for how many times a next hop is used by a route
118 private final Multiset<IpAddress> nextHopsCount = ConcurrentHashMultiset.create();
119
120 // Mapping from prefix to its current next hop
121 private final Map<IpPrefix, IpAddress> prefixToNextHop = Maps.newHashMap();
122
123 // Mapping from next hop IP to next hop object containing group info
alshabib2a441c62015-04-13 18:39:38 -0700124 private final Map<IpAddress, Integer> nextHops = Maps.newHashMap();
Jonathan Hart7baba072015-02-23 14:27:59 -0800125
126 // Stores FIB updates that are waiting for groups to be set up
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700127 private final Multimap<NextHopGroupKey, FibEntry> pendingUpdates = HashMultimap.create();
Jonathan Hartf5829202015-02-12 09:37:02 -0800128
Saurav Dasfbe25c52015-03-04 11:12:00 -0800129 // Device id of data-plane switch - should be learned from config
130 private DeviceId deviceId;
131
132 // Device id of control-plane switch (OVS) connected to BGP Speaker - should be
133 // learned from config
134 private DeviceId ctrlDeviceId;
Jonathan Hartf5829202015-02-12 09:37:02 -0800135
Saurav Dasbd7f7422015-04-23 16:31:47 -0700136 // Responsible for handling BGP traffic (encapsulated within OF messages)
137 // between the data-plane switch and the Quagga VM using a control plane OVS.
Jonathan Hartf5829202015-02-12 09:37:02 -0800138 private TunnellingConnectivityManager connectivityManager;
139
Saurav Dasbd7f7422015-04-23 16:31:47 -0700140 private DeviceListener deviceListener;
sangho5eaf0332015-03-09 15:08:12 -0700141 private IcmpHandler icmpHandler;
142
Jonathan Hartf5829202015-02-12 09:37:02 -0800143 @Activate
144 protected void activate() {
Jonathan Hartf5829202015-02-12 09:37:02 -0800145 appId = coreService.registerApplication(BGP_ROUTER_APP);
Saurav Dasfbe25c52015-03-04 11:12:00 -0800146 getDeviceConfiguration(configService.getBgpSpeakers());
Jonathan Hartf5829202015-02-12 09:37:02 -0800147
148 connectivityManager = new TunnellingConnectivityManager(appId,
149 configService,
Jonathan Hart936a7292015-03-06 18:02:57 -0800150 packetService,
Saurav Das3d038262015-04-23 12:36:58 -0700151 flowObjectiveService);
Jonathan Hartf5829202015-02-12 09:37:02 -0800152
sangho5eaf0332015-03-09 15:08:12 -0700153 icmpHandler = new IcmpHandler(configService, packetService);
Saurav Dasbd7f7422015-04-23 16:31:47 -0700154 deviceListener = new InnerDeviceListener();
Pingping Line28ae4c2015-03-13 11:37:03 -0700155 routingService.addFibListener(new InternalFibListener());
156 routingService.start();
Saurav Dasbd7f7422015-04-23 16:31:47 -0700157 deviceService.addListener(deviceListener);
Jonathan Hartf5829202015-02-12 09:37:02 -0800158 connectivityManager.start();
sangho5eaf0332015-03-09 15:08:12 -0700159 icmpHandler.start();
160
Jonathan Hartf5829202015-02-12 09:37:02 -0800161 log.info("BgpRouter started");
162 }
163
164 @Deactivate
165 protected void deactivate() {
166 routingService.stop();
167 connectivityManager.stop();
sangho5eaf0332015-03-09 15:08:12 -0700168 icmpHandler.stop();
Saurav Dasbd7f7422015-04-23 16:31:47 -0700169 deviceService.removeListener(deviceListener);
170 //processIntfFilters(false, configService.getInterfaces()); //TODO necessary?
Jonathan Hartf5829202015-02-12 09:37:02 -0800171 log.info("BgpRouter stopped");
172 }
173
Saurav Dasfbe25c52015-03-04 11:12:00 -0800174 private void getDeviceConfiguration(Map<String, BgpSpeaker> bgps) {
175 if (bgps == null || bgps.values().isEmpty()) {
176 log.error("BGP speakers configuration is missing");
177 return;
178 }
179 for (BgpSpeaker s : bgps.values()) {
180 ctrlDeviceId = s.connectPoint().deviceId();
181 if (s.interfaceAddresses() == null || s.interfaceAddresses().isEmpty()) {
182 log.error("BGP Router must have interfaces configured");
183 return;
184 }
185 deviceId = s.interfaceAddresses().get(0).connectPoint().deviceId();
186 break;
187 }
sangho5eaf0332015-03-09 15:08:12 -0700188
Saurav Dasfbe25c52015-03-04 11:12:00 -0800189 log.info("Router dpid: {}", deviceId);
190 log.info("Control Plane OVS dpid: {}", ctrlDeviceId);
191 }
192
Jonathan Hartf5829202015-02-12 09:37:02 -0800193 private void updateFibEntry(Collection<FibUpdate> updates) {
alshabib2a441c62015-04-13 18:39:38 -0700194 Map<FibEntry, Integer> toInstall = new HashMap<>(updates.size());
Jonathan Hart5b141422015-03-06 12:59:09 -0800195
Jonathan Hartf5829202015-02-12 09:37:02 -0800196 for (FibUpdate update : updates) {
Jonathan Hart7baba072015-02-23 14:27:59 -0800197 FibEntry entry = update.entry();
Jonathan Hartf5829202015-02-12 09:37:02 -0800198
Jonathan Hart7baba072015-02-23 14:27:59 -0800199 addNextHop(entry);
Jonathan Hartf5829202015-02-12 09:37:02 -0800200
alshabib2a441c62015-04-13 18:39:38 -0700201 Integer nextId;
Jonathan Hart7baba072015-02-23 14:27:59 -0800202 synchronized (pendingUpdates) {
alshabib2a441c62015-04-13 18:39:38 -0700203 nextId = nextHops.get(entry.nextHopIp());
Jonathan Hartf5829202015-02-12 09:37:02 -0800204 }
205
alshabib2a441c62015-04-13 18:39:38 -0700206 toInstall.put(update.entry(), nextId);
Jonathan Hartf5829202015-02-12 09:37:02 -0800207 }
Jonathan Hart5b141422015-03-06 12:59:09 -0800208
209 installFlows(toInstall);
Jonathan Hartf5829202015-02-12 09:37:02 -0800210 }
211
alshabib2a441c62015-04-13 18:39:38 -0700212 private void installFlows(Map<FibEntry, Integer> entriesToInstall) {
Jonathan Hart7baba072015-02-23 14:27:59 -0800213
alshabib2a441c62015-04-13 18:39:38 -0700214 for (Map.Entry<FibEntry, Integer> entry : entriesToInstall.entrySet()) {
Jonathan Hart5b141422015-03-06 12:59:09 -0800215 FibEntry fibEntry = entry.getKey();
alshabib2a441c62015-04-13 18:39:38 -0700216 Integer nextId = entry.getValue();
Jonathan Hart5b141422015-03-06 12:59:09 -0800217
alshabib2a441c62015-04-13 18:39:38 -0700218 flowObjectiveService.forward(deviceId,
Saurav Dasbd7f7422015-04-23 16:31:47 -0700219 generateRibForwardingObj(fibEntry.prefix(), nextId).add());
Saurav Das3d038262015-04-23 12:36:58 -0700220 log.trace("Sending forwarding objective {} -> nextId:{}", fibEntry, nextId);
Jonathan Hart5b141422015-03-06 12:59:09 -0800221 }
222
Jonathan Hart7baba072015-02-23 14:27:59 -0800223 }
224
225 private synchronized void deleteFibEntry(Collection<FibUpdate> withdraws) {
Jonathan Hart5b141422015-03-06 12:59:09 -0800226
Jonathan Hart7baba072015-02-23 14:27:59 -0800227 for (FibUpdate update : withdraws) {
228 FibEntry entry = update.entry();
alshabib2a441c62015-04-13 18:39:38 -0700229 Integer nextId = nextHops.get(entry.nextHopIp());
Jonathan Hart7baba072015-02-23 14:27:59 -0800230
Saurav Dasbd7f7422015-04-23 16:31:47 -0700231 /* Group group = deleteNextHop(entry.prefix());
Jonathan Hart37d659c2015-03-08 19:20:38 -0700232 if (group == null) {
233 log.warn("Group not found when deleting {}", entry);
234 return;
alshabib2a441c62015-04-13 18:39:38 -0700235 }*/
Jonathan Hartf5829202015-02-12 09:37:02 -0800236
alshabib2a441c62015-04-13 18:39:38 -0700237 flowObjectiveService.forward(deviceId,
Saurav Dasbd7f7422015-04-23 16:31:47 -0700238 generateRibForwardingObj(entry.prefix(), nextId).remove());
Jonathan Hartf5829202015-02-12 09:37:02 -0800239
Jonathan Hartf5829202015-02-12 09:37:02 -0800240 }
Jonathan Hart5b141422015-03-06 12:59:09 -0800241
Jonathan Hartf5829202015-02-12 09:37:02 -0800242 }
243
Saurav Dasbd7f7422015-04-23 16:31:47 -0700244 private ForwardingObjective.Builder generateRibForwardingObj(IpPrefix prefix,
245 Integer nextId) {
Jonathan Hart37d659c2015-03-08 19:20:38 -0700246 TrafficSelector selector = DefaultTrafficSelector.builder()
247 .matchEthType(Ethernet.TYPE_IPV4)
248 .matchIPDst(prefix)
249 .build();
250
Jonathan Hart12ef2052015-03-10 13:58:13 -0700251 int priority = prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET;
252
alshabib2a441c62015-04-13 18:39:38 -0700253 ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective.builder()
254 .fromApp(appId)
255 .makePermanent()
256 .nextStep(nextId)
257 .withSelector(selector)
258 .withPriority(priority)
259 .withFlag(ForwardingObjective.Flag.SPECIFIC);
260
261 return fwdBuilder;
Jonathan Hart37d659c2015-03-08 19:20:38 -0700262 }
263
Jonathan Hart7baba072015-02-23 14:27:59 -0800264 private synchronized void addNextHop(FibEntry entry) {
265 prefixToNextHop.put(entry.prefix(), entry.nextHopIp());
266 if (nextHopsCount.count(entry.nextHopIp()) == 0) {
Jonathan Hartf5829202015-02-12 09:37:02 -0800267 // There was no next hop in the multiset
268
Jonathan Hart7baba072015-02-23 14:27:59 -0800269 Interface egressIntf = configService.getMatchingInterface(entry.nextHopIp());
Jonathan Hartf5829202015-02-12 09:37:02 -0800270 if (egressIntf == null) {
Jonathan Hart7baba072015-02-23 14:27:59 -0800271 log.warn("no egress interface found for {}", entry);
Jonathan Hartf5829202015-02-12 09:37:02 -0800272 return;
273 }
274
Jonathan Hart7baba072015-02-23 14:27:59 -0800275 NextHopGroupKey groupKey = new NextHopGroupKey(entry.nextHopIp());
276
277 NextHop nextHop = new NextHop(entry.nextHopIp(), entry.nextHopMac(), groupKey);
Jonathan Hartf5829202015-02-12 09:37:02 -0800278
279 TrafficTreatment treatment = DefaultTrafficTreatment.builder()
280 .setEthSrc(egressIntf.mac())
281 .setEthDst(nextHop.mac())
Jonathan Hart54b406b2015-03-06 16:24:14 -0800282 .pushVlan()
Jonathan Hartf5829202015-02-12 09:37:02 -0800283 .setVlanId(egressIntf.vlan())
alshabibda1644e2015-03-13 14:01:35 -0700284 .setVlanPcp((byte) 0)
Jonathan Hartf5829202015-02-12 09:37:02 -0800285 .setOutput(egressIntf.connectPoint().port())
286 .build();
287
Saurav Das3ea46622015-04-22 14:01:34 -0700288 int nextId = flowObjectiveService.allocateNextId();
289
alshabib2a441c62015-04-13 18:39:38 -0700290 NextObjective nextObjective = DefaultNextObjective.builder()
Saurav Das3ea46622015-04-22 14:01:34 -0700291 .withId(nextId)
alshabib2a441c62015-04-13 18:39:38 -0700292 .addTreatment(treatment)
293 .withType(NextObjective.Type.SIMPLE)
294 .fromApp(appId)
Saurav Dasbd7f7422015-04-23 16:31:47 -0700295 .add(); // TODO add callbacks
alshabib2a441c62015-04-13 18:39:38 -0700296
297 flowObjectiveService.next(deviceId, nextObjective);
298
Saurav Das3ea46622015-04-22 14:01:34 -0700299 nextHops.put(nextHop.ip(), nextId);
Jonathan Hart7baba072015-02-23 14:27:59 -0800300
Jonathan Hartf5829202015-02-12 09:37:02 -0800301 }
Jonathan Hart7baba072015-02-23 14:27:59 -0800302
303 nextHopsCount.add(entry.nextHopIp());
Jonathan Hartf5829202015-02-12 09:37:02 -0800304 }
305
alshabib2a441c62015-04-13 18:39:38 -0700306 /*private synchronized Group deleteNextHop(IpPrefix prefix) {
Jonathan Hart7baba072015-02-23 14:27:59 -0800307 IpAddress nextHopIp = prefixToNextHop.remove(prefix);
308 NextHop nextHop = nextHops.get(nextHopIp);
309 if (nextHop == null) {
310 log.warn("No next hop found when removing prefix {}", prefix);
Jonathan Hart37d659c2015-03-08 19:20:38 -0700311 return null;
Jonathan Hart7baba072015-02-23 14:27:59 -0800312 }
313
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700314 Group group = groupService.getGroup(deviceId,
315 new DefaultGroupKey(appKryo.
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700316 serialize(nextHop.group())));
Jonathan Hart37d659c2015-03-08 19:20:38 -0700317
Jonathan Hartf9f2cbb2015-03-12 17:44:03 -0700318 // FIXME disabling group deletes for now until we verify the logic is OK
Saurav Dasbd7f7422015-04-23 16:31:47 -0700319 if (nextHopsCount.remove(nextHopIp, 1) <= 1) {
Jonathan Hartf5829202015-02-12 09:37:02 -0800320 // There was one or less next hops, so there are now none
321
Jonathan Hart7baba072015-02-23 14:27:59 -0800322 log.debug("removing group for next hop {}", nextHop);
Jonathan Hartf5829202015-02-12 09:37:02 -0800323
Jonathan Hart7baba072015-02-23 14:27:59 -0800324 nextHops.remove(nextHopIp);
325
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -0700326 groupService.removeGroup(deviceId,
327 new DefaultGroupKey(appKryo.build().serialize(nextHop.group())),
328 appId);
Saurav Dasbd7f7422015-04-23 16:31:47 -0700329 }
Jonathan Hart37d659c2015-03-08 19:20:38 -0700330
331 return group;
alshabib2a441c62015-04-13 18:39:38 -0700332 }*/
Jonathan Hartf5829202015-02-12 09:37:02 -0800333
334 private class InternalFibListener implements FibListener {
335
336 @Override
337 public void update(Collection<FibUpdate> updates,
338 Collection<FibUpdate> withdraws) {
339 BgpRouter.this.deleteFibEntry(withdraws);
340 BgpRouter.this.updateFibEntry(updates);
341 }
342 }
alshabib10580802015-02-18 18:30:33 -0800343
Saurav Dascfd63d22015-04-13 16:08:24 -0700344 private void processIntfFilters(boolean install, Set<Interface> intfs) {
345 log.info("Processing {} router interfaces", intfs.size());
346 for (Interface intf : intfs) {
347 FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
348 fob.withKey(Criteria.matchInPort(intf.connectPoint().port()))
349 .addCondition(Criteria.matchEthDst(intf.mac()))
350 .addCondition(Criteria.matchVlanId(intf.vlan()));
351 intf.ipAddresses().stream()
352 .forEach(ipaddr -> fob.addCondition(
353 Criteria.matchIPDst(ipaddr.subnetAddress())));
354 fob.permit().fromApp(appId);
Saurav Dasbd7f7422015-04-23 16:31:47 -0700355 flowObjectiveService.filter(
356 deviceId,
357 fob.add(new ObjectiveContext() {
358 @Override
359 public void onSuccess(Objective objective) {
360 log.info("Successfully installed interface based "
361 + "filtering objcetives");
362 }
363
364 @Override
365 public void onError(Objective objective,
366 ObjectiveError error) {
367 log.error("Failed to install interface filters {}: {}",
368 objective, error);
369 // TODO something more than just logging
370 }
371 }));
alshabib10580802015-02-18 18:30:33 -0800372 }
Jonathan Hart7baba072015-02-23 14:27:59 -0800373 }
alshabib10580802015-02-18 18:30:33 -0800374
Saurav Dasbd7f7422015-04-23 16:31:47 -0700375 // Triggers driver setup when a device is (re)detected.
376 private class InnerDeviceListener implements DeviceListener {
Jonathan Hart7baba072015-02-23 14:27:59 -0800377 @Override
Saurav Dasbd7f7422015-04-23 16:31:47 -0700378 public void event(DeviceEvent event) {
379 switch (event.type()) {
380 case DEVICE_ADDED:
381 case DEVICE_AVAILABILITY_CHANGED:
382 if (deviceService.isAvailable(event.subject().id())) {
383 log.info("Device connected {}", event.subject().id());
384 processIntfFilters(true, configService.getInterfaces());
Jonathan Hart7baba072015-02-23 14:27:59 -0800385
Saurav Dasbd7f7422015-04-23 16:31:47 -0700386 /* For test only - will be removed before Cardinal release */
387 delay(1000);
388 FibEntry fibEntry = new FibEntry(Ip4Prefix.valueOf("10.1.0.0/16"),
389 Ip4Address.valueOf("192.168.10.1"),
390 MacAddress.valueOf("DE:AD:BE:EF:FE:ED"));
391 FibUpdate fibUpdate = new FibUpdate(FibUpdate.Type.UPDATE, fibEntry);
392 updateFibEntry(Collections.singletonList(fibUpdate));
393 }
394 break;
Jonathan Hart5b141422015-03-06 12:59:09 -0800395
Saurav Dasbd7f7422015-04-23 16:31:47 -0700396 // TODO other cases
397 case DEVICE_UPDATED:
398 break;
399 case DEVICE_REMOVED:
400 break;
401 case DEVICE_SUSPENDED:
402 break;
403 case PORT_ADDED:
404 break;
405 case PORT_UPDATED:
406 break;
407 case PORT_REMOVED:
408 break;
409 default:
410 break;
Jonathan Hart7baba072015-02-23 14:27:59 -0800411 }
412 }
Saurav Dasbd7f7422015-04-23 16:31:47 -0700413 }
Jonathan Hartf5829202015-02-12 09:37:02 -0800414}