Search in sources :

Example 16 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch 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);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Instructions(org.openkilda.rulemanager.Instructions)

Example 17 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch 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);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Instructions(org.openkilda.rulemanager.Instructions)

Example 18 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.

the class TransitIslVxlanRuleGenerator 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();
    }
    Set<FieldMatch> match = buildTransitIslVxlanRuleMatch();
    Instructions instructions = Instructions.builder().goToTable(OfTable.TRANSIT).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new PortColourCookie(CookieType.MULTI_TABLE_ISL_VXLAN_TRANSIT_RULES, islPort)).table(OfTable.INPUT).priority(ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE).match(match).instructions(instructions).build());
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SwitchFeature(org.openkilda.model.SwitchFeature) PortColourCookie(org.openkilda.model.cookie.PortColourCookie)

Example 19 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch 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);
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 20 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.

the class MultiTableServer42IngressRuleGeneratorTest method assertInputCommand.

private void assertInputCommand(FlowSpeakerData command) {
    assertEquals(SWITCH_1.getSwitchId(), command.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), command.getOfVersion().toString());
    assertEquals(new PortColourCookie(SERVER_42_FLOW_RTT_INPUT, PORT_NUMBER_1), command.getCookie());
    assertEquals(OfTable.INPUT, command.getTable());
    assertEquals(Priority.SERVER_42_FLOW_RTT_INPUT_PRIORITY, command.getPriority());
    assertTrue(command.getDependsOn().isEmpty());
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).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(PORT_NUMBER_1 + PORT_OFFSET).build(), FieldMatch.builder().field(Field.ETH_SRC).value(SERVER_42_MAC_ADDRESS.toLong()).build());
    assertEqualsMatch(expectedMatch, command.getMatch());
    List<Action> expectedApplyActions = 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());
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).goToTable(OfTable.PRE_INGRESS).writeMetadata(mapMetadata(RoutingMetadata.builder().inputPort(PORT_NUMBER_1).build(SWITCH_1.getFeatures()))).build();
    assertEquals(expectedInstructions, command.getInstructions());
    assertTrue(command.getFlags().isEmpty());
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortColourCookie(org.openkilda.model.cookie.PortColourCookie)

Aggregations

FieldMatch (org.openkilda.rulemanager.match.FieldMatch)121 Test (org.junit.Test)61 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)55 Instructions (org.openkilda.rulemanager.Instructions)55 SpeakerData (org.openkilda.rulemanager.SpeakerData)50 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)50 Action (org.openkilda.rulemanager.action.Action)46 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)41 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)41 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)37 Flow (org.openkilda.model.Flow)31 Cookie (org.openkilda.model.cookie.Cookie)30 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)27 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)25 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)24 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)23 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)15 FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)12 Switch (org.openkilda.model.Switch)12 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)12