use of org.openkilda.model.SwitchFeature in project open-kilda by telstra.
the class Server42FlowRttOutputVxlanFlowGenerator method generateFlow.
@Override
public SwitchFlowTuple generateFlow(IOFSwitch sw) {
Set<SwitchFeature> features = featureDetectorService.detectSwitch(sw);
if (!features.contains(NOVIFLOW_PUSH_POP_VXLAN) && !features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
return SwitchFlowTuple.getEmpty();
}
OFFactory ofFactory = sw.getOFFactory();
List<OFAction> actions = new ArrayList<>();
actions.add(buildPopVxlanAction(ofFactory, features));
if (server42Vlan > 0) {
actions.add(actionPushVlan(ofFactory, EthType.VLAN_FRAME.getValue()));
actions.add(actionReplaceVlan(ofFactory, server42Vlan));
}
actions.add(actionSetSrcMac(ofFactory, convertDpIdToMac(sw.getId())));
actions.add(actionSetDstMac(ofFactory, org.projectfloodlight.openflow.types.MacAddress.of(server42MacAddress.getAddress())));
actions.add(actionSetUdpSrcAction(ofFactory, TransportPort.of(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT)));
if (features.contains(NOVIFLOW_COPY_FIELD)) {
// NOTE: We must call copy field action after all set field actions. All set actions called after copy field
// actions will be ignored. It's Noviflow bug.
actions.add(buildCopyTimestamp(ofFactory));
}
actions.add(actionSetOutputPort(ofFactory, OFPort.of(server42Port)));
OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE, SERVER_42_FLOW_RTT_OUTPUT_VXLAN_PRIORITY, INPUT_TABLE_ID).setMatch(buildMatch(sw.getId(), ofFactory)).setInstructions(ImmutableList.of(buildInstructionApplyActions(ofFactory, actions))).build();
return SwitchFlowTuple.builder().sw(sw).flow(flowMod).build();
}
use of org.openkilda.model.SwitchFeature in project open-kilda by telstra.
the class Server42FlowRttVxlanTurningFlowGenerator method generateFlow.
@Override
public SwitchFlowTuple generateFlow(IOFSwitch sw) {
Set<SwitchFeature> switchFeatures = featureDetectorService.detectSwitch(sw);
if (!switchFeatures.contains(NOVIFLOW_SWAP_ETH_SRC_ETH_DST) && !switchFeatures.contains(KILDA_OVS_SWAP_FIELD)) {
return SwitchFlowTuple.getEmpty();
}
OFFactory ofFactory = sw.getOFFactory();
Match match = buildMatch(sw.getId(), ofFactory);
List<OFAction> actions = ImmutableList.of(actionSetUdpSrcAction(ofFactory, TransportPort.of(SERVER_42_FLOW_RTT_REVERSE_UDP_VXLAN_PORT)), buildSwapAction(switchFeatures, ofFactory), actionSetOutputPort(ofFactory, OFPort.IN_PORT));
OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE, SERVER_42_FLOW_RTT_VXLAN_TURNING_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(buildInstructionApplyActions(ofFactory, actions))).build();
return SwitchFlowTuple.builder().sw(sw).flow(flowMod).build();
}
use of org.openkilda.model.SwitchFeature in project open-kilda by telstra.
the class ArpPostIngressVxlanFlowGenerator method getArpFlowMod.
@Override
OFFlowMod getArpFlowMod(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().arpFlag(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(ARP_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, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_VXLAN_PRIORITY, POST_INGRESS_TABLE_ID).setMatch(match).setInstructions(meter != null ? ImmutableList.of(meter, actions) : ImmutableList.of(actions)).build();
}
Aggregations