Srikanth Vavilapalli
Committed by Gerrit Code Review

Segment Routing refactor with flow objectives

Change-Id: I0b87f89bb8b18522b9d38bdf5e96f55485b6f1e3
Showing 22 changed files with 718 additions and 173 deletions
...@@ -24,7 +24,6 @@ import org.onosproject.net.Device; ...@@ -24,7 +24,6 @@ import org.onosproject.net.Device;
24 import org.onosproject.net.DeviceId; 24 import org.onosproject.net.DeviceId;
25 import org.onosproject.net.Link; 25 import org.onosproject.net.Link;
26 import org.onosproject.net.MastershipRole; 26 import org.onosproject.net.MastershipRole;
27 -import org.onosproject.net.flow.FlowRule;
28 import org.slf4j.Logger; 27 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory; 28 import org.slf4j.LoggerFactory;
30 29
...@@ -38,7 +37,8 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -38,7 +37,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
38 37
39 public class DefaultRoutingHandler { 38 public class DefaultRoutingHandler {
40 39
41 - private static Logger log = LoggerFactory.getLogger(DefaultRoutingHandler.class); 40 + private static Logger log = LoggerFactory
41 + .getLogger(DefaultRoutingHandler.class);
42 42
43 private SegmentRoutingManager srManager; 43 private SegmentRoutingManager srManager;
44 private RoutingRulePopulator rulePopulator; 44 private RoutingRulePopulator rulePopulator;
...@@ -56,7 +56,8 @@ public class DefaultRoutingHandler { ...@@ -56,7 +56,8 @@ public class DefaultRoutingHandler {
56 // population process started. 56 // population process started.
57 STARTED, 57 STARTED,
58 58
59 - // population process was aborted due to errors, mostly for groups not found. 59 + // population process was aborted due to errors, mostly for groups not
60 + // found.
60 ABORTED, 61 ABORTED,
61 62
62 // population process was finished successfully. 63 // population process was finished successfully.
...@@ -89,8 +90,7 @@ public class DefaultRoutingHandler { ...@@ -89,8 +90,7 @@ public class DefaultRoutingHandler {
89 log.info("Starts to populate routing rules"); 90 log.info("Starts to populate routing rules");
90 91
91 for (Device sw : srManager.deviceService.getDevices()) { 92 for (Device sw : srManager.deviceService.getDevices()) {
92 - if (srManager.mastershipService. 93 + if (srManager.mastershipService.getLocalRole(sw.id()) != MastershipRole.MASTER) {
93 - getLocalRole(sw.id()) != MastershipRole.MASTER) {
94 continue; 94 continue;
95 } 95 }
96 96
...@@ -323,11 +323,11 @@ public class DefaultRoutingHandler { ...@@ -323,11 +323,11 @@ public class DefaultRoutingHandler {
323 private boolean populateEcmpRoutingRules(DeviceId destSw, 323 private boolean populateEcmpRoutingRules(DeviceId destSw,
324 ECMPShortestPathGraph ecmpSPG) { 324 ECMPShortestPathGraph ecmpSPG) {
325 325
326 - HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> switchVia = 326 + HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> switchVia = ecmpSPG
327 - ecmpSPG.getAllLearnedSwitchesAndVia(); 327 + .getAllLearnedSwitchesAndVia();
328 for (Integer itrIdx : switchVia.keySet()) { 328 for (Integer itrIdx : switchVia.keySet()) {
329 - HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swViaMap = 329 + HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swViaMap = switchVia
330 - switchVia.get(itrIdx); 330 + .get(itrIdx);
331 for (DeviceId targetSw : swViaMap.keySet()) { 331 for (DeviceId targetSw : swViaMap.keySet()) {
332 Set<DeviceId> nextHops = new HashSet<>(); 332 Set<DeviceId> nextHops = new HashSet<>();
333 333
...@@ -347,7 +347,8 @@ public class DefaultRoutingHandler { ...@@ -347,7 +347,8 @@ public class DefaultRoutingHandler {
347 return true; 347 return true;
348 } 348 }
349 349
350 - private boolean populateEcmpRoutingRulePartial(DeviceId targetSw, DeviceId destSw, 350 + private boolean populateEcmpRoutingRulePartial(DeviceId targetSw,
351 + DeviceId destSw,
351 Set<DeviceId> nextHops) { 352 Set<DeviceId> nextHops) {
352 boolean result; 353 boolean result;
353 354
...@@ -355,7 +356,8 @@ public class DefaultRoutingHandler { ...@@ -355,7 +356,8 @@ public class DefaultRoutingHandler {
355 nextHops.add(destSw); 356 nextHops.add(destSw);
356 } 357 }
357 358
358 - // If both target switch and dest switch are edge routers, then set IP rule 359 + // If both target switch and dest switch are edge routers, then set IP
360 + // rule
359 // for both subnet and router IP. 361 // for both subnet and router IP.
360 if (config.isEdgeDevice(targetSw) && config.isEdgeDevice(destSw)) { 362 if (config.isEdgeDevice(targetSw) && config.isEdgeDevice(destSw)) {
361 List<Ip4Prefix> subnets = config.getSubnets(destSw); 363 List<Ip4Prefix> subnets = config.getSubnets(destSw);
...@@ -374,7 +376,7 @@ public class DefaultRoutingHandler { ...@@ -374,7 +376,7 @@ public class DefaultRoutingHandler {
374 return false; 376 return false;
375 } 377 }
376 378
377 - // If the target switch is an edge router, then set IP rules for the router IP. 379 + // TODO: If the target switch is an edge router, then set IP rules for the router IP.
378 } else if (config.isEdgeDevice(targetSw)) { 380 } else if (config.isEdgeDevice(targetSw)) {
379 Ip4Address routerIp = config.getRouterIp(destSw); 381 Ip4Address routerIp = config.getRouterIp(destSw);
380 IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); 382 IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH);
...@@ -383,7 +385,7 @@ public class DefaultRoutingHandler { ...@@ -383,7 +385,7 @@ public class DefaultRoutingHandler {
383 return false; 385 return false;
384 } 386 }
385 387
386 - // If the target switch is an transit router, then set MPLS rules only. 388 + // TODO: If the target switch is an transit router, then set MPLS rules only.
387 } else if (!config.isEdgeDevice(targetSw)) { 389 } else if (!config.isEdgeDevice(targetSw)) {
388 result = rulePopulator.populateMplsRule(targetSw, destSw, nextHops); 390 result = rulePopulator.populateMplsRule(targetSw, destSw, nextHops);
389 if (!result) { 391 if (!result) {
...@@ -395,38 +397,25 @@ public class DefaultRoutingHandler { ...@@ -395,38 +397,25 @@ public class DefaultRoutingHandler {
395 } 397 }
396 398
397 /** 399 /**
398 - * Populates table miss entries for all tables, and pipeline rules for 400 + * Populates table miss entries for all tables, and pipeline rules for VLAN
399 - * VLAN and TACM tables. 401 + * and TACM tables.
400 * 402 *
401 * @param deviceId Switch ID to set the rules 403 * @param deviceId Switch ID to set the rules
402 */ 404 */
403 public void populateTtpRules(DeviceId deviceId) { 405 public void populateTtpRules(DeviceId deviceId) {
404 -
405 - rulePopulator.populateTableMissEntry(deviceId, FlowRule.Type.VLAN,
406 - true, false, false, FlowRule.Type.DEFAULT);
407 - rulePopulator.populateTableMissEntry(deviceId, FlowRule.Type.ETHER,
408 - true, false, false, FlowRule.Type.DEFAULT);
409 - rulePopulator.populateTableMissEntry(deviceId, FlowRule.Type.IP,
410 - false, true, true, FlowRule.Type.ACL);
411 - rulePopulator.populateTableMissEntry(deviceId, FlowRule.Type.MPLS,
412 - false, true, true, FlowRule.Type.ACL);
413 - rulePopulator.populateTableMissEntry(deviceId, FlowRule.Type.ACL,
414 - false, false, false, FlowRule.Type.DEFAULT);
415 -
416 rulePopulator.populateTableVlan(deviceId); 406 rulePopulator.populateTableVlan(deviceId);
417 rulePopulator.populateTableTMac(deviceId); 407 rulePopulator.populateTableTMac(deviceId);
418 } 408 }
419 409
420 /** 410 /**
421 - * Start the flow rule population process if it was never started. 411 + * Start the flow rule population process if it was never started. The
422 - * The process finishes successfully when all flow rules are set and 412 + * process finishes successfully when all flow rules are set and stops with
423 - * stops with ABORTED status when any groups required for flows is not 413 + * ABORTED status when any groups required for flows is not set yet.
424 - * set yet.
425 */ 414 */
426 public void startPopulationProcess() { 415 public void startPopulationProcess() {
427 synchronized (populationStatus) { 416 synchronized (populationStatus) {
428 - if (populationStatus == Status.IDLE || 417 + if (populationStatus == Status.IDLE
429 - populationStatus == Status.SUCCEEDED) { 418 + || populationStatus == Status.SUCCEEDED) {
430 populationStatus = Status.STARTED; 419 populationStatus = Status.STARTED;
431 populateAllRoutingRules(); 420 populateAllRoutingRules();
432 } 421 }
...@@ -441,7 +430,8 @@ public class DefaultRoutingHandler { ...@@ -441,7 +430,8 @@ public class DefaultRoutingHandler {
441 synchronized (populationStatus) { 430 synchronized (populationStatus) {
442 if (populationStatus == Status.ABORTED) { 431 if (populationStatus == Status.ABORTED) {
443 populationStatus = Status.STARTED; 432 populationStatus = Status.STARTED;
444 - // TODO: we need to restart from the point aborted instead of restarting. 433 + // TODO: we need to restart from the point aborted instead of
434 + // restarting.
445 populateAllRoutingRules(); 435 populateAllRoutingRules();
446 } 436 }
447 } 437 }
......
1 +/*
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 + */
16 +package org.onosproject.segmentrouting;
17 +
18 +import com.google.common.collect.Lists;
19 +
20 +import org.onlab.packet.Ip4Address;
21 +import org.onlab.packet.Ip4Prefix;
22 +import org.onlab.packet.IpPrefix;
23 +import org.onlab.packet.MacAddress;
24 +import org.onosproject.net.DeviceId;
25 +import org.onosproject.net.Link;
26 +import org.onosproject.net.PortNumber;
27 +import org.slf4j.Logger;
28 +import org.slf4j.LoggerFactory;
29 +
30 +import java.util.List;
31 +import java.util.Set;
32 +
33 +/**
34 + * This class is temporary class and used only for test.
35 + * It will be replaced with "real" Network Config Manager.
36 + *
37 + * TODO: Knock off this wrapper and directly use DeviceConfiguration class
38 + */
39 +
40 +public class NetworkConfigHandler {
41 +
42 + private static Logger log = LoggerFactory.getLogger(NetworkConfigHandler.class);
43 + private SegmentRoutingManager srManager;
44 + private DeviceConfiguration deviceConfig;
45 +
46 + public NetworkConfigHandler(SegmentRoutingManager srManager,
47 + DeviceConfiguration deviceConfig) {
48 + this.srManager = srManager;
49 + this.deviceConfig = deviceConfig;
50 + }
51 +
52 + public List<Ip4Address> getGatewayIpAddress(DeviceId deviceId) {
53 + return this.deviceConfig.getSubnetGatewayIps(deviceId);
54 + }
55 +
56 + public IpPrefix getRouterIpAddress(DeviceId deviceId) {
57 + return IpPrefix.valueOf(deviceConfig.getRouterIp(deviceId), 32);
58 + }
59 +
60 + public MacAddress getRouterMacAddress(DeviceId deviceId) {
61 + return deviceConfig.getDeviceMac(deviceId);
62 + }
63 +
64 + public boolean inSameSubnet(DeviceId deviceId, Ip4Address destIp) {
65 +
66 + List<Ip4Prefix> subnets = getSubnetInfo(deviceId);
67 + if (subnets == null) {
68 + return false;
69 + }
70 +
71 + return subnets.stream()
72 + .anyMatch((subnet) -> subnet.contains(destIp));
73 + }
74 +
75 + public boolean inSameSubnet(Ip4Address address, int sid) {
76 + DeviceId deviceId = deviceConfig.getDeviceId(sid);
77 + if (deviceId == null) {
78 + log.warn("Cannot find a device for SID {}", sid);
79 + return false;
80 + }
81 +
82 + return inSameSubnet(deviceId, address);
83 + }
84 +
85 + public List<Ip4Prefix> getSubnetInfo(DeviceId deviceId) {
86 + return deviceConfig.getSubnets(deviceId);
87 + }
88 +
89 + public int getMplsId(DeviceId deviceId) {
90 + return deviceConfig.getSegmentId(deviceId);
91 + }
92 +
93 + public int getMplsId(MacAddress routerMac) {
94 + return deviceConfig.getSegmentId(routerMac);
95 + }
96 +
97 + public int getMplsId(Ip4Address routerIpAddress) {
98 + return deviceConfig.getSegmentId(routerIpAddress);
99 + }
100 +
101 + public boolean isEcmpNotSupportedInTransit(DeviceId deviceId) {
102 + //TODO: temporarily changing to true to test with Dell
103 + return true;
104 + }
105 +
106 + public boolean isTransitRouter(DeviceId deviceId) {
107 + return !(deviceConfig.isEdgeDevice(deviceId));
108 + }
109 +
110 +
111 + public boolean isEdgeRouter(DeviceId deviceId) {
112 + return deviceConfig.isEdgeDevice(deviceId);
113 + }
114 +
115 + private List<PortNumber> getPortsToNeighbors(DeviceId deviceId, List<DeviceId> fwdSws) {
116 +
117 + List<PortNumber> portNumbers = Lists.newArrayList();
118 +
119 + Set<Link> links = srManager.linkService.getDeviceEgressLinks(deviceId);
120 + for (Link link: links) {
121 + for (DeviceId swId: fwdSws) {
122 + if (link.dst().deviceId().equals(swId)) {
123 + portNumbers.add(link.src().port());
124 + break;
125 + }
126 + }
127 + }
128 +
129 + return portNumbers;
130 + }
131 +
132 + public List<PortNumber> getPortsToDevice(DeviceId deviceId) {
133 + List<PortNumber> portNumbers = Lists.newArrayList();
134 +
135 + Set<Link> links = srManager.linkService.getDeviceEgressLinks(deviceId);
136 + for (Link link: links) {
137 + if (link.dst().deviceId().equals(deviceId)) {
138 + portNumbers.add(link.src().port());
139 + }
140 + }
141 +
142 + return portNumbers;
143 + }
144 +
145 +
146 + public Ip4Address getDestinationRouterAddress(Ip4Address destIpAddress) {
147 + return deviceConfig.getRouterIpAddressForASubnetHost(destIpAddress);
148 + }
149 +
150 + public DeviceId getDeviceId(Ip4Address ip4Address) {
151 + return deviceConfig.getDeviceId(ip4Address);
152 + }
153 +
154 + public MacAddress getRouterMac(Ip4Address targetAddress) {
155 + return deviceConfig.getRouterMacForAGatewayIp(targetAddress);
156 + }
157 +}
...@@ -36,12 +36,10 @@ import org.onosproject.net.Port; ...@@ -36,12 +36,10 @@ import org.onosproject.net.Port;
36 import org.onosproject.net.device.DeviceEvent; 36 import org.onosproject.net.device.DeviceEvent;
37 import org.onosproject.net.device.DeviceListener; 37 import org.onosproject.net.device.DeviceListener;
38 import org.onosproject.net.device.DeviceService; 38 import org.onosproject.net.device.DeviceService;
39 -import org.onosproject.net.flow.FlowRuleService; 39 +import org.onosproject.net.flowobjective.FlowObjectiveService;
40 import org.onosproject.net.group.Group; 40 import org.onosproject.net.group.Group;
41 import org.onosproject.net.group.GroupEvent; 41 import org.onosproject.net.group.GroupEvent;
42 import org.onosproject.net.group.GroupKey; 42 import org.onosproject.net.group.GroupKey;
43 -import org.onosproject.net.group.GroupListener;
44 -import org.onosproject.net.group.GroupService;
45 import org.onosproject.net.host.HostService; 43 import org.onosproject.net.host.HostService;
46 import org.onosproject.net.intent.IntentService; 44 import org.onosproject.net.intent.IntentService;
47 import org.onosproject.net.link.LinkEvent; 45 import org.onosproject.net.link.LinkEvent;
...@@ -68,7 +66,8 @@ import java.util.concurrent.TimeUnit; ...@@ -68,7 +66,8 @@ import java.util.concurrent.TimeUnit;
68 @Component(immediate = true) 66 @Component(immediate = true)
69 public class SegmentRoutingManager { 67 public class SegmentRoutingManager {
70 68
71 - private static Logger log = LoggerFactory.getLogger(SegmentRoutingManager.class); 69 + private static Logger log = LoggerFactory
70 + .getLogger(SegmentRoutingManager.class);
72 71
73 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 72 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
74 protected CoreService coreService; 73 protected CoreService coreService;
...@@ -89,15 +88,12 @@ public class SegmentRoutingManager { ...@@ -89,15 +88,12 @@ public class SegmentRoutingManager {
89 protected DeviceService deviceService; 88 protected DeviceService deviceService;
90 89
91 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 90 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
92 - protected FlowRuleService flowRuleService; 91 + protected FlowObjectiveService flowObjectiveService;
93 92
94 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 93 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
95 protected LinkService linkService; 94 protected LinkService linkService;
96 95
97 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 96 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
98 - protected GroupService groupService;
99 -
100 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
101 protected MastershipService mastershipService; 97 protected MastershipService mastershipService;
102 protected ArpHandler arpHandler = null; 98 protected ArpHandler arpHandler = null;
103 protected IcmpHandler icmpHandler = null; 99 protected IcmpHandler icmpHandler = null;
...@@ -110,12 +106,12 @@ public class SegmentRoutingManager { ...@@ -110,12 +106,12 @@ public class SegmentRoutingManager {
110 private InternalPacketProcessor processor = new InternalPacketProcessor(); 106 private InternalPacketProcessor processor = new InternalPacketProcessor();
111 private InternalEventHandler eventHandler = new InternalEventHandler(); 107 private InternalEventHandler eventHandler = new InternalEventHandler();
112 108
113 - private ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); 109 + private ScheduledExecutorService executorService = Executors
110 + .newScheduledThreadPool(1);
114 111
115 private static ScheduledFuture<?> eventHandlerFuture = null; 112 private static ScheduledFuture<?> eventHandlerFuture = null;
116 private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<Event>(); 113 private ConcurrentLinkedQueue<Event> eventQueue = new ConcurrentLinkedQueue<Event>();
117 - private Map<DeviceId, DefaultGroupHandler> groupHandlerMap 114 + private Map<DeviceId, DefaultGroupHandler> groupHandlerMap = new ConcurrentHashMap<DeviceId, DefaultGroupHandler>();
118 - = new ConcurrentHashMap<DeviceId, DefaultGroupHandler>();
119 115
120 private NetworkConfigManager networkConfigService = new NetworkConfigManager();; 116 private NetworkConfigManager networkConfigService = new NetworkConfigManager();;
121 117
...@@ -125,7 +121,8 @@ public class SegmentRoutingManager { ...@@ -125,7 +121,8 @@ public class SegmentRoutingManager {
125 121
126 @Activate 122 @Activate
127 protected void activate() { 123 protected void activate() {
128 - appId = coreService.registerApplication("org.onosproject.segmentrouting"); 124 + appId = coreService
125 + .registerApplication("org.onosproject.segmentrouting");
129 networkConfigService.init(); 126 networkConfigService.init();
130 deviceConfiguration = new DeviceConfiguration(networkConfigService); 127 deviceConfiguration = new DeviceConfiguration(networkConfigService);
131 arpHandler = new ArpHandler(this); 128 arpHandler = new ArpHandler(this);
...@@ -136,24 +133,21 @@ public class SegmentRoutingManager { ...@@ -136,24 +133,21 @@ public class SegmentRoutingManager {
136 133
137 packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); 134 packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2);
138 linkService.addListener(new InternalLinkListener()); 135 linkService.addListener(new InternalLinkListener());
139 - groupService.addListener(new InternalGroupListener());
140 deviceService.addListener(new InternalDeviceListener()); 136 deviceService.addListener(new InternalDeviceListener());
141 137
142 - for (Device device: deviceService.getDevices()) { 138 + for (Device device : deviceService.getDevices()) {
143 - if (mastershipService. 139 + if (mastershipService.getLocalRole(device.id()) == MastershipRole.MASTER) {
144 - getLocalRole(device.id()) == MastershipRole.MASTER) { 140 + DefaultGroupHandler groupHandler = DefaultGroupHandler
145 - DefaultGroupHandler groupHandler = 141 + .createGroupHandler(device.id(), appId,
146 - DefaultGroupHandler.createGroupHandler(device.id(), 142 + deviceConfiguration, linkService,
147 - appId, deviceConfiguration, linkService, groupService); 143 + flowObjectiveService);
148 - groupHandler.createGroups();
149 groupHandlerMap.put(device.id(), groupHandler); 144 groupHandlerMap.put(device.id(), groupHandler);
150 defaultRoutingHandler.populateTtpRules(device.id()); 145 defaultRoutingHandler.populateTtpRules(device.id());
151 log.debug("Initiating default group handling for {}", device.id()); 146 log.debug("Initiating default group handling for {}", device.id());
152 } else { 147 } else {
153 log.debug("Activate: Local role {} " 148 log.debug("Activate: Local role {} "
154 + "is not MASTER for device {}", 149 + "is not MASTER for device {}",
155 - mastershipService. 150 + mastershipService.getLocalRole(device.id()),
156 - getLocalRole(device.id()),
157 device.id()); 151 device.id());
158 } 152 }
159 } 153 }
...@@ -177,13 +171,19 @@ public class SegmentRoutingManager { ...@@ -177,13 +171,19 @@ public class SegmentRoutingManager {
177 */ 171 */
178 public GroupKey getGroupKey(NeighborSet ns) { 172 public GroupKey getGroupKey(NeighborSet ns) {
179 173
180 - for (DefaultGroupHandler groupHandler: groupHandlerMap.values()) { 174 + for (DefaultGroupHandler groupHandler : groupHandlerMap.values()) {
181 return groupHandler.getGroupKey(ns); 175 return groupHandler.getGroupKey(ns);
182 } 176 }
183 177
184 return null; 178 return null;
185 } 179 }
186 180
181 + public int getNextObjectiveId(DeviceId deviceId, NeighborSet ns) {
182 +
183 + return (groupHandlerMap.get(deviceId) != null) ? groupHandlerMap
184 + .get(deviceId).getNextObjectiveId(ns) : -1;
185 + }
186 +
187 private class InternalPacketProcessor implements PacketProcessor { 187 private class InternalPacketProcessor implements PacketProcessor {
188 188
189 @Override 189 @Override
...@@ -213,8 +213,8 @@ public class SegmentRoutingManager { ...@@ -213,8 +213,8 @@ public class SegmentRoutingManager {
213 private class InternalLinkListener implements LinkListener { 213 private class InternalLinkListener implements LinkListener {
214 @Override 214 @Override
215 public void event(LinkEvent event) { 215 public void event(LinkEvent event) {
216 - if (event.type() == LinkEvent.Type.LINK_ADDED || 216 + if (event.type() == LinkEvent.Type.LINK_ADDED
217 - event.type() == LinkEvent.Type.LINK_REMOVED) { 217 + || event.type() == LinkEvent.Type.LINK_REMOVED) {
218 scheduleEventHandlerIfNotScheduled(event); 218 scheduleEventHandlerIfNotScheduled(event);
219 } 219 }
220 } 220 }
...@@ -224,11 +224,9 @@ public class SegmentRoutingManager { ...@@ -224,11 +224,9 @@ public class SegmentRoutingManager {
224 224
225 @Override 225 @Override
226 public void event(DeviceEvent event) { 226 public void event(DeviceEvent event) {
227 - if (mastershipService. 227 + if (mastershipService.getLocalRole(event.subject().id()) != MastershipRole.MASTER) {
228 - getLocalRole(event.subject().id()) != MastershipRole.MASTER) {
229 log.debug("Local role {} is not MASTER for device {}", 228 log.debug("Local role {} is not MASTER for device {}",
230 - mastershipService. 229 + mastershipService.getLocalRole(event.subject().id()),
231 - getLocalRole(event.subject().id()),
232 event.subject().id()); 230 event.subject().id());
233 return; 231 return;
234 } 232 }
...@@ -245,33 +243,13 @@ public class SegmentRoutingManager { ...@@ -245,33 +243,13 @@ public class SegmentRoutingManager {
245 } 243 }
246 } 244 }
247 245
248 - private class InternalGroupListener implements GroupListener {
249 -
250 - @Override
251 - public void event(GroupEvent event) {
252 - switch (event.type()) {
253 - case GROUP_ADDED:
254 - scheduleEventHandlerIfNotScheduled(event);
255 - break;
256 - case GROUP_ADD_REQUESTED:
257 - log.info("Group add requested");
258 - break;
259 - case GROUP_UPDATED:
260 - break;
261 - default:
262 - log.warn("Unhandled group event type: {}", event.type());
263 - }
264 - }
265 - }
266 -
267 private void scheduleEventHandlerIfNotScheduled(Event event) { 246 private void scheduleEventHandlerIfNotScheduled(Event event) {
268 247
269 eventQueue.add(event); 248 eventQueue.add(event);
270 numOfEvents++; 249 numOfEvents++;
271 - if (eventHandlerFuture == null || 250 + if (eventHandlerFuture == null || eventHandlerFuture.isDone()) {
272 - eventHandlerFuture.isDone()) { 251 + eventHandlerFuture = executorService
273 - eventHandlerFuture = executorService.schedule(eventHandler, 252 + .schedule(eventHandler, 100, TimeUnit.MILLISECONDS);
274 - 100, TimeUnit.MILLISECONDS);
275 numOfHandlerScheduled++; 253 numOfHandlerScheduled++;
276 } 254 }
277 255
...@@ -311,15 +289,12 @@ public class SegmentRoutingManager { ...@@ -311,15 +289,12 @@ public class SegmentRoutingManager {
311 } 289 }
312 } 290 }
313 291
314 -
315 -
316 private void processLinkAdded(Link link) { 292 private void processLinkAdded(Link link) {
317 log.debug("A new link {} was added", link.toString()); 293 log.debug("A new link {} was added", link.toString());
318 294
319 - if (mastershipService. 295 + if (mastershipService.getLocalRole(link.src().deviceId()) == MastershipRole.MASTER) {
320 - getLocalRole(link.src().deviceId()) == MastershipRole.MASTER) { 296 + DefaultGroupHandler groupHandler = groupHandlerMap.get(link.src()
321 - DefaultGroupHandler groupHandler = 297 + .deviceId());
322 - groupHandlerMap.get(link.src().deviceId());
323 if (groupHandler != null) { 298 if (groupHandler != null) {
324 groupHandler.linkUp(link); 299 groupHandler.linkUp(link);
325 } 300 }
...@@ -332,7 +307,6 @@ public class SegmentRoutingManager { ...@@ -332,7 +307,6 @@ public class SegmentRoutingManager {
332 defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(link); 307 defaultRoutingHandler.populateRoutingRulesForLinkStatusChange(link);
333 } 308 }
334 309
335 -
336 private void processGroupAdded(Group group) { 310 private void processGroupAdded(Group group) {
337 log.debug("A new group with ID {} was added", group.id()); 311 log.debug("A new group with ID {} was added", group.id());
338 defaultRoutingHandler.resumePopulationProcess(); 312 defaultRoutingHandler.resumePopulationProcess();
...@@ -341,20 +315,14 @@ public class SegmentRoutingManager { ...@@ -341,20 +315,14 @@ public class SegmentRoutingManager {
341 private void processDeviceAdded(Device device) { 315 private void processDeviceAdded(Device device) {
342 log.debug("A new device with ID {} was added", device.id()); 316 log.debug("A new device with ID {} was added", device.id());
343 defaultRoutingHandler.populateTtpRules(device.id()); 317 defaultRoutingHandler.populateTtpRules(device.id());
344 - DefaultGroupHandler dgh = DefaultGroupHandler.createGroupHandler( 318 + DefaultGroupHandler dgh = DefaultGroupHandler.createGroupHandler(device
345 - device.id(), 319 + .id(), appId, deviceConfiguration, linkService, flowObjectiveService);
346 - appId,
347 - deviceConfiguration,
348 - linkService,
349 - groupService);
350 - dgh.createGroups();
351 groupHandlerMap.put(device.id(), dgh); 320 groupHandlerMap.put(device.id(), dgh);
352 } 321 }
353 322
354 private void processPortRemoved(Device device, Port port) { 323 private void processPortRemoved(Device device, Port port) {
355 log.debug("Port {} was removed", port.toString()); 324 log.debug("Port {} was removed", port.toString());
356 - DefaultGroupHandler groupHandler = 325 + DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id());
357 - groupHandlerMap.get(device.id());
358 if (groupHandler != null) { 326 if (groupHandler != null) {
359 groupHandler.portDown(port.number()); 327 groupHandler.portDown(port.number());
360 } 328 }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.segmentrouting.grouphandler; 16 package org.onosproject.segmentrouting.grouphandler;
17 17
18 -import java.util.Arrays;
19 import java.util.HashSet; 18 import java.util.HashSet;
20 import java.util.List; 19 import java.util.List;
21 import java.util.Set; 20 import java.util.Set;
...@@ -26,10 +25,7 @@ import org.onosproject.net.DeviceId; ...@@ -26,10 +25,7 @@ import org.onosproject.net.DeviceId;
26 import org.onosproject.net.Link; 25 import org.onosproject.net.Link;
27 import org.onosproject.net.flow.DefaultTrafficTreatment; 26 import org.onosproject.net.flow.DefaultTrafficTreatment;
28 import org.onosproject.net.flow.TrafficTreatment; 27 import org.onosproject.net.flow.TrafficTreatment;
29 -import org.onosproject.net.group.DefaultGroupBucket; 28 +import org.onosproject.net.flowobjective.FlowObjectiveService;
30 -import org.onosproject.net.group.GroupBucket;
31 -import org.onosproject.net.group.GroupBuckets;
32 -import org.onosproject.net.group.GroupService;
33 import org.onosproject.net.link.LinkService; 29 import org.onosproject.net.link.LinkService;
34 30
35 /** 31 /**
...@@ -55,8 +51,8 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { ...@@ -55,8 +51,8 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
55 ApplicationId appId, 51 ApplicationId appId,
56 DeviceProperties config, 52 DeviceProperties config,
57 LinkService linkService, 53 LinkService linkService,
58 - GroupService groupService) { 54 + FlowObjectiveService flowObjService) {
59 - super(deviceId, appId, config, linkService, groupService); 55 + super(deviceId, appId, config, linkService, flowObjService);
60 } 56 }
61 57
62 @Override 58 @Override
...@@ -130,7 +126,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { ...@@ -130,7 +126,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
130 .setMpls(MplsLabel. 126 .setMpls(MplsLabel.
131 mplsLabel(ns.getEdgeLabel())); 127 mplsLabel(ns.getEdgeLabel()));
132 } 128 }
133 - GroupBucket updatedBucket = DefaultGroupBucket. 129 + /*GroupBucket updatedBucket = DefaultGroupBucket.
134 createSelectGroupBucket(tBuilder.build()); 130 createSelectGroupBucket(tBuilder.build());
135 GroupBuckets updatedBuckets = new GroupBuckets( 131 GroupBuckets updatedBuckets = new GroupBuckets(
136 Arrays.asList(updatedBucket)); 132 Arrays.asList(updatedBucket));
...@@ -140,7 +136,8 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { ...@@ -140,7 +136,8 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
140 getGroupKey(ns), 136 getGroupKey(ns),
141 updatedBuckets, 137 updatedBuckets,
142 getGroupKey(ns), 138 getGroupKey(ns),
143 - appId); 139 + appId);*/
140 + //TODO: Use nextObjective APIs to update the next objective
144 } 141 }
145 } 142 }
146 143
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.segmentrouting.grouphandler; 16 package org.onosproject.segmentrouting.grouphandler;
17 17
18 -import java.util.Arrays;
19 import java.util.HashSet; 18 import java.util.HashSet;
20 import java.util.Set; 19 import java.util.Set;
21 20
...@@ -25,10 +24,7 @@ import org.onosproject.net.DeviceId; ...@@ -25,10 +24,7 @@ import org.onosproject.net.DeviceId;
25 import org.onosproject.net.Link; 24 import org.onosproject.net.Link;
26 import org.onosproject.net.flow.DefaultTrafficTreatment; 25 import org.onosproject.net.flow.DefaultTrafficTreatment;
27 import org.onosproject.net.flow.TrafficTreatment; 26 import org.onosproject.net.flow.TrafficTreatment;
28 -import org.onosproject.net.group.DefaultGroupBucket; 27 +import org.onosproject.net.flowobjective.FlowObjectiveService;
29 -import org.onosproject.net.group.GroupBucket;
30 -import org.onosproject.net.group.GroupBuckets;
31 -import org.onosproject.net.group.GroupService;
32 import org.onosproject.net.link.LinkService; 28 import org.onosproject.net.link.LinkService;
33 29
34 /** 30 /**
...@@ -49,8 +45,8 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { ...@@ -49,8 +45,8 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
49 ApplicationId appId, 45 ApplicationId appId,
50 DeviceProperties config, 46 DeviceProperties config,
51 LinkService linkService, 47 LinkService linkService,
52 - GroupService groupService) { 48 + FlowObjectiveService flowObjService) {
53 - super(deviceId, appId, config, linkService, groupService); 49 + super(deviceId, appId, config, linkService, flowObjService);
54 } 50 }
55 51
56 @Override 52 @Override
...@@ -118,7 +114,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { ...@@ -118,7 +114,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
118 .setMpls(MplsLabel. 114 .setMpls(MplsLabel.
119 mplsLabel(ns.getEdgeLabel())); 115 mplsLabel(ns.getEdgeLabel()));
120 } 116 }
121 - GroupBucket updatedBucket = DefaultGroupBucket. 117 + /*GroupBucket updatedBucket = DefaultGroupBucket.
122 createSelectGroupBucket(tBuilder.build()); 118 createSelectGroupBucket(tBuilder.build());
123 GroupBuckets updatedBuckets = new GroupBuckets( 119 GroupBuckets updatedBuckets = new GroupBuckets(
124 Arrays.asList(updatedBucket)); 120 Arrays.asList(updatedBucket));
...@@ -128,7 +124,8 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { ...@@ -128,7 +124,8 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
128 getGroupKey(ns), 124 getGroupKey(ns),
129 updatedBuckets, 125 updatedBuckets,
130 getGroupKey(ns), 126 getGroupKey(ns),
131 - appId); 127 + appId);*/
128 + //TODO: Use nextObjective APIs to update the next objective
132 } 129 }
133 } 130 }
134 131
......
...@@ -25,19 +25,13 @@ import java.util.List; ...@@ -25,19 +25,13 @@ import java.util.List;
25 25
26 import org.onlab.packet.MplsLabel; 26 import org.onlab.packet.MplsLabel;
27 import org.onosproject.core.ApplicationId; 27 import org.onosproject.core.ApplicationId;
28 -import org.onosproject.core.GroupId;
29 import org.onosproject.segmentrouting.grouphandler.GroupBucketIdentifier.BucketOutputType; 28 import org.onosproject.segmentrouting.grouphandler.GroupBucketIdentifier.BucketOutputType;
30 import org.onosproject.net.DeviceId; 29 import org.onosproject.net.DeviceId;
31 import org.onosproject.net.PortNumber; 30 import org.onosproject.net.PortNumber;
32 import org.onosproject.net.flow.DefaultTrafficTreatment; 31 import org.onosproject.net.flow.DefaultTrafficTreatment;
33 import org.onosproject.net.flow.TrafficTreatment; 32 import org.onosproject.net.flow.TrafficTreatment;
34 -import org.onosproject.net.group.DefaultGroupBucket; 33 +import org.onosproject.net.flowobjective.FlowObjectiveService;
35 -import org.onosproject.net.group.DefaultGroupDescription;
36 import org.onosproject.net.group.GroupBucket; 34 import org.onosproject.net.group.GroupBucket;
37 -import org.onosproject.net.group.GroupBuckets;
38 -import org.onosproject.net.group.GroupDescription;
39 -import org.onosproject.net.group.GroupEvent;
40 -import org.onosproject.net.group.GroupService;
41 import org.onosproject.net.link.LinkService; 35 import org.onosproject.net.link.LinkService;
42 import org.slf4j.Logger; 36 import org.slf4j.Logger;
43 37
...@@ -58,14 +52,14 @@ public class PolicyGroupHandler extends DefaultGroupHandler { ...@@ -58,14 +52,14 @@ public class PolicyGroupHandler extends DefaultGroupHandler {
58 * @param appId application identifier 52 * @param appId application identifier
59 * @param config interface to retrieve the device properties 53 * @param config interface to retrieve the device properties
60 * @param linkService link service object 54 * @param linkService link service object
61 - * @param groupService group service object 55 + * @param flowObjService flow objective service object
62 */ 56 */
63 public PolicyGroupHandler(DeviceId deviceId, 57 public PolicyGroupHandler(DeviceId deviceId,
64 ApplicationId appId, 58 ApplicationId appId,
65 DeviceProperties config, 59 DeviceProperties config,
66 LinkService linkService, 60 LinkService linkService,
67 - GroupService groupService) { 61 + FlowObjectiveService flowObjService) {
68 - super(deviceId, appId, config, linkService, groupService); 62 + super(deviceId, appId, config, linkService, flowObjService);
69 } 63 }
70 64
71 public PolicyGroupIdentifier createPolicyGroupChain(String id, 65 public PolicyGroupIdentifier createPolicyGroupChain(String id,
...@@ -111,15 +105,16 @@ public class PolicyGroupHandler extends DefaultGroupHandler { ...@@ -111,15 +105,16 @@ public class PolicyGroupHandler extends DefaultGroupHandler {
111 .setEthSrc(nodeMacAddr) 105 .setEthSrc(nodeMacAddr)
112 .pushMpls() 106 .pushMpls()
113 .setMpls(MplsLabel.mplsLabel(label)); 107 .setMpls(MplsLabel.mplsLabel(label));
114 - outBuckets.add(DefaultGroupBucket. 108 + /*outBuckets.add(DefaultGroupBucket.
115 createSelectGroupBucket(tBuilder.build())); 109 createSelectGroupBucket(tBuilder.build()));
116 GroupDescription desc = new 110 GroupDescription desc = new
117 DefaultGroupDescription(deviceId, 111 DefaultGroupDescription(deviceId,
118 GroupDescription.Type.INDIRECT, 112 GroupDescription.Type.INDIRECT,
119 new GroupBuckets(outBuckets)); 113 new GroupBuckets(outBuckets));
120 - //TODO: BoS 114 + //TODO: BoS*/
121 previousGroupkey = key; 115 previousGroupkey = key;
122 - groupService.addGroup(desc); 116 + //groupService.addGroup(desc);
117 + //TODO: Use nextObjective APIs here
123 } else { 118 } else {
124 // Intermediate Groups 119 // Intermediate Groups
125 GroupBucketIdentifier bucketId = 120 GroupBucketIdentifier bucketId =
...@@ -179,20 +174,22 @@ public class PolicyGroupHandler extends DefaultGroupHandler { ...@@ -179,20 +174,22 @@ public class PolicyGroupHandler extends DefaultGroupHandler {
179 .setMpls(MplsLabel.mplsLabel(bucketId.label())); 174 .setMpls(MplsLabel.mplsLabel(bucketId.label()));
180 } 175 }
181 //TODO: BoS 176 //TODO: BoS
182 - outBuckets.add(DefaultGroupBucket. 177 + /*outBuckets.add(DefaultGroupBucket.
183 - createSelectGroupBucket(tBuilder.build())); 178 + createSelectGroupBucket(tBuilder.build()));*/
184 } 179 }
185 - GroupDescription desc = new 180 + /*GroupDescription desc = new
186 DefaultGroupDescription(deviceId, 181 DefaultGroupDescription(deviceId,
187 GroupDescription.Type.SELECT, 182 GroupDescription.Type.SELECT,
188 new GroupBuckets(outBuckets)); 183 new GroupBuckets(outBuckets));
189 - groupService.addGroup(desc); 184 + groupService.addGroup(desc);*/
185 + //TODO: Use nextObjective APIs here
190 } 186 }
191 } 187 }
192 return innermostGroupkey; 188 return innermostGroupkey;
193 } 189 }
194 190
195 - @Override 191 + //TODO: Use nextObjective APIs to handle the group chains
192 + /*@Override
196 protected void handleGroupEvent(GroupEvent event) { 193 protected void handleGroupEvent(GroupEvent event) {
197 if (event.type() == GroupEvent.Type.GROUP_ADDED) { 194 if (event.type() == GroupEvent.Type.GROUP_ADDED) {
198 if (dependentGroups.get(event.subject().appCookie()) != null) { 195 if (dependentGroups.get(event.subject().appCookie()) != null) {
...@@ -253,7 +250,7 @@ public class PolicyGroupHandler extends DefaultGroupHandler { ...@@ -253,7 +250,7 @@ public class PolicyGroupHandler extends DefaultGroupHandler {
253 } 250 }
254 } 251 }
255 } 252 }
256 - } 253 + }*/
257 254
258 public PolicyGroupIdentifier generatePolicyGroupKey(String id, 255 public PolicyGroupIdentifier generatePolicyGroupKey(String id,
259 List<PolicyGroupParams> params) { 256 List<PolicyGroupParams> params) {
...@@ -343,9 +340,10 @@ public class PolicyGroupHandler extends DefaultGroupHandler { ...@@ -343,9 +340,10 @@ public class PolicyGroupHandler extends DefaultGroupHandler {
343 groupsToBeDeleted.add(bucketId.outGroup()); 340 groupsToBeDeleted.add(bucketId.outGroup());
344 } 341 }
345 } 342 }
346 - groupService.removeGroup(deviceId, 343 + /*groupService.removeGroup(deviceId,
347 getGroupKey(innerMostGroupKey), 344 getGroupKey(innerMostGroupKey),
348 - appId); 345 + appId);*/
346 + //TODO: Use nextObjective APIs here
349 it.remove(); 347 it.remove();
350 } 348 }
351 } 349 }
......
...@@ -356,10 +356,14 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -356,10 +356,14 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
356 356
357 @Override 357 @Override
358 public TrafficTreatment build() { 358 public TrafficTreatment build() {
359 - if (deferred.size() == 0 && immediate.size() == 0 359 + //Don't add DROP instruction by default when instruction
360 - && table == null && !clear) { 360 + //set is empty. This will be handled in DefaultSingleTablePipeline
361 - drop(); 361 + //driver.
362 - } 362 +
363 + //if (deferred.size() == 0 && immediate.size() == 0
364 + // && table == null && !clear) {
365 + // drop();
366 + //}
363 return new DefaultTrafficTreatment(deferred, immediate, table, clear); 367 return new DefaultTrafficTreatment(deferred, immediate, table, clear);
364 } 368 }
365 369
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 package org.onosproject.driver.pipeline; 16 package org.onosproject.driver.pipeline;
17 17
18 import com.google.common.util.concurrent.SettableFuture; 18 import com.google.common.util.concurrent.SettableFuture;
19 +
19 import org.onlab.osgi.ServiceDirectory; 20 import org.onlab.osgi.ServiceDirectory;
20 import org.onosproject.core.DefaultGroupId; 21 import org.onosproject.core.DefaultGroupId;
21 import org.onosproject.net.DeviceId; 22 import org.onosproject.net.DeviceId;
...@@ -23,11 +24,14 @@ import org.onosproject.net.behaviour.Pipeliner; ...@@ -23,11 +24,14 @@ import org.onosproject.net.behaviour.Pipeliner;
23 import org.onosproject.net.behaviour.PipelinerContext; 24 import org.onosproject.net.behaviour.PipelinerContext;
24 import org.onosproject.net.driver.AbstractHandlerBehaviour; 25 import org.onosproject.net.driver.AbstractHandlerBehaviour;
25 import org.onosproject.net.flow.DefaultFlowRule; 26 import org.onosproject.net.flow.DefaultFlowRule;
27 +import org.onosproject.net.flow.DefaultTrafficTreatment;
26 import org.onosproject.net.flow.FlowRule; 28 import org.onosproject.net.flow.FlowRule;
27 import org.onosproject.net.flow.FlowRuleOperations; 29 import org.onosproject.net.flow.FlowRuleOperations;
28 import org.onosproject.net.flow.FlowRuleOperationsContext; 30 import org.onosproject.net.flow.FlowRuleOperationsContext;
29 import org.onosproject.net.flow.FlowRuleService; 31 import org.onosproject.net.flow.FlowRuleService;
30 import org.onosproject.net.flow.TrafficSelector; 32 import org.onosproject.net.flow.TrafficSelector;
33 +import org.onosproject.net.flow.TrafficTreatment;
34 +import org.onosproject.net.flow.instructions.Instructions;
31 import org.onosproject.net.flowobjective.FilteringObjective; 35 import org.onosproject.net.flowobjective.FilteringObjective;
32 import org.onosproject.net.flowobjective.ForwardingObjective; 36 import org.onosproject.net.flowobjective.ForwardingObjective;
33 import org.onosproject.net.flowobjective.NextObjective; 37 import org.onosproject.net.flowobjective.NextObjective;
...@@ -70,9 +74,18 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme ...@@ -70,9 +74,18 @@ public class DefaultSingleTablePipeline extends AbstractHandlerBehaviour impleme
70 } 74 }
71 75
72 TrafficSelector selector = fwd.selector(); 76 TrafficSelector selector = fwd.selector();
77 + TrafficTreatment treatment = fwd.treatment();
78 + if ((fwd.treatment().deferred().size() == 0) &&
79 + (fwd.treatment().immediate().size() == 0) &&
80 + (fwd.treatment().tableTransition() == null) &&
81 + (!fwd.treatment().clearedDeferred())) {
82 + TrafficTreatment.Builder flowTreatment = DefaultTrafficTreatment.builder();
83 + flowTreatment.add(Instructions.createDrop());
84 + treatment = flowTreatment.build();
85 + }
73 86
74 FlowRule rule = new DefaultFlowRule(deviceId, selector, 87 FlowRule rule = new DefaultFlowRule(deviceId, selector,
75 - fwd.treatment(), 88 + treatment,
76 fwd.priority(), fwd.appId(), 89 fwd.priority(), fwd.appId(),
77 new DefaultGroupId(fwd.id()), 90 new DefaultGroupId(fwd.id()),
78 fwd.timeout(), fwd.permanent()); 91 fwd.timeout(), fwd.permanent());
......
1 +/*
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 + */
16 +package org.onosproject.driver.pipeline;
17 +
18 +import java.util.ArrayList;
19 +import java.util.Collection;
20 +import java.util.Collections;
21 +import java.util.List;
22 +
23 +import org.onlab.packet.Ethernet;
24 +import org.onlab.packet.MacAddress;
25 +import org.onosproject.core.ApplicationId;
26 +import org.onosproject.net.behaviour.NextGroup;
27 +import org.onosproject.net.flow.DefaultFlowRule;
28 +import org.onosproject.net.flow.DefaultTrafficSelector;
29 +import org.onosproject.net.flow.DefaultTrafficTreatment;
30 +import org.onosproject.net.flow.FlowRule;
31 +import org.onosproject.net.flow.TrafficSelector;
32 +import org.onosproject.net.flow.TrafficTreatment;
33 +import org.onosproject.net.flow.criteria.Criterion;
34 +import org.onosproject.net.flow.criteria.EthCriterion;
35 +import org.onosproject.net.flow.criteria.EthTypeCriterion;
36 +import org.onosproject.net.flow.criteria.IPCriterion;
37 +import org.onosproject.net.flow.criteria.MplsCriterion;
38 +import org.onosproject.net.flow.instructions.Instruction;
39 +import org.onosproject.net.flowobjective.FilteringObjective;
40 +import org.onosproject.net.flowobjective.ForwardingObjective;
41 +import org.onosproject.net.flowobjective.ObjectiveError;
42 +import org.onosproject.net.group.Group;
43 +import org.onosproject.net.group.GroupKey;
44 +
45 +/**
46 + * Spring-open driver implementation for Dell hardware switches.
47 + */
48 +public class SpringOpenTTPDell extends SpringOpenTTP {
49 +
50 + /* Table IDs to be used for Dell Open Segment Routers*/
51 + private static final int DELL_TABLE_VLAN = 17;
52 + private static final int DELL_TABLE_TMAC = 18;
53 + private static final int DELL_TABLE_IPV4_UNICAST = 30;
54 + private static final int DELL_TABLE_MPLS = 25;
55 + private static final int DELL_TABLE_ACL = 40;
56 +
57 + //TODO: Store this info in the distributed store.
58 + private MacAddress deviceTMac = null;
59 +
60 + public SpringOpenTTPDell() {
61 + super();
62 + vlanTableId = DELL_TABLE_VLAN;
63 + tmacTableId = DELL_TABLE_TMAC;
64 + ipv4UnicastTableId = DELL_TABLE_IPV4_UNICAST;
65 + mplsTableId = DELL_TABLE_MPLS;
66 + aclTableId = DELL_TABLE_ACL;
67 + }
68 +
69 + @Override
70 + protected void setTableMissEntries() {
71 + // No need to set table-miss-entries in Dell switches
72 + return;
73 + }
74 +
75 + @Override
76 + //Dell switches need ETH_DST based match condition in all IP table entries.
77 + //So this method overrides the default spring-open behavior and adds
78 + //ETH_DST match condition while pushing IP table flow rules
79 + protected Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
80 + log.debug("Processing specific");
81 + TrafficSelector selector = fwd.selector();
82 + EthTypeCriterion ethType = (EthTypeCriterion) selector
83 + .getCriterion(Criterion.Type.ETH_TYPE);
84 + if ((ethType == null) ||
85 + ((((short) ethType.ethType()) != Ethernet.TYPE_IPV4) &&
86 + (((short) ethType.ethType()) != Ethernet.MPLS_UNICAST))) {
87 + log.debug("processSpecific: Unsupported "
88 + + "forwarding objective criteraia");
89 + fail(fwd, ObjectiveError.UNSUPPORTED);
90 + return Collections.emptySet();
91 + }
92 +
93 + TrafficSelector.Builder filteredSelectorBuilder =
94 + DefaultTrafficSelector.builder();
95 + int forTableId = -1;
96 + if (((short) ethType.ethType()) == Ethernet.TYPE_IPV4) {
97 + if (deviceTMac == null) {
98 + log.debug("processSpecific: ETH_DST filtering "
99 + + "objective is not set which is required "
100 + + "before sending a IPv4 forwarding objective");
101 + //TODO: Map the error to more appropriate error code.
102 + fail(fwd, ObjectiveError.DEVICEMISSING);
103 + return Collections.emptySet();
104 + }
105 + filteredSelectorBuilder = filteredSelectorBuilder
106 + .matchEthType(Ethernet.TYPE_IPV4)
107 + .matchEthDst(deviceTMac)
108 + .matchIPDst(((IPCriterion) selector
109 + .getCriterion(Criterion.Type.IPV4_DST))
110 + .ip());
111 + forTableId = ipv4UnicastTableId;
112 + log.debug("processing IPv4 specific forwarding objective");
113 + } else {
114 + filteredSelectorBuilder = filteredSelectorBuilder
115 + .matchEthType(Ethernet.MPLS_UNICAST)
116 + .matchMplsLabel(((MplsCriterion)
117 + selector.getCriterion(Criterion.Type.MPLS_LABEL)).label());
118 + //TODO: Add Match for BoS
119 + //if (selector.getCriterion(Criterion.Type.MPLS_BOS) != null) {
120 + //}
121 + forTableId = mplsTableId;
122 + log.debug("processing MPLS specific forwarding objective");
123 + }
124 +
125 + TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment
126 + .builder();
127 + if (fwd.treatment() != null) {
128 + for (Instruction i : fwd.treatment().allInstructions()) {
129 + treatmentBuilder.add(i);
130 + }
131 + }
132 +
133 + if (fwd.nextId() != null) {
134 + NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
135 +
136 + if (next != null) {
137 + GroupKey key = appKryo.deserialize(next.data());
138 +
139 + Group group = groupService.getGroup(deviceId, key);
140 +
141 + if (group == null) {
142 + log.warn("The group left!");
143 + fail(fwd, ObjectiveError.GROUPMISSING);
144 + return Collections.emptySet();
145 + }
146 + treatmentBuilder.group(group.id());
147 + log.debug("Adding OUTGROUP action");
148 + }
149 + }
150 +
151 + TrafficSelector filteredSelector = filteredSelectorBuilder.build();
152 + TrafficTreatment treatment = treatmentBuilder.transition(aclTableId)
153 + .build();
154 +
155 + FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
156 + .fromApp(fwd.appId()).withPriority(fwd.priority())
157 + .forDevice(deviceId).withSelector(filteredSelector)
158 + .withTreatment(treatment);
159 +
160 + if (fwd.permanent()) {
161 + ruleBuilder.makePermanent();
162 + } else {
163 + ruleBuilder.makeTemporary(fwd.timeout());
164 + }
165 +
166 + ruleBuilder.forTable(forTableId);
167 + return Collections.singletonList(ruleBuilder.build());
168 +
169 + }
170 +
171 + @Override
172 + //Dell switches need ETH_DST based match condition in all IP table entries.
173 + //So while processing the ETH_DST based filtering objective, store
174 + //the device MAC to be used locally to use it while pushing the IP rules.
175 + protected List<FlowRule> processEthDstFilter(Criterion c,
176 + FilteringObjective filt,
177 + ApplicationId applicationId) {
178 + List<FlowRule> rules = new ArrayList<FlowRule>();
179 + EthCriterion e = (EthCriterion) c;
180 + TrafficSelector.Builder selectorIp = DefaultTrafficSelector
181 + .builder();
182 + TrafficTreatment.Builder treatmentIp = DefaultTrafficTreatment
183 + .builder();
184 +
185 + // Store device termination Mac to be used in IP flow entries
186 + deviceTMac = e.mac();
187 +
188 + selectorIp.matchEthDst(e.mac());
189 + selectorIp.matchEthType(Ethernet.TYPE_IPV4);
190 + treatmentIp.transition(ipv4UnicastTableId);
191 + FlowRule ruleIp = DefaultFlowRule.builder().forDevice(deviceId)
192 + .withSelector(selectorIp.build())
193 + .withTreatment(treatmentIp.build())
194 + .withPriority(filt.priority()).fromApp(applicationId)
195 + .makePermanent().forTable(tmacTableId).build();
196 + log.debug("adding IP ETH rule for MAC: {}", e.mac());
197 + rules.add(ruleIp);
198 +
199 + TrafficSelector.Builder selectorMpls = DefaultTrafficSelector
200 + .builder();
201 + TrafficTreatment.Builder treatmentMpls = DefaultTrafficTreatment
202 + .builder();
203 + selectorMpls.matchEthDst(e.mac());
204 + selectorMpls.matchEthType(Ethernet.MPLS_UNICAST);
205 + treatmentMpls.transition(mplsTableId);
206 + FlowRule ruleMpls = DefaultFlowRule.builder()
207 + .forDevice(deviceId).withSelector(selectorMpls.build())
208 + .withTreatment(treatmentMpls.build())
209 + .withPriority(filt.priority()).fromApp(applicationId)
210 + .makePermanent().forTable(tmacTableId).build();
211 + log.debug("adding MPLS ETH rule for MAC: {}", e.mac());
212 + rules.add(ruleMpls);
213 +
214 + return rules;
215 + }
216 +
217 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -23,4 +23,12 @@ ...@@ -23,4 +23,12 @@
23 <behaviour api="org.onosproject.net.behaviour.Pipeliner" 23 <behaviour api="org.onosproject.net.behaviour.Pipeliner"
24 impl="org.onosproject.driver.pipeline.OVSCorsaPipeline"/> 24 impl="org.onosproject.driver.pipeline.OVSCorsaPipeline"/>
25 </driver> 25 </driver>
26 + <driver name="spring-open-cpqd" manufacturer="Stanford University, Ericsson Research and CPqD Research" hwVersion="OpenFlow 1.3 Reference Userspace Switch" swVersion="Apr 6 2015 16:10:53">
27 + <behaviour api="org.onosproject.net.behaviour.Pipeliner"
28 + impl="org.onosproject.driver.pipeline.SpringOpenTTP"/>
29 + </driver>
30 + <driver name="spring-open" manufacturer="Dell " hwVersion="OpenFlow switch HW ver. 1.0" swVersion="OpenFlow switch SW ver. 1.0 and 1.3">
31 + <behaviour api="org.onosproject.net.behaviour.Pipeliner"
32 + impl="org.onosproject.driver.pipeline.SpringOpenTTPDell"/>
33 + </driver>
26 </drivers> 34 </drivers>
......
...@@ -19,10 +19,11 @@ package org.onosproject.openflow.controller.driver; ...@@ -19,10 +19,11 @@ package org.onosproject.openflow.controller.driver;
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.net.InetSocketAddress; 20 import java.net.InetSocketAddress;
21 import java.net.SocketAddress; 21 import java.net.SocketAddress;
22 -import java.util.Collections; 22 +import java.util.ArrayList;
23 import java.util.List; 23 import java.util.List;
24 import java.util.concurrent.RejectedExecutionException; 24 import java.util.concurrent.RejectedExecutionException;
25 import java.util.concurrent.atomic.AtomicInteger; 25 import java.util.concurrent.atomic.AtomicInteger;
26 +import java.util.stream.Collectors;
26 27
27 import org.jboss.netty.channel.Channel; 28 import org.jboss.netty.channel.Channel;
28 import org.onlab.packet.IpAddress; 29 import org.onlab.packet.IpAddress;
...@@ -64,7 +65,7 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { ...@@ -64,7 +65,7 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
64 65
65 private OFVersion ofVersion; 66 private OFVersion ofVersion;
66 67
67 - protected OFPortDescStatsReply ports; 68 + protected List<OFPortDescStatsReply> ports = new ArrayList<>();
68 69
69 protected boolean tableFull; 70 protected boolean tableFull;
70 71
...@@ -251,7 +252,12 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { ...@@ -251,7 +252,12 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
251 252
252 @Override 253 @Override
253 public void setPortDescReply(OFPortDescStatsReply portDescReply) { 254 public void setPortDescReply(OFPortDescStatsReply portDescReply) {
254 - this.ports = portDescReply; 255 + this.ports.add(portDescReply);
256 + }
257 +
258 + @Override
259 + public void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies) {
260 + this.ports.addAll(portDescReplies);
255 } 261 }
256 262
257 @Override 263 @Override
...@@ -379,7 +385,10 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { ...@@ -379,7 +385,10 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
379 385
380 @Override 386 @Override
381 public List<OFPortDesc> getPorts() { 387 public List<OFPortDesc> getPorts() {
382 - return Collections.unmodifiableList(ports.getEntries()); 388 + return this.ports.stream()
389 + .flatMap((portReply) -> (portReply.getEntries().stream()))
390 + .collect(Collectors.toList());
391 + //return Collections.unmodifiableList(ports.getEntries());
383 } 392 }
384 393
385 @Override 394 @Override
......
...@@ -137,6 +137,12 @@ public interface OpenFlowSwitchDriver extends OpenFlowSwitch { ...@@ -137,6 +137,12 @@ public interface OpenFlowSwitchDriver extends OpenFlowSwitch {
137 public void setPortDescReply(OFPortDescStatsReply portDescReply); 137 public void setPortDescReply(OFPortDescStatsReply portDescReply);
138 138
139 /** 139 /**
140 + * Sets the ports on this switch.
141 + * @param portDescReplies list of port set and descriptions
142 + */
143 + public void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies);
144 +
145 + /**
140 * Sets the features reply for this switch. 146 * Sets the features reply for this switch.
141 * @param featuresReply the features to set. 147 * @param featuresReply the features to set.
142 */ 148 */
......
...@@ -97,7 +97,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -97,7 +97,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
97 97
98 // Temporary storage for switch-features and port-description 98 // Temporary storage for switch-features and port-description
99 private OFFeaturesReply featuresReply; 99 private OFFeaturesReply featuresReply;
100 - private OFPortDescStatsReply portDescReply; 100 + private List<OFPortDescStatsReply> portDescReplies;
101 + //private OFPortDescStatsReply portDescReply;
101 // a concurrent ArrayList to temporarily store port status messages 102 // a concurrent ArrayList to temporarily store port status messages
102 // before we are ready to deal with them 103 // before we are ready to deal with them
103 private final CopyOnWriteArrayList<OFPortStatus> pendingPortStatusMsg; 104 private final CopyOnWriteArrayList<OFPortStatus> pendingPortStatusMsg;
...@@ -121,6 +122,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -121,6 +122,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
121 this.controller = controller; 122 this.controller = controller;
122 this.state = ChannelState.INIT; 123 this.state = ChannelState.INIT;
123 this.pendingPortStatusMsg = new CopyOnWriteArrayList<OFPortStatus>(); 124 this.pendingPortStatusMsg = new CopyOnWriteArrayList<OFPortStatus>();
125 + this.portDescReplies = new ArrayList<OFPortDescStatsReply>();
124 factory13 = controller.getOFMessageFactory13(); 126 factory13 = controller.getOFMessageFactory13();
125 factory10 = controller.getOFMessageFactory10(); 127 factory10 = controller.getOFMessageFactory10();
126 duplicateDpidFound = Boolean.FALSE; 128 duplicateDpidFound = Boolean.FALSE;
...@@ -294,10 +296,15 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -294,10 +296,15 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
294 } 296 }
295 if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) { 297 if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
296 log.warn("Stats reply indicates more stats from sw {} for " 298 log.warn("Stats reply indicates more stats from sw {} for "
297 - + "port description - not currently handled", 299 + + "port description",
298 h.getSwitchInfoString()); 300 h.getSwitchInfoString());
301 + h.portDescReplies.add((OFPortDescStatsReply)m);
302 + return;
303 + }
304 + else {
305 + h.portDescReplies.add((OFPortDescStatsReply)m);
299 } 306 }
300 - h.portDescReply = (OFPortDescStatsReply) m; // temp store 307 + //h.portDescReply = (OFPortDescStatsReply) m; // temp store
301 log.info("Received port desc reply for switch at {}", 308 log.info("Received port desc reply for switch at {}",
302 h.getSwitchInfoString()); 309 h.getSwitchInfoString());
303 try { 310 try {
...@@ -418,7 +425,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -418,7 +425,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
418 425
419 h.sw.setOFVersion(h.ofVersion); 426 h.sw.setOFVersion(h.ofVersion);
420 h.sw.setFeaturesReply(h.featuresReply); 427 h.sw.setFeaturesReply(h.featuresReply);
421 - h.sw.setPortDescReply(h.portDescReply); 428 + //h.sw.setPortDescReply(h.portDescReply);
429 + h.sw.setPortDescReplies(h.portDescReplies);
422 h.sw.setConnected(true); 430 h.sw.setConnected(true);
423 h.sw.setChannel(h.channel); 431 h.sw.setChannel(h.channel);
424 // boolean success = h.sw.connectSwitch(); 432 // boolean success = h.sw.connectSwitch();
......
...@@ -255,6 +255,10 @@ public class RoleManagerTest { ...@@ -255,6 +255,10 @@ public class RoleManagerTest {
255 } 255 }
256 256
257 @Override 257 @Override
258 + public void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies) {
259 + }
260 +
261 + @Override
258 public void setFeaturesReply(OFFeaturesReply featuresReply) { 262 public void setFeaturesReply(OFFeaturesReply featuresReply) {
259 } 263 }
260 264
......
...@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory; ...@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
32 32
33 import java.util.Collections; 33 import java.util.Collections;
34 import java.util.List; 34 import java.util.List;
35 +import java.util.stream.Collectors;
35 36
36 /** 37 /**
37 * A simple implementation of a driver manager that differentiates between 38 * A simple implementation of a driver manager that differentiates between
...@@ -73,6 +74,14 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory { ...@@ -73,6 +74,14 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory {
73 return new OFSwitchImplSpringOpenTTP(dpid, desc); 74 return new OFSwitchImplSpringOpenTTP(dpid, desc);
74 } 75 }
75 76
77 + //TODO: Temporary work around until the configuration based
78 + // driver manager framework is ready
79 + if (vendor.contains("Dell")
80 + &&
81 + hw.contains("OpenFlow switch HW ver. 1.0")) {
82 + return new OFSwitchImplSpringOpenTTPDellOSR(dpid, desc);
83 + }
84 +
76 if (hw.startsWith("Open vSwitch")) { 85 if (hw.startsWith("Open vSwitch")) {
77 if (ofv == OFVersion.OF_10) { 86 if (ofv == OFVersion.OF_10) {
78 return new OFSwitchImplOVS10(dpid, desc); 87 return new OFSwitchImplOVS10(dpid, desc);
...@@ -140,7 +149,9 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory { ...@@ -140,7 +149,9 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory {
140 if (this.factory().getVersion() == OFVersion.OF_10) { 149 if (this.factory().getVersion() == OFVersion.OF_10) {
141 return Collections.unmodifiableList(features.getPorts()); 150 return Collections.unmodifiableList(features.getPorts());
142 } else { 151 } else {
143 - return Collections.unmodifiableList(ports.getEntries()); 152 + return Collections.unmodifiableList(this.ports.stream()
153 + .flatMap((portReply) -> (portReply.getEntries().stream()))
154 + .collect(Collectors.toList()));
144 } 155 }
145 } 156 }
146 157
......
...@@ -183,7 +183,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -183,7 +183,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
183 @Override 183 @Override
184 public List<OFPortDesc> getPorts() { 184 public List<OFPortDesc> getPorts() {
185 List<OFPortDesc> portEntries = new ArrayList<>(); 185 List<OFPortDesc> portEntries = new ArrayList<>();
186 - portEntries.addAll(ports.getEntries()); 186 + portEntries.addAll(super.getPorts());
187 if (wPorts != null) { 187 if (wPorts != null) {
188 portEntries.addAll(wPorts.getEntries()); 188 portEntries.addAll(wPorts.getEntries());
189 } 189 }
......
...@@ -34,6 +34,8 @@ import java.util.Collections; ...@@ -34,6 +34,8 @@ import java.util.Collections;
34 import java.util.List; 34 import java.util.List;
35 import java.util.concurrent.atomic.AtomicBoolean; 35 import java.util.concurrent.atomic.AtomicBoolean;
36 36
37 +//TODO: Knock-off this class as we don't need any switch/app specific
38 +//drivers in the south bound layers.
37 public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { 39 public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch {
38 40
39 private OFFactory factory; 41 private OFFactory factory;
...@@ -48,8 +50,9 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { ...@@ -48,8 +50,9 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch {
48 private static final int TABLE_MPLS = 3; 50 private static final int TABLE_MPLS = 3;
49 private static final int TABLE_ACL = 5; 51 private static final int TABLE_ACL = 5;
50 52
51 - /* Set the default values. These variables will get 53 + /*
52 - * overwritten based on the switch vendor type 54 + * Set the default values. These variables will get overwritten based on the
55 + * switch vendor type
53 */ 56 */
54 protected int vlanTableId = TABLE_VLAN; 57 protected int vlanTableId = TABLE_VLAN;
55 protected int tmacTableId = TABLE_TMAC; 58 protected int tmacTableId = TABLE_TMAC;
...@@ -64,13 +67,13 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { ...@@ -64,13 +67,13 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch {
64 setSwitchDescription(desc); 67 setSwitchDescription(desc);
65 } 68 }
66 69
67 -
68 @Override 70 @Override
69 public String toString() { 71 public String toString() {
70 - return "OFSwitchImplSpringOpenTTP [" + ((channel != null) 72 + return "OFSwitchImplSpringOpenTTP ["
71 - ? channel.getRemoteAddress() : "?") 73 + + ((channel != null) ? channel.getRemoteAddress() : "?")
72 - + " DPID[" + ((this.getStringId() != null) ? 74 + + " DPID["
73 - this.getStringId() : "?") + "]]"; 75 + + ((this.getStringId() != null) ? this.getStringId() : "?")
76 + + "]]";
74 } 77 }
75 78
76 @Override 79 @Override
...@@ -78,7 +81,6 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { ...@@ -78,7 +81,6 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch {
78 return null; 81 return null;
79 } 82 }
80 83
81 -
82 @Override 84 @Override
83 public void startDriverHandshake() { 85 public void startDriverHandshake() {
84 log.debug("Starting driver handshake for sw {}", getStringId()); 86 log.debug("Starting driver handshake for sw {}", getStringId());
...@@ -101,8 +103,6 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { ...@@ -101,8 +103,6 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch {
101 return driverHandshakeComplete.get(); 103 return driverHandshakeComplete.get();
102 } 104 }
103 105
104 -
105 -
106 @Override 106 @Override
107 public void processDriverHandshakeMessage(OFMessage m) { 107 public void processDriverHandshakeMessage(OFMessage m) {
108 if (!startDriverHandshakeCalled) { 108 if (!startDriverHandshakeCalled) {
...@@ -113,15 +113,14 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { ...@@ -113,15 +113,14 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch {
113 } 113 }
114 } 114 }
115 115
116 -
117 @Override 116 @Override
118 public void write(OFMessage msg) { 117 public void write(OFMessage msg) {
119 - this.channel.write(Collections.singletonList(msg)); 118 + channel.write(Collections.singletonList(msg));
120 } 119 }
121 120
122 @Override 121 @Override
123 public void write(List<OFMessage> msgs) { 122 public void write(List<OFMessage> msgs) {
124 - this.channel.write(msgs); 123 + channel.write(msgs);
125 } 124 }
126 125
127 @Override 126 @Override
...@@ -134,9 +133,9 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { ...@@ -134,9 +133,9 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch {
134 for (OFInstruction i : instructions) { 133 for (OFInstruction i : instructions) {
135 if (i instanceof OFInstructionGotoTable) { 134 if (i instanceof OFInstructionGotoTable) {
136 OFInstructionGotoTable gotoTable = (OFInstructionGotoTable) i; 135 OFInstructionGotoTable gotoTable = (OFInstructionGotoTable) i;
137 - TableType tid = TableType.values()[gotoTable.getTableId().getValue()]; 136 + TableType tid = TableType.values()[gotoTable.getTableId()
138 - newInstructions.add( 137 + .getValue()];
139 - gotoTable.createBuilder() 138 + newInstructions.add(gotoTable.createBuilder()
140 .setTableId(getTableId(tid)).build()); 139 .setTableId(getTableId(tid)).build());
141 } else { 140 } else {
142 newInstructions.add(i); 141 newInstructions.add(i);
...@@ -167,7 +166,8 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { ...@@ -167,7 +166,8 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch {
167 case TABLE_TMAC: 166 case TABLE_TMAC:
168 return TableType.ETHER; 167 return TableType.ETHER;
169 default: 168 default:
170 - log.error("Table type for Table id {} is not supported in the driver", tid); 169 + log.error("Table type for Table id {} is not supported in the driver",
170 + tid);
171 return TableType.NONE; 171 return TableType.NONE;
172 } 172 }
173 } 173 }
......
1 +/*
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 + */
16 +package org.onosproject.openflow.drivers;
17 +
18 +import org.onosproject.openflow.controller.Dpid;
19 +import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
20 +import org.projectfloodlight.openflow.types.TableId;
21 +
22 +/**
23 + * OFDescriptionStatistics Vendor (Manufacturer Desc.): Dell Make (Hardware
24 + * Desc.) : OpenFlow 1.3 Reference Userspace Switch Model (Datapath Desc.) :
25 + * None Software : Serial : None.
26 + */
27 +//TODO: Knock-off this class as we don't need any switch/app specific
28 +//drivers in the south bound layers.
29 +public class OFSwitchImplSpringOpenTTPDellOSR extends OFSwitchImplSpringOpenTTP {
30 +
31 + /* Table IDs to be used for Dell Open Segment Routers*/
32 + private static final int DELL_TABLE_VLAN = 17;
33 + private static final int DELL_TABLE_TMAC = 18;
34 + private static final int DELL_TABLE_IPV4_UNICAST = 30;
35 + private static final int DELL_TABLE_MPLS = 25;
36 + private static final int DELL_TABLE_ACL = 40;
37 +
38 + public OFSwitchImplSpringOpenTTPDellOSR(Dpid dpid, OFDescStatsReply desc) {
39 + super(dpid, desc);
40 + vlanTableId = DELL_TABLE_VLAN;
41 + tmacTableId = DELL_TABLE_TMAC;
42 + ipv4UnicastTableId = DELL_TABLE_IPV4_UNICAST;
43 + mplsTableId = DELL_TABLE_MPLS;
44 + aclTableId = DELL_TABLE_ACL;
45 + }
46 +
47 + @Override
48 + public TableType getTableType(TableId tid) {
49 + switch (tid.getValue()) {
50 + case DELL_TABLE_IPV4_UNICAST:
51 + return TableType.IP;
52 + case DELL_TABLE_MPLS:
53 + return TableType.MPLS;
54 + case DELL_TABLE_ACL:
55 + return TableType.ACL;
56 + case DELL_TABLE_VLAN:
57 + return TableType.VLAN;
58 + case DELL_TABLE_TMAC:
59 + return TableType.ETHER;
60 + default:
61 + log.error("Table type for Table id {} is not supported in the driver", tid);
62 + return TableType.NONE;
63 + }
64 + }
65 +}
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "comment": " Multilayer topology description and configuration",
3 + "restrictSwitches": true,
4 + "restrictLinks": true,
5 +
6 + "switchConfig":
7 + [
8 + { "nodeDpid" : "of:00010001e88b9368", "name": "Dell-R1", "type": "Router_SR", "allowed": true,
9 + "latitude": 80.80, "longitude": 90.10,
10 + "params": { "routerIp": "192.168.0.1/32",
11 + "routerMac": "00:01:e8:8b:93:6b",
12 + "nodeSid": 101,
13 + "isEdgeRouter" : true,
14 + "subnets": [
15 + { "portNo": 46, "subnetIp": "10.200.1.1/24" }
16 + ]
17 + }
18 + },
19 +
20 + { "nodeDpid": "of:00010001e88b939b", "name": "Dell-R2", "type": "Router_SR", "allowed": true,
21 + "latitude": 80.80, "longitude": 90.10,
22 + "params": { "routerIp": "192.168.0.2/32",
23 + "routerMac": "00:01:e8:8b:93:9e",
24 + "nodeSid": 102,
25 + "isEdgeRouter" : true,
26 + "subnets": [
27 + { "portNo": 46, "subnetIp": "10.200.2.1/24" }
28 + ]
29 + }
30 + },
31 +
32 + { "nodeDpid": "of:00010001e88b938c", "name": "Dell-R3", "type": "Router_SR", "allowed": true,
33 + "latitude": 80.80, "longitude": 90.10,
34 + "params": { "routerIp": "192.168.0.3/32",
35 + "routerMac": "00:01:e8:8b:93:8f",
36 + "nodeSid": 103,
37 + "isEdgeRouter" : true,
38 + "subnets": [
39 + { "portNo": 46, "subnetIp": "10.200.3.1/24" }
40 + ]
41 + }
42 + },
43 +
44 + { "nodeDpid": "of:00010001e88b93ad", "name": "Dell-R4", "type": "Router_SR", "allowed": true,
45 + "latitude": 80.80, "longitude": 90.10,
46 + "params": { "routerIp": "192.168.0.4/32",
47 + "routerMac": "00:01:e8:8b:93:b0",
48 + "nodeSid": 104,
49 + "isEdgeRouter" : true,
50 + "subnets": [
51 + { "portNo": 46, "subnetIp": "10.200.4.1/24" }
52 + ]
53 + }
54 + },
55 +
56 + { "nodeDpid": "of:00010001e88b93bc", "name": "Dell-R5", "type": "Router_SR", "allowed": true,
57 + "latitude": 80.80, "longitude": 90.10,
58 + "params": { "routerIp": "192.168.0.5/32",
59 + "routerMac": "00:01:e8:8b:93:bf",
60 + "nodeSid": 105,
61 + "isEdgeRouter" : false
62 + }
63 + },
64 +
65 + { "nodeDpid": "of:00010001e88b93c2", "name": "Dell-R6", "type": "Router_SR", "allowed": true,
66 + "latitude": 80.80, "longitude": 90.10,
67 + "params": { "routerIp": "192.168.0.6/32",
68 + "routerMac": "00:01:e8:8b:93:c5",
69 + "nodeSid": 106,
70 + "isEdgeRouter" : false
71 + }
72 + },
73 +
74 + { "nodeDpid": "of:00010001e88b9398", "name": "Dell-R7", "type": "Router_SR", "allowed": true,
75 + "latitude": 80.80, "longitude": 90.10,
76 + "params": { "routerIp": "192.168.0.7/32",
77 + "routerMac": "00:01:e8:8b:93:9b",
78 + "nodeSid": 107,
79 + "isEdgeRouter": false
80 + }
81 + },
82 +
83 + { "nodeDpid": "of:00010001e88b27e3", "name": "Dell-R8", "type": "Router_SR", "allowed": true,
84 + "latitude": 80.80, "longitude": 90.10,
85 + "params": { "routerIp": "192.168.0.8/32",
86 + "routerMac": "00:01:e8:8b:27:e6",
87 + "nodeSid": 108,
88 + "isEdgeRouter": false
89 + }
90 + }
91 +
92 + ]
93 +}