Fix bug 171. EchoReply payload must be the same as the correspoding EchoRequest payload 48/3348/4
authorArtur Downar <adownar@advaoptical.com>
Wed, 27 Nov 2013 16:53:47 +0000 (17:53 +0100)
committerArtur Downar <adownar@advaoptical.com>
Tue, 3 Dec 2013 11:13:52 +0000 (12:13 +0100)
openVSwitch send empty request resulting in null payload in ODP
redundant import removed
rabased to the latest merged commit

Change-Id: I74ebd0995986f385301c7866632d829db8743766
Signed-off-by: Artur Downar <adownar@advaoptical.com>
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java

index 6fddef0..7a177fa 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
 import org.openflow.protocol.OFBarrierReply;
 import org.openflow.protocol.OFBarrierRequest;
 import org.openflow.protocol.OFEchoReply;
+import org.openflow.protocol.OFEchoRequest;
 import org.openflow.protocol.OFError;
 import org.openflow.protocol.OFFeaturesReply;
 import org.openflow.protocol.OFFlowMod;
@@ -60,6 +61,7 @@ import org.openflow.util.HexString;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 public class SwitchHandler implements ISwitch {
     private static final Logger logger = LoggerFactory.getLogger(SwitchHandler.class);
     private static final int SWITCH_LIVENESS_TIMER = 5000;
@@ -371,6 +373,14 @@ public class SwitchHandler implements ISwitch {
                 break;
             case ECHO_REQUEST:
                 OFEchoReply echoReply = (OFEchoReply) factory.getMessage(OFType.ECHO_REPLY);
+
+                byte []payload = ((OFEchoRequest)msg).getPayload();
+                if (payload != null && payload.length != 0 ) {
+                    // the response must have the same payload as the request
+                    echoReply.setPayload(payload);
+                    echoReply.setLength( (short)(echoReply.getLength() + payload.length) );
+                }
+
                 // respond immediately
                 asyncSendNow(echoReply, msg.getXid());