Search in sources :

Example 11 with FlowTransitEncapsulation

use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.

the class PersistenceDataAdapterTest method shouldProvideCorrectVxlanEncapsulation.

@Test
public void shouldProvideCorrectVxlanEncapsulation() {
    PathId pathId = new PathId("path1");
    Set<PathId> pathIds = Sets.newHashSet(pathId);
    Vxlan vxlan = Vxlan.builder().flowId("flowId").pathId(pathId).vni(8).build();
    when(vxlanRepository.findByPathId(pathId, null)).thenReturn(Collections.singletonList(vxlan));
    adapter = PersistenceDataAdapter.builder().pathIds(pathIds).persistenceManager(persistenceManager).build();
    FlowTransitEncapsulation actual = adapter.getTransitEncapsulation(pathId, null);
    assertEquals(FlowEncapsulationType.VXLAN, actual.getType());
    assertEquals(vxlan.getVni(), actual.getId().intValue());
    adapter.getTransitEncapsulation(pathId, null);
    verify(transitVlanRepository).findByPathId(pathId, null);
    verify(vxlanRepository).findByPathId(pathId, null);
    verifyNoMoreInteractions(transitVlanRepository);
    verifyNoMoreInteractions(vxlanRepository);
}
Also used : PathId(org.openkilda.model.PathId) Vxlan(org.openkilda.model.Vxlan) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) Test(org.junit.Test)

Example 12 with FlowTransitEncapsulation

use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.

the class IngressFlowSegmentInstallFlowModFactory method makeTransformActions.

@Override
protected List<OFAction> makeTransformActions(List<Integer> vlanStack, boolean groupIsPresent) {
    List<OFAction> actions = new ArrayList<>();
    FlowTransitEncapsulation encapsulation = command.getEncapsulation();
    switch(encapsulation.getType()) {
        case TRANSIT_VLAN:
            actions.addAll(makeVlanEncapsulationTransformActions(vlanStack, groupIsPresent));
            break;
        case VXLAN:
            actions.addAll(makeVxLanEncapsulationTransformActions(vlanStack, groupIsPresent));
            break;
        default:
            throw new NotImplementedEncapsulationException(getClass(), encapsulation.getType(), command.getSwitchId(), command.getMetadata().getFlowId());
    }
    return actions;
}
Also used : NotImplementedEncapsulationException(org.openkilda.floodlight.error.NotImplementedEncapsulationException) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation)

Example 13 with FlowTransitEncapsulation

use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.

the class SpeakerFlowSegmentRequestBuilder method makeRequests.

private List<FlowSegmentRequestFactory> makeRequests(CommandContext context, Flow flow, FlowPath path, FlowPath oppositePath, boolean doIngress, boolean doTransit, boolean doEgress, SpeakerRequestBuildContext speakerRequestBuildContext, MirrorContext mirrorContext) {
    // TODO: this swap is weird, need to clean this up and not to rely on luck.
    if (path == null) {
        path = oppositePath;
        oppositePath = null;
        speakerRequestBuildContext = SpeakerRequestBuildContext.builder().forward(speakerRequestBuildContext.getReverse()).reverse(speakerRequestBuildContext.getForward()).build();
    }
    if (path == null) {
        throw new IllegalArgumentException("At least one flow path must be not null");
    }
    boolean isDeleteOperation = speakerRequestBuildContext.isDeleteOperation();
    FlowTransitEncapsulation encapsulation = null;
    if (!flow.isOneSwitchFlow()) {
        try {
            encapsulation = getEncapsulation(flow.getEncapsulationType(), path.getPathId(), oppositePath != null ? oppositePath.getPathId() : null);
        } catch (IllegalStateException e) {
            if (!isDeleteOperation) {
                throw e;
            }
            encapsulation = DELETE_ENCAPSULATION_STUB;
        }
    }
    List<FlowSegmentRequestFactory> requests = new ArrayList<>(makePathRequests(flow, path, context, encapsulation, doIngress, doTransit, doEgress, createRulesContext(speakerRequestBuildContext.getForward()), mirrorContext));
    if (oppositePath != null) {
        if (!flow.isOneSwitchFlow()) {
            try {
                encapsulation = getEncapsulation(flow.getEncapsulationType(), oppositePath.getPathId(), path.getPathId());
            } catch (IllegalStateException e) {
                if (!isDeleteOperation) {
                    throw e;
                }
                encapsulation = DELETE_ENCAPSULATION_STUB;
            }
        }
        requests.addAll(makePathRequests(flow, oppositePath, context, encapsulation, doIngress, doTransit, doEgress, createRulesContext(speakerRequestBuildContext.getReverse()), mirrorContext));
    }
    return requests;
}
Also used : IngressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory) IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) EgressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory) EgressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory) TransitFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory) FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) ArrayList(java.util.ArrayList) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation)

