BUG 1310 Simplefix - guarded shake() from late arriving HELLO 00/8900/2
authorjameshall03885 <ghall@brocade.com>
Thu, 10 Jul 2014 15:04:30 +0000 (11:04 -0400)
committerjameshall03885 <ghall@brocade.com>
Thu, 10 Jul 2014 15:41:19 +0000 (11:41 -0400)
Added two new IT scenarios.  The NoVBM_OF10_TwoHello produces a
duplicate datapathId problem prior to this fix.

Change-Id: Idedac4524acd15d77df73223cd75d67b5b1f4887
Signed-off-by: jameshall03885 <ghall@brocade.com>
openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/OFPluginToLibraryTest.java
openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/ScenarioFactory.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/HandshakeManagerImpl.java

index 646b066eb8567a9537c638fb47120d4dbdc4b59b..1a94d5d6cbc53a257c1022917946dc2b587bc8c9 100644 (file)
@@ -48,7 +48,7 @@ public class OFPluginToLibraryTest {
 
     @Inject @Filter(timeout=5000)
     OpenflowPluginProvider openflowPluginProvider;
-    
+
     @Inject
     BundleContext ctx;
 
@@ -56,12 +56,12 @@ public class OFPluginToLibraryTest {
 
     /**
      * test setup
-     * @throws InterruptedException 
+     * @throws InterruptedException
      */
     @Before
     public void setUp() throws InterruptedException {
         LOG.debug("openflowPluginProvider: "+openflowPluginProvider);
-        //FIXME: plugin should provide service exposing startup result via future 
+        //FIXME: plugin should provide service exposing startup result via future
         Thread.sleep(5000);
     }
 
@@ -80,7 +80,7 @@ public class OFPluginToLibraryTest {
         }
 
         //TODO: dump errors of plugin (by exploiting ErrorHandler)
-        
+
         try {
             LOG.debug("checking if simulator succeeded to connect to controller");
             boolean simulatorWasOnline = switchSim.getIsOnlineFuture().get(100, TimeUnit.MILLISECONDS);
@@ -89,7 +89,7 @@ public class OFPluginToLibraryTest {
             String message = "simulator probably failed to connect to controller";
             LOG.error(message, e);
             Assert.fail(message);
-        } 
+        }
     }
 
     /**
@@ -168,6 +168,55 @@ public class OFPluginToLibraryTest {
         switchSim.start();
     }
 
+    /**
+     * test with MLX running OF10 and OFP running OF13/OF10
+     *
+     * MLX issues an OFPT_ERROR on the version compatability MLX issues a second
+     * HELLO after the second OFP HELLO
+     *
+     * @throws Exception
+     */
+    @Test
+    public void handshakeOkNoVBM_OF10_TwoHello() throws Exception {
+        LOG.debug("handshakeOkMLX10 integration test");
+        LOG.debug("openflowPluginProvider: " + openflowPluginProvider);
+
+        switchSim = createSimpleClient();
+        switchSim.setSecuredClient(false);
+        Stack<ClientEvent> handshakeScenario = ScenarioFactory
+                .createHandshakeScenarioNoVBM_OF10_TwoHello();
+        // handshakeScenario.setElementAt(new SleepEvent(5000),
+        // handshakeScenario
+        // .size());
+
+        ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
+        switchSim.setScenarioHandler(scenario);
+        switchSim.start();
+    }
+
+    /**
+     * test with Mininet running OF10 and OFP running OF13/OF10
+     *
+     * Mininet issues an OFPT_ERROR on the version compatability Mininet doesn't
+     * issue a second HELLO
+     *
+     * @throws Exception
+     */
+    @Test
+    public void handshakeOkNoVBM_OF10_SingleHello() throws Exception {
+        LOG.debug("handshakeOkMLX10 integration test");
+        LOG.debug("openflowPluginProvider: " + openflowPluginProvider);
+
+        switchSim = createSimpleClient();
+        switchSim.setSecuredClient(false);
+        Stack<ClientEvent> handshakeScenario = ScenarioFactory
+                .createHandshakeScenarioNOVBM_OF10_OneHello();
+
+        ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
+        switchSim.setScenarioHandler(scenario);
+        switchSim.start();
+    }
+
     /**
      * @return
      */
@@ -196,13 +245,13 @@ public class OFPluginToLibraryTest {
 
                 OFPaxOptionsAssistant.osgiConsoleBundles(),
                 OFPaxOptionsAssistant.loggingBudles(),
-                
+
                 TestHelper.junitAndMockitoBundles(),
-                TestHelper.mdSalCoreBundles(), 
+                TestHelper.mdSalCoreBundles(),
                 TestHelper.configMinumumBundles(),
                 TestHelper.baseModelBundles(),
-                TestHelper.flowCapableModelBundles(), 
-                
+                TestHelper.flowCapableModelBundles(),
+
                 OFPaxOptionsAssistant.ofPluginBundles());
     }
 
