use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.
the class EgressRuleGeneratorTest method buildVxlanSingleTableFullPortEgressRuleTest.
@Test
public void buildVxlanSingleTableFullPortEgressRuleTest() {
FlowPath path = buildPath(false);
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.INPUT, VXLAN_ENCAPSULATION, expectedApplyActions);
}
use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.
the class ArpPostIngressVxlanRuleGeneratorTest method checkInstructionsOf15.
@Override
protected void checkInstructionsOf15(Instructions instructions, MeterId meterId) {
assertEquals(3, instructions.getApplyActions().size());
Action first = instructions.getApplyActions().get(0);
assertTrue(first instanceof PopVxlanAction);
PopVxlanAction popVxlanAction = (PopVxlanAction) first;
assertEquals(ActionType.POP_VXLAN_NOVIFLOW, popVxlanAction.getType());
Action second = instructions.getApplyActions().get(1);
assertTrue(second instanceof PortOutAction);
PortOutAction portOutAction = (PortOutAction) second;
assertEquals(SpecialPortType.CONTROLLER, portOutAction.getPortNumber().getPortType());
Action third = instructions.getApplyActions().get(2);
assertTrue(third instanceof MeterAction);
MeterAction meterAction = (MeterAction) third;
assertEquals(meterId, meterAction.getMeterId());
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
}
use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithoutMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithoutMeterForOf13() {
sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_PUSH_POP_VXLAN, PKTPS_FLAG));
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(1, commands.size());
commands.forEach(c -> assertEquals(sw.getSwitchId(), c.getSwitchId()));
commands.forEach(c -> assertEquals(sw.getOfVersion(), c.getOfVersion().toString()));
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertTrue(flowCommandData.getDependsOn().isEmpty());
// Check flow command
checkFlowCommandBaseProperties(flowCommandData);
checkMatch(flowCommandData.getMatch());
// Check instructions without meter
Instructions instructions = flowCommandData.getInstructions();
assertEquals(3, instructions.getApplyActions().size());
Action first = instructions.getApplyActions().get(0);
assertTrue(first instanceof PopVxlanAction);
PopVxlanAction popVxlanAction = (PopVxlanAction) first;
assertEquals(ActionType.POP_VXLAN_NOVIFLOW, popVxlanAction.getType());
Action second = instructions.getApplyActions().get(1);
assertTrue(second instanceof PortOutAction);
PortOutAction sendToControllerAction = (PortOutAction) second;
assertEquals(SpecialPortType.CONTROLLER, sendToControllerAction.getPortNumber().getPortType());
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
}
use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGenerator method buildUnicastVerificationRuleVxlan.
private FlowSpeakerData buildUnicastVerificationRuleVxlan(Switch sw, Cookie cookie) {
List<Action> actions = new ArrayList<>();
if (sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN)) {
actions.add(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW));
} else {
actions.add(new PopVxlanAction(ActionType.POP_VXLAN_OVS));
}
actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
// todo remove unnecessary action
actions.add(SetFieldAction.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).build());
Instructions instructions = Instructions.builder().applyActions(actions).build();
long ethSrc = new SwitchId(config.getFlowPingMagicSrcMacAddress()).toLong();
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(ETH_SRC).value(ethSrc).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(UDP_SRC).value(STUB_VXLAN_UDP_SRC).build());
return FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(VERIFICATION_RULE_VXLAN_PRIORITY).match(match).instructions(instructions).build();
}
use of org.openkilda.rulemanager.action.PopVxlanAction in project open-kilda by telstra.
the class OfInstructionsConverter method convertToRuleManagerAction.
/**
* Converts action.
*/
public Action convertToRuleManagerAction(OFAction action) {
switch(action.getType()) {
case PUSH_VLAN:
return new PushVlanAction();
case POP_VLAN:
return new PopVlanAction();
case METER:
OFActionMeter meterAction = (OFActionMeter) action;
MeterId meterId = new MeterId(meterAction.getMeterId());
return new MeterAction(meterId);
case GROUP:
OFActionGroup groupAction = (OFActionGroup) action;
GroupId groupId = new GroupId(groupAction.getGroup().getGroupNumber());
return new GroupAction(groupId);
case OUTPUT:
OFActionOutput outputAction = (OFActionOutput) action;
PortNumber portNumber = convertPort(outputAction.getPort());
return new PortOutAction(portNumber);
case EXPERIMENTER:
if (action instanceof OFActionNoviflowPushVxlanTunnel) {
OFActionNoviflowPushVxlanTunnel pushNoviVxlan = (OFActionNoviflowPushVxlanTunnel) action;
return PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_NOVIFLOW).vni((int) pushNoviVxlan.getVni()).srcMacAddress(convertMac(pushNoviVxlan.getEthSrc())).dstMacAddress(convertMac(pushNoviVxlan.getEthDst())).srcIpv4Address(convertIPv4Address(pushNoviVxlan.getIpv4Src())).dstIpv4Address(convertIPv4Address(pushNoviVxlan.getIpv4Dst())).udpSrc(pushNoviVxlan.getUdpSrc()).build();
} else if (action instanceof OFActionKildaPushVxlanField) {
OFActionKildaPushVxlanField pushKildaVxlan = (OFActionKildaPushVxlanField) action;
return PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_OVS).vni((int) pushKildaVxlan.getVni()).srcMacAddress(convertMac(pushKildaVxlan.getEthSrc())).dstMacAddress(convertMac(pushKildaVxlan.getEthDst())).srcIpv4Address(convertIPv4Address(pushKildaVxlan.getIpv4Src())).dstIpv4Address(convertIPv4Address(pushKildaVxlan.getIpv4Dst())).udpSrc(pushKildaVxlan.getUdpSrc()).build();
} else if (action instanceof OFActionNoviflowCopyField) {
OFActionNoviflowCopyField copyField = (OFActionNoviflowCopyField) action;
return CopyFieldAction.builder().numberOfBits(copyField.getNBits()).srcOffset(copyField.getSrcOffset()).dstOffset(copyField.getDstOffset()).oxmSrcHeader(convertOxmHeader(copyField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(copyField.getOxmDstHeader())).build();
} else if (action instanceof OFActionNoviflowSwapField) {
OFActionNoviflowSwapField swapField = (OFActionNoviflowSwapField) action;
return SwapFieldAction.builder().type(ActionType.NOVI_SWAP_FIELD).numberOfBits(swapField.getNBits()).srcOffset(swapField.getSrcOffset()).dstOffset(swapField.getDstOffset()).oxmSrcHeader(convertOxmHeader(swapField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(swapField.getOxmDstHeader())).build();
} else if (action instanceof OFActionKildaSwapField) {
OFActionKildaSwapField swapField = (OFActionKildaSwapField) action;
return SwapFieldAction.builder().type(ActionType.KILDA_SWAP_FIELD).numberOfBits(swapField.getNBits()).srcOffset(swapField.getSrcOffset()).dstOffset(swapField.getDstOffset()).oxmSrcHeader(convertOxmHeader(swapField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(swapField.getOxmDstHeader())).build();
} else if (action instanceof OFActionNoviflowPopVxlanTunnel) {
return new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW);
} else if (action instanceof OFActionKildaPopVxlanField) {
return new PopVxlanAction(ActionType.POP_VXLAN_OVS);
} else {
throw new IllegalStateException(format("Unknown experimenter action %s", action.getType()));
}
case SET_FIELD:
OFActionSetField setFieldAction = (OFActionSetField) action;
return convertOxm(setFieldAction.getField());
case SET_VLAN_VID:
OFActionSetVlanVid setVlanVid = (OFActionSetVlanVid) action;
return SetFieldAction.builder().field(Field.VLAN_VID).value(setVlanVid.getVlanVid().getVlan()).build();
default:
throw new IllegalStateException(format("Unknown action type %s", action.getType()));
}
}
Aggregations