Skip to content

Commit

Permalink
Merge branch 'release-1.31.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitacherevko committed Aug 14, 2019
2 parents 07ee482 + 67ed313 commit 92bc71f
Show file tree
Hide file tree
Showing 33 changed files with 910 additions and 99 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## v1.31.0 (14/08/2019)

### Bug Fixes:
- [#2662](https://github.com/telstra/open-kilda/pull/2662) Fixed incorrect converting meter rate/burstsize from packets to kilobits [**floodlight**]
- [#2685](https://github.com/telstra/open-kilda/pull/2685) Fix default flow creation in v2 +fixed resetting of FSM in case of retry [**northbound**]

### Improvements:
- [#2672](https://github.com/telstra/open-kilda/pull/2672) Misc fixes in tests [**tests**]

### Other changes:
- [#2637](https://github.com/telstra/open-kilda/pull/2637) Enable Vxlan support for v2 api [**floodlight**]
- [#2683](https://github.com/telstra/open-kilda/pull/2683) Fix Kilda-FlowOperations-Filtered-Table Kibana search

For the complete list of changes, check out [the commit log](https://github.com/telstra/open-kilda/compare/v1.30.1...v1.31.0).

### Affected Components:
flow-hs, nb, fl

---

## v1.30.1 (07/08/2019)

### Bug Fixes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ public InstallEgressRule(@JsonProperty("message_context") MessageContext message
@JsonProperty("transit_encapsulation_type")
FlowEncapsulationType transitEncapsulationType,
@JsonProperty("output_vlan_type") OutputVlanType outputVlanType,
@JsonProperty("output_vlan_id") Integer outputVlanId) {
@JsonProperty("output_vlan_id") Integer outputVlanId,
@JsonProperty("ingress_switch_id") SwitchId ingressSwitchId) {
super(messageContext, commandId, flowId, cookie, switchId, inputPort, outputPort,
transitEncapsulationId, transitEncapsulationType);
transitEncapsulationId, transitEncapsulationType, ingressSwitchId);
this.outputVlanType = outputVlanType;
this.outputVlanId = outputVlanId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public class InstallTransitRule extends InstallFlowRule {
@JsonProperty("transit_encapsulation_type")
protected FlowEncapsulationType transitEncapsulationType;


@JsonProperty("ingress_switch_id")
protected SwitchId ingressSwitchId;

@JsonCreator
public InstallTransitRule(@JsonProperty("message_context") MessageContext messageContext,
@JsonProperty("command_id") UUID commandId,
Expand All @@ -57,9 +61,12 @@ public InstallTransitRule(@JsonProperty("message_context") MessageContext messag
@JsonProperty("output_port") Integer outputPort,
@JsonProperty("transit_encapsulation_id") Integer transitEncapsulationId,
@JsonProperty("transit_encapsulation_type")
FlowEncapsulationType transitEncapsulationType) {
FlowEncapsulationType transitEncapsulationType,
@JsonProperty("ingress_switch_id") SwitchId ingressSwitchId
) {
super(messageContext, commandId, flowId, cookie, switchId, inputPort, outputPort);
this.transitEncapsulationId = transitEncapsulationId;
this.transitEncapsulationType = transitEncapsulationType;
this.ingressSwitchId = ingressSwitchId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package org.openkilda.floodlight.command.flow;

import static org.openkilda.model.FlowEncapsulationType.TRANSIT_VLAN;
import static org.openkilda.model.FlowEncapsulationType.VXLAN;
import static org.projectfloodlight.openflow.protocol.OFVersion.OF_12;

import org.openkilda.floodlight.FloodlightResponse;
Expand All @@ -26,6 +28,7 @@
import org.openkilda.floodlight.utils.CompletableFutureAdapter;
import org.openkilda.messaging.MessageContext;
import org.openkilda.model.Cookie;
import org.openkilda.model.FlowEncapsulationType;
import org.openkilda.model.SwitchId;

import lombok.Getter;
Expand All @@ -39,6 +42,7 @@
import org.projectfloodlight.openflow.protocol.errormsg.OFFlowModFailedErrorMsg;
import org.projectfloodlight.openflow.protocol.match.Match;
import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.projectfloodlight.openflow.types.MacAddress;
import org.projectfloodlight.openflow.types.OFGroup;
import org.projectfloodlight.openflow.types.OFPort;
import org.projectfloodlight.openflow.types.OFVlanVidMatch;
Expand Down Expand Up @@ -92,11 +96,22 @@ protected FloodlightResponse buildError(Throwable error) {
.build();
}

final Match matchFlow(Integer inputPort, Integer inputVlan, OFFactory ofFactory) {
final Match matchFlow(Integer inputPort, Integer tunnelId, FlowEncapsulationType encapsulationType,
MacAddress ethSrc, OFFactory ofFactory) {
Match.Builder mb = ofFactory.buildMatch();
mb.setExact(MatchField.IN_PORT, OFPort.of(inputPort));
if (inputVlan > 0) {
matchVlan(ofFactory, mb, inputVlan);
if (tunnelId > 0) {
switch (encapsulationType) {
case TRANSIT_VLAN:
matchVlan(ofFactory, mb, tunnelId);
break;
case VXLAN:
matchVxlan(ofFactory, mb, tunnelId, ethSrc);
break;
default:
throw new UnsupportedOperationException(
String.format("Unknown encapsulation type: %s", encapsulationType));
}
}

return mb.build();
Expand All @@ -111,6 +126,18 @@ final void matchVlan(OFFactory ofFactory, Match.Builder matchBuilder, int vlanId
}
}

final void matchVxlan(OFFactory ofFactory, Match.Builder matchBuilder, long tunnelId,
MacAddress ethSrc) {
if (ethSrc != null) {
matchBuilder.setExact(MatchField.ETH_SRC, ethSrc);
}
if (OF_12.compareTo(ofFactory.getVersion()) >= 0) {
throw new UnsupportedOperationException("Switch doesn't support tunnel_id match");
} else {
matchBuilder.setExact(MatchField.TUNNEL_ID, U64.of(tunnelId));
}
}

final CompletableFuture<List<OFFlowStatsEntry>> dumpFlowTable(IOFSwitch sw) {
OFFactory ofFactory = sw.getOFFactory();
OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package org.openkilda.floodlight.command.flow;

import static org.openkilda.floodlight.switchmanager.SwitchManager.convertDpIdToMac;

import org.openkilda.floodlight.FloodlightResponse;
import org.openkilda.floodlight.command.MessageWriter;
import org.openkilda.floodlight.command.OfCommand;
Expand All @@ -39,6 +41,7 @@
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.match.Match;
import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.MacAddress;
import org.projectfloodlight.openflow.types.OFPort;
import org.projectfloodlight.openflow.types.U64;

Expand Down Expand Up @@ -134,8 +137,12 @@ private OFFlowDelete buildFlowDeleteByCriteria(OFFactory ofFactory, DeleteRulesC

if (criteria.getInPort() != null) {
// Match either In Port or both Port & Vlan criteria.
MacAddress srcMac = convertDpIdToMac(DatapathId.of(criteria.getIngressSwitchId().toLong()));

Match match = matchFlow(criteria.getInPort(),
Optional.ofNullable(criteria.getEncapsulationId()).orElse(0), ofFactory);

Optional.ofNullable(criteria.getEncapsulationId()).orElse(0),
criteria.getEncapsulationType(), srcMac, ofFactory);
builder.setMatch(match);
} else if (criteria.getEncapsulationId() != null) {
// Match In Vlan criterion if In Port is not specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

package org.openkilda.floodlight.command.flow;

import static org.openkilda.floodlight.switchmanager.SwitchManager.convertDpIdToMac;
import static org.openkilda.messaging.Utils.ETH_TYPE;

import org.openkilda.floodlight.command.MessageWriter;
import org.openkilda.messaging.MessageContext;
import org.openkilda.model.Cookie;
Expand All @@ -30,6 +33,8 @@
import org.projectfloodlight.openflow.protocol.OFFlowMod;
import org.projectfloodlight.openflow.protocol.action.OFAction;
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.MacAddress;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -52,9 +57,10 @@ public InstallEgressRuleCommand(@JsonProperty("command_id") UUID commandId,
@JsonProperty("output_vlan_id") Integer outputVlanId,
@JsonProperty("transit_encapsulation_id") Integer transitEncapsulationId,
@JsonProperty("transit_encapsulation_type")
FlowEncapsulationType transitEncapsulationType) {
FlowEncapsulationType transitEncapsulationType,
@JsonProperty("ingress_switch_id") SwitchId ingressSwitchId) {
super(commandId, flowId, messageContext, cookie, switchId, inputPort, outputPort,
transitEncapsulationId, transitEncapsulationType);
transitEncapsulationId, transitEncapsulationType, ingressSwitchId);
this.outputVlanType = outputVlanType;
this.outputVlanId = outputVlanId;
}
Expand All @@ -65,7 +71,7 @@ public List<MessageWriter> getCommands(IOFSwitch sw, FloodlightModuleContext mod
OFFactory ofFactory = sw.getOFFactory();

// output action based on encap scheme
actionList.add(getOutputAction(ofFactory));
actionList.addAll(getOutputAction(ofFactory));

// transmit packet from outgoing port
actionList.add(setOutputPort(ofFactory));
Expand All @@ -74,15 +80,45 @@ public List<MessageWriter> getCommands(IOFSwitch sw, FloodlightModuleContext mod
OFInstructionApplyActions actions = applyActions(ofFactory, actionList);

// build FLOW_MOD command, no meter
MacAddress srcMac = convertDpIdToMac(DatapathId.of(ingressSwitchId.toLong()));

OFFlowMod flowMod = prepareFlowModBuilder(ofFactory)
.setMatch(matchFlow(inputPort, transitEncapsulationId, ofFactory))
.setMatch(matchFlow(inputPort, transitEncapsulationId, transitEncapsulationType, srcMac, ofFactory))
.setInstructions(ImmutableList.of(actions))
.build();

return Collections.singletonList(new MessageWriter(flowMod));
}

private OFAction getOutputAction(OFFactory ofFactory) {
private List<OFAction> getOutputAction(OFFactory ofFactory) {
switch (transitEncapsulationType) {
case TRANSIT_VLAN:
return Collections.singletonList(getOutputActionVlan(ofFactory));
case VXLAN:
return getOutputActionsForVxlan(ofFactory);
default:
throw new UnsupportedOperationException(
String.format("Unknown encapsulation type: %s", transitEncapsulationType));

}

}

private List<OFAction> getOutputActionsForVxlan(OFFactory ofFactory) {
List<OFAction> actionList = new ArrayList<>(2);
actionList.add(ofFactory.actions().noviflowPopVxlanTunnel());
if (outputVlanType == OutputVlanType.PUSH) {
actionList.add(actionPushVlan(ofFactory, ETH_TYPE));
actionList.add(actionReplaceVlan(ofFactory, outputVlanId));
} else if (outputVlanType == OutputVlanType.REPLACE) {
actionList.add(actionReplaceVlan(ofFactory, outputVlanId));
} else if (outputVlanType == OutputVlanType.POP) {
actionList.add(actionPopVlan(ofFactory));
}
return actionList;
}

private OFAction getOutputActionVlan(OFFactory ofFactory) {
OFAction action;

switch (outputVlanType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

package org.openkilda.floodlight.command.flow;

import static org.openkilda.floodlight.switchmanager.SwitchManager.INTERNAL_ETH_DEST_OFFSET;
import static org.openkilda.floodlight.switchmanager.SwitchManager.MAC_ADDRESS_SIZE_IN_BITS;
import static org.openkilda.floodlight.switchmanager.SwitchManager.STUB_VXLAN_ETH_DST_MAC;
import static org.openkilda.floodlight.switchmanager.SwitchManager.STUB_VXLAN_IPV4_DST;
import static org.openkilda.floodlight.switchmanager.SwitchManager.STUB_VXLAN_IPV4_SRC;
import static org.openkilda.floodlight.switchmanager.SwitchManager.STUB_VXLAN_UDP_SRC;
import static org.openkilda.floodlight.switchmanager.SwitchManager.convertDpIdToMac;
import static org.openkilda.messaging.Utils.ETH_TYPE;
import static org.projectfloodlight.openflow.protocol.OFVersion.OF_15;

Expand Down Expand Up @@ -49,7 +56,9 @@
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
import org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter;
import org.projectfloodlight.openflow.protocol.match.Match;
import org.projectfloodlight.openflow.types.EthType;
import org.projectfloodlight.openflow.protocol.oxm.OFOxms;
import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.MacAddress;
import org.projectfloodlight.openflow.types.OFPort;

import java.util.ArrayList;
Expand Down Expand Up @@ -82,7 +91,7 @@ public InstallIngressRuleCommand(@JsonProperty("command_id") UUID commandId,
@JsonProperty("transit_encapsulation_type")
FlowEncapsulationType transitEncapsulationType) {
super(commandId, flowId, messageContext, cookie, switchId, inputPort, outputPort,
transitEncapsulationId, transitEncapsulationType);
transitEncapsulationId, transitEncapsulationType, switchId);
this.bandwidth = bandwidth;
this.inputVlanId = inputVlanId;
this.outputVlanType = outputVlanType;
Expand All @@ -103,7 +112,15 @@ public List<MessageWriter> getCommands(IOFSwitch sw, FloodlightModuleContext mod
}

List<OFAction> getOutputAction(OFFactory ofFactory) {
return inputVlanTypeToOfActionList(ofFactory);
switch (transitEncapsulationType) {
case TRANSIT_VLAN:
return inputVlanTypeToOfActionList(ofFactory);
case VXLAN:
return transitVxlanToActionList(ofFactory);
default:
throw new UnsupportedOperationException(
String.format("Unknown encapsulation type: %s", transitEncapsulationType));
}
}

OFPort getOutputPort() {
Expand All @@ -128,7 +145,7 @@ final OFFlowMod getInstallRuleCommand(IOFSwitch sw, FeatureDetectorService featu
OFInstructionApplyActions actions = applyActions(ofFactory, actionList);

// build match by input port and input vlan id
Match match = matchFlow(inputPort, inputVlanId, ofFactory);
Match match = matchFlow(inputPort, inputVlanId, FlowEncapsulationType.TRANSIT_VLAN, null, ofFactory);

// build FLOW_MOD command with meter
OFFlowAdd.Builder builder = prepareFlowModBuilder(ofFactory)
Expand All @@ -152,9 +169,36 @@ private List<OFAction> inputVlanTypeToOfActionList(OFFactory ofFactory) {
return actionList;
}

final OFAction actionPushVlan(OFFactory ofFactory, int etherType) {
private List<OFAction> transitVxlanToActionList(OFFactory ofFactory) {
List<OFAction> actionList = new ArrayList<>(3);
MacAddress srcMac = convertDpIdToMac(DatapathId.of(switchId.toLong()));
actionList.add(actionPushVxlan(ofFactory, transitEncapsulationId, srcMac));
actionList.add(actionVxlanEthDstCopyField(ofFactory));
return actionList;
}

private OFAction actionPushVxlan(OFFactory ofFactory, long tunnelId, MacAddress ethSrc) {
OFActions actions = ofFactory.actions();
return actions.buildPushVlan().setEthertype(EthType.of(etherType)).build();
return actions.buildNoviflowPushVxlanTunnel()
.setVni(tunnelId)
.setEthSrc(ethSrc)
.setEthDst(STUB_VXLAN_ETH_DST_MAC)
.setUdpSrc(STUB_VXLAN_UDP_SRC)
.setIpv4Src(STUB_VXLAN_IPV4_SRC)
.setIpv4Dst(STUB_VXLAN_IPV4_DST)
.setFlags((short) 0x01)
.build();
}

private OFAction actionVxlanEthDstCopyField(OFFactory ofFactory) {
OFOxms oxms = ofFactory.oxms();
return ofFactory.actions().buildNoviflowCopyField()
.setNBits(MAC_ADDRESS_SIZE_IN_BITS)
.setSrcOffset(INTERNAL_ETH_DEST_OFFSET)
.setDstOffset(0)
.setOxmSrcHeader(oxms.buildNoviflowPacketOffset().getTypeLen())
.setOxmDstHeader(oxms.buildNoviflowPacketOffset().getTypeLen())
.build();
}

OFInstructionMeter getMeterInstructions(Set<Feature> supportedFeatures, OFFactory ofFactory,
Expand Down
Loading

0 comments on commit 92bc71f

Please sign in to comment.