Example 14 with FlowTransitEncapsulation

use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.

the class IngressFlowSegmentInstallFlowModFactory method makeServer42IngressFlowTransformActions.

@Override
protected List<OFAction> makeServer42IngressFlowTransformActions(List<Integer> vlanStack) {
    List<OFAction> actions = new ArrayList<>();
    FlowTransitEncapsulation encapsulation = command.getEncapsulation();
    switch(encapsulation.getType()) {
        case TRANSIT_VLAN:
            MacAddress ethSrc = MacAddress.of(sw.getId());
            MacAddress ethDst = MacAddress.of(command.getEgressSwitchId().toLong());
            actions.add(of.actions().setField(of.oxms().ethSrc(ethSrc)));
            actions.add(of.actions().setField(of.oxms().ethDst(ethDst)));
            if (!getCommand().getMetadata().isMultiTable()) {
                actions.add(of.actions().setField(of.oxms().udpSrc(TransportPort.of(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT))));
                actions.add(of.actions().setField(of.oxms().udpDst(TransportPort.of(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT))));
                if (switchFeatures.contains(NOVIFLOW_COPY_FIELD)) {
                    actions.add(buildServer42CopyFirstTimestamp(of));
                }
            }
            actions.addAll(makeVlanEncapsulationTransformActions(vlanStack, false));
            break;
        case VXLAN:
            if (!getCommand().getMetadata().isMultiTable() && switchFeatures.contains(NOVIFLOW_COPY_FIELD)) {
                actions.add(buildServer42CopyFirstTimestamp(of));
            }
            actions.addAll(OfAdapter.INSTANCE.makeVlanReplaceActions(of, vlanStack, Collections.emptyList()));
            actions.add(pushVxlanAction(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT));
            break;
        default:
            throw new NotImplementedEncapsulationException(getClass(), encapsulation.getType(), command.getSwitchId(), command.getMetadata().getFlowId());
    }
    return actions;
}
Also used : NotImplementedEncapsulationException(org.openkilda.floodlight.error.NotImplementedEncapsulationException) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) MacAddress(org.projectfloodlight.openflow.types.MacAddress)

Example 15 with FlowTransitEncapsulation

use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.

the class PingTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    Ping origin = new Ping(new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
    serializer.serialize(origin);
    Ping decoded = (Ping) serializer.deserialize();
    Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Also used : FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) Test(org.junit.Test)

Aggregations

FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)21 SwitchId (org.openkilda.model.SwitchId)12 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 Flow (org.openkilda.model.Flow)7 YFlow (org.openkilda.model.YFlow)6 InfoMessage (org.openkilda.messaging.info.InfoMessage)5 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)5 Ping (org.openkilda.messaging.model.Ping)5 PathId (org.openkilda.model.PathId)5 Switch (org.openkilda.model.Switch)5 Ethernet (net.floodlightcontroller.packet.Ethernet)3 IPacket (net.floodlightcontroller.packet.IPacket)3 FlowEndpoint (org.openkilda.model.FlowEndpoint)3 PathSegment (org.openkilda.model.PathSegment)3 HashSet (java.util.HashSet)2 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)2 FlowTransitData (org.openkilda.floodlight.model.FlowTransitData)2 InputService (org.openkilda.floodlight.service.of.InputService)2 MessageContext (org.openkilda.messaging.MessageContext)2