Search in sources :

Example 21 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class FlowLoopIngressRuleGeneratorTest method buildSingleTableDefaultFlowRuleTest.

@Test
public void buildSingleTableDefaultFlowRuleTest() {
    Flow flow = buildFlow(PATH, 0, 0, 0, 0);
    List<SpeakerData> commands = buildGenerator(flow, false).generateCommands(SWITCH_1);
    assertIngressCommands(commands, OfTable.INPUT, Priority.LOOP_DEFAULT_FLOW_PRIORITY, newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build()), newArrayList(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT))));
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction) 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 22 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class FlowLoopIngressRuleGeneratorTest method buildMultiTableDoubleVlanRuleTest.

@Test
public void buildMultiTableDoubleVlanRuleTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_1, INNER_VLAN_1, 0, 0);
    List<SpeakerData> commands = buildGenerator(flow, true).generateCommands(SWITCH_1);
    assertIngressCommands(commands, OfTable.INGRESS, Priority.LOOP_DOUBLE_VLAN_FLOW_PRIORITY, newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_1).build(), buildMetadataMatch(OUTER_VLAN_1)), newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_1).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT))));
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) 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 23 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber 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 24 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber 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 25 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber 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)

Aggregations

PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)76 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)76 Action (org.openkilda.rulemanager.action.Action)58 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)52 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)52 SpeakerData (org.openkilda.rulemanager.SpeakerData)49 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)47 Test (org.junit.Test)46 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)41 Flow (org.openkilda.model.Flow)40 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)37 Instructions (org.openkilda.rulemanager.Instructions)24 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)23 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)21 ArrayList (java.util.ArrayList)19 Cookie (org.openkilda.model.cookie.Cookie)15 FlowPath (org.openkilda.model.FlowPath)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)14 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)13 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)8