mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-15 17:31:31 +02:00
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:
parent
9e5c5ca225
commit
6fd1ca95aa
@ -27,7 +27,7 @@ import org.onosproject.net.packet.PacketService;
|
|||||||
description = "Lists packet requests")
|
description = "Lists packet requests")
|
||||||
public class PacketRequestsListCommand extends AbstractShellCommand {
|
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
|
@Override
|
||||||
protected void execute() {
|
protected void execute() {
|
||||||
@ -41,8 +41,7 @@ public class PacketRequestsListCommand extends AbstractShellCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void print(PacketRequest request) {
|
private void print(PacketRequest request) {
|
||||||
print(FMT, request.nodeId(), request.appId().name(), request.priority(),
|
print(FMT, request.nodeId(), request.appId().name(), request.priority(), request.selector().criteria());
|
||||||
request.selector().criteria(), request.copy());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public final class DefaultPacketRequest implements PacketRequest {
|
|||||||
private final ApplicationId appId;
|
private final ApplicationId appId;
|
||||||
private final NodeId nodeId;
|
private final NodeId nodeId;
|
||||||
private final Optional<DeviceId> deviceId;
|
private final Optional<DeviceId> deviceId;
|
||||||
private final boolean copy;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new packet request.
|
* Creates a new packet request.
|
||||||
@ -46,27 +46,11 @@ public final class DefaultPacketRequest implements PacketRequest {
|
|||||||
*/
|
*/
|
||||||
public DefaultPacketRequest(TrafficSelector selector, PacketPriority priority,
|
public DefaultPacketRequest(TrafficSelector selector, PacketPriority priority,
|
||||||
ApplicationId appId, NodeId nodeId, Optional<DeviceId> deviceId) {
|
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.selector = selector;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
this.nodeId = nodeId;
|
this.nodeId = nodeId;
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
this.copy = copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -93,14 +77,9 @@ public final class DefaultPacketRequest implements PacketRequest {
|
|||||||
return nodeId;
|
return nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean copy() {
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(selector, priority, appId, nodeId, deviceId, copy);
|
return Objects.hash(selector, priority, appId, nodeId, deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,8 +95,7 @@ public final class DefaultPacketRequest implements PacketRequest {
|
|||||||
&& Objects.equals(this.priority, other.priority)
|
&& Objects.equals(this.priority, other.priority)
|
||||||
&& Objects.equals(this.appId, other.appId)
|
&& Objects.equals(this.appId, other.appId)
|
||||||
&& Objects.equals(this.nodeId, other.nodeId)
|
&& Objects.equals(this.nodeId, other.nodeId)
|
||||||
&& Objects.equals(this.deviceId, other.deviceId)
|
&& Objects.equals(this.deviceId, other.deviceId);
|
||||||
&& Objects.equals(this.copy, other.copy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -128,7 +106,6 @@ public final class DefaultPacketRequest implements PacketRequest {
|
|||||||
.add("appId", appId)
|
.add("appId", appId)
|
||||||
.add("nodeId", nodeId)
|
.add("nodeId", nodeId)
|
||||||
.add("applies to", deviceId.map(DeviceId::toString).orElse("all"))
|
.add("applies to", deviceId.map(DeviceId::toString).orElse("all"))
|
||||||
.add("copy", copy)
|
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,11 +62,4 @@ public interface PacketRequest {
|
|||||||
*/
|
*/
|
||||||
Optional<DeviceId> deviceId();
|
Optional<DeviceId> deviceId();
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtains copy flag.
|
|
||||||
*
|
|
||||||
* @return true if copy flag is set
|
|
||||||
*/
|
|
||||||
boolean copy();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,22 +69,6 @@ public interface PacketService {
|
|||||||
void requestPackets(TrafficSelector selector, PacketPriority priority,
|
void requestPackets(TrafficSelector selector, PacketPriority priority,
|
||||||
ApplicationId appId);
|
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
|
* Requests that packets matching the given selector are punted from the
|
||||||
@ -111,23 +95,6 @@ public interface PacketService {
|
|||||||
void cancelPackets(TrafficSelector selector, PacketPriority priority,
|
void cancelPackets(TrafficSelector selector, PacketPriority priority,
|
||||||
ApplicationId appId);
|
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
|
* Cancels previous packet requests for packets matching the given
|
||||||
* selector to be punted from the dataplane to the controller. If a
|
* selector to be punted from the dataplane to the controller. If a
|
||||||
|
@ -49,11 +49,6 @@ public class PacketServiceAdapter implements PacketService {
|
|||||||
ApplicationId appId) {
|
ApplicationId appId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requestPackets(TrafficSelector selector, PacketPriority priority,
|
|
||||||
ApplicationId appId, boolean copy) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void requestPackets(TrafficSelector selector, PacketPriority priority,
|
public void requestPackets(TrafficSelector selector, PacketPriority priority,
|
||||||
ApplicationId appId, Optional<DeviceId> deviceId) {
|
ApplicationId appId, Optional<DeviceId> deviceId) {
|
||||||
@ -65,11 +60,6 @@ public class PacketServiceAdapter implements PacketService {
|
|||||||
ApplicationId appId) {
|
ApplicationId appId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
|
|
||||||
ApplicationId appId, boolean copy) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
|
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
|
||||||
ApplicationId appId, Optional<DeviceId> deviceId) {
|
ApplicationId appId, Optional<DeviceId> deviceId) {
|
||||||
|
@ -181,19 +181,12 @@ public class PacketManager
|
|||||||
@Override
|
@Override
|
||||||
public void requestPackets(TrafficSelector selector, PacketPriority priority,
|
public void requestPackets(TrafficSelector selector, PacketPriority priority,
|
||||||
ApplicationId appId) {
|
ApplicationId appId) {
|
||||||
this.requestPackets(selector, priority, appId, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requestPackets(TrafficSelector selector, PacketPriority priority,
|
|
||||||
ApplicationId appId, boolean copy) {
|
|
||||||
checkPermission(PACKET_READ);
|
checkPermission(PACKET_READ);
|
||||||
checkNotNull(selector, ERROR_NULL_SELECTOR);
|
checkNotNull(selector, ERROR_NULL_SELECTOR);
|
||||||
checkNotNull(appId, ERROR_NULL_APP_ID);
|
checkNotNull(appId, ERROR_NULL_APP_ID);
|
||||||
|
|
||||||
PacketRequest request = new DefaultPacketRequest(selector, priority, appId,
|
PacketRequest request = new DefaultPacketRequest(selector, priority, appId,
|
||||||
localNodeId, Optional.empty(), copy);
|
localNodeId, Optional.empty());
|
||||||
|
|
||||||
store.requestPackets(request);
|
store.requestPackets(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,23 +203,19 @@ public class PacketManager
|
|||||||
localNodeId, deviceId);
|
localNodeId, deviceId);
|
||||||
|
|
||||||
store.requestPackets(request);
|
store.requestPackets(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
|
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
|
||||||
ApplicationId appId) {
|
ApplicationId appId) {
|
||||||
this.cancelPackets(selector, priority, appId, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelPackets(TrafficSelector selector, PacketPriority priority,
|
|
||||||
ApplicationId appId, boolean copy) {
|
|
||||||
checkPermission(PACKET_READ);
|
checkPermission(PACKET_READ);
|
||||||
checkNotNull(selector, ERROR_NULL_SELECTOR);
|
checkNotNull(selector, ERROR_NULL_SELECTOR);
|
||||||
checkNotNull(appId, ERROR_NULL_APP_ID);
|
checkNotNull(appId, ERROR_NULL_APP_ID);
|
||||||
|
|
||||||
|
|
||||||
PacketRequest request = new DefaultPacketRequest(selector, priority, appId,
|
PacketRequest request = new DefaultPacketRequest(selector, priority, appId,
|
||||||
localNodeId, Optional.empty(), copy);
|
localNodeId, Optional.empty());
|
||||||
store.cancelPackets(request);
|
store.cancelPackets(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,18 +322,17 @@ public class PacketManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DefaultForwardingObjective.Builder createBuilder(PacketRequest request) {
|
private DefaultForwardingObjective.Builder createBuilder(PacketRequest request) {
|
||||||
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
|
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
|
||||||
tBuilder.punt();
|
.punt()
|
||||||
if (!request.copy()) {
|
.wipeDeferred()
|
||||||
tBuilder.wipeDeferred();
|
.build();
|
||||||
}
|
|
||||||
|
|
||||||
return DefaultForwardingObjective.builder()
|
return DefaultForwardingObjective.builder()
|
||||||
.withPriority(request.priority().priorityValue())
|
.withPriority(request.priority().priorityValue())
|
||||||
.withSelector(request.selector())
|
.withSelector(request.selector())
|
||||||
.fromApp(appId)
|
.fromApp(appId)
|
||||||
.withFlag(ForwardingObjective.Flag.VERSATILE)
|
.withFlag(ForwardingObjective.Flag.VERSATILE)
|
||||||
.withTreatment(tBuilder.build())
|
.withTreatment(treatment)
|
||||||
.makePermanent();
|
.makePermanent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user