Search in sources :

Example 11 with FieldMatch

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

the class TransitYRuleGeneratorTest method assertTransitCommand.

private void assertTransitCommand(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(SWITCH_1.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().contains(SHARED_METER_UUID));
    assertEquals(COOKIE, flowCommandData.getCookie());
    assertEquals(table, flowCommandData.getTable());
    assertEquals(Priority.Y_FLOW_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch;
    if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_1, encapsulation.getId());
    } else {
        expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_1, encapsulation.getId());
    }
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(Lists.newArrayList(new PortOutAction(new PortNumber(PORT_NUMBER_2)))).goToMeter(SHARED_METER_ID).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertEquals(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS), flowCommandData.getFlags());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 12 with FieldMatch

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

the class SingleTableServer42IngressRuleGenerator method buildMatch.

private Set<FieldMatch> buildMatch(FlowEndpoint ingressEndpoint) {
    int udpSrcPort = ingressEndpoint.getPortNumber() + 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());
    if (isVlanIdSet(ingressEndpoint.getOuterVlanId())) {
        match.add(FieldMatch.builder().field(Field.VLAN_VID).value(ingressEndpoint.getOuterVlanId()).build());
    }
    return match;
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 13 with FieldMatch

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

the class MultiTableServer42IngressRuleGenerator method buildServer42IngressSingleVlanCommand.

private FlowSpeakerData buildServer42IngressSingleVlanCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    RoutingMetadata metadata = RoutingMetadata.builder().inputPort(ingressEndpoint.getPortNumber()).outerVlanId(ingressEndpoint.getOuterVlanId()).build(sw.getFeatures());
    Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(switchProperties.getServer42Port()).build(), FieldMatch.builder().field(Field.METADATA).value(metadata.getValue()).mask(metadata.getMask()).build());
    return buildServer42IngressCommand(sw, ingressEndpoint, match, SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY);
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata)

Example 14 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch 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();
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) FlowEndpoint(org.openkilda.model.FlowEndpoint) PortColourCookie(org.openkilda.model.cookie.PortColourCookie)

Example 15 with FieldMatch

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

the class UniCastDiscoveryRuleGenerator method buildMatch.

private Set<FieldMatch> buildMatch(Switch sw) {
    Set<FieldMatch> match = new HashSet<>();
    long srcMac = new SwitchId(config.getFlowPingMagicSrcMacAddress()).toLong();
    long dstMac = sw.getSwitchId().toLong();
    match.add(FieldMatch.builder().field(Field.ETH_SRC).value(srcMac).mask(Mask.NO_MASK).build());
    match.add(FieldMatch.builder().field(Field.ETH_DST).value(dstMac).mask(Mask.NO_MASK).build());
    return match;
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) SwitchId(org.openkilda.model.SwitchId) HashSet(java.util.HashSet)

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