Search in sources :

Example 6 with PopVxlanAction

use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.

the class ArpPostIngressVxlanRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    if (!(sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN) || sw.getFeatures().contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN))) {
        return Collections.emptyList();
    }
    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(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(ARP_VXLAN_UDP_SRC).build(), FieldMatch.builder().field(Field.UDP_DST).value(VXLAN_UDP_DST).build());
    if (sw.getFeatures().contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
        match.add(FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build());
    }
    List<Action> actions = new ArrayList<>();
    if (sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN)) {
        actions.add(new PopVxlanAction(POP_VXLAN_NOVIFLOW));
    } else {
        actions.add(new PopVxlanAction(POP_VXLAN_OVS));
    }
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    Cookie cookie = new Cookie(ARP_POST_INGRESS_VXLAN_COOKIE);
    return buildCommands(sw, cookie, OfTable.POST_INGRESS, Priority.ARP_POST_INGRESS_VXLAN_PRIORITY, match, instructions);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) ArrayList(java.util.ArrayList) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 7 with PopVxlanAction

use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.

the class LldpPostIngressVxlanRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    if (!(sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN) || sw.getFeatures().contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN))) {
        return Collections.emptyList();
    }
    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(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(STUB_VXLAN_UDP_SRC).build(), FieldMatch.builder().field(Field.UDP_DST).value(VXLAN_UDP_DST).build());
    if (sw.getFeatures().contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
        match.add(FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build());
    }
    List<Action> actions = new ArrayList<>();
    if (sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN)) {
        actions.add(new PopVxlanAction(POP_VXLAN_NOVIFLOW));
    } else {
        actions.add(new PopVxlanAction(POP_VXLAN_OVS));
    }
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    Cookie cookie = new Cookie(LLDP_POST_INGRESS_VXLAN_COOKIE);
    return buildCommands(sw, cookie, OfTable.POST_INGRESS, Priority.LLDP_POST_INGRESS_VXLAN_PRIORITY, match, instructions);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) ArrayList(java.util.ArrayList) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 8 with PopVxlanAction

use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.

the class EgressRuleGeneratorTest method buildVxlanMultiTableFullPortEgressRuleTest.

@Test
public void buildVxlanMultiTableFullPortEgressRuleTest() {
    FlowPath path = buildPath(true);
    Flow flow = buildFlow(path, 0, 0);
    EgressRuleGenerator generator = buildGenerator(path, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW), new PortOutAction(new PortNumber(PORT_NUMBER_4)));
    assertEgressCommands(commands, OfTable.EGRESS, VXLAN_ENCAPSULATION, expectedApplyActions);
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) FlowPath(org.openkilda.model.FlowPath) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 9 with PopVxlanAction

use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.

the class EgressRuleGeneratorTest method buildVxlanMultiTableOuterVlanEgressRuleTest.

@Test
public void buildVxlanMultiTableOuterVlanEgressRuleTest() {
    FlowPath path = buildPath(true);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, 0);
    EgressRuleGenerator generator = buildGenerator(path, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_4)));
    assertEgressCommands(commands, OfTable.EGRESS, VXLAN_ENCAPSULATION, expectedApplyActions);
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) FlowPath(org.openkilda.model.FlowPath) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 10 with PopVxlanAction

use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.

the class EgressRuleGeneratorTest method buildVxlanMultiTableOuterInnerVlanEgressRuleTest.

@Test
public void buildVxlanMultiTableOuterInnerVlanEgressRuleTest() {
    FlowPath path = buildPath(true);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, INNER_VLAN_ID);
    EgressRuleGenerator generator = buildGenerator(path, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID).build(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_4)));
    assertEgressCommands(commands, OfTable.EGRESS, VXLAN_ENCAPSULATION, expectedApplyActions);
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) FlowPath(org.openkilda.model.FlowPath) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)27 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)25 Action (org.openkilda.rulemanager.action.Action)24 Test (org.junit.Test)15 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)13 SpeakerData (org.openkilda.rulemanager.SpeakerData)13 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)13 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)13 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)13 Flow (org.openkilda.model.Flow)10 FlowPath (org.openkilda.model.FlowPath)10 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)10 MeterAction (org.openkilda.rulemanager.action.MeterAction)10 GroupAction (org.openkilda.rulemanager.action.GroupAction)8 ArrayList (java.util.ArrayList)6 Instructions (org.openkilda.rulemanager.Instructions)6 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)5 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)3 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)3 GroupId (org.openkilda.model.GroupId)2