use of org.openkilda.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.
the class LldpPostIngressVxlanFlowGenerator method getLldpFlowMod.
@Override
OFFlowMod getLldpFlowMod(IOFSwitch sw, OFInstructionMeter meter, List<OFAction> actionList) {
OFFactory ofFactory = sw.getOFFactory();
Set<SwitchFeature> features = featureDetectorService.detectSwitch(sw);
if (!features.contains(NOVIFLOW_PUSH_POP_VXLAN) && !features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
return null;
}
RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().lldpFlag(true), sw);
Match.Builder matchBuilder = ofFactory.buildMatch().setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).setExact(MatchField.IP_PROTO, IpProtocol.UDP).setExact(MatchField.UDP_SRC, TransportPort.of(STUB_VXLAN_UDP_SRC)).setExact(MatchField.UDP_DST, TransportPort.of(VXLAN_UDP_DST));
if (features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
matchBuilder.setExact(MatchField.ETH_TYPE, EthType.IPv4);
}
Match match = matchBuilder.build();
if (features.contains(NOVIFLOW_PUSH_POP_VXLAN)) {
actionList.add(ofFactory.actions().noviflowPopVxlanTunnel());
} else {
actionList.add(ofFactory.actions().kildaPopVxlanField());
}
actionList.add(actionSendToController(sw.getOFFactory()));
OFInstructionApplyActions actions = ofFactory.instructions().applyActions(actionList).createBuilder().build();
return prepareFlowModBuilder(ofFactory, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_POST_INGRESS_VXLAN_PRIORITY, POST_INGRESS_TABLE_ID).setMatch(match).setInstructions(meter != null ? ImmutableList.of(meter, actions) : ImmutableList.of(actions)).build();
}
use of org.openkilda.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.
the class IngressFlowModFactory method makeServer42IngressFlowMatch.
private Match makeServer42IngressFlowMatch(Match.Builder builder, int server42UpdPortOffset) {
builder.setExact(MatchField.IN_PORT, OFPort.of(command.getRulesContext().getServer42Port()));
if (getCommand().getMetadata().isMultiTable()) {
RoutingMetadata metadata = buildServer42IngressMetadata();
builder.setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build();
} else {
MacAddress macAddress = MacAddress.of(getCommand().getRulesContext().getServer42MacAddress().toString());
int udpSrcPort = server42UpdPortOffset + command.getEndpoint().getPortNumber();
builder.setExact(MatchField.ETH_SRC, macAddress).setExact(MatchField.ETH_TYPE, EthType.IPv4).setExact(MatchField.IP_PROTO, IpProtocol.UDP).setExact(MatchField.UDP_SRC, TransportPort.of(udpSrcPort));
}
return builder.build();
}
use of org.openkilda.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.
the class IngressFlowModFactory method makeSingleVlanFlowLoopMessage.
/**
* Make ingress flow loop rule to match all flow traffic by port&vlan and route it back to port from
* where it came.
*/
public OFFlowMod makeSingleVlanFlowLoopMessage() {
FlowEndpoint endpoint = command.getEndpoint();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(switchFeatures);
return flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.INGRESS_TABLE_ID)).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).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.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.
the class IngressFlowModFactory method makeSingleVlanForwardMessage.
/**
* Make rule to forward traffic matched by outer VLAN tag and forward in in ISL (or out port in case one-switch
* flow).
*/
public OFFlowMod makeSingleVlanForwardMessage(EffectiveIds effectiveIds) {
FlowEndpoint endpoint = command.getEndpoint();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(switchFeatures);
OFFlowMod.Builder builder = flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.INGRESS_TABLE_ID)).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build());
// list as current vlanStack
return makeForwardMessage(builder, effectiveIds, Collections.emptyList());
}
use of org.openkilda.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.
the class IngressFlowSegmentInstallFlowModFactoryTest method testMakeSingleVlanForwardMessageVlanEncoded.
private void testMakeSingleVlanForwardMessageVlanEncoded(MeterConfig meter) {
IngressFlowSegmentInstallCommand command = makeCommand(endpointSingleVlan, meter, encapsulationVlan);
FlowEndpoint endpoint = command.getEndpoint();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(Collections.emptySet());
List<OFAction> vlanTransformation = OfAdapter.INSTANCE.makeVlanReplaceActions(of, Collections.emptyList(), Collections.singletonList(command.getEncapsulation().getId()));
OFFlowAdd expected = makeVlanForwardingMessage(command, 0, of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build(), getTargetIngressTableId(), vlanTransformation);
IngressFlowModFactory factory = makeFactory(command);
verifyOfMessageEquals(expected, factory.makeSingleVlanForwardMessage(new EffectiveIds(getEffectiveMeterId(command.getMeterConfig()), null)));
}
Aggregations