Search in sources :

Example 36 with RoutingMetadata

use of org.openkilda.rulemanager.utils.RoutingMetadata in project open-kilda by telstra.

the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVlanEncapsulationFullPortTest.

@Test
public void buildCommandsVlanEncapsulationFullPortTest() {
    Flow flow = buildFlow(PATH, 0, 0);
    MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(2, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(1);
    assertInputCommand(inputCustomerCommand);
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_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(SetFieldAction.builder().field(Field.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
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) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 37 with RoutingMetadata

use of org.openkilda.rulemanager.utils.RoutingMetadata 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);
}
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 38 with RoutingMetadata

use of org.openkilda.rulemanager.utils.RoutingMetadata in project open-kilda by telstra.

the class ArpPostIngressOneSwitchRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    RoutingMetadata metadata = makeMetadataMatch(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_ONE_SWITCH_COOKIE);
    return buildCommands(sw, cookie, OfTable.POST_INGRESS, Priority.ARP_POST_INGRESS_ONE_SWITCH_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 39 with RoutingMetadata

use of org.openkilda.rulemanager.utils.RoutingMetadata in project open-kilda by telstra.

the class MultiTableServer42IngressRuleGenerator method buildServer42IngressDoubleVlanCommand.

private FlowSpeakerData buildServer42IngressDoubleVlanCommand(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(), FieldMatch.builder().field(Field.VLAN_VID).value(ingressEndpoint.getInnerVlanId()).build());
    return buildServer42IngressCommand(sw, ingressEndpoint, match, SERVER_42_INGRESS_DOUBLE_VLAN_FLOW_PRIORITY);
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata)

Example 40 with RoutingMetadata

use of org.openkilda.rulemanager.utils.RoutingMetadata in project open-kilda by telstra.

the class MultiTableServer42IngressRuleGenerator method buildServer42IngressFullPortCommand.

private FlowSpeakerData buildServer42IngressFullPortCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    RoutingMetadata metadata = RoutingMetadata.builder().inputPort(ingressEndpoint.getPortNumber()).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_DEFAULT_FLOW_PRIORITY);
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata)

Aggregations

RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)42 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)37 Test (org.junit.Test)18 Flow (org.openkilda.model.Flow)16 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)14 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)14 SpeakerData (org.openkilda.rulemanager.SpeakerData)14 Action (org.openkilda.rulemanager.action.Action)14 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)14 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)14 Instructions (org.openkilda.rulemanager.Instructions)13 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)12 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)12 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)12 Cookie (org.openkilda.model.cookie.Cookie)8 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)8 FlowSideAdapter (org.openkilda.adapter.FlowSideAdapter)7 OfMetadata (org.openkilda.rulemanager.OfMetadata)7 FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)6 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)6