Saurav Das
Committed by Gerrit Code Review

In this commit:

    Removing dependence on hashing for unique groupkeys in ofdpa driver.
    Group-store no longer removes groups from store if a group-operation fails due to GROUP_EXISTS.
    Group-store also checks for unique group-id when given by app.
    Group-provider now logs warning before making call to core.

Change-Id: I4a1dcb887cb74cd6e245df0c82c90a50d8f3898a
...@@ -537,6 +537,19 @@ public class DistributedGroupStore ...@@ -537,6 +537,19 @@ public class DistributedGroupStore
537 // Get a new group identifier 537 // Get a new group identifier
538 id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId())); 538 id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
539 } else { 539 } else {
540 + // we need to use the identifier passed in by caller, but check if
541 + // already used
542 + Group existing = getGroup(groupDesc.deviceId(),
543 + new DefaultGroupId(groupDesc.givenGroupId()));
544 + if (existing != null) {
545 + log.warn("Group already exists with the same id: 0x{} in dev:{} "
546 + + "but with different key: {} (request gkey: {})",
547 + Integer.toHexString(groupDesc.givenGroupId()),
548 + groupDesc.deviceId(),
549 + existing.appCookie(),
550 + groupDesc.appCookie());
551 + return;
552 + }
540 id = new DefaultGroupId(groupDesc.givenGroupId()); 553 id = new DefaultGroupId(groupDesc.givenGroupId());
541 } 554 }
542 // Create a group entry object 555 // Create a group entry object
...@@ -621,7 +634,8 @@ public class DistributedGroupStore ...@@ -621,7 +634,8 @@ public class DistributedGroupStore
621 // Check if a group is existing with the provided key 634 // Check if a group is existing with the provided key
622 Group oldGroup = getGroup(deviceId, oldAppCookie); 635 Group oldGroup = getGroup(deviceId, oldAppCookie);
623 if (oldGroup == null) { 636 if (oldGroup == null) {
624 - log.warn("updateGroupDescriptionInternal: Group not found...strange"); 637 + log.warn("updateGroupDescriptionInternal: Group not found...strange. "
638 + + "GroupKey:{} DeviceId:{}", oldAppCookie, deviceId);
625 return; 639 return;
626 } 640 }
627 641
...@@ -940,6 +954,19 @@ public class DistributedGroupStore ...@@ -940,6 +954,19 @@ public class DistributedGroupStore
940 log.warn("Current extraneous groups in device:{} are: {}", 954 log.warn("Current extraneous groups in device:{} are: {}",
941 deviceId, 955 deviceId,
942 getExtraneousGroups(deviceId)); 956 getExtraneousGroups(deviceId));
957 + if (operation.buckets().equals(existing.buckets())) {
958 + if (existing.state() == GroupState.PENDING_ADD) {
959 + log.info("GROUP_EXISTS: GroupID and Buckets match for group in pending "
960 + + "add state - moving to ADDED for group {} in device {}",
961 + existing.id(), deviceId);
962 + addOrUpdateGroupEntry(existing);
963 + return;
964 + } else {
965 + log.warn("GROUP EXISTS: Group ID matched but buckets did not. "
966 + + "Operation: {} Existing: {}", operation.buckets(),
967 + existing.buckets());
968 + }
969 + }
943 } 970 }
944 switch (operation.opType()) { 971 switch (operation.opType()) {
945 case ADD: 972 case ADD:
......
...@@ -1030,26 +1030,30 @@ public class OFDPA2Pipeline extends AbstractHandlerBehaviour implements Pipeline ...@@ -1030,26 +1030,30 @@ public class OFDPA2Pipeline extends AbstractHandlerBehaviour implements Pipeline
1030 obj.context().ifPresent(context -> context.onError(obj, error)); 1030 obj.context().ifPresent(context -> context.onError(obj, error));
1031 } 1031 }
1032 1032
1033 -
1034 @Override 1033 @Override
1035 public List<String> getNextMappings(NextGroup nextGroup) { 1034 public List<String> getNextMappings(NextGroup nextGroup) {
1036 List<String> mappings = new ArrayList<>(); 1035 List<String> mappings = new ArrayList<>();
1037 List<Deque<GroupKey>> gkeys = appKryo.deserialize(nextGroup.data()); 1036 List<Deque<GroupKey>> gkeys = appKryo.deserialize(nextGroup.data());
1038 for (Deque<GroupKey> gkd : gkeys) { 1037 for (Deque<GroupKey> gkd : gkeys) {
1039 Group lastGroup = null; 1038 Group lastGroup = null;
1040 - String gchain = ""; 1039 + StringBuffer gchain = new StringBuffer();
1041 for (GroupKey gk : gkd) { 1040 for (GroupKey gk : gkd) {
1042 Group g = groupService.getGroup(deviceId, gk); 1041 Group g = groupService.getGroup(deviceId, gk);
1043 - gchain += " 0x" + Integer.toHexString(g.id().id()) + " -->"; 1042 + if (g == null) {
1043 + gchain.append(" ERROR").append(" -->");
1044 + continue;
1045 + }
1046 + gchain.append(" 0x").append(Integer.toHexString(g.id().id()))
1047 + .append(" -->");
1044 lastGroup = g; 1048 lastGroup = g;
1045 } 1049 }
1046 // add port information for last group in group-chain 1050 // add port information for last group in group-chain
1047 for (Instruction i: lastGroup.buckets().buckets().get(0).treatment().allInstructions()) { 1051 for (Instruction i: lastGroup.buckets().buckets().get(0).treatment().allInstructions()) {
1048 if (i instanceof OutputInstruction) { 1052 if (i instanceof OutputInstruction) {
1049 - gchain += " port:" + ((OutputInstruction) i).port(); 1053 + gchain.append(" port:").append(((OutputInstruction) i).port());
1050 } 1054 }
1051 } 1055 }
1052 - mappings.add(gchain); 1056 + mappings.add(gchain.toString());
1053 } 1057 }
1054 return mappings; 1058 return mappings;
1055 } 1059 }
......
...@@ -337,11 +337,11 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv ...@@ -337,11 +337,11 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
337 GroupMsgErrorCode.values()[(code.ordinal())]; 337 GroupMsgErrorCode.values()[(code.ordinal())];
338 GroupOperation failedOperation = GroupOperation 338 GroupOperation failedOperation = GroupOperation
339 .createFailedGroupOperation(operation, failureCode); 339 .createFailedGroupOperation(operation, failureCode);
340 + log.warn("Received a group mod error {}", msg);
340 providerService.groupOperationFailed(deviceId, 341 providerService.groupOperationFailed(deviceId,
341 failedOperation); 342 failedOperation);
342 pendingGroupOperations.remove(pendingGroupId); 343 pendingGroupOperations.remove(pendingGroupId);
343 pendingXidMaps.remove(pendingGroupId); 344 pendingXidMaps.remove(pendingGroupId);
344 - log.warn("Received a group mod error {}", msg);
345 } else { 345 } else {
346 log.error("Cannot find pending group operation with group ID: {}", 346 log.error("Cannot find pending group operation with group ID: {}",
347 pendingGroupId); 347 pendingGroupId);
......