use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class IngressFlowModFactory method makeDoubleVlanFlowLoopMessage.
/**
* Make ingress flow loop rule to match all flow traffic by port and two vlans and route it back to port from
* where it came and restore vlan stack.
*/
public OFFlowMod makeDoubleVlanFlowLoopMessage() {
FlowEndpoint endpoint = command.getEndpoint();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(switchFeatures);
return flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.INGRESS_TABLE_ID), 10).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(endpoint.getInnerVlanId())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build()).setCookie(U64.of(command.getCookie().getValue())).setInstructions(makeIngressFlowLoopInstructions(endpoint)).build();
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class IngressFlowModFactory method makeDoubleVlanServer42IngressFlowMessage.
/**
* Make rule to match server 42 packets by inner VLAN tag and forward in in ISL.
*/
public OFFlowMod makeDoubleVlanServer42IngressFlowMessage() {
FlowEndpoint endpoint = command.getEndpoint();
RoutingMetadata metadata = buildServer42IngressMetadata();
OFFlowMod.Builder builder = flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.INGRESS_TABLE_ID), SERVER_42_INGRESS_DOUBLE_VLAN_FLOW_PRIORITY_OFFSET).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(getCommand().getRulesContext().getServer42Port())).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(endpoint.getInnerVlanId())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build());
return makeServer42IngressFlowMessage(builder, FlowEndpoint.makeVlanStack(endpoint.getInnerVlanId()));
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class IngressFlowModFactory method makeServer42OuterVlanMatchSharedMessage.
/**
* Make rule to match traffic by server 42 port and vlan, write vlan into metadata and pass packet into next table.
* This rule is shared across all flow with equal vlan(outer).
*/
public OFFlowMod makeServer42OuterVlanMatchSharedMessage() {
FlowEndpoint endpoint = command.getEndpoint();
FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.SERVER42_QINQ_OUTER_VLAN).portNumber(getCommand().getRulesContext().getServer42Port()).vlanId(endpoint.getOuterVlanId()).build();
return flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.PRE_INGRESS_TABLE_ID)).setCookie(U64.of(cookie.getValue())).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(getCommand().getRulesContext().getServer42Port())).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(endpoint.getOuterVlanId())).build()).setInstructions(makeOuterVlanMatchInstructions()).build();
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class OneSwitchFlowInstallFlowModFactory method makeOutputAction.
@Override
protected OFAction makeOutputAction() {
FlowEndpoint endpoint = command.getEndpoint();
FlowEndpoint egressEndpoint = command.getEgressEndpoint();
if (endpoint.getPortNumber().equals(egressEndpoint.getPortNumber())) {
return super.makeOutputAction(OFPort.IN_PORT);
}
return super.makeOutputAction(OFPort.of(egressEndpoint.getPortNumber()));
}
use of org.openkilda.model.FlowEndpoint in project open-kilda by telstra.
the class SimpleSwitchRuleConverter method buildIngressSimpleSwitchRules.
/**
* Build ingress rules ({@link SimpleSwitchRule}) for provided {@link FlowPath}.
*/
public List<SimpleSwitchRule> buildIngressSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) {
boolean forward = flow.isForward(flowPath);
int inPort = forward ? flow.getSrcPort() : flow.getDestPort();
int outPort = forward ? flow.getDestPort() : flow.getSrcPort();
SimpleSwitchRule rule = SimpleSwitchRule.builder().switchId(flowPath.getSrcSwitchId()).cookie(flowPath.getCookie().getValue()).inPort(inPort).meterId(flowPath.getMeterId() != null ? flowPath.getMeterId().getValue() : null).meterRate(flow.getBandwidth()).meterBurstSize(Meter.calculateBurstSize(flow.getBandwidth(), flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient, flowPath.getSrcSwitch().getDescription())).meterFlags(Meter.getMeterKbpsFlags()).ingressRule(true).build();
FlowSideAdapter ingress = FlowSideAdapter.makeIngressAdapter(flow, flowPath);
FlowEndpoint endpoint = ingress.getEndpoint();
if (flowPath.isSrcWithMultiTable()) {
// in multi-table mode actual ingress rule will match port+inner_vlan+metadata(outer_vlan)
if (FlowEndpoint.isVlanIdSet(endpoint.getInnerVlanId())) {
rule.setInVlan(endpoint.getInnerVlanId());
}
} else {
rule.setInVlan(endpoint.getOuterVlanId());
}
int transitVlan = 0;
int vni = 0;
if (flow.isOneSwitchFlow()) {
FlowEndpoint egressEndpoint = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint();
rule.setOutPort(outPort);
rule.setOutVlan(calcVlanSetSequence(ingress, flowPath, egressEndpoint.getVlanStack()));
} else {
PathSegment ingressSegment = flowPath.getSegments().stream().filter(segment -> segment.getSrcSwitchId().equals(flowPath.getSrcSwitchId())).findAny().orElseThrow(() -> new IllegalStateException(String.format("PathSegment was not found for ingress flow rule, flowId: %s", flow.getFlowId())));
outPort = ingressSegment.getSrcPort();
rule.setOutPort(outPort);
if (flow.getEncapsulationType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
transitVlan = encapsulationId.getEncapsulationId();
rule.setOutVlan(calcVlanSetSequence(ingress, flowPath, Collections.singletonList(transitVlan)));
} else if (flow.getEncapsulationType().equals(FlowEncapsulationType.VXLAN)) {
vni = encapsulationId.getEncapsulationId();
rule.setTunnelId(vni);
}
}
List<SimpleSwitchRule> rules = Lists.newArrayList(rule);
if (ingress.isLooped() && !flowPath.isProtected()) {
rules.add(buildIngressLoopSimpleSwitchRule(rule, flowPath, ingress));
}
Optional<FlowMirrorPoints> foundFlowMirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(mirrorPoints -> mirrorPoints.getMirrorSwitchId().equals(flowPath.getSrcSwitchId())).findFirst();
if (foundFlowMirrorPoints.isPresent()) {
FlowMirrorPoints flowMirrorPoints = foundFlowMirrorPoints.get();
SimpleSwitchRule mirrorRule = rule.toBuilder().outPort(0).tunnelId(0).cookie(flowPath.getCookie().toBuilder().mirror(true).build().getValue()).groupId(flowMirrorPoints.getMirrorGroupId().intValue()).groupBuckets(mapGroupBuckets(flowMirrorPoints.getMirrorPaths(), outPort, transitVlan, vni)).build();
if (!flow.isOneSwitchFlow()) {
mirrorRule.setOutVlan(Collections.emptyList());
}
rules.add(mirrorRule);
}
return rules;
}
Aggregations