use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGenerator method buildServer42InputCommand.
private FlowSpeakerData buildServer42InputCommand(Switch sw, int inPort) {
int udpSrcPort = inPort + config.getServer42FlowRttUdpPortOffset();
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(switchProperties.getServer42Port()).build(), FieldMatch.builder().field(Field.ETH_SRC).value(switchProperties.getServer42MacAddress().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(udpSrcPort).build());
PortColourCookie cookie = new PortColourCookie(CookieType.SERVER_42_FLOW_RTT_INPUT, inPort);
List<Action> applyActions = Lists.newArrayList(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());
if (sw.getFeatures().contains(NOVIFLOW_COPY_FIELD)) {
applyActions.add(buildServer42CopyFirstTimestamp());
}
Instructions instructions = Instructions.builder().applyActions(applyActions).goToTable(OfTable.PRE_INGRESS).writeMetadata(mapMetadata(RoutingMetadata.builder().inputPort(inPort).build(sw.getFeatures()))).build();
return FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(Priority.SERVER_42_FLOW_RTT_INPUT_PRIORITY).match(match).instructions(instructions).build();
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class SingleTableIngressYRuleGenerator method buildFlowIngressCommand.
private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
List<Action> actions = new ArrayList<>();
Instructions instructions = Instructions.builder().applyActions(actions).build();
actions.addAll(buildTransformActions(ingressEndpoint.getOuterVlanId(), sw.getFeatures()));
actions.add(new PortOutAction(getOutPort(flowPath, flow)));
addMeterToInstructions(sharedMeterId, sw, instructions);
FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie().toBuilder().yFlow(true).build()).table(OfTable.INPUT).priority(isFullPortEndpoint(ingressEndpoint) ? Constants.Priority.Y_DEFAULT_FLOW_PRIORITY : Constants.Priority.Y_FLOW_PRIORITY).match(buildMatch(ingressEndpoint, sw.getFeatures())).instructions(instructions);
if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
}
return builder.build();
}
use of org.openkilda.rulemanager.Instructions 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;
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class ArpIngressRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().arpFlag(true), sw);
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.METADATA).value(metadata.getValue()).mask(metadata.getMask()).build());
Instructions instructions = buildSendToControllerInstructions();
Cookie cookie = new Cookie(ARP_INGRESS_COOKIE);
return buildCommands(sw, cookie, OfTable.INGRESS, Priority.ARP_INGRESS_PRIORITY, match, instructions);
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class ArpPostIngressRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().arpFlag(true), sw);
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.METADATA).value(metadata.getValue()).mask(metadata.getMask()).build());
Instructions instructions = buildSendToControllerInstructions();
Cookie cookie = new Cookie(ARP_POST_INGRESS_COOKIE);
return buildCommands(sw, cookie, OfTable.POST_INGRESS, Priority.ARP_POST_INGRESS_PRIORITY, match, instructions);
}
Aggregations