Disabling packet IO in default interpreter

Change-Id: Id668034928ebe93f704a999d4fc33a66f7069fdf
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/DefaultP4Interpreter.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/DefaultP4Interpreter.java
index 6029590..e0ea07b 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/DefaultP4Interpreter.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/DefaultP4Interpreter.java
@@ -52,6 +52,7 @@
 
 import java.nio.ByteBuffer;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 
@@ -73,6 +74,8 @@
     // FIXME: Should move this class out of the p4runtime drivers.
     // e.g. in a dedicated onos/pipeconf directory, along with any related P4 source code.
 
+    private static final boolean PACKET_IO_ENABLED = false;
+
     public static final String TABLE0 = "table0";
     public static final String SEND_TO_CPU = "send_to_cpu";
     public static final String PORT = "port";
@@ -191,6 +194,11 @@
     @Override
     public Collection<PiPacketOperation> mapOutboundPacket(OutboundPacket packet)
             throws PiInterpreterException {
+
+        if (!PACKET_IO_ENABLED) {
+            return Collections.emptyList();
+        }
+
         TrafficTreatment treatment = packet.treatment();
 
         // default.p4 supports only OUTPUT instructions.
@@ -224,6 +232,11 @@
     @Override
     public InboundPacket mapInboundPacket(DeviceId deviceId, PiPacketOperation packetIn)
             throws PiInterpreterException {
+
+        if (!PACKET_IO_ENABLED) {
+            return null;
+        }
+
         // Assuming that the packet is ethernet, which is fine since default.p4 can deparse only ethernet packets.
         Ethernet ethPkt = new Ethernet();
 
diff --git a/providers/p4runtime/packet/src/main/java/org/onosproject/provider/p4runtime/packet/impl/P4RuntimePacketProvider.java b/providers/p4runtime/packet/src/main/java/org/onosproject/provider/p4runtime/packet/impl/P4RuntimePacketProvider.java
index bf7c2d5..998e269 100644
--- a/providers/p4runtime/packet/src/main/java/org/onosproject/provider/p4runtime/packet/impl/P4RuntimePacketProvider.java
+++ b/providers/p4runtime/packet/src/main/java/org/onosproject/provider/p4runtime/packet/impl/P4RuntimePacketProvider.java
@@ -155,6 +155,10 @@
                     InboundPacket inPkt = deviceService.getDevice(eventSubject.deviceId())
                             .as(PiPipelineInterpreter.class)
                             .mapInboundPacket(eventSubject.deviceId(), operation);
+                    if (inPkt == null) {
+                        log.warn("Received null inbound packet. Ignoring.");
+                        return;
+                    }
                     //Creating the corresponding outbound Packet
                     //FIXME Wrapping of bytebuffer might be optimized with .asReadOnlyByteBuffer()
                     OutboundPacket outPkt = new DefaultOutboundPacket(eventSubject.deviceId(), null,