use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithoutUpdDstMatchForOf13.
@Test
public void shouldBuildCorrectRuleWithoutUpdDstMatchForOf13() {
sw = buildSwitch("OF_13", Sets.newHashSet(METERS, GROUP_PACKET_OUT_CONTROLLER, PKTPS_FLAG));
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(3, commands.size());
commands.forEach(c -> assertEquals(sw.getSwitchId(), c.getSwitchId()));
commands.forEach(c -> assertEquals(sw.getOfVersion(), c.getOfVersion().toString()));
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
GroupSpeakerData groupCommandData = getCommand(GroupSpeakerData.class, commands);
assertEquals(2, flowCommandData.getDependsOn().size());
assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
assertTrue(flowCommandData.getDependsOn().contains(groupCommandData.getUuid()));
// Check flow command
checkFlowCommandBaseProperties(flowCommandData);
// Check match is only by eth_dst
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(1, match.size());
checkEthDstMatch(match);
checkGroupInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId(), groupCommandData.getGroupId());
// Check meter command
checkMeterCommand(meterCommandData);
// Check group command
checkGroupCommand(groupCommandData);
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class IngressMirrorRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
List<SpeakerData> result = new ArrayList<>();
FlowMirrorPoints mirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(points -> sw.getSwitchId().equals(points.getMirrorSwitchId())).findFirst().orElse(null);
if (mirrorPoints == null) {
return result;
}
FlowEndpoint ingressEndpoint = checkAndBuildIngressEndpoint(flow, flowPath, sw.getSwitchId());
FlowSpeakerData ingressCommand = buildFlowIngressCommand(sw, ingressEndpoint, mirrorPoints.getMirrorGroupId());
result.add(ingressCommand);
SpeakerData groupCommand = buildGroup(sw, mirrorPoints);
result.add(groupCommand);
ingressCommand.getDependsOn().add(groupCommand.getUuid());
if (sharedMeterCommandUuid != null) {
ingressCommand.getDependsOn().add(sharedMeterCommandUuid);
}
return result;
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class BroadCastDiscoveryRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
List<SpeakerData> commands = new ArrayList<>();
List<Action> actions = new ArrayList<>();
Instructions instructions = Instructions.builder().applyActions(actions).build();
FlowSpeakerData flowCommand = buildRule(sw, instructions);
commands.add(flowCommand);
MeterId meterId = createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE);
SpeakerData meterCommand = generateMeterCommandForServiceRule(sw, meterId, config.getBroadcastRateLimit(), config.getSystemMeterBurstSizeInPackets(), config.getDiscoPacketSize());
if (meterCommand != null) {
commands.add(meterCommand);
addMeterToInstructions(meterId, sw, instructions);
}
GroupSpeakerData groupCommand = null;
if (sw.getFeatures().contains(SwitchFeature.GROUP_PACKET_OUT_CONTROLLER)) {
groupCommand = getRoundTripLatencyGroup(sw);
actions.add(new GroupAction(groupCommand.getGroupId()));
commands.add(groupCommand);
} else {
actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
}
if (meterCommand != null) {
flowCommand.getDependsOn().add(meterCommand.getUuid());
}
if (groupCommand != null) {
flowCommand.getDependsOn().add(groupCommand.getUuid());
}
return commands;
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
// should be replaced with fair feature detection based on ActionId's during handshake
if (!(sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN) || sw.getFeatures().contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN))) {
return Collections.emptyList();
}
Cookie cookie = new Cookie(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE);
FlowSpeakerData flowCommand = buildUnicastVerificationRuleVxlan(sw, cookie);
List<SpeakerData> result = new ArrayList<>();
result.add(flowCommand);
MeterId meterId = createMeterIdForDefaultRule(cookie.getValue());
long meterRate = config.getUnicastRateLimit();
MeterSpeakerData meterCommand = generateMeterCommandForServiceRule(sw, meterId, meterRate, config.getSystemMeterBurstSizeInPackets(), config.getDiscoPacketSize());
if (meterCommand != null) {
addMeterToInstructions(meterId, sw, flowCommand.getInstructions());
flowCommand.getDependsOn().add(meterCommand.getUuid());
result.add(meterCommand);
}
return result;
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class InputArpRuleGeneratorTest method buildCorrectRuleForOf13Test.
@Test
public void buildCorrectRuleForOf13Test() {
FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, false, true);
FlowSideAdapter overlapAdapter = new FlowSourceAdapter(Flow.builder().flowId("some").srcSwitch(SW).destSwitch(buildSwitch("OF_13", Collections.emptySet())).detectConnectedDevices(DetectConnectedDevices.builder().srcArp(false).srcSwitchArp(false).build()).build());
InputArpRuleGenerator generator = InputArpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(Sets.newHashSet(overlapAdapter)).build();
List<SpeakerData> commands = generator.generateCommands(SW);
assertEquals(1, commands.size());
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(SW.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(SW.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().isEmpty());
assertEquals(new PortColourCookie(CookieType.ARP_INPUT_CUSTOMER_TYPE, PORT_NUMBER_1), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(Priority.ARP_INPUT_CUSTOMER_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.ARP).build());
assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
RoutingMetadata metadata = RoutingMetadata.builder().arpFlag(true).build(SW.getFeatures());
Instructions expectedInstructions = Instructions.builder().writeMetadata(new OfMetadata(metadata.getValue(), metadata.getMask())).goToTable(OfTable.PRE_INGRESS).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
assertTrue(flowCommandData.getFlags().isEmpty());
}
Aggregations