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
// Get a new group identifier
id = new DefaultGroupId(getFreeGroupIdValue(groupDesc.deviceId()));
} else {
// we need to use the identifier passed in by caller, but check if
// already used
Group existing = getGroup(groupDesc.deviceId(),
new DefaultGroupId(groupDesc.givenGroupId()));
if (existing != null) {
log.warn("Group already exists with the same id: 0x{} in dev:{} "
+ "but with different key: {} (request gkey: {})",
Integer.toHexString(groupDesc.givenGroupId()),
groupDesc.deviceId(),
existing.appCookie(),
groupDesc.appCookie());
return;
}
id = new DefaultGroupId(groupDesc.givenGroupId());
}
// Create a group entry object
......@@ -621,7 +634,8 @@ public class DistributedGroupStore
// Check if a group is existing with the provided key
Group oldGroup = getGroup(deviceId, oldAppCookie);
if (oldGroup == null) {
log.warn("updateGroupDescriptionInternal: Group not found...strange");
log.warn("updateGroupDescriptionInternal: Group not found...strange. "
+ "GroupKey:{} DeviceId:{}", oldAppCookie, deviceId);
return;
}
......@@ -940,6 +954,19 @@ public class DistributedGroupStore
log.warn("Current extraneous groups in device:{} are: {}",
deviceId,
getExtraneousGroups(deviceId));
if (operation.buckets().equals(existing.buckets())) {
if (existing.state() == GroupState.PENDING_ADD) {
log.info("GROUP_EXISTS: GroupID and Buckets match for group in pending "
+ "add state - moving to ADDED for group {} in device {}",
existing.id(), deviceId);
addOrUpdateGroupEntry(existing);
return;
} else {
log.warn("GROUP EXISTS: Group ID matched but buckets did not. "
+ "Operation: {} Existing: {}", operation.buckets(),
existing.buckets());
}
}
}
switch (operation.opType()) {
case ADD:
......
......@@ -1030,26 +1030,30 @@ public class OFDPA2Pipeline extends AbstractHandlerBehaviour implements Pipeline
obj.context().ifPresent(context -> context.onError(obj, error));
}
@Override
public List<String> getNextMappings(NextGroup nextGroup) {
List<String> mappings = new ArrayList<>();
List<Deque<GroupKey>> gkeys = appKryo.deserialize(nextGroup.data());
for (Deque<GroupKey> gkd : gkeys) {
Group lastGroup = null;
String gchain = "";
StringBuffer gchain = new StringBuffer();
for (GroupKey gk : gkd) {
Group g = groupService.getGroup(deviceId, gk);
gchain += " 0x" + Integer.toHexString(g.id().id()) + " -->";
if (g == null) {
gchain.append(" ERROR").append(" -->");
continue;
}
gchain.append(" 0x").append(Integer.toHexString(g.id().id()))
.append(" -->");
lastGroup = g;
}
// add port information for last group in group-chain
for (Instruction i: lastGroup.buckets().buckets().get(0).treatment().allInstructions()) {
if (i instanceof OutputInstruction) {
gchain += " port:" + ((OutputInstruction) i).port();
gchain.append(" port:").append(((OutputInstruction) i).port());
}
}
mappings.add(gchain);
mappings.add(gchain.toString());
}
return mappings;
}
......
......@@ -337,11 +337,11 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv
GroupMsgErrorCode.values()[(code.ordinal())];
GroupOperation failedOperation = GroupOperation
.createFailedGroupOperation(operation, failureCode);
log.warn("Received a group mod error {}", msg);
providerService.groupOperationFailed(deviceId,
failedOperation);
pendingGroupOperations.remove(pendingGroupId);
pendingXidMaps.remove(pendingGroupId);
log.warn("Received a group mod error {}", msg);
} else {
log.error("Cannot find pending group operation with group ID: {}",
pendingGroupId);
......