index 740248df1476ed07de6a1dc2b804bd5716ce18ea..a13236552ed4ad5470a9d477d4245a386a3b7205 100644 (file)
@@ -16,10 +16,10 @@ import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 
 /**
- * provisioning of most common scenarios used by testing of integration between OFLibrary, OFPlugin and MD-SAL 
+ * provisioning of most common scenarios used by testing of integration between OFLibrary, OFPlugin and MD-SAL
  */
 public abstract class ScenarioFactory {
-    
+
     /** version bitmap hex-string containing version 1.3 */
     public static final String VERSION_BITMAP_13 = "00 01 00 08 00 00 00 10";
     /** version bitmap hex-string containing versions: 1.0 + 1.3 */
@@ -41,18 +41,20 @@ public abstract class ScenarioFactory {
     public static Stack<ClientEvent> createHandshakeScenarioVBM(
             String switchVersionBitmap, short auxId, String pluginVersionBitmap) {
         Stack<ClientEvent> stack = new Stack<>();
-        
-        stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 01 " 
-                + switchVersionBitmap)));
-        stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 "
-                + pluginVersionBitmap)));
-        stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02")));
-        stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes(
-                "04 06 00 20 00 00 00 02 "
-                + "00 01 02 03 04 05 06 07 "
-                + "00 01 02 03 01 "
-                + Integer.toHexString(auxId)
-                + " 00 00 00 01 02 03 00 01 02 03")));
+
+        stack.add(0, new SendEvent(ByteBufUtils
+                .hexStringToBytes("04 00 00 10 00 00 00 01 "
+                        + switchVersionBitmap)));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("04 00 00 10 00 00 00 15 "
+                        + pluginVersionBitmap)));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("04 05 00 08 00 00 00 02")));
+        stack.add(0, new SendEvent(ByteBufUtils
+                .hexStringToBytes("04 06 00 20 00 00 00 02 "
+                        + "00 01 02 03 04 05 06 07 " + "00 01 02 03 01 "
+                        + Integer.toHexString(auxId)
+                        + " 00 00 00 01 02 03 00 01 02 03")));
         addSleep(stack);
         return stack;
     }
