private GroupDescription.Type getGroupType(OFGroupType type) { switch (type) { case ALL: return GroupDescription.Type.ALL; case INDIRECT: return GroupDescription.Type.INDIRECT; case SELECT: return GroupDescription.Type.SELECT; case FF: return GroupDescription.Type.FAILOVER; default: log.error("Unsupported OF group type : {}", type); break; } return null; }
private OFGroupType getOFGroupType(GroupDescription.Type groupType) { switch (groupType) { case INDIRECT: return OFGroupType.INDIRECT; case SELECT: return OFGroupType.SELECT; case FAILOVER: return OFGroupType.FF; case ALL: return OFGroupType.ALL; default: log.error("Unsupported group type : {}", groupType); break; } return null; }
private void deleteGroup(EcmpInfo groupInfo) { List<OFMessage> msglist = new ArrayList<OFMessage>(); OFGroup group = OFGroup.of(groupInfo.groupId); OFMessage gm = factory.buildGroupDelete() .setGroup(group) // .setGroupType(groupInfo.groupType) /* Due to a bug in CPqD // switch */ .setGroupType(OFGroupType.SELECT) .setXid(getNextTransactionId()) .build(); msglist.add(gm); log.debug("GroupDelete in sw {} groupId {}", getStringId(), groupInfo.groupId); try { write(msglist); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private EcmpInfo createInnermostLabelGroup(int innermostGroupId, List<PortNumber> ports, int mplsLabel, boolean bos, HashMap<PortNumber, Integer> lastSetOfGroupIds) { List<BucketInfo> buckets = new ArrayList<BucketInfo>(); for (PortNumber sp : ports) { Dpid neighborDpid = portToNeighbors.get(sp); BucketInfo b = new BucketInfo(neighborDpid, MacAddress.of(srConfig.getRouterMac()), getNeighborRouterMacAddress(neighborDpid), null, mplsLabel, bos, lastSetOfGroupIds.get(sp)); buckets.add(b); } EcmpInfo ecmpInfo = new EcmpInfo(innermostGroupId, OFGroupType.SELECT, buckets); setEcmpGroup(ecmpInfo); log.debug( "createInnermostLabelGroup: Creating select group {} in sw {} " + "with: {}", innermostGroupId, getStringId(), ecmpInfo); return ecmpInfo; }
@Override public void startDriverHandshake() { if (startDriverHandshakeCalled) { throw new SwitchDriverSubHandshakeAlreadyStarted(); } startDriverHandshakeCalled = true; OFFlowMod fm = factory().buildFlowDelete() .setTableId(TableId.ALL) .setOutGroup(OFGroup.ANY) .build(); sendMsg(ImmutableList.of(fm)); OFGroupMod gm = factory().buildGroupDelete() .setGroup(OFGroup.ALL) .setGroupType(OFGroupType.ALL) .build(); sendMsg(ImmutableList.of(gm)); handshakeComplete.set(true); log.info("Handshake with device {} ended", super.getStringId()); }
private OFGroupDescStatsEntry ofGroupDescStatsEntry(Group group) { List<OFBucket> ofBuckets = Lists.newArrayList(); group.buckets().buckets().forEach(groupBucket -> { ofBuckets.add(FACTORY.buildBucket() .setWeight(groupBucket.weight()) .setWatchGroup(OFGroup.of(groupBucket.watchGroup().id())) .setWatchPort(OFPort.of((int) groupBucket.watchPort().toLong())) .build() ); }); OFGroup ofGroup = OFGroup.of(group.givenGroupId()); OFGroupType ofGroupType = OFGroupType.valueOf(group.type().name()); OFGroupDescStatsEntry entry = FACTORY.buildGroupDescStatsEntry() .setGroup(ofGroup) .setGroupType(ofGroupType) .setBuckets(ofBuckets) .build(); return entry; }
@Override public void startDriverHandshake() { if (startDriverHandshakeCalled) { throw new SwitchDriverSubHandshakeAlreadyStarted(); } startDriverHandshakeCalled = true; OFFlowMod fm = factory().buildFlowDelete() .setTableId(TableId.ALL) .setOutGroup(OFGroup.ANY) .build(); sendMsg(Collections.singletonList(fm)); OFGroupMod gm = factory().buildGroupDelete() .setGroup(OFGroup.ALL) .setGroupType(OFGroupType.ALL) .build(); sendMsg(Collections.singletonList(gm)); OFMeterMod mm = factory().buildMeterMod() .setMeterId(MeterId.ALL.id()) .build(); sendMsg(Collections.singletonList(mm)); barrierXid = getNextTransactionId(); OFBarrierRequest barrier = factory().buildBarrierRequest() .setXid(barrierXid).build(); sendHandshakeMessage(barrier); }
/** * Builds the GroupDel OF message. * * @return GroupDel OF message */ public OFGroupDelete buildGroupDel() { OFGroupDelete groupMsg = factory.buildGroupDelete() .setGroup(OFGroup.of(groupId.id())) .setGroupType(OFGroupType.SELECT) .setXid(xid) .build(); return groupMsg; }
@Test public void groupModFailure() { TestOpenFlowGroupProviderService testProviderService = (TestOpenFlowGroupProviderService) providerService; GroupId groupId = new DefaultGroupId(1); List<GroupBucket> bucketList = Lists.newArrayList(); TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); builder.setOutput(PortNumber.portNumber(1)); GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket(builder.build()); bucketList.add(bucket); GroupBuckets buckets = new GroupBuckets(bucketList); List<GroupOperation> operationList = Lists.newArrayList(); GroupOperation operation = GroupOperation.createAddGroupOperation(groupId, GroupDescription.Type.SELECT, buckets); operationList.add(operation); GroupOperations operations = new GroupOperations(operationList); provider.performGroupOperation(deviceId, operations); OFGroupModFailedErrorMsg.Builder errorBuilder = OFFactories.getFactory(OFVersion.OF_13).errorMsgs().buildGroupModFailedErrorMsg(); OFGroupMod.Builder groupBuilder = OFFactories.getFactory(OFVersion.OF_13).buildGroupModify(); groupBuilder.setGroupType(OFGroupType.ALL); groupBuilder.setGroup(OFGroup.of(1)); errorBuilder.setCode(OFGroupModFailedCode.GROUP_EXISTS); errorBuilder.setXid(provider.getXidAndAdd(0) - 1); controller.processPacket(dpid1, errorBuilder.build()); assertNotNull("Operation failed should not be null", testProviderService.failedOperation); }
@Override public void switchActivated(DatapathId switchId) { IOFSwitch sw = switchService.getSwitch(switchId); if (sw == null) { log.warn("Switch {} was activated but had no switch object in the switch service. Perhaps it quickly disconnected", switchId); return; } if (OFDPAUtils.isOFDPASwitch(sw)) { sw.write(sw.getOFFactory().buildFlowDelete() .setTableId(TableId.ALL) .build() ); sw.write(sw.getOFFactory().buildGroupDelete() .setGroup(OFGroup.ANY) .setGroupType(OFGroupType.ALL) .build() ); sw.write(sw.getOFFactory().buildGroupDelete() .setGroup(OFGroup.ANY) .setGroupType(OFGroupType.INDIRECT) .build() ); sw.write(sw.getOFFactory().buildBarrierRequest().build()); List<OFPortModeTuple> portModes = new ArrayList<OFPortModeTuple>(); for (OFPortDesc p : sw.getPorts()) { portModes.add(OFPortModeTuple.of(p.getPortNo(), OFPortMode.ACCESS)); } if (log.isWarnEnabled()) { log.warn("For OF-DPA switch {}, initializing VLAN {} on ports {}", new Object[] { switchId, VlanVid.ZERO, portModes}); } OFDPAUtils.addLearningSwitchPrereqs(sw, VlanVid.ZERO, portModes); } }
private void pushOFCreateGroup(IOFSwitch sw) { /* Creates group flow with set queue option */ OFFactory of13Factory = sw.getOFFactory(); OFGroupAdd addGroup = of13Factory.buildGroupAdd() .setGroup(OFGroup.of(multicastGroup.ofGroupId)) .setGroupType(OFGroupType.ALL) .setBuckets(multicastGroup.getMemberOFBucketList(sw.getId())) .build(); sw.write(addGroup); }
private void pushOFModifyGroup(IOFSwitch sw) { /* Creates group flow with set queue option */ OFFactory of13Factory = sw.getOFFactory(); OFGroupMod modGroup = of13Factory.buildGroupModify() .setGroup(OFGroup.of(multicastGroup.ofGroupId)) .setGroupType(OFGroupType.ALL) .setBuckets(multicastGroup.getMemberOFBucketList(sw.getId())) .build(); sw.write(modGroup); }
protected void pushOFDeleteGroup(IOFSwitch sw) { /* Delete the queues attached to all the member ports*/ long queueId = -1; OFPort ofp = null; ArrayList<OFBucket> ofBuckets = multicastGroup.getMemberOFBucketList(sw.getId()); OVSDBContext ovsdbContext = mcObject.ovsdbChannelMap.get(sw.getId()); for (OFBucket ofb : ofBuckets) { queueId = -1; ofp = null; for (OFAction ofa: ofb.getActions()){ if (ofa.getType() == OFActionType.SET_QUEUE){ OFActionSetQueue ofas = (OFActionSetQueue) ofa; queueId = ofas.getQueueId(); /* removes queue using OVSDBContext on the switch */ } if (ofa.getType() == OFActionType.OUTPUT){ OFActionOutput ofo = (OFActionOutput) ofa; ofp = ofo.getPort(); /* removes queue using OVSDBContext on the switch */ } } if (ofp != null && queueId != -1) ovsdbContext.deleteQueueOnPort(ofp, (int)queueId); else logger.error("pushOFDeleteGroup: unexpected actionset in group bucket"); } /* Creates group flow with set queue option */ OFFactory of13Factory = sw.getOFFactory(); OFGroupDelete delGroup = of13Factory.buildGroupDelete() .setGroup(OFGroup.of(multicastGroup.ofGroupId)) .setGroupType(OFGroupType.ALL) .build(); sw.write(delGroup); }
public static OFGroupType readFrom(ChannelBuffer bb) throws OFParseError { try { return ofWireValue(bb.readByte()); } catch (IllegalArgumentException e) { throw new OFParseError(e); } }
public static OFGroupType ofWireValue(byte val) { switch(val) { case ALL_VAL: return OFGroupType.ALL; case SELECT_VAL: return OFGroupType.SELECT; case INDIRECT_VAL: return OFGroupType.INDIRECT; case FF_VAL: return OFGroupType.FF; default: throw new IllegalArgumentException("Illegal wire value for type OFGroupType in version 1.2: " + val); } }
public static byte toWireValue(OFGroupType e) { switch(e) { case ALL: return ALL_VAL; case SELECT: return SELECT_VAL; case INDIRECT: return INDIRECT_VAL; case FF: return FF_VAL; default: throw new IllegalArgumentException("Illegal enum value for type OFGroupType in version 1.2: " + e); } }
public static OFGroupType ofWireValue(byte val) { switch(val) { case ALL_VAL: return OFGroupType.ALL; case SELECT_VAL: return OFGroupType.SELECT; case INDIRECT_VAL: return OFGroupType.INDIRECT; case FF_VAL: return OFGroupType.FF; default: throw new IllegalArgumentException("Illegal wire value for type OFGroupType in version 1.3: " + val); } }
public static byte toWireValue(OFGroupType e) { switch(e) { case ALL: return ALL_VAL; case SELECT: return SELECT_VAL; case INDIRECT: return INDIRECT_VAL; case FF: return FF_VAL; default: throw new IllegalArgumentException("Illegal enum value for type OFGroupType in version 1.3: " + e); } }
public static OFGroupType ofWireValue(byte val) { switch(val) { case ALL_VAL: return OFGroupType.ALL; case SELECT_VAL: return OFGroupType.SELECT; case INDIRECT_VAL: return OFGroupType.INDIRECT; case FF_VAL: return OFGroupType.FF; default: throw new IllegalArgumentException("Illegal wire value for type OFGroupType in version 1.1: " + val); } }
public static byte toWireValue(OFGroupType e) { switch(e) { case ALL: return ALL_VAL; case SELECT: return SELECT_VAL; case INDIRECT: return INDIRECT_VAL; case FF: return FF_VAL; default: throw new IllegalArgumentException("Illegal enum value for type OFGroupType in version 1.1: " + e); } }
public static OFGroupType ofWireValue(byte val) { switch(val) { case ALL_VAL: return OFGroupType.ALL; case SELECT_VAL: return OFGroupType.SELECT; case INDIRECT_VAL: return OFGroupType.INDIRECT; case FF_VAL: return OFGroupType.FF; default: throw new IllegalArgumentException("Illegal wire value for type OFGroupType in version 1.4: " + val); } }
public static byte toWireValue(OFGroupType e) { switch(e) { case ALL: return ALL_VAL; case SELECT: return SELECT_VAL; case INDIRECT: return INDIRECT_VAL; case FF: return FF_VAL; default: throw new IllegalArgumentException("Illegal enum value for type OFGroupType in version 1.4: " + e); } }
private void processGroupDesc(OFGroupDescStatsReply gdsr) { log.info("Sw: {} Group Desc {} in driverState {} ", getStringId(), gdsr, driverState); if (driverState == DriverState.AUDIT_GROUPS) { auditBucketToGroupIds = new ConcurrentHashMap<List<BucketInfo>, List<Integer>>(); for (OFGroupDescStatsEntry entry : gdsr.getEntries()) { int groupId = entry.getGroup().getGroupNumber(); OFGroupType groupType = entry.getGroupType(); List<OFBucket> buckets = entry.getBuckets(); List<BucketInfo> driverBuckets = new ArrayList<BucketInfo>(); for (OFBucket bucket : buckets) { driverBuckets.add(getDriverBucketFromOFBucket(bucket)); } Collections.sort(driverBuckets); List<Integer> groupIds = auditBucketToGroupIds.get(driverBuckets); if (groupIds == null) groupIds = new ArrayList<Integer>(); groupIds.add(groupId); auditBucketToGroupIds.put(driverBuckets, groupIds); ecmpGroups.put(groupId, new EcmpInfo(groupId, groupType, driverBuckets)); } log.debug("processGroupDesc: Groups that are present in " + "switch {} are {} ", getStringId(), ecmpGroups); } else { // TODO -- actually do verification } try { nextDriverState(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private EcmpInfo createIndirectGroup(int groupId, MacAddress srcMac, MacAddress dstMac, PortNumber outPort, int gotoGroupNo, int mplsLabel, boolean bos) { List<BucketInfo> buckets = new ArrayList<BucketInfo>(); BucketInfo b = new BucketInfo(null, srcMac, dstMac, outPort, mplsLabel, bos, gotoGroupNo); buckets.add(b); EcmpInfo ecmpInfo = new EcmpInfo(groupId, OFGroupType.INDIRECT, buckets); setEcmpGroup(ecmpInfo); log.debug( "createIndirectGroup: Creating indirect group {} in sw {} " + "with: {}", groupId, getStringId(), ecmpInfo); return ecmpInfo; }