Add a config parameter to disable classifying OVS switches as OVS (meaning we
use the default switch implementation for them)

This is a workaround for a Flow Space Firewall issue when using OVS switches.

Change-Id: I0d3e9be460e45cc1fed22087e8df55cc832cae0a
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index af3353f..2152875 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -1216,6 +1216,14 @@
         } else {
             log.info("Using OF1.0 pipeline for the CPqD software switch");
         }
+
+        String disableOvsClassification =
+                configParams.get("disableOvsClassification");
+        if (disableOvsClassification != null &&
+                disableOvsClassification.equalsIgnoreCase("true")) {
+            DriverManager.setDisableOvsClassification(true);
+            log.info("OVS switches will be classified as default switches");
+        }
     }
 
     /**
diff --git a/src/main/java/net/onrc/onos/core/drivermanager/DriverManager.java b/src/main/java/net/onrc/onos/core/drivermanager/DriverManager.java
index e212655..5c967ed 100644
--- a/src/main/java/net/onrc/onos/core/drivermanager/DriverManager.java
+++ b/src/main/java/net/onrc/onos/core/drivermanager/DriverManager.java
@@ -20,6 +20,11 @@
     // single table with packet-ins.
     private static boolean cpqdUsePipeline13 = false;
 
+    // This flag can be set to prevent the driver manager from classifying
+    // switches as OVS switches (and thereby the default switch implementation
+    // will be used).
+    private static boolean disableOvsClassification = false;
+
     /**
      * Return an IOFSwitch object based on switch's manufacturer description
      * from OFDescStatsReply.
@@ -37,7 +42,7 @@
             return new OFSwitchImplCPqD13(desc, cpqdUsePipeline13);
         }
 
-        if (vendor.startsWith("Nicira") &&
+        if (!disableOvsClassification && vendor.startsWith("Nicira") &&
                 hw.startsWith("Open vSwitch")) {
             if (ofv == OFVersion.OF_10) {
                 return new OFSwitchImplOVS10(desc);
@@ -71,4 +76,22 @@
     public static void setConfigForCpqd(boolean usePipeline13) {
         cpqdUsePipeline13 = usePipeline13;
     }
+
+    /**
+     * Sets the configuration parameter which determines whether switches can
+     * be classified as OVS switches or as the default switch implementation.
+     *
+     * Our use case for this is when running OVS under the Flow Space Firewall
+     * (FSFW). The FSFW relays the switch desc reply (containing OVS
+     * description) from the switch to the controller. This causes us to
+     * classify the fake FSFW switch as OVS, however the FSFW switch doesn't
+     * support Nicira role requests and it breaks if we try to send them.
+     * Our workaround is to disable classifying switches as OVS.
+     *
+     * @param disableOvsClassificationFlag whether to use OVS switches or not
+     */
+    public static void setDisableOvsClassification(
+            boolean disableOvsClassificationFlag) {
+        disableOvsClassification = disableOvsClassificationFlag;
+    }
 }