Search in sources :

Example 51 with Action

use of org.openkilda.rulemanager.action.Action 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 52 with Action

use of org.openkilda.rulemanager.action.Action 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 53 with Action

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

the class Server42IslRttInputRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    int udpOffset = config.getServer42IslRttUdpPortOffset();
    Set<FieldMatch> match = buildMatch(server42Port, udpOffset + islPort, sw.getSwitchId());
    long ethDst = new SwitchId(config.getServer42IslRttMagicMacAddress()).toLong();
    List<Action> actions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_FORWARD_UDP_PORT).build(), SetFieldAction.builder().field(Field.ETH_DST).value(ethDst).build(), new PortOutAction(new PortNumber(islPort)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(encodeServer42IslRttInput(islPort))).table(OfTable.INPUT).priority(SERVER_42_ISL_RTT_INPUT_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) SwitchId(org.openkilda.model.SwitchId) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 54 with Action

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

the class MultiTableIngressYRuleGeneratorTest method buildTransformActionsOneSwitchFullPortInSingleVlanOutTest.

@Test
public void buildTransformActionsOneSwitchFullPortInSingleVlanOutTest() {
    Flow flow = buildFlow(ONE_SWITCH_PATH, 0, 0, OUTER_VLAN_ID_2, 0);
    MultiTableIngressYRuleGenerator generator = buildGenerator(ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
    List<Action> transformActions = generator.buildTransformActions(0, FEATURES);
    List<Action> expectedActions = newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_2).build());
    assertEquals(expectedActions, transformActions);
}
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) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 55 with Action

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

the class MultiTableIngressYRuleGeneratorTest method buildTransformActionsOneSwitchDoubleVlanInSingleVlanOutTest.

@Test
public void buildTransformActionsOneSwitchDoubleVlanInSingleVlanOutTest() {
    Flow flow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1, OUTER_VLAN_ID_2, 0);
    MultiTableIngressYRuleGenerator generator = buildGenerator(ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
    List<Action> transformActions = generator.buildTransformActions(INNER_VLAN_ID_1, FEATURES);
    List<Action> expectedActions = newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_2).build());
    assertEquals(expectedActions, transformActions);
}
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) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

Action (org.openkilda.rulemanager.action.Action)196 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)195 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)168 Test (org.junit.Test)151 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)149 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)146 Flow (org.openkilda.model.Flow)136 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)117 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)67 SpeakerData (org.openkilda.rulemanager.SpeakerData)67 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)59 GroupAction (org.openkilda.rulemanager.action.GroupAction)55 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)47 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)46 Instructions (org.openkilda.rulemanager.Instructions)34 ArrayList (java.util.ArrayList)29 FlowPath (org.openkilda.model.FlowPath)27 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)23 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)21 CopyFieldAction (org.openkilda.rulemanager.action.noviflow.CopyFieldAction)20