use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class SingleTableIngressRuleGenerator method buildFlowIngressCommand.
private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
List<Action> actions = new ArrayList<>();
Instructions instructions = Instructions.builder().applyActions(actions).build();
// TODO should we check if switch supports encapsulation?
actions.addAll(buildTransformActions(ingressEndpoint.getOuterVlanId(), sw.getFeatures()));
actions.add(new PortOutAction(getOutPort(flowPath, flow)));
addMeterToInstructions(flowPath.getMeterId(), sw, instructions);
FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie()).table(OfTable.INPUT).priority(isFullPortEndpoint(ingressEndpoint) ? Constants.Priority.DEFAULT_FLOW_PRIORITY : Constants.Priority.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 LldpPostIngressRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().lldpFlag(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(LLDP_POST_INGRESS_COOKIE);
return buildCommands(sw, cookie, OfTable.POST_INGRESS, Priority.LLDP_POST_INGRESS_PRIORITY, match, instructions);
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class RoundTripLatencyRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
if (!sw.getFeatures().contains(NOVIFLOW_COPY_FIELD)) {
return Collections.emptyList();
}
Set<FieldMatch> match = roundTripLatencyRuleMatch(sw);
List<Action> actions = ImmutableList.of(actionAddRxTimestamp(), new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
Instructions instructions = Instructions.builder().applyActions(actions).build();
return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(ROUND_TRIP_LATENCY_RULE_COOKIE)).table(OfTable.INPUT).priority(ROUND_TRIP_LATENCY_RULE_PRIORITY).match(match).instructions(instructions).build());
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class Server42FlowRttOutputVxlanRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
Set<SwitchFeature> features = sw.getFeatures();
if (!features.contains(NOVIFLOW_PUSH_POP_VXLAN) && !features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
return Collections.emptyList();
}
List<Action> actions = new ArrayList<>();
actions.add(buildPopVxlanAction(features));
if (server42Vlan > 0) {
actions.add(new PushVlanAction());
actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(server42Vlan).build());
}
actions.add(SetFieldAction.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toLong()).build());
actions.add(SetFieldAction.builder().field(Field.ETH_DST).value(server42MacAddress.toLong()).build());
actions.add(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT).build());
if (sw.getFeatures().contains(NOVIFLOW_COPY_FIELD)) {
// NOTE: We must call copy field action after all set field actions. All set actions called after copy field
// actions will be ignored. It's Noviflow bug.
actions.add(buildCopyTimestamp());
}
actions.add(new PortOutAction(new PortNumber(server42Port)));
Instructions instructions = Instructions.builder().applyActions(actions).build();
return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_PRIORITY).match(buildMatch(sw.getSwitchId())).instructions(instructions).build());
}
use of org.openkilda.rulemanager.Instructions in project open-kilda by telstra.
the class Server42FlowRttVxlanTurningRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
Set<SwitchFeature> features = sw.getFeatures();
if (!features.contains(NOVIFLOW_SWAP_ETH_SRC_ETH_DST) && !features.contains(KILDA_OVS_SWAP_FIELD)) {
return Collections.emptyList();
}
Set<FieldMatch> match = buildMatch(sw.getSwitchId());
match.add(FieldMatch.builder().field(Field.UDP_DST).value(VXLAN_UDP_DST).build());
Instructions instructions = buildInstructions(sw, SERVER_42_FLOW_RTT_REVERSE_UDP_VXLAN_PORT);
return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_FLOW_RTT_VXLAN_TURNING_PRIORITY).match(match).instructions(instructions).build());
}
Aggregations