@@ -66,22 +68,195 @@ public abstract class ScenarioFactory {
 
     /**
      * @param auxId
-     * @param pluginVersionBitmap 
+     * @param pluginVersionBitmap
+     * @return handshake scenario without switch version bitmap
+     */
+    public static Stack<ClientEvent> createHandshakeScenario(short auxId,
+            String pluginVersionBitmap) {
+        Stack<ClientEvent> stack = new Stack<>();
+
+        stack.add(0, new SendEvent(ByteBufUtils
+                .hexStringToBytes("04 00 00 08 00 00 00 01")));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("04 00 00 10 00 00 00 15 "
+                        + pluginVersionBitmap)));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("04 05 00 08 00 00 00 02")));
+        stack.add(0, new SendEvent(ByteBufUtils
+                .hexStringToBytes("04 06 00 20 00 00 00 02 "
+                        + "00 01 02 03 04 05 06 07 " + "00 01 02 03 01 "
+                        + Integer.toHexString(auxId)
+                        + " 00 00 00 01 02 03 00 01 02 03")));
+        addSleep(stack);
+        return stack;
+    }
+
+    /**
+     * Attempt to simulate the MLX running 1.0 talking to ODL
+     *
+     * @param auxId
+     * @param pluginVersionBitmap
+     * @return handshake scenario without switch version bitmap
+     */
+    public static Stack<ClientEvent> createHandshakeScenarioNoVBM_OF10_TwoHello() {
+        Stack<ClientEvent> stack = new Stack<>();
+
+        stack.add(0, new SendEvent(ByteBufUtils
+                .hexStringToBytes("01 00 00 08 00 00 01 67")));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                        .hexStringToBytes("04 00 00 10 00 00 00 15 00 01 00 08 00 00 00 12")));
+        stack.add(0, new SendEvent(ByteBufUtils
+                .hexStringToBytes("01 01 00 0c 00 00 00 15 00 00 00 00")));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("01 00 00 08 00 00 01 68")));
+        stack.add(0, new SendEvent(ByteBufUtils
+                .hexStringToBytes("01 00 00 08 00 00 01 68")));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("01 05 00 08 00 00 01 69")));
+
+        stack.add(0, new SendEvent(
+                ByteBufUtils
+                        .hexStringToBytes("01 06 00 80 00 00 01 69 cc 4e 24 1c 4a 00 00 00"
+                                + " 00 00 01 00 01 00 00 00 00 00 00 07 00 00 01 0f"
+                                + " 00 61 cc 4e 24 1c 4a 60 65 74 68 33 2f 31 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
+                                + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40"
+                                + " 00 62 cc 4e 24 1c 4a 61 65 74 68 33 2f 32 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
+                                + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40")));
+
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("01 10 00 0c 00 00 00 01 00 00 00 00")));
+
+        stack.add(0, new SendEvent(
+                ByteBufUtils
+                        .hexStringToBytes("01 11 04 2c 00 00 00 01 00 00 00 00 42 72 6f 63"
+                                + " 61 64 65 20 43 6f 6d 6d 75 6e 69 63 61 74 69"
+                                + " 6f 6e 73 2c 20 49 6e 63 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 4d 75 6c"
+                                + " 74 69 2d 53 65 72 76 69 63 65 20 49 72 6f 6e"
+                                + " 77 61 72 65 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 4e 49"
+                                + " 20 35 2e 37 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4e"
+                                + " 6f 6e 65 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 4e 6f 6e 65 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00")));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("01 05 00 08 00 00 01 69")));
+
+        stack.add(0, new SendEvent(
+                ByteBufUtils
+                        .hexStringToBytes("01 06 00 80 00 00 01 69 cc 4e 24 1c 4a 00 00 00"
+                                + " 00 00 01 00 01 00 00 00 00 00 00 07 00 00 01 0f"
+                                + " 00 61 cc 4e 24 1c 4a 60 65 74 68 33 2f 31 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
+                                + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40"
+                                + " 00 62 cc 4e 24 1c 4a 61 65 74 68 33 2f 32 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
+                                + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40")));
+
+        stack.add(0, new SleepEvent(5000));
+
+        addSleep(stack);
+        return stack;
+    }
+
+    /**
+     * Attempt to simulate the MLX running 1.0 talking to ODL
+     *
+     * @param auxId
+     * @param pluginVersionBitmap
      * @return handshake scenario without switch version bitmap
      */
-    public static Stack<ClientEvent> createHandshakeScenario(short auxId, String pluginVersionBitmap) {
+    public static Stack<ClientEvent> createHandshakeScenarioNOVBM_OF10_OneHello() {
+        System.out.println("createHandshakeScenarioMininet");
         Stack<ClientEvent> stack = new Stack<>();
-        
-        stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
-        stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 "
-                + pluginVersionBitmap)));
-        stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02")));
-        stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes(
-                "04 06 00 20 00 00 00 02 "
-                + "00 01 02 03 04 05 06 07 "
-                + "00 01 02 03 01 "
-                + Integer.toHexString(auxId)
-                + " 00 00 00 01 02 03 00 01 02 03")));
+
+        stack.add(0, new SendEvent(ByteBufUtils
+                .hexStringToBytes("01 00 00 08 00 00 00 0d")));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("04 00 00 10 00 00 00 15")));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("01 00 00 08 00 00 00 0e")));
+        stack.add(0, new WaitForMessageEvent(ByteBufUtils
+                .hexStringToBytes("01 05 00 08 00 00 00 0f")));
+
+        stack.add(0, new SendEvent(
+                ByteBufUtils
+                        .hexStringToBytes("01 01 00 14 00 00 00 0e 00 01 00 01 01 00 00 08 00 00 00 0e")));
+
+        stack.add(0, new SendEvent(
+                ByteBufUtils
+                        .hexStringToBytes(" 01 06 00 b0 00 00 00 0f 00 00 00 00 00 00 00 01 00 00 01 00 fe 00"
+                                + " 00 00 00 00 00 c7 00 00 0f ff 00 01 fa 01 ff 57 86 aa 73 31 2d"
+                                + " 65 74 68 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01"
+                                + " 00 00 00 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 02 c2 51 d8"
+                                + " 24 38 97 73 31 2d 65 74 68 32 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 c0 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 ff fe ea bd f8 db 41 40 73 31 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+                                + " 00 00 00 00 00 00 00")));
         addSleep(stack);
         return stack;
     }
index c17b65318860b3fbf65476c49ba07a9a467a4b6d..bdb13f748fdca34e563f1ba795bb73a5114869ac 100644 (file)
@@ -75,6 +75,15 @@ public class HandshakeManagerImpl implements HandshakeManager {
 
     @Override
     public void shake() {
+
+        if (version != null) {
+            // Some switches respond with a second HELLO acknowledging our HELLO
+            // but we've already completed the handshake based on the negotiated
+            // version and have registered this switch.
+            LOG.debug("Hello recieved after handshake already settled ... ignoring.");
+            return;
+        }
+
         LOG.trace("handshake STARTED");
         setActiveXid(20L);
         HelloMessage receivedHelloLoc = receivedHello;