use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class SingleTableServer42IngressRuleGeneratorTest method buildCommandsFullPortTransitVlanTest.
@Test
public void buildCommandsFullPortTransitVlanTest() {
Flow flow = buildFlow(PATH, 0);
SingleTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(1, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.ETH_SRC).value(SERVER_42_MAC_ADDRESS.toLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(PORT_OFFSET + PORT_NUMBER_1).build());
List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build(), SetFieldAction.builder().field(Field.UDP_DST).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build(), COPY_FIELD_ACTION, new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class MultiTableIngressYRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
if (flow.isOneSwitchFlow()) {
throw new IllegalStateException("Y-Flow rules can't be created for one switch flow");
}
List<SpeakerData> result = new ArrayList<>();
FlowEndpoint ingressEndpoint = checkAndBuildIngressEndpoint(flow, flowPath, sw.getSwitchId());
FlowSpeakerData command = buildFlowIngressCommand(sw, ingressEndpoint);
if (command == null) {
return Collections.emptyList();
}
result.add(command);
if (generateMeterCommand) {
SpeakerData meterCommand = buildMeter(externalMeterCommandUuid, flowPath, config, sharedMeterId, sw);
if (meterCommand != null) {
result.add(meterCommand);
command.getDependsOn().add(externalMeterCommandUuid);
}
} else if (sw.getFeatures().contains(METERS) && sharedMeterId != null) {
command.getDependsOn().add(externalMeterCommandUuid);
}
return result;
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
List<SpeakerData> result = new ArrayList<>();
if (switchProperties == null || !switchProperties.isMultiTable() || !switchProperties.isServer42FlowRtt() || flowPath.isOneSwitchFlow()) {
return result;
}
FlowEndpoint ingressEndpoint = getIngressEndpoint(sw.getSwitchId());
result.add(buildServer42IngressCommand(sw, ingressEndpoint));
if (needToBuildServer42PreIngressRule(ingressEndpoint)) {
result.add(buildServer42PreIngressCommand(sw, ingressEndpoint));
}
if (needToBuildServer42InputRule(ingressEndpoint)) {
result.add(buildServer42InputCommand(sw, ingressEndpoint.getPortNumber()));
}
return result;
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class EgressMirrorRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
List<SpeakerData> result = new ArrayList<>();
if (flowPath.isOneSwitchFlow() || flowPath.getSegments().isEmpty()) {
return result;
}
FlowMirrorPoints mirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(points -> sw.getSwitchId().equals(points.getMirrorSwitchId())).findFirst().orElse(null);
if (mirrorPoints == null) {
return result;
}
PathSegment lastSegment = flowPath.getSegments().get(flowPath.getSegments().size() - 1);
FlowEndpoint egressEndpoint = checkAndBuildEgressEndpoint(flow, flowPath, sw.getSwitchId());
SpeakerData egressCommand = buildEgressCommand(sw, lastSegment.getDestPort(), egressEndpoint, mirrorPoints.getMirrorGroupId());
result.add(egressCommand);
SpeakerData groupCommand = buildGroup(sw, mirrorPoints, egressEndpoint.getPortNumber());
result.add(groupCommand);
egressCommand.getDependsOn().add(groupCommand.getUuid());
return result;
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class UniCastDiscoveryRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
List<SpeakerData> commands = new ArrayList<>();
Instructions instructions = Instructions.builder().applyActions(new ArrayList<>()).build();
FlowSpeakerData flowCommand = buildRule(sw, instructions);
if (flowCommand == null) {
return Collections.emptyList();
} else {
commands.add(flowCommand);
}
MeterId meterId = createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE);
SpeakerData meterCommand = generateMeterCommandForServiceRule(sw, meterId, config.getUnicastRateLimit(), config.getSystemMeterBurstSizeInPackets(), config.getDiscoPacketSize());
if (meterCommand != null) {
commands.add(meterCommand);
addMeterToInstructions(meterId, sw, instructions);
}
instructions.getApplyActions().add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
// todo remove useless set field action
instructions.getApplyActions().add(SetFieldAction.builder().field(Field.ETH_DST).value(sw.getSwitchId().toLong()).build());
if (meterCommand != null) {
flowCommand.getDependsOn().add(meterCommand.getUuid());
}
return commands;
}
Aggregations