mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-23 05:11:04 +02:00
ONOS-1856: Supports ports (~65535) for the tunnel policy
- Add some missing Java docs Change-Id: I0ef750efdb9b667a5b5edbd91cf7b4cc54afd38c
This commit is contained in:
parent
1b02f8245d
commit
f9d0bf1cf7
@ -249,6 +249,12 @@ public class SegmentRoutingManager implements SegmentRoutingService {
|
|||||||
return policyHandler.getPolicies();
|
return policyHandler.getPolicies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tunnel object with the tunnel ID.
|
||||||
|
*
|
||||||
|
* @param tunnelId Tunnel ID
|
||||||
|
* @return Tunnel reference
|
||||||
|
*/
|
||||||
public Tunnel getTunnel(String tunnelId) {
|
public Tunnel getTunnel(String tunnelId) {
|
||||||
return tunnelHandler.getTunnel(tunnelId);
|
return tunnelHandler.getTunnel(tunnelId);
|
||||||
}
|
}
|
||||||
@ -269,10 +275,12 @@ public class SegmentRoutingManager implements SegmentRoutingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns the next objective ID for the NeighborSet given. If the nextObjectiveID does not exist,
|
||||||
|
* a new one is created and returned.
|
||||||
*
|
*
|
||||||
* @param deviceId
|
* @param deviceId Device ID
|
||||||
* @param ns
|
* @param ns NegighborSet
|
||||||
* @return
|
* @return next objective ID
|
||||||
*/
|
*/
|
||||||
public int getNextObjectiveId(DeviceId deviceId, NeighborSet ns) {
|
public int getNextObjectiveId(DeviceId deviceId, NeighborSet ns) {
|
||||||
|
|
||||||
@ -287,10 +295,11 @@ public class SegmentRoutingManager implements SegmentRoutingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Removes the next objective ID.
|
||||||
*
|
*
|
||||||
* @param deviceId
|
* @param deviceId Device ID
|
||||||
* @param objectiveId
|
* @param objectiveId next objective ID to remove
|
||||||
* @return
|
* @return true, if succeeds, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean removeNextObjective(DeviceId deviceId, int objectiveId) {
|
public boolean removeNextObjective(DeviceId deviceId, int objectiveId) {
|
||||||
return groupHandlerMap.get(deviceId).removeGroup(objectiveId);
|
return groupHandlerMap.get(deviceId).removeGroup(objectiveId);
|
||||||
|
@ -26,6 +26,8 @@ import org.onosproject.net.flow.TrafficSelector;
|
|||||||
import org.onosproject.net.flow.criteria.Criterion;
|
import org.onosproject.net.flow.criteria.Criterion;
|
||||||
import org.onosproject.net.flow.criteria.IPCriterion;
|
import org.onosproject.net.flow.criteria.IPCriterion;
|
||||||
import org.onosproject.net.flow.criteria.IPProtocolCriterion;
|
import org.onosproject.net.flow.criteria.IPProtocolCriterion;
|
||||||
|
import org.onosproject.net.flow.criteria.TcpPortCriterion;
|
||||||
|
import org.onosproject.net.flow.criteria.UdpPortCriterion;
|
||||||
import org.onosproject.segmentrouting.Policy;
|
import org.onosproject.segmentrouting.Policy;
|
||||||
import org.onosproject.segmentrouting.TunnelPolicy;
|
import org.onosproject.segmentrouting.TunnelPolicy;
|
||||||
|
|
||||||
@ -39,6 +41,8 @@ public final class PolicyCodec extends JsonCodec<Policy> {
|
|||||||
private static final String DST_IP = "dst_ip";
|
private static final String DST_IP = "dst_ip";
|
||||||
private static final String SRC_IP = "src_ip";
|
private static final String SRC_IP = "src_ip";
|
||||||
private static final String PROTO_TYPE = "proto_type";
|
private static final String PROTO_TYPE = "proto_type";
|
||||||
|
private static final String SRC_PORT = "src_tp_port";
|
||||||
|
private static final String DST_PORT = "dst_tp_port";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectNode encode(Policy policy, CodecContext context) {
|
public ObjectNode encode(Policy policy, CodecContext context) {
|
||||||
@ -58,6 +62,29 @@ public final class PolicyCodec extends JsonCodec<Policy> {
|
|||||||
Criterion.Type.IPV4_SRC);
|
Criterion.Type.IPV4_SRC);
|
||||||
result.put(SRC_IP, criterion.ip().toString());
|
result.put(SRC_IP, criterion.ip().toString());
|
||||||
}
|
}
|
||||||
|
if (policy.selector().getCriterion(Criterion.Type.IP_PROTO) != null) {
|
||||||
|
IPProtocolCriterion protocolCriterion =
|
||||||
|
(IPProtocolCriterion) policy.selector().getCriterion(Criterion.Type.IP_PROTO);
|
||||||
|
result.put(PROTO_TYPE, protocolCriterion.protocol());
|
||||||
|
}
|
||||||
|
if (policy.selector().getCriterion(Criterion.Type.TCP_SRC) != null) {
|
||||||
|
TcpPortCriterion tcpPortCriterion =
|
||||||
|
(TcpPortCriterion) policy.selector().getCriterion(Criterion.Type.TCP_SRC);
|
||||||
|
result.put(SRC_PORT, tcpPortCriterion.toString());
|
||||||
|
} else if (policy.selector().getCriterion(Criterion.Type.UDP_SRC) != null) {
|
||||||
|
UdpPortCriterion udpPortCriterion =
|
||||||
|
(UdpPortCriterion) policy.selector().getCriterion(Criterion.Type.UDP_SRC);
|
||||||
|
result.put(SRC_PORT, udpPortCriterion.toString());
|
||||||
|
}
|
||||||
|
if (policy.selector().getCriterion(Criterion.Type.TCP_DST) != null) {
|
||||||
|
TcpPortCriterion tcpPortCriterion =
|
||||||
|
(TcpPortCriterion) policy.selector().getCriterion(Criterion.Type.TCP_DST);
|
||||||
|
result.put(DST_PORT, tcpPortCriterion.toString());
|
||||||
|
} else if (policy.selector().getCriterion(Criterion.Type.UDP_DST) != null) {
|
||||||
|
UdpPortCriterion udpPortCriterion =
|
||||||
|
(UdpPortCriterion) policy.selector().getCriterion(Criterion.Type.UDP_DST);
|
||||||
|
result.put(DST_PORT, udpPortCriterion.toString());
|
||||||
|
}
|
||||||
if (policy.selector().getCriterion(Criterion.Type.IP_PROTO) != null) {
|
if (policy.selector().getCriterion(Criterion.Type.IP_PROTO) != null) {
|
||||||
IPProtocolCriterion protocolCriterion =
|
IPProtocolCriterion protocolCriterion =
|
||||||
(IPProtocolCriterion) policy.selector().getCriterion(Criterion.Type.IP_PROTO);
|
(IPProtocolCriterion) policy.selector().getCriterion(Criterion.Type.IP_PROTO);
|
||||||
@ -81,6 +108,8 @@ public final class PolicyCodec extends JsonCodec<Policy> {
|
|||||||
String srcIp = json.path(SRC_IP).asText();
|
String srcIp = json.path(SRC_IP).asText();
|
||||||
String tunnelId = json.path(TUNNEL_ID).asText();
|
String tunnelId = json.path(TUNNEL_ID).asText();
|
||||||
String protoType = json.path(PROTO_TYPE).asText();
|
String protoType = json.path(PROTO_TYPE).asText();
|
||||||
|
short srcPort = json.path(SRC_PORT).shortValue();
|
||||||
|
short dstPort = json.path(DST_PORT).shortValue();
|
||||||
|
|
||||||
if (tunnelId != null) {
|
if (tunnelId != null) {
|
||||||
TrafficSelector.Builder tsb = DefaultTrafficSelector.builder();
|
TrafficSelector.Builder tsb = DefaultTrafficSelector.builder();
|
||||||
@ -94,8 +123,22 @@ public final class PolicyCodec extends JsonCodec<Policy> {
|
|||||||
if (protoType != null && !protoType.isEmpty()) {
|
if (protoType != null && !protoType.isEmpty()) {
|
||||||
Short ipProto = Short.valueOf(IpProtocol.valueOf(protoType).value());
|
Short ipProto = Short.valueOf(IpProtocol.valueOf(protoType).value());
|
||||||
tsb.matchIPProtocol(ipProto.byteValue());
|
tsb.matchIPProtocol(ipProto.byteValue());
|
||||||
|
if (IpProtocol.valueOf(protoType).equals(IpProtocol.TCP)) {
|
||||||
|
if (srcPort != 0) {
|
||||||
|
tsb.matchTcpSrc(srcPort);
|
||||||
|
}
|
||||||
|
if (dstPort != 0) {
|
||||||
|
tsb.matchTcpDst(dstPort);
|
||||||
|
}
|
||||||
|
} else if (IpProtocol.valueOf(protoType).equals(IpProtocol.UDP)) {
|
||||||
|
if (srcPort != 0) {
|
||||||
|
tsb.matchUdpSrc(srcPort);
|
||||||
|
}
|
||||||
|
if (dstPort != 0) {
|
||||||
|
tsb.matchUdpDst(dstPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TunnelPolicy.Builder tpb = TunnelPolicy.builder().setPolicyId(pid);
|
TunnelPolicy.Builder tpb = TunnelPolicy.builder().setPolicyId(pid);
|
||||||
if (tunnelId != null) {
|
if (tunnelId != null) {
|
||||||
tpb.setTunnelId(tunnelId);
|
tpb.setTunnelId(tunnelId);
|
||||||
|
@ -49,7 +49,6 @@ import org.onosproject.net.flow.criteria.Criterion;
|
|||||||
import org.onosproject.net.flow.criteria.EthCriterion;
|
import org.onosproject.net.flow.criteria.EthCriterion;
|
||||||
import org.onosproject.net.flow.criteria.EthTypeCriterion;
|
import org.onosproject.net.flow.criteria.EthTypeCriterion;
|
||||||
import org.onosproject.net.flow.criteria.IPCriterion;
|
import org.onosproject.net.flow.criteria.IPCriterion;
|
||||||
import org.onosproject.net.flow.criteria.IPProtocolCriterion;
|
|
||||||
import org.onosproject.net.flow.criteria.MplsCriterion;
|
import org.onosproject.net.flow.criteria.MplsCriterion;
|
||||||
import org.onosproject.net.flow.criteria.PortCriterion;
|
import org.onosproject.net.flow.criteria.PortCriterion;
|
||||||
import org.onosproject.net.flow.criteria.VlanIdCriterion;
|
import org.onosproject.net.flow.criteria.VlanIdCriterion;
|
||||||
@ -393,37 +392,6 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
|
|||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
TrafficSelector.Builder filteredSelectorBuilder =
|
|
||||||
DefaultTrafficSelector.builder();
|
|
||||||
if (ethType.ethType() == Ethernet.TYPE_IPV4) {
|
|
||||||
IPCriterion ipSrc = (IPCriterion) selector
|
|
||||||
.getCriterion(Criterion.Type.IPV4_SRC);
|
|
||||||
IPCriterion ipDst = (IPCriterion) selector
|
|
||||||
.getCriterion(Criterion.Type.IPV4_DST);
|
|
||||||
IPProtocolCriterion ipProto = (IPProtocolCriterion) selector
|
|
||||||
.getCriterion(Criterion.Type.IP_PROTO);
|
|
||||||
|
|
||||||
filteredSelectorBuilder
|
|
||||||
.matchEthType(Ethernet.TYPE_IPV4);
|
|
||||||
|
|
||||||
if (ipSrc != null) {
|
|
||||||
filteredSelectorBuilder.matchIPSrc(ipSrc.ip());
|
|
||||||
}
|
|
||||||
if (ipDst != null) {
|
|
||||||
filteredSelectorBuilder.matchIPDst(ipDst.ip());
|
|
||||||
}
|
|
||||||
if (ipProto != null) {
|
|
||||||
filteredSelectorBuilder.matchIPProtocol(
|
|
||||||
Short.valueOf(ipProto.protocol()).byteValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug("processing IPv4 specific forwarding objective");
|
|
||||||
} else {
|
|
||||||
log.warn("VERSATILE forwarding objective does not support {} yet.",
|
|
||||||
ethType.ethType());
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment
|
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment
|
||||||
.builder();
|
.builder();
|
||||||
treatmentBuilder.wipeDeferred();
|
treatmentBuilder.wipeDeferred();
|
||||||
@ -449,12 +417,11 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour
|
|||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
TrafficSelector filteredSelector = filteredSelectorBuilder.build();
|
|
||||||
TrafficTreatment treatment = treatmentBuilder.build();
|
TrafficTreatment treatment = treatmentBuilder.build();
|
||||||
|
|
||||||
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
|
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
|
||||||
.fromApp(fwd.appId()).withPriority(fwd.priority())
|
.fromApp(fwd.appId()).withPriority(fwd.priority())
|
||||||
.forDevice(deviceId).withSelector(filteredSelector)
|
.forDevice(deviceId).withSelector(fwd.selector())
|
||||||
.withTreatment(treatment);
|
.withTreatment(treatment);
|
||||||
|
|
||||||
if (fwd.permanent()) {
|
if (fwd.permanent()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user