Revert "Allows duplicating packets when requesting packet-in via PacketService"

and makes wipeDeferred as default.

This reverts commit 874900ec363da57928d6f087527e6e9cbfbc0645.

Change-Id: I080ece4f2f316a95c36bdd09f91c0482fbe6f8d9
This commit is contained in:
Pier Luigi Ventre 2017-01-13 03:15:50 +00:00 committed by Jonathan Hart
parent 9e5c5ca225
commit 6fd1ca95aa
6 changed files with 14 additions and 100 deletions

View File

@ -27,7 +27,7 @@ import org.onosproject.net.packet.PacketService;
description = "Lists packet requests")
public class PacketRequestsListCommand extends AbstractShellCommand {
private static final String FMT = "nodeId=%s appId=%s, priority=%s, criteria=%s copy=%s";
private static final String FMT = "nodeId=%s appId=%s, priority=%s, criteria=%s";
@Override
protected void execute() {
@ -41,8 +41,7 @@ public class PacketRequestsListCommand extends AbstractShellCommand {
}
private void print(PacketRequest request) {
print(FMT, request.nodeId(), request.appId().name(), request.priority(),
request.selector().criteria(), request.copy());
print(FMT, request.nodeId(), request.appId().name(), request.priority(), request.selector().criteria());
}
}

View File

@ -34,7 +34,7 @@ public final class DefaultPacketRequest implements PacketRequest {
private final ApplicationId appId;
private final NodeId nodeId;
private final Optional<DeviceId> deviceId;
private final boolean copy;
/**
* Creates a new packet request.
@ -46,27 +46,11 @@ public final class DefaultPacketRequest implements PacketRequest {
*/
public DefaultPacketRequest(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, NodeId nodeId, Optional<DeviceId> deviceId) {
this(selector, priority, appId, nodeId, deviceId, false);
}
/**
* Creates a new packet request.
* @param selector traffic selector
* @param priority intercept priority
* @param appId application id
* @param nodeId identifier of node where request originated
* @param deviceId device id
* @param copy copy flag
*/
public DefaultPacketRequest(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, NodeId nodeId, Optional<DeviceId> deviceId,
boolean copy) {
this.selector = selector;
this.priority = priority;
this.appId = appId;
this.nodeId = nodeId;
this.deviceId = deviceId;
this.copy = copy;
}
@Override
@ -93,14 +77,9 @@ public final class DefaultPacketRequest implements PacketRequest {
return nodeId;
}
@Override
public boolean copy() {
return copy;
}
@Override
public int hashCode() {
return Objects.hash(selector, priority, appId, nodeId, deviceId, copy);
return Objects.hash(selector, priority, appId, nodeId, deviceId);
}
@Override
@ -116,8 +95,7 @@ public final class DefaultPacketRequest implements PacketRequest {
&& Objects.equals(this.priority, other.priority)
&& Objects.equals(this.appId, other.appId)
&& Objects.equals(this.nodeId, other.nodeId)
&& Objects.equals(this.deviceId, other.deviceId)
&& Objects.equals(this.copy, other.copy);
&& Objects.equals(this.deviceId, other.deviceId);
}
@Override
@ -128,7 +106,6 @@ public final class DefaultPacketRequest implements PacketRequest {
.add("appId", appId)
.add("nodeId", nodeId)
.add("applies to", deviceId.map(DeviceId::toString).orElse("all"))
.add("copy", copy)
.toString();
}
}

View File

@ -62,11 +62,4 @@ public interface PacketRequest {
*/
Optional<DeviceId> deviceId();
/**
* Obtains copy flag.
*
* @return true if copy flag is set
*/
boolean copy();
}

View File

@ -69,22 +69,6 @@ public interface PacketService {
void requestPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId);
/**
* Requests that packets matching the given selector are punted from the
* dataplane to the controller.
*
* @param selector the traffic selector used to match packets
* @param priority the priority of the rule
* @param appId the application ID of the requester
* @param copy request a copy of the matching packet to be punted to the controller.
* <p>
* If false, the original packet is always sent to the controller.
* If true, a copy of the packet is sent to the controller,
* as long as the packet can be duplicated.
* If duplication is not supported, the original packet will be sent to the controller.
*/
void requestPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, boolean copy);
/**
* Requests that packets matching the given selector are punted from the
@ -111,23 +95,6 @@ public interface PacketService {
void cancelPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId);
/**
* Cancels previous packet requests for packets matching the given
* selector to be punted from the dataplane to the controller.
*
* @param selector the traffic selector used to match packets
* @param priority the priority of the rule
* @param appId the application ID of the requester
* @param copy request a copy of the matching packet to be punted to the controller.
* <p>
* If false, the original packet is always sent to the controller.
* If true, a copy of the packet is sent to the controller,
* as long as the packet can be duplicated.
* If duplication is not supported, the original packet will be sent to the controller.
*/
void cancelPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, boolean copy);
/**
* Cancels previous packet requests for packets matching the given
* selector to be punted from the dataplane to the controller. If a

View File

@ -49,11 +49,6 @@ public class PacketServiceAdapter implements PacketService {
ApplicationId appId) {
}
@Override
public void requestPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, boolean copy) {
}
@Override
public void requestPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, Optional<DeviceId> deviceId) {
@ -65,11 +60,6 @@ public class PacketServiceAdapter implements PacketService {
ApplicationId appId) {
}
@Override
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, boolean copy) {
}
@Override
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, Optional<DeviceId> deviceId) {

View File

@ -181,19 +181,12 @@ public class PacketManager
@Override
public void requestPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId) {
this.requestPackets(selector, priority, appId, false);
}
@Override
public void requestPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, boolean copy) {
checkPermission(PACKET_READ);
checkNotNull(selector, ERROR_NULL_SELECTOR);
checkNotNull(appId, ERROR_NULL_APP_ID);
PacketRequest request = new DefaultPacketRequest(selector, priority, appId,
localNodeId, Optional.empty(), copy);
localNodeId, Optional.empty());
store.requestPackets(request);
}
@ -210,23 +203,19 @@ public class PacketManager
localNodeId, deviceId);
store.requestPackets(request);
}
@Override
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId) {
this.cancelPackets(selector, priority, appId, false);
}
@Override
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
ApplicationId appId, boolean copy) {
checkPermission(PACKET_READ);
checkNotNull(selector, ERROR_NULL_SELECTOR);
checkNotNull(appId, ERROR_NULL_APP_ID);
PacketRequest request = new DefaultPacketRequest(selector, priority, appId,
localNodeId, Optional.empty(), copy);
localNodeId, Optional.empty());
store.cancelPackets(request);
}
@ -333,18 +322,17 @@ public class PacketManager
}
private DefaultForwardingObjective.Builder createBuilder(PacketRequest request) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.punt();
if (!request.copy()) {
tBuilder.wipeDeferred();
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.punt()
.wipeDeferred()
.build();
return DefaultForwardingObjective.builder()
.withPriority(request.priority().priorityValue())
.withSelector(request.selector())
.fromApp(appId)
.withFlag(ForwardingObjective.Flag.VERSATILE)
.withTreatment(tBuilder.build())
.withTreatment(treatment)
.makePermanent();
}