use of org.openkilda.rulemanager.Instructions 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.Instructions in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGenerator method buildUnicastVerificationRuleVxlan.
private FlowSpeakerData buildUnicastVerificationRuleVxlan(Switch sw, Cookie cookie) {
List<Action> actions = new ArrayList<>();
if (sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN)) {
actions.add(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW));
} else {
actions.add(new PopVxlanAction(ActionType.POP_VXLAN_OVS));
}
actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
// todo remove unnecessary action
actions.add(SetFieldAction.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).build());
Instructions instructions = Instructions.builder().applyActions(actions).build();
long ethSrc = new SwitchId(config.getFlowPingMagicSrcMacAddress()).toLong();
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(ETH_SRC).value(ethSrc).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(UDP_SRC).value(STUB_VXLAN_UDP_SRC).build());
return FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(VERIFICATION_RULE_VXLAN_PRIORITY).match(match).instructions(instructions).build();
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class MultiTableIngressRuleGenerator method buildCustomerPortSharedCatchCommand.
private FlowSpeakerData buildCustomerPortSharedCatchCommand(Switch sw, FlowEndpoint endpoint) {
PortColourCookie cookie = new PortColourCookie(CookieType.MULTI_TABLE_INGRESS_RULES, endpoint.getPortNumber());
Instructions instructions = Instructions.builder().goToTable(OfTable.PRE_INGRESS).build();
FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(endpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(Priority.INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE).match(Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(endpoint.getPortNumber()).build())).instructions(instructions);
return builder.build();
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class MultiTableIngressRuleGenerator method buildFlowPreIngressCommand.
private FlowSpeakerData buildFlowPreIngressCommand(Switch sw, FlowEndpoint endpoint) {
FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.QINQ_OUTER_VLAN).portNumber(endpoint.getPortNumber()).vlanId(endpoint.getOuterVlanId()).build();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(sw.getFeatures());
Instructions instructions = Instructions.builder().applyActions(Lists.newArrayList(new PopVlanAction())).writeMetadata(new OfMetadata(metadata.getValue(), metadata.getMask())).goToTable(OfTable.INGRESS).build();
FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(endpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.PRE_INGRESS).priority(Constants.Priority.FLOW_PRIORITY).match(buildPreIngressMatch(endpoint)).instructions(instructions);
// todo add RESET_COUNTERS flag
return builder.build();
}
use of org.openkilda.rulemanager.Instructions 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