use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.
the class FlowLoopTransitRuleGenerator method buildInstructions.
private Instructions buildInstructions(SwitchId switchId) {
List<Action> applyActions = new ArrayList<>();
if (FlowEncapsulationType.VXLAN.equals(encapsulation.getType())) {
// After turning of VXLAN packet we must update eth_dst header because egress rule on the last switch
// will match the packet by this field.
applyActions.add(SetFieldAction.builder().field(ETH_SRC).value(switchId.toMacAddressAsLong()).build());
applyActions.add(SetFieldAction.builder().field(ETH_DST).value(flowPath.getSrcSwitchId().toMacAddressAsLong()).build());
}
applyActions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
return Instructions.builder().applyActions(applyActions).build();
}
use of org.openkilda.rulemanager.ProtoConstants.PortNumber 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.ProtoConstants.PortNumber 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.ProtoConstants.PortNumber in project open-kilda by telstra.
the class Server42IslRttOutputRuleGenerator method generateCommands.
@Override
public List<SpeakerData> generateCommands(Switch sw) {
List<Action> actions = new ArrayList<>();
if (server42Vlan > 0) {
actions.add(new PushVlanAction());
actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(server42Vlan).build());
}
actions.add(SetFieldAction.builder().field(ETH_SRC).value(sw.getSwitchId().toMacAddressAsLong()).build());
actions.add(SetFieldAction.builder().field(ETH_DST).value(server42MacAddress.toLong()).build());
actions.add(new PortOutAction(new PortNumber(server42Port)));
Instructions instructions = Instructions.builder().applyActions(actions).build();
Set<FieldMatch> match = buildMatch(new MacAddress(config.getServer42IslRttMagicMacAddress()));
return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_ISL_RTT_OUTPUT_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_ISL_RTT_OUTPUT_PRIORITY).match(match).instructions(instructions).build());
}
use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.
the class FlowLoopIngressRuleGenerator method makeIngressFlowLoopInstructions.
private Instructions makeIngressFlowLoopInstructions(FlowEndpoint endpoint) {
List<Action> applyActions = new ArrayList<>();
if (multiTable) {
applyActions.addAll(Utils.makeVlanReplaceActions(FlowEndpoint.makeVlanStack(endpoint.getInnerVlanId()), endpoint.getVlanStack()));
}
applyActions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
return Instructions.builder().applyActions(applyActions).build();
}
Aggregations