Srikanth Vavilapalli

ONOS-1823 and ONOS-1838:Segment Routing Multi-instance Support-1

Change-Id: I3cc848415a609a9c4001d135e51104c62fb2830d
Showing 18 changed files with 381 additions and 230 deletions
...@@ -89,14 +89,18 @@ public class DefaultRoutingHandler { ...@@ -89,14 +89,18 @@ public class DefaultRoutingHandler {
89 populationStatus = Status.STARTED; 89 populationStatus = Status.STARTED;
90 rulePopulator.resetCounter(); 90 rulePopulator.resetCounter();
91 log.info("Starts to populate routing rules"); 91 log.info("Starts to populate routing rules");
92 + log.debug("populateAllRoutingRules: populationStatus is STARTED");
92 93
93 for (Device sw : srManager.deviceService.getDevices()) { 94 for (Device sw : srManager.deviceService.getDevices()) {
94 if (srManager.mastershipService.getLocalRole(sw.id()) != MastershipRole.MASTER) { 95 if (srManager.mastershipService.getLocalRole(sw.id()) != MastershipRole.MASTER) {
96 + log.debug("populateAllRoutingRules: skipping device {}...we are not master",
97 + sw.id());
95 continue; 98 continue;
96 } 99 }
97 100
98 ECMPShortestPathGraph ecmpSpg = new ECMPShortestPathGraph(sw.id(), srManager); 101 ECMPShortestPathGraph ecmpSpg = new ECMPShortestPathGraph(sw.id(), srManager);
99 if (!populateEcmpRoutingRules(sw.id(), ecmpSpg)) { 102 if (!populateEcmpRoutingRules(sw.id(), ecmpSpg)) {
103 + log.debug("populateAllRoutingRules: populationStatus is ABORTED");
100 populationStatus = Status.ABORTED; 104 populationStatus = Status.ABORTED;
101 log.debug("Abort routing rule population"); 105 log.debug("Abort routing rule population");
102 return false; 106 return false;
...@@ -106,6 +110,7 @@ public class DefaultRoutingHandler { ...@@ -106,6 +110,7 @@ public class DefaultRoutingHandler {
106 // TODO: Set adjacency routing rule for all switches 110 // TODO: Set adjacency routing rule for all switches
107 } 111 }
108 112
113 + log.debug("populateAllRoutingRules: populationStatus is SUCCEEDED");
109 populationStatus = Status.SUCCEEDED; 114 populationStatus = Status.SUCCEEDED;
110 log.info("Completes routing rule population. Total # of rules pushed : {}", 115 log.info("Completes routing rule population. Total # of rules pushed : {}",
111 rulePopulator.getCounter()); 116 rulePopulator.getCounter());
...@@ -144,6 +149,8 @@ public class DefaultRoutingHandler { ...@@ -144,6 +149,8 @@ public class DefaultRoutingHandler {
144 log.info("Starts rule population from link change"); 149 log.info("Starts rule population from link change");
145 150
146 Set<ArrayList<DeviceId>> routeChanges; 151 Set<ArrayList<DeviceId>> routeChanges;
152 + log.trace("populateRoutingRulesForLinkStatusChange: "
153 + + "populationStatus is STARTED");
147 populationStatus = Status.STARTED; 154 populationStatus = Status.STARTED;
148 if (linkFail == null) { 155 if (linkFail == null) {
149 // Compare all routes of existing ECMP SPG with the new ones 156 // Compare all routes of existing ECMP SPG with the new ones
...@@ -155,16 +162,19 @@ public class DefaultRoutingHandler { ...@@ -155,16 +162,19 @@ public class DefaultRoutingHandler {
155 162
156 if (routeChanges.isEmpty()) { 163 if (routeChanges.isEmpty()) {
157 log.info("No route changes for the link status change"); 164 log.info("No route changes for the link status change");
165 + log.debug("populateRoutingRulesForLinkStatusChange: populationStatus is SUCCEEDED");
158 populationStatus = Status.SUCCEEDED; 166 populationStatus = Status.SUCCEEDED;
159 return true; 167 return true;
160 } 168 }
161 169
162 if (repopulateRoutingRulesForRoutes(routeChanges)) { 170 if (repopulateRoutingRulesForRoutes(routeChanges)) {
171 + log.debug("populateRoutingRulesForLinkStatusChange: populationStatus is SUCCEEDED");
163 populationStatus = Status.SUCCEEDED; 172 populationStatus = Status.SUCCEEDED;
164 log.info("Complete to repopulate the rules. # of rules populated : {}", 173 log.info("Complete to repopulate the rules. # of rules populated : {}",
165 rulePopulator.getCounter()); 174 rulePopulator.getCounter());
166 return true; 175 return true;
167 } else { 176 } else {
177 + log.debug("populateRoutingRulesForLinkStatusChange: populationStatus is ABORTED");
168 populationStatus = Status.ABORTED; 178 populationStatus = Status.ABORTED;
169 log.warn("Failed to repopulate the rules."); 179 log.warn("Failed to repopulate the rules.");
170 return false; 180 return false;
...@@ -177,6 +187,7 @@ public class DefaultRoutingHandler { ...@@ -177,6 +187,7 @@ public class DefaultRoutingHandler {
177 for (ArrayList<DeviceId> link: routes) { 187 for (ArrayList<DeviceId> link: routes) {
178 // When only the source device is defined, reinstall routes to all other devices 188 // When only the source device is defined, reinstall routes to all other devices
179 if (link.size() == 1) { 189 if (link.size() == 1) {
190 + log.trace("repopulateRoutingRulesForRoutes: running ECMP graph for device {}", link.get(0));
180 ECMPShortestPathGraph ecmpSpg = new ECMPShortestPathGraph(link.get(0), srManager); 191 ECMPShortestPathGraph ecmpSpg = new ECMPShortestPathGraph(link.get(0), srManager);
181 if (populateEcmpRoutingRules(link.get(0), ecmpSpg)) { 192 if (populateEcmpRoutingRules(link.get(0), ecmpSpg)) {
182 currentEcmpSpgMap.put(link.get(0), ecmpSpg); 193 currentEcmpSpgMap.put(link.get(0), ecmpSpg);
...@@ -187,8 +198,7 @@ public class DefaultRoutingHandler { ...@@ -187,8 +198,7 @@ public class DefaultRoutingHandler {
187 } else { 198 } else {
188 DeviceId src = link.get(0); 199 DeviceId src = link.get(0);
189 DeviceId dst = link.get(1); 200 DeviceId dst = link.get(1);
190 - log.trace("repopulateRoutingRulesForRoutes: running ECMP graph " 201 + log.trace("repopulateRoutingRulesForRoutes: running ECMP graph for device {}", dst);
191 - + "for device {}", dst);
192 ECMPShortestPathGraph ecmpSpg = updatedEcmpSpgMap.get(dst); 202 ECMPShortestPathGraph ecmpSpg = updatedEcmpSpgMap.get(dst);
193 HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> switchVia = 203 HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> switchVia =
194 ecmpSpg.getAllLearnedSwitchesAndVia(); 204 ecmpSpg.getAllLearnedSwitchesAndVia();
...@@ -278,14 +288,12 @@ public class DefaultRoutingHandler { ...@@ -278,14 +288,12 @@ public class DefaultRoutingHandler {
278 log.debug("Checking route change for switch {}", sw.id()); 288 log.debug("Checking route change for switch {}", sw.id());
279 ECMPShortestPathGraph ecmpSpg = currentEcmpSpgMap.get(sw.id()); 289 ECMPShortestPathGraph ecmpSpg = currentEcmpSpgMap.get(sw.id());
280 if (ecmpSpg == null) { 290 if (ecmpSpg == null) {
281 - log.debug("No existing ECMP path for Switch {}", sw.id()); 291 + log.debug("No existing ECMP graph for device {}", sw.id());
282 ArrayList<DeviceId> route = new ArrayList<>(); 292 ArrayList<DeviceId> route = new ArrayList<>();
283 route.add(sw.id()); 293 route.add(sw.id());
284 routes.add(route); 294 routes.add(route);
285 continue; 295 continue;
286 } 296 }
287 - log.debug("computeRouteChange: running ECMP graph "
288 - + "for device {}", sw.id());
289 ECMPShortestPathGraph newEcmpSpg = updatedEcmpSpgMap.get(sw.id()); 297 ECMPShortestPathGraph newEcmpSpg = updatedEcmpSpgMap.get(sw.id());
290 currentEcmpSpgMap.put(sw.id(), newEcmpSpg); 298 currentEcmpSpgMap.put(sw.id(), newEcmpSpg);
291 HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> switchVia = 299 HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> switchVia =
...@@ -400,6 +408,8 @@ public class DefaultRoutingHandler { ...@@ -400,6 +408,8 @@ public class DefaultRoutingHandler {
400 // rule for both subnet and router IP. 408 // rule for both subnet and router IP.
401 if (config.isEdgeDevice(targetSw) && config.isEdgeDevice(destSw)) { 409 if (config.isEdgeDevice(targetSw) && config.isEdgeDevice(destSw)) {
402 List<Ip4Prefix> subnets = config.getSubnets(destSw); 410 List<Ip4Prefix> subnets = config.getSubnets(destSw);
411 + log.debug("populateEcmpRoutingRulePartial in device {} towards {} for subnets {}",
412 + targetSw, destSw, subnets);
403 result = rulePopulator.populateIpRuleForSubnet(targetSw, 413 result = rulePopulator.populateIpRuleForSubnet(targetSw,
404 subnets, 414 subnets,
405 destSw, 415 destSw,
...@@ -410,6 +420,8 @@ public class DefaultRoutingHandler { ...@@ -410,6 +420,8 @@ public class DefaultRoutingHandler {
410 420
411 Ip4Address routerIp = config.getRouterIp(destSw); 421 Ip4Address routerIp = config.getRouterIp(destSw);
412 IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); 422 IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH);
423 + log.debug("populateEcmpRoutingRulePartial in device {} towards {} for router IP {}",
424 + targetSw, destSw, routerIpPrefix);
413 result = rulePopulator.populateIpRuleForRouter(targetSw, routerIpPrefix, destSw, nextHops); 425 result = rulePopulator.populateIpRuleForRouter(targetSw, routerIpPrefix, destSw, nextHops);
414 if (!result) { 426 if (!result) {
415 return false; 427 return false;
...@@ -419,6 +431,8 @@ public class DefaultRoutingHandler { ...@@ -419,6 +431,8 @@ public class DefaultRoutingHandler {
419 } else if (config.isEdgeDevice(targetSw)) { 431 } else if (config.isEdgeDevice(targetSw)) {
420 Ip4Address routerIp = config.getRouterIp(destSw); 432 Ip4Address routerIp = config.getRouterIp(destSw);
421 IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH); 433 IpPrefix routerIpPrefix = IpPrefix.valueOf(routerIp, IpPrefix.MAX_INET_MASK_LENGTH);
434 + log.debug("populateEcmpRoutingRulePartial in device {} towards {} for router IP {}",
435 + targetSw, destSw, routerIpPrefix);
422 result = rulePopulator.populateIpRuleForRouter(targetSw, routerIpPrefix, destSw, nextHops); 436 result = rulePopulator.populateIpRuleForRouter(targetSw, routerIpPrefix, destSw, nextHops);
423 if (!result) { 437 if (!result) {
424 return false; 438 return false;
...@@ -426,6 +440,8 @@ public class DefaultRoutingHandler { ...@@ -426,6 +440,8 @@ public class DefaultRoutingHandler {
426 } 440 }
427 441
428 // Populates MPLS rules to all routers 442 // Populates MPLS rules to all routers
443 + log.debug("populateEcmpRoutingRulePartial in device{} towards {} for all MPLS rules",
444 + targetSw, destSw);
429 result = rulePopulator.populateMplsRule(targetSw, destSw, nextHops); 445 result = rulePopulator.populateMplsRule(targetSw, destSw, nextHops);
430 if (!result) { 446 if (!result) {
431 return false; 447 return false;
...@@ -453,9 +469,13 @@ public class DefaultRoutingHandler { ...@@ -453,9 +469,13 @@ public class DefaultRoutingHandler {
453 public void startPopulationProcess() { 469 public void startPopulationProcess() {
454 synchronized (populationStatus) { 470 synchronized (populationStatus) {
455 if (populationStatus == Status.IDLE 471 if (populationStatus == Status.IDLE
456 - || populationStatus == Status.SUCCEEDED) { 472 + || populationStatus == Status.SUCCEEDED
473 + || populationStatus == Status.ABORTED) {
457 populationStatus = Status.STARTED; 474 populationStatus = Status.STARTED;
458 populateAllRoutingRules(); 475 populateAllRoutingRules();
476 + } else {
477 + log.warn("Not initiating startPopulationProcess as populationStatus is {}",
478 + populationStatus);
459 } 479 }
460 } 480 }
461 } 481 }
......
...@@ -99,6 +99,9 @@ public class DeviceConfiguration implements DeviceProperties { ...@@ -99,6 +99,9 @@ public class DeviceConfiguration implements DeviceProperties {
99 deviceConfigMap.get(deviceId).nodeSid); 99 deviceConfigMap.get(deviceId).nodeSid);
100 return deviceConfigMap.get(deviceId).nodeSid; 100 return deviceConfigMap.get(deviceId).nodeSid;
101 } else { 101 } else {
102 + log.warn("getSegmentId for device {} "
103 + + "throwing IllegalStateException "
104 + + "because device does not exist in config", deviceId);
102 throw new IllegalStateException(); 105 throw new IllegalStateException();
103 } 106 }
104 } 107 }
...@@ -151,6 +154,9 @@ public class DeviceConfiguration implements DeviceProperties { ...@@ -151,6 +154,9 @@ public class DeviceConfiguration implements DeviceProperties {
151 deviceConfigMap.get(deviceId).mac); 154 deviceConfigMap.get(deviceId).mac);
152 return deviceConfigMap.get(deviceId).mac; 155 return deviceConfigMap.get(deviceId).mac;
153 } else { 156 } else {
157 + log.warn("getDeviceMac for device {} "
158 + + "throwing IllegalStateException "
159 + + "because device does not exist in config", deviceId);
154 throw new IllegalStateException(); 160 throw new IllegalStateException();
155 } 161 }
156 } 162 }
...@@ -168,6 +174,9 @@ public class DeviceConfiguration implements DeviceProperties { ...@@ -168,6 +174,9 @@ public class DeviceConfiguration implements DeviceProperties {
168 deviceConfigMap.get(deviceId).ip); 174 deviceConfigMap.get(deviceId).ip);
169 return deviceConfigMap.get(deviceId).ip; 175 return deviceConfigMap.get(deviceId).ip;
170 } else { 176 } else {
177 + log.warn("getRouterIp for device {} "
178 + + "throwing IllegalStateException "
179 + + "because device does not exist in config", deviceId);
171 throw new IllegalStateException(); 180 throw new IllegalStateException();
172 } 181 }
173 } 182 }
...@@ -187,6 +196,9 @@ public class DeviceConfiguration implements DeviceProperties { ...@@ -187,6 +196,9 @@ public class DeviceConfiguration implements DeviceProperties {
187 deviceConfigMap.get(deviceId).isEdge); 196 deviceConfigMap.get(deviceId).isEdge);
188 return deviceConfigMap.get(deviceId).isEdge; 197 return deviceConfigMap.get(deviceId).isEdge;
189 } else { 198 } else {
199 + log.warn("isEdgeDevice for device {} "
200 + + "throwing IllegalStateException "
201 + + "because device does not exist in config", deviceId);
190 throw new IllegalStateException(); 202 throw new IllegalStateException();
191 } 203 }
192 } 204 }
......
...@@ -217,6 +217,11 @@ public class RoutingRulePopulator { ...@@ -217,6 +217,11 @@ public class RoutingRulePopulator {
217 217
218 // If the next hop is the destination router, do PHP 218 // If the next hop is the destination router, do PHP
219 if (nextHops.size() == 1 && destSwId.equals(nextHops.toArray()[0])) { 219 if (nextHops.size() == 1 && destSwId.equals(nextHops.toArray()[0])) {
220 + log.debug("populateMplsRule: Installing MPLS forwarding objective for "
221 + + "label {} in switch {} with PHP",
222 + config.getSegmentId(destSwId),
223 + deviceId);
224 +
220 ForwardingObjective.Builder fwdObjBosBuilder = 225 ForwardingObjective.Builder fwdObjBosBuilder =
221 getMplsForwardingObjective(deviceId, 226 getMplsForwardingObjective(deviceId,
222 destSwId, 227 destSwId,
...@@ -237,6 +242,11 @@ public class RoutingRulePopulator { ...@@ -237,6 +242,11 @@ public class RoutingRulePopulator {
237 return false; 242 return false;
238 } 243 }
239 } else { 244 } else {
245 + log.debug("Installing MPLS forwarding objective for "
246 + + "label {} in switch {} without PHP",
247 + config.getSegmentId(destSwId),
248 + deviceId);
249 +
240 ForwardingObjective.Builder fwdObjBosBuilder = 250 ForwardingObjective.Builder fwdObjBosBuilder =
241 getMplsForwardingObjective(deviceId, 251 getMplsForwardingObjective(deviceId,
242 destSwId, 252 destSwId,
...@@ -264,8 +274,6 @@ public class RoutingRulePopulator { ...@@ -264,8 +274,6 @@ public class RoutingRulePopulator {
264 .makePermanent()).withSelector(selector) 274 .makePermanent()).withSelector(selector)
265 .withPriority(100)) 275 .withPriority(100))
266 .withFlag(ForwardingObjective.Flag.SPECIFIC); 276 .withFlag(ForwardingObjective.Flag.SPECIFIC);
267 - log.debug("Installing MPLS forwarding objective in switch {}",
268 - deviceId);
269 srManager.flowObjectiveService.forward(deviceId, 277 srManager.flowObjectiveService.forward(deviceId,
270 fwdObjBuilder.add()); 278 fwdObjBuilder.add());
271 rulePopulationCounter.incrementAndGet(); 279 rulePopulationCounter.incrementAndGet();
......
...@@ -19,16 +19,12 @@ import java.util.HashSet; ...@@ -19,16 +19,12 @@ import java.util.HashSet;
19 import java.util.List; 19 import java.util.List;
20 import java.util.Set; 20 import java.util.Set;
21 21
22 -import org.onlab.packet.MplsLabel;
23 import org.onosproject.core.ApplicationId; 22 import org.onosproject.core.ApplicationId;
24 import org.onosproject.net.DeviceId; 23 import org.onosproject.net.DeviceId;
25 import org.onosproject.net.Link; 24 import org.onosproject.net.Link;
26 -import org.onosproject.net.flow.DefaultTrafficTreatment;
27 -import org.onosproject.net.flow.TrafficTreatment;
28 -import org.onosproject.net.flowobjective.DefaultNextObjective;
29 import org.onosproject.net.flowobjective.FlowObjectiveService; 25 import org.onosproject.net.flowobjective.FlowObjectiveService;
30 -import org.onosproject.net.flowobjective.NextObjective;
31 import org.onosproject.net.link.LinkService; 26 import org.onosproject.net.link.LinkService;
27 +import org.onosproject.store.service.EventuallyConsistentMap;
32 28
33 /** 29 /**
34 * Default ECMP group handler creation module for an edge device. 30 * Default ECMP group handler creation module for an edge device.
...@@ -53,8 +49,11 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { ...@@ -53,8 +49,11 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
53 ApplicationId appId, 49 ApplicationId appId,
54 DeviceProperties config, 50 DeviceProperties config,
55 LinkService linkService, 51 LinkService linkService,
56 - FlowObjectiveService flowObjService) { 52 + FlowObjectiveService flowObjService,
57 - super(deviceId, appId, config, linkService, flowObjService); 53 + EventuallyConsistentMap<
54 + NeighborSetNextObjectiveStoreKey,
55 + Integer> nsNextObjStore) {
56 + super(deviceId, appId, config, linkService, flowObjService, nsNextObjStore);
58 } 57 }
59 58
60 @Override 59 @Override
...@@ -108,7 +107,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { ...@@ -108,7 +107,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
108 107
109 @Override 108 @Override
110 protected void newPortToExistingNeighbor(Link newNeighborLink) { 109 protected void newPortToExistingNeighbor(Link newNeighborLink) {
111 - log.debug("New port to existing neighbor: Updating " 110 + /*log.debug("New port to existing neighbor: Updating "
112 + "groups for edge device {}", deviceId); 111 + "groups for edge device {}", deviceId);
113 addNeighborAtPort(newNeighborLink.dst().deviceId(), 112 addNeighborAtPort(newNeighborLink.dst().deviceId(),
114 newNeighborLink.src().port()); 113 newNeighborLink.src().port());
...@@ -129,7 +128,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { ...@@ -129,7 +128,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
129 mplsLabel(ns.getEdgeLabel())); 128 mplsLabel(ns.getEdgeLabel()));
130 } 129 }
131 130
132 - Integer nextId = deviceNextObjectiveIds.get(getGroupKey(ns)); 131 + Integer nextId = deviceNextObjectiveIds.get(ns);
133 if (nextId != null) { 132 if (nextId != null) {
134 NextObjective.Builder nextObjBuilder = DefaultNextObjective 133 NextObjective.Builder nextObjBuilder = DefaultNextObjective
135 .builder().withId(nextId) 134 .builder().withId(nextId)
...@@ -140,7 +139,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler { ...@@ -140,7 +139,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
140 NextObjective nextObjective = nextObjBuilder.add(); 139 NextObjective nextObjective = nextObjBuilder.add();
141 flowObjectiveService.next(deviceId, nextObjective); 140 flowObjectiveService.next(deviceId, nextObjective);
142 } 141 }
143 - } 142 + }*/
144 } 143 }
145 144
146 @Override 145 @Override
......
...@@ -18,16 +18,12 @@ package org.onosproject.segmentrouting.grouphandler; ...@@ -18,16 +18,12 @@ package org.onosproject.segmentrouting.grouphandler;
18 import java.util.HashSet; 18 import java.util.HashSet;
19 import java.util.Set; 19 import java.util.Set;
20 20
21 -import org.onlab.packet.MplsLabel;
22 import org.onosproject.core.ApplicationId; 21 import org.onosproject.core.ApplicationId;
23 import org.onosproject.net.DeviceId; 22 import org.onosproject.net.DeviceId;
24 import org.onosproject.net.Link; 23 import org.onosproject.net.Link;
25 -import org.onosproject.net.flow.DefaultTrafficTreatment;
26 -import org.onosproject.net.flow.TrafficTreatment;
27 -import org.onosproject.net.flowobjective.DefaultNextObjective;
28 import org.onosproject.net.flowobjective.FlowObjectiveService; 24 import org.onosproject.net.flowobjective.FlowObjectiveService;
29 -import org.onosproject.net.flowobjective.NextObjective;
30 import org.onosproject.net.link.LinkService; 25 import org.onosproject.net.link.LinkService;
26 +import org.onosproject.store.service.EventuallyConsistentMap;
31 27
32 /** 28 /**
33 * Default ECMP group handler creation module for a transit device. 29 * Default ECMP group handler creation module for a transit device.
...@@ -47,8 +43,11 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { ...@@ -47,8 +43,11 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
47 ApplicationId appId, 43 ApplicationId appId,
48 DeviceProperties config, 44 DeviceProperties config,
49 LinkService linkService, 45 LinkService linkService,
50 - FlowObjectiveService flowObjService) { 46 + FlowObjectiveService flowObjService,
51 - super(deviceId, appId, config, linkService, flowObjService); 47 + EventuallyConsistentMap<
48 + NeighborSetNextObjectiveStoreKey,
49 + Integer> nsNextObjStore) {
50 + super(deviceId, appId, config, linkService, flowObjService, nsNextObjStore);
52 } 51 }
53 52
54 @Override 53 @Override
...@@ -96,7 +95,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { ...@@ -96,7 +95,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
96 95
97 @Override 96 @Override
98 protected void newPortToExistingNeighbor(Link newNeighborLink) { 97 protected void newPortToExistingNeighbor(Link newNeighborLink) {
99 - log.debug("New port to existing neighbor: Updating " 98 + /*log.debug("New port to existing neighbor: Updating "
100 + "groups for transit device {}", deviceId); 99 + "groups for transit device {}", deviceId);
101 addNeighborAtPort(newNeighborLink.dst().deviceId(), 100 addNeighborAtPort(newNeighborLink.dst().deviceId(),
102 newNeighborLink.src().port()); 101 newNeighborLink.src().port());
...@@ -118,7 +117,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { ...@@ -118,7 +117,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
118 } 117 }
119 118
120 119
121 - Integer nextId = deviceNextObjectiveIds.get(getGroupKey(ns)); 120 + Integer nextId = deviceNextObjectiveIds.get(ns);
122 if (nextId != null) { 121 if (nextId != null) {
123 NextObjective.Builder nextObjBuilder = DefaultNextObjective 122 NextObjective.Builder nextObjBuilder = DefaultNextObjective
124 .builder().withId(nextId) 123 .builder().withId(nextId)
...@@ -129,7 +128,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler { ...@@ -129,7 +128,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
129 NextObjective nextObjective = nextObjBuilder.add(); 128 NextObjective nextObjective = nextObjBuilder.add();
130 flowObjectiveService.next(deviceId, nextObjective); 129 flowObjectiveService.next(deviceId, nextObjective);
131 } 130 }
132 - } 131 + }*/
133 } 132 }
134 133
135 @Override 134 @Override
......
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 +
17 +package org.onosproject.segmentrouting.grouphandler;
18 +
19 +import java.util.Objects;
20 +
21 +import org.onosproject.net.DeviceId;
22 +
23 +/**
24 + * Class definition of Key for Neighborset to NextObjective store.
25 + */
26 +public class NeighborSetNextObjectiveStoreKey {
27 + private final DeviceId deviceId;
28 + private final NeighborSet ns;
29 +
30 + public NeighborSetNextObjectiveStoreKey(DeviceId deviceId,
31 + NeighborSet ns) {
32 + this.deviceId = deviceId;
33 + this.ns = ns;
34 + }
35 +
36 + public DeviceId deviceId() {
37 + return this.deviceId;
38 + }
39 +
40 + public NeighborSet neighborSet() {
41 + return this.ns;
42 + }
43 +
44 + @Override
45 + public boolean equals(Object o) {
46 + if (this == o) {
47 + return true;
48 + }
49 + if (!(o instanceof NeighborSetNextObjectiveStoreKey)) {
50 + return false;
51 + }
52 + NeighborSetNextObjectiveStoreKey that =
53 + (NeighborSetNextObjectiveStoreKey) o;
54 + return (Objects.equals(this.deviceId, that.deviceId) &&
55 + Objects.equals(this.ns, that.ns));
56 + }
57 +
58 + // The list of neighbor ids and label are used for comparison.
59 + @Override
60 + public int hashCode() {
61 + int result = 17;
62 + result = 31 * result + Objects.hashCode(this.deviceId)
63 + + Objects.hashCode(this.ns);
64 +
65 + return result;
66 + }
67 +
68 + @Override
69 + public String toString() {
70 + return "Device: " + deviceId + " Neighborset: " + ns;
71 + }
72 +}
...@@ -27,6 +27,7 @@ import java.util.List; ...@@ -27,6 +27,7 @@ import java.util.List;
27 import org.onlab.packet.MplsLabel; 27 import org.onlab.packet.MplsLabel;
28 import org.onosproject.core.ApplicationId; 28 import org.onosproject.core.ApplicationId;
29 import org.onosproject.segmentrouting.grouphandler.GroupBucketIdentifier.BucketOutputType; 29 import org.onosproject.segmentrouting.grouphandler.GroupBucketIdentifier.BucketOutputType;
30 +import org.onosproject.store.service.EventuallyConsistentMap;
30 import org.onosproject.net.DeviceId; 31 import org.onosproject.net.DeviceId;
31 import org.onosproject.net.PortNumber; 32 import org.onosproject.net.PortNumber;
32 import org.onosproject.net.flow.DefaultTrafficTreatment; 33 import org.onosproject.net.flow.DefaultTrafficTreatment;
...@@ -58,8 +59,11 @@ public class PolicyGroupHandler extends DefaultGroupHandler { ...@@ -58,8 +59,11 @@ public class PolicyGroupHandler extends DefaultGroupHandler {
58 ApplicationId appId, 59 ApplicationId appId,
59 DeviceProperties config, 60 DeviceProperties config,
60 LinkService linkService, 61 LinkService linkService,
61 - FlowObjectiveService flowObjService) { 62 + FlowObjectiveService flowObjService,
62 - super(deviceId, appId, config, linkService, flowObjService); 63 + EventuallyConsistentMap<
64 + NeighborSetNextObjectiveStoreKey,
65 + Integer> nsNextObjStore) {
66 + super(deviceId, appId, config, linkService, flowObjService, nsNextObjStore);
63 } 67 }
64 68
65 public PolicyGroupIdentifier createPolicyGroupChain(String id, 69 public PolicyGroupIdentifier createPolicyGroupChain(String id,
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.group; 16 package org.onosproject.net.group;
17 17
18 +import java.util.Collection;
19 +
18 import org.onosproject.core.GroupId; 20 import org.onosproject.core.GroupId;
19 import org.onosproject.net.DeviceId; 21 import org.onosproject.net.DeviceId;
20 import org.onosproject.store.Store; 22 import org.onosproject.store.Store;
...@@ -162,4 +164,12 @@ public interface GroupStore extends Store<GroupEvent, GroupStoreDelegate> { ...@@ -162,4 +164,12 @@ public interface GroupStore extends Store<GroupEvent, GroupStoreDelegate> {
162 * @param operation the group operation failed 164 * @param operation the group operation failed
163 */ 165 */
164 void groupOperationFailed(DeviceId deviceId, GroupOperation operation); 166 void groupOperationFailed(DeviceId deviceId, GroupOperation operation);
167 +
168 + /**
169 + * Submits the group metrics to store for a given device ID.
170 + *
171 + * @param deviceId the device ID
172 + * @param groupEntries the group entries as received from southbound
173 + */
174 + void pushGroupMetrics(DeviceId deviceId, Collection<Group> groupEntries);
165 } 175 }
......
...@@ -15,7 +15,11 @@ ...@@ -15,7 +15,11 @@
15 */ 15 */
16 package org.onosproject.net.group.impl; 16 package org.onosproject.net.group.impl;
17 17
18 -import com.google.common.collect.Sets; 18 +import static org.slf4j.LoggerFactory.getLogger;
19 +
20 +import java.util.Collection;
21 +import java.util.Collections;
22 +
19 import org.apache.felix.scr.annotations.Activate; 23 import org.apache.felix.scr.annotations.Activate;
20 import org.apache.felix.scr.annotations.Component; 24 import org.apache.felix.scr.annotations.Component;
21 import org.apache.felix.scr.annotations.Deactivate; 25 import org.apache.felix.scr.annotations.Deactivate;
...@@ -48,13 +52,6 @@ import org.onosproject.net.provider.AbstractProviderRegistry; ...@@ -48,13 +52,6 @@ import org.onosproject.net.provider.AbstractProviderRegistry;
48 import org.onosproject.net.provider.AbstractProviderService; 52 import org.onosproject.net.provider.AbstractProviderService;
49 import org.slf4j.Logger; 53 import org.slf4j.Logger;
50 54
51 -import java.util.Collection;
52 -import java.util.Collections;
53 -import java.util.Iterator;
54 -import java.util.Set;
55 -
56 -import static org.slf4j.LoggerFactory.getLogger;
57 -
58 /** 55 /**
59 * Provides implementation of the group service APIs. 56 * Provides implementation of the group service APIs.
60 */ 57 */
...@@ -316,131 +313,13 @@ public class GroupManager ...@@ -316,131 +313,13 @@ public class GroupManager
316 store.groupOperationFailed(deviceId, operation); 313 store.groupOperationFailed(deviceId, operation);
317 } 314 }
318 315
319 - private void groupMissing(Group group) {
320 - checkValidity();
321 - GroupProvider gp = getProvider(group.deviceId());
322 - switch (group.state()) {
323 - case PENDING_DELETE:
324 - log.debug("Group {} delete confirmation from device {}",
325 - group, group.deviceId());
326 - store.removeGroupEntry(group);
327 - break;
328 - case ADDED:
329 - case PENDING_ADD:
330 - log.debug("Group {} is in store but not on device {}",
331 - group, group.deviceId());
332 - GroupOperation groupAddOp = GroupOperation.
333 - createAddGroupOperation(group.id(),
334 - group.type(),
335 - group.buckets());
336 - GroupOperations groupOps = new GroupOperations(
337 - Collections.singletonList(groupAddOp));
338 - gp.performGroupOperation(group.deviceId(), groupOps);
339 - break;
340 - default:
341 - log.debug("Group {} has not been installed.", group);
342 - break;
343 - }
344 - }
345 -
346 -
347 - private void extraneousGroup(Group group) {
348 - log.debug("Group {} is on device {} but not in store.",
349 - group, group.deviceId());
350 - checkValidity();
351 - store.addOrUpdateExtraneousGroupEntry(group);
352 - }
353 -
354 - private void groupAdded(Group group) {
355 - checkValidity();
356 -
357 - log.trace("Group {} Added or Updated in device {}",
358 - group, group.deviceId());
359 - store.addOrUpdateGroupEntry(group);
360 - }
361 -
362 @Override 316 @Override
363 public void pushGroupMetrics(DeviceId deviceId, 317 public void pushGroupMetrics(DeviceId deviceId,
364 Collection<Group> groupEntries) { 318 Collection<Group> groupEntries) {
365 log.trace("Received group metrics from device {}", 319 log.trace("Received group metrics from device {}",
366 deviceId); 320 deviceId);
367 - boolean deviceInitialAuditStatus = 321 + checkValidity();
368 - store.deviceInitialAuditStatus(deviceId); 322 + store.pushGroupMetrics(deviceId, groupEntries);
369 - Set<Group> southboundGroupEntries =
370 - Sets.newHashSet(groupEntries);
371 - Set<Group> storedGroupEntries =
372 - Sets.newHashSet(store.getGroups(deviceId));
373 - Set<Group> extraneousStoredEntries =
374 - Sets.newHashSet(store.getExtraneousGroups(deviceId));
375 -
376 - log.trace("Displaying all ({}) southboundGroupEntries for device {}",
377 - southboundGroupEntries.size(),
378 - deviceId);
379 - for (Iterator<Group> it = southboundGroupEntries.iterator(); it.hasNext();) {
380 - Group group = it.next();
381 - log.trace("Group {} in device {}", group, deviceId);
382 - }
383 -
384 - log.trace("Displaying all ({}) stored group entries for device {}",
385 - storedGroupEntries.size(),
386 - deviceId);
387 - for (Iterator<Group> it1 = storedGroupEntries.iterator(); it1.hasNext();) {
388 - Group group = it1.next();
389 - log.trace("Stored Group {} for device {}", group, deviceId);
390 - }
391 -
392 - for (Iterator<Group> it2 = southboundGroupEntries.iterator(); it2.hasNext();) {
393 - Group group = it2.next();
394 - if (storedGroupEntries.remove(group)) {
395 - // we both have the group, let's update some info then.
396 - log.trace("Group AUDIT: group {} exists "
397 - + "in both planes for device {}",
398 - group.id(), deviceId);
399 - groupAdded(group);
400 - it2.remove();
401 - }
402 - }
403 - for (Group group : southboundGroupEntries) {
404 - if (store.getGroup(group.deviceId(), group.id()) != null) {
405 - // There is a group existing with the same id
406 - // It is possible that group update is
407 - // in progress while we got a stale info from switch
408 - if (!storedGroupEntries.remove(store.getGroup(
409 - group.deviceId(), group.id()))) {
410 - log.warn("Group AUDIT: Inconsistent state:"
411 - + "Group exists in ID based table while "
412 - + "not present in key based table");
413 - }
414 - } else {
415 - // there are groups in the switch that aren't in the store
416 - log.trace("Group AUDIT: extraneous group {} exists "
417 - + "in data plane for device {}",
418 - group.id(), deviceId);
419 - extraneousStoredEntries.remove(group);
420 - extraneousGroup(group);
421 - }
422 - }
423 - for (Group group : storedGroupEntries) {
424 - // there are groups in the store that aren't in the switch
425 - log.trace("Group AUDIT: group {} missing "
426 - + "in data plane for device {}",
427 - group.id(), deviceId);
428 - groupMissing(group);
429 - }
430 - for (Group group : extraneousStoredEntries) {
431 - // there are groups in the extraneous store that
432 - // aren't in the switch
433 - log.trace("Group AUDIT: clearing extransoeus group {} "
434 - + "from store for device {}",
435 - group.id(), deviceId);
436 - store.removeExtraneousGroupEntry(group);
437 - }
438 -
439 - if (!deviceInitialAuditStatus) {
440 - log.debug("Group AUDIT: Setting device {} initial "
441 - + "AUDIT completed", deviceId);
442 - store.deviceInitialAuditCompleted(deviceId, true);
443 - }
444 } 323 }
445 } 324 }
446 325
...@@ -450,10 +329,16 @@ public class GroupManager ...@@ -450,10 +329,16 @@ public class GroupManager
450 public void event(DeviceEvent event) { 329 public void event(DeviceEvent event) {
451 switch (event.type()) { 330 switch (event.type()) {
452 case DEVICE_REMOVED: 331 case DEVICE_REMOVED:
453 - log.debug("Clearing device {} initial " 332 + case DEVICE_AVAILABILITY_CHANGED:
454 - + "AUDIT completed status as device is going down", 333 + if (!deviceService.isAvailable(event.subject().id())) {
455 - event.subject().id()); 334 + log.debug("GroupService DeviceListener: Received event {}."
456 - store.deviceInitialAuditCompleted(event.subject().id(), false); 335 + + "Device is no more available."
336 + + "Clearing device {} initial "
337 + + "AUDIT completed status",
338 + event.type(),
339 + event.subject().id());
340 + store.deviceInitialAuditCompleted(event.subject().id(), false);
341 + }
457 break; 342 break;
458 343
459 default: 344 default:
......
...@@ -315,6 +315,7 @@ public final class KryoNamespaces { ...@@ -315,6 +315,7 @@ public final class KryoNamespaces {
315 Instructions.DropInstruction.class, 315 Instructions.DropInstruction.class,
316 Instructions.OutputInstruction.class, 316 Instructions.OutputInstruction.class,
317 Instructions.GroupInstruction.class, 317 Instructions.GroupInstruction.class,
318 + Instructions.TableTypeTransition.class,
318 L0ModificationInstruction.class, 319 L0ModificationInstruction.class,
319 L0ModificationInstruction.L0SubType.class, 320 L0ModificationInstruction.L0SubType.class,
320 L0ModificationInstruction.ModLambdaInstruction.class, 321 L0ModificationInstruction.ModLambdaInstruction.class,
......
...@@ -19,9 +19,12 @@ import static org.apache.commons.lang3.concurrent.ConcurrentUtils.createIfAbsent ...@@ -19,9 +19,12 @@ import static org.apache.commons.lang3.concurrent.ConcurrentUtils.createIfAbsent
19 import static org.slf4j.LoggerFactory.getLogger; 19 import static org.slf4j.LoggerFactory.getLogger;
20 20
21 import java.util.ArrayList; 21 import java.util.ArrayList;
22 +import java.util.Collection;
22 import java.util.HashMap; 23 import java.util.HashMap;
24 +import java.util.Iterator;
23 import java.util.List; 25 import java.util.List;
24 import java.util.Optional; 26 import java.util.Optional;
27 +import java.util.Set;
25 import java.util.concurrent.ConcurrentHashMap; 28 import java.util.concurrent.ConcurrentHashMap;
26 import java.util.concurrent.ConcurrentMap; 29 import java.util.concurrent.ConcurrentMap;
27 import java.util.concurrent.atomic.AtomicInteger; 30 import java.util.concurrent.atomic.AtomicInteger;
...@@ -54,6 +57,7 @@ import org.slf4j.Logger; ...@@ -54,6 +57,7 @@ import org.slf4j.Logger;
54 57
55 import com.google.common.base.Function; 58 import com.google.common.base.Function;
56 import com.google.common.collect.FluentIterable; 59 import com.google.common.collect.FluentIterable;
60 +import com.google.common.collect.Sets;
57 61
58 /** 62 /**
59 * Manages inventory of group entries using trivial in-memory implementation. 63 * Manages inventory of group entries using trivial in-memory implementation.
...@@ -583,4 +587,131 @@ public class SimpleGroupStore ...@@ -583,4 +587,131 @@ public class SimpleGroupStore
583 getExtraneousGroupIdTable(deviceId).values()); 587 getExtraneousGroupIdTable(deviceId).values());
584 } 588 }
585 589
590 + @Override
591 + public void pushGroupMetrics(DeviceId deviceId,
592 + Collection<Group> groupEntries) {
593 + boolean deviceInitialAuditStatus =
594 + deviceInitialAuditStatus(deviceId);
595 + Set<Group> southboundGroupEntries =
596 + Sets.newHashSet(groupEntries);
597 + Set<Group> storedGroupEntries =
598 + Sets.newHashSet(getGroups(deviceId));
599 + Set<Group> extraneousStoredEntries =
600 + Sets.newHashSet(getExtraneousGroups(deviceId));
601 +
602 + log.trace("pushGroupMetrics: Displaying all ({}) "
603 + + "southboundGroupEntries for device {}",
604 + southboundGroupEntries.size(),
605 + deviceId);
606 + for (Iterator<Group> it = southboundGroupEntries.iterator(); it.hasNext();) {
607 + Group group = it.next();
608 + log.trace("Group {} in device {}", group, deviceId);
609 + }
610 +
611 + log.trace("Displaying all ({}) stored group entries for device {}",
612 + storedGroupEntries.size(),
613 + deviceId);
614 + for (Iterator<Group> it1 = storedGroupEntries.iterator();
615 + it1.hasNext();) {
616 + Group group = it1.next();
617 + log.trace("Stored Group {} for device {}", group, deviceId);
618 + }
619 +
620 + for (Iterator<Group> it2 = southboundGroupEntries.iterator(); it2.hasNext();) {
621 + Group group = it2.next();
622 + if (storedGroupEntries.remove(group)) {
623 + // we both have the group, let's update some info then.
624 + log.trace("Group AUDIT: group {} exists "
625 + + "in both planes for device {}",
626 + group.id(), deviceId);
627 + groupAdded(group);
628 + it2.remove();
629 + }
630 + }
631 + for (Group group : southboundGroupEntries) {
632 + if (getGroup(group.deviceId(), group.id()) != null) {
633 + // There is a group existing with the same id
634 + // It is possible that group update is
635 + // in progress while we got a stale info from switch
636 + if (!storedGroupEntries.remove(getGroup(
637 + group.deviceId(), group.id()))) {
638 + log.warn("Group AUDIT: Inconsistent state:"
639 + + "Group exists in ID based table while "
640 + + "not present in key based table");
641 + }
642 + } else {
643 + // there are groups in the switch that aren't in the store
644 + log.trace("Group AUDIT: extraneous group {} exists "
645 + + "in data plane for device {}",
646 + group.id(), deviceId);
647 + extraneousStoredEntries.remove(group);
648 + extraneousGroup(group);
649 + }
650 + }
651 + for (Group group : storedGroupEntries) {
652 + // there are groups in the store that aren't in the switch
653 + log.trace("Group AUDIT: group {} missing "
654 + + "in data plane for device {}",
655 + group.id(), deviceId);
656 + groupMissing(group);
657 + }
658 + for (Group group : extraneousStoredEntries) {
659 + // there are groups in the extraneous store that
660 + // aren't in the switch
661 + log.trace("Group AUDIT: clearing extransoeus group {} "
662 + + "from store for device {}",
663 + group.id(), deviceId);
664 + removeExtraneousGroupEntry(group);
665 + }
666 +
667 + if (!deviceInitialAuditStatus) {
668 + log.debug("Group AUDIT: Setting device {} initial "
669 + + "AUDIT completed", deviceId);
670 + deviceInitialAuditCompleted(deviceId, true);
671 + }
672 + }
673 +
674 + private void groupMissing(Group group) {
675 + switch (group.state()) {
676 + case PENDING_DELETE:
677 + log.debug("Group {} delete confirmation from device {}",
678 + group, group.deviceId());
679 + removeGroupEntry(group);
680 + break;
681 + case ADDED:
682 + case PENDING_ADD:
683 + case PENDING_UPDATE:
684 + log.debug("Group {} is in store but not on device {}",
685 + group, group.deviceId());
686 + StoredGroupEntry existing = (groupEntriesById.get(
687 + group.deviceId()) != null) ?
688 + groupEntriesById.get(group.deviceId()).get(group.id()) :
689 + null;
690 + log.trace("groupMissing: group "
691 + + "entry {} in device {} moving "
692 + + "from {} to PENDING_ADD",
693 + existing.id(),
694 + existing.deviceId(),
695 + existing.state());
696 + existing.setState(Group.GroupState.PENDING_ADD);
697 + notifyDelegate(new GroupEvent(GroupEvent.Type.GROUP_ADD_REQUESTED,
698 + group));
699 + break;
700 + default:
701 + log.debug("Group {} has not been installed.", group);
702 + break;
703 + }
704 + }
705 +
706 + private void extraneousGroup(Group group) {
707 + log.debug("Group {} is on device {} but not in store.",
708 + group, group.deviceId());
709 + addOrUpdateExtraneousGroupEntry(group);
710 + }
711 +
712 + private void groupAdded(Group group) {
713 + log.trace("Group {} Added or Updated in device {}",
714 + group, group.deviceId());
715 + addOrUpdateGroupEntry(group);
716 + }
586 } 717 }
......
...@@ -195,11 +195,17 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -195,11 +195,17 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
195 @Override 195 @Override
196 public void onSuccess(FlowRuleOperations ops) { 196 public void onSuccess(FlowRuleOperations ops) {
197 pass(fwd); 197 pass(fwd);
198 + log.debug("Provisioned tables in {} with "
199 + + "forwarding rules for segment "
200 + + "router", deviceId);
198 } 201 }
199 202
200 @Override 203 @Override
201 public void onError(FlowRuleOperations ops) { 204 public void onError(FlowRuleOperations ops) {
202 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED); 205 fail(fwd, ObjectiveError.FLOWINSTALLATIONFAILED);
206 + log.warn("Failed to provision tables in {} with "
207 + + "forwarding rules for segment router",
208 + deviceId);
203 } 209 }
204 })); 210 }));
205 211
...@@ -228,6 +234,8 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -228,6 +234,8 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
228 } 234 }
229 235
230 private void removeGroup(NextObjective nextObjective) { 236 private void removeGroup(NextObjective nextObjective) {
237 + log.debug("removeGroup in {}: for next objective id {}",
238 + deviceId, nextObjective.id());
231 final GroupKey key = new DefaultGroupKey( 239 final GroupKey key = new DefaultGroupKey(
232 appKryo.serialize(nextObjective.id())); 240 appKryo.serialize(nextObjective.id()));
233 groupService.removeGroup(deviceId, key, appId); 241 groupService.removeGroup(deviceId, key, appId);
...@@ -293,6 +301,8 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -293,6 +301,8 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
293 } 301 }
294 302
295 private void addBucketToGroup(NextObjective nextObjective) { 303 private void addBucketToGroup(NextObjective nextObjective) {
304 + log.debug("addBucketToGroup in {}: for next objective id {}",
305 + deviceId, nextObjective.id());
296 Collection<TrafficTreatment> treatments = nextObjective.next(); 306 Collection<TrafficTreatment> treatments = nextObjective.next();
297 TrafficTreatment treatment = treatments.iterator().next(); 307 TrafficTreatment treatment = treatments.iterator().next();
298 final GroupKey key = new DefaultGroupKey( 308 final GroupKey key = new DefaultGroupKey(
...@@ -317,6 +327,8 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -317,6 +327,8 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
317 } 327 }
318 328
319 private void removeBucketFromGroup(NextObjective nextObjective) { 329 private void removeBucketFromGroup(NextObjective nextObjective) {
330 + log.debug("removeBucketFromGroup in {}: for next objective id {}",
331 + deviceId, nextObjective.id());
320 NextGroup nextGroup = flowObjectiveStore.getNextGroup(nextObjective.id()); 332 NextGroup nextGroup = flowObjectiveStore.getNextGroup(nextObjective.id());
321 if (nextGroup != null) { 333 if (nextGroup != null) {
322 Collection<TrafficTreatment> treatments = nextObjective.next(); 334 Collection<TrafficTreatment> treatments = nextObjective.next();
...@@ -369,7 +381,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -369,7 +381,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
369 if ((ethType == null) || 381 if ((ethType == null) ||
370 ((((short) ethType.ethType()) != Ethernet.TYPE_IPV4) && 382 ((((short) ethType.ethType()) != Ethernet.TYPE_IPV4) &&
371 (((short) ethType.ethType()) != Ethernet.MPLS_UNICAST))) { 383 (((short) ethType.ethType()) != Ethernet.MPLS_UNICAST))) {
372 - log.debug("processSpecific: Unsupported " 384 + log.warn("processSpecific: Unsupported "
373 + "forwarding objective criteraia"); 385 + "forwarding objective criteraia");
374 fail(fwd, ObjectiveError.UNSUPPORTED); 386 fail(fwd, ObjectiveError.UNSUPPORTED);
375 return Collections.emptySet(); 387 return Collections.emptySet();
...@@ -424,6 +436,10 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -424,6 +436,10 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
424 } 436 }
425 treatmentBuilder.group(group.id()); 437 treatmentBuilder.group(group.id());
426 log.debug("Adding OUTGROUP action"); 438 log.debug("Adding OUTGROUP action");
439 + } else {
440 + log.warn("processSpecific: No associated next objective object");
441 + fail(fwd, ObjectiveError.GROUPMISSING);
442 + return Collections.emptySet();
427 } 443 }
428 } 444 }
429 445
...@@ -485,15 +501,39 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -485,15 +501,39 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
485 return rules; 501 return rules;
486 } 502 }
487 503
504 + protected List<FlowRule> processVlanIdFilter(Criterion c,
505 + FilteringObjective filt,
506 + ApplicationId applicationId) {
507 + List<FlowRule> rules = new ArrayList<FlowRule>();
508 + VlanIdCriterion v = (VlanIdCriterion) c;
509 + log.debug("adding rule for VLAN: {}", v.vlanId());
510 + TrafficSelector.Builder selector = DefaultTrafficSelector
511 + .builder();
512 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment
513 + .builder();
514 + PortCriterion p = (PortCriterion) filt.key();
515 + if (v.vlanId() != VlanId.NONE) {
516 + selector.matchVlanId(v.vlanId());
517 + selector.matchInPort(p.port());
518 + treatment.deferred().popVlan();
519 + }
520 + treatment.transition(tmacTableId);
521 + FlowRule rule = DefaultFlowRule.builder().forDevice(deviceId)
522 + .withSelector(selector.build())
523 + .withTreatment(treatment.build())
524 + .withPriority(filt.priority()).fromApp(applicationId)
525 + .makePermanent().forTable(vlanTableId).build();
526 + rules.add(rule);
527 +
528 + return rules;
529 + }
530 +
488 private void processFilter(FilteringObjective filt, boolean install, 531 private void processFilter(FilteringObjective filt, boolean install,
489 ApplicationId applicationId) { 532 ApplicationId applicationId) {
490 // This driver only processes filtering criteria defined with switch 533 // This driver only processes filtering criteria defined with switch
491 // ports as the key 534 // ports as the key
492 - PortCriterion p; 535 + if (filt.key().equals(Criteria.dummy())
493 - if (!filt.key().equals(Criteria.dummy()) 536 + || filt.key().type() != Criterion.Type.IN_PORT) {
494 - && filt.key().type() == Criterion.Type.IN_PORT) {
495 - p = (PortCriterion) filt.key();
496 - } else {
497 log.warn("No key defined in filtering objective from app: {}. Not" 537 log.warn("No key defined in filtering objective from app: {}. Not"
498 + "processing filtering objective", applicationId); 538 + "processing filtering objective", applicationId);
499 fail(filt, ObjectiveError.UNKNOWN); 539 fail(filt, ObjectiveError.UNKNOWN);
...@@ -509,24 +549,11 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -509,24 +549,11 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
509 ops = install ? ops.add(rule) : ops.remove(rule); 549 ops = install ? ops.add(rule) : ops.remove(rule);
510 } 550 }
511 } else if (c.type() == Criterion.Type.VLAN_VID) { 551 } else if (c.type() == Criterion.Type.VLAN_VID) {
512 - VlanIdCriterion v = (VlanIdCriterion) c; 552 + for (FlowRule rule : processVlanIdFilter(c,
513 - log.debug("adding rule for VLAN: {}", v.vlanId()); 553 + filt,
514 - TrafficSelector.Builder selector = DefaultTrafficSelector 554 + applicationId)) {
515 - .builder(); 555 + ops = install ? ops.add(rule) : ops.remove(rule);
516 - TrafficTreatment.Builder treatment = DefaultTrafficTreatment
517 - .builder();
518 - if (v.vlanId() != VlanId.NONE) {
519 - selector.matchVlanId(v.vlanId());
520 - selector.matchInPort(p.port());
521 - treatment.deferred().popVlan();
522 } 556 }
523 - treatment.transition(tmacTableId);
524 - FlowRule rule = DefaultFlowRule.builder().forDevice(deviceId)
525 - .withSelector(selector.build())
526 - .withTreatment(treatment.build())
527 - .withPriority(filt.priority()).fromApp(applicationId)
528 - .makePermanent().forTable(vlanTableId).build();
529 - ops = install ? ops.add(rule) : ops.remove(rule);
530 } else if (c.type() == Criterion.Type.IPV4_DST) { 557 } else if (c.type() == Criterion.Type.IPV4_DST) {
531 IPCriterion ip = (IPCriterion) c; 558 IPCriterion ip = (IPCriterion) c;
532 log.debug("adding rule for IP: {}", ip.ip()); 559 log.debug("adding rule for IP: {}", ip.ip());
...@@ -554,13 +581,15 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -554,13 +581,15 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
554 @Override 581 @Override
555 public void onSuccess(FlowRuleOperations ops) { 582 public void onSuccess(FlowRuleOperations ops) {
556 pass(filt); 583 pass(filt);
557 - log.info("Provisioned tables for segment router"); 584 + log.debug("Provisioned tables in {} with fitering "
585 + + "rules for segment router", deviceId);
558 } 586 }
559 587
560 @Override 588 @Override
561 public void onError(FlowRuleOperations ops) { 589 public void onError(FlowRuleOperations ops) {
562 fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED); 590 fail(filt, ObjectiveError.FLOWINSTALLATIONFAILED);
563 - log.info("Failed to provision tables for segment router"); 591 + log.warn("Failed to provision tables in {} with "
592 + + "fitering rules for segment router", deviceId);
564 } 593 }
565 })); 594 }));
566 } 595 }
...@@ -618,6 +647,8 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -618,6 +647,8 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
618 @Override 647 @Override
619 public void event(GroupEvent event) { 648 public void event(GroupEvent event) {
620 if (event.type() == GroupEvent.Type.GROUP_ADDED) { 649 if (event.type() == GroupEvent.Type.GROUP_ADDED) {
650 + log.debug("InnerGroupListener: Group ADDED "
651 + + "event received in device {}", deviceId);
621 GroupKey key = event.subject().appCookie(); 652 GroupKey key = event.subject().appCookie();
622 653
623 NextObjective obj = pendingGroups.getIfPresent(key); 654 NextObjective obj = pendingGroups.getIfPresent(key);
...@@ -628,6 +659,9 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour ...@@ -628,6 +659,9 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
628 pass(obj); 659 pass(obj);
629 pendingGroups.invalidate(key); 660 pendingGroups.invalidate(key);
630 } 661 }
662 + } else if (event.type() == GroupEvent.Type.GROUP_ADD_FAILED) {
663 + log.warn("InnerGroupListener: Group ADD "
664 + + "failed event received in device {}", deviceId);
631 } 665 }
632 } 666 }
633 } 667 }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.driver.pipeline; 16 package org.onosproject.driver.pipeline;
17 17
18 -import java.util.ArrayList;
19 import java.util.Collection; 18 import java.util.Collection;
20 import java.util.Collections; 19 import java.util.Collections;
21 import java.util.List; 20 import java.util.List;
...@@ -145,6 +144,10 @@ public class SpringOpenTTPDell extends SpringOpenTTP { ...@@ -145,6 +144,10 @@ public class SpringOpenTTPDell extends SpringOpenTTP {
145 } 144 }
146 treatmentBuilder.group(group.id()); 145 treatmentBuilder.group(group.id());
147 log.debug("Adding OUTGROUP action"); 146 log.debug("Adding OUTGROUP action");
147 + } else {
148 + log.warn("processSpecific: No associated next objective object");
149 + fail(fwd, ObjectiveError.GROUPMISSING);
150 + return Collections.emptySet();
148 } 151 }
149 } 152 }
150 153
...@@ -175,43 +178,23 @@ public class SpringOpenTTPDell extends SpringOpenTTP { ...@@ -175,43 +178,23 @@ public class SpringOpenTTPDell extends SpringOpenTTP {
175 protected List<FlowRule> processEthDstFilter(Criterion c, 178 protected List<FlowRule> processEthDstFilter(Criterion c,
176 FilteringObjective filt, 179 FilteringObjective filt,
177 ApplicationId applicationId) { 180 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 181 // Store device termination Mac to be used in IP flow entries
182 + EthCriterion e = (EthCriterion) c;
186 deviceTMac = e.mac(); 183 deviceTMac = e.mac();
187 184
188 - selectorIp.matchEthDst(e.mac()); 185 + log.debug("For now not adding any TMAC rules "
189 - selectorIp.matchEthType(Ethernet.TYPE_IPV4); 186 + + "into Dell switches as it is ignoring");
190 - treatmentIp.transition(ipv4UnicastTableId); 187 +
191 - FlowRule ruleIp = DefaultFlowRule.builder().forDevice(deviceId) 188 + return Collections.emptyList();
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 } 189 }
216 190
191 + @Override
192 + protected List<FlowRule> processVlanIdFilter(Criterion c,
193 + FilteringObjective filt,
194 + ApplicationId applicationId) {
195 + log.debug("For now not adding any VLAN rules "
196 + + "into Dell switches as it is ignoring");
197 +
198 + return Collections.emptyList();
199 + }
217 } 200 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -37,13 +37,6 @@ ...@@ -37,13 +37,6 @@
37 <behaviour api="org.onosproject.net.behaviour.Pipeliner" 37 <behaviour api="org.onosproject.net.behaviour.Pipeliner"
38 impl="org.onosproject.driver.pipeline.SpringOpenTTPDell"/> 38 impl="org.onosproject.driver.pipeline.SpringOpenTTPDell"/>
39 </driver> 39 </driver>
40 - <driver name="cpqd" manufacturer="Stanford University, Ericsson Research and CPqD Research"
41 - hwVersion="OpenFlow 1.3 Reference Userspace Switch" swVersion=".*">
42 - <behaviour api="org.onosproject.net.behaviour.Pipeliner"
43 - impl="org.onosproject.driver.pipeline.SpringOpenTTP"/>
44 - <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
45 - impl="org.onosproject.driver.handshaker.OFSwitchImplSpringOpenTTP"/>
46 - </driver>
47 <driver name="linc-oe" extends="default" 40 <driver name="linc-oe" extends="default"
48 manufacturer="FlowForwarding.org" hwVersion="Unknown" swVersion="LINC-OE OpenFlow Software Switch 1.1"> 41 manufacturer="FlowForwarding.org" hwVersion="Unknown" swVersion="LINC-OE OpenFlow Software Switch 1.1">
49 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" 42 <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
......
...@@ -295,7 +295,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -295,7 +295,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
295 return; 295 return;
296 } 296 }
297 if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) { 297 if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
298 - log.warn("Stats reply indicates more stats from sw {} for " 298 + log.debug("Stats reply indicates more stats from sw {} for "
299 + "port description", 299 + "port description",
300 h.getSwitchInfoString()); 300 h.getSwitchInfoString());
301 h.portDescReplies.add((OFPortDescStatsReply)m); 301 h.portDescReplies.add((OFPortDescStatsReply)m);
......