use of org.openkilda.rulemanager.action.PortOutAction 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.action.PortOutAction 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.action.PortOutAction in project open-kilda by telstra.
the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanWithOuterVlanOverlappingTest.
@Test
public void buildCommandsVlanEncapsulationDoubleVlanWithOuterVlanOverlappingTest() {
Flow oneSwitchFlow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_1, 0);
Set<FlowSideAdapter> overlapping = Sets.newHashSet(FlowSideAdapter.makeIngressAdapter(oneSwitchFlow, ONE_SWITCH_PATH));
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(2, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(1);
assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
RoutingMetadata ingressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, METER_ID, null);
assertMeterCommand(meterCommand);
}
use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVxlanEncapsulationSingleVlanTest.
@Test
public void buildCommandsVxlanEncapsulationSingleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(3, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
assertInputCommand(inputCustomerCommand);
RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
List<Action> expectedIngressActions = newArrayList(buildPushVxlan(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
use of org.openkilda.rulemanager.action.PortOutAction in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.
@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(3, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
assertInputCommand(inputCustomerCommand);
RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
Aggregations