Add DATAPATH_ID to switch packaging, to enable persistent DPIDs.
authorBen Pfaff <blp@nicira.com>
Wed, 26 Nov 2008 19:38:28 +0000 (11:38 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 27 Nov 2008 06:26:42 +0000 (22:26 -0800)
debian/openflow-switch.default
debian/openflow-switch.init

index 9529ddf..7eedab5 100644 (file)
@@ -122,3 +122,13 @@ DAEMON_OPTS=""
 # will disable core dumps.  Setting it to "unlimited" will dump all
 # core files regardless of size.
 #CORE_LIMIT=unlimited
+
+# DATAPATH_ID: Identifier for this switch.
+#
+# By default, the switch generates a new, random datapath ID every time
+# it starts up.  By setting this value, the datapath ID will be consistent
+# from one run to the next.
+#
+# Set DATAPATH_ID to a MAC address in the form XX:XX:XX:XX:XX:XX where each
+# X is a hexadecimal digit (0-9 or a-f).
+#DATAPATH_ID=XX:XX:XX:XX:XX:XX 
index 9b8acf6..fa17d2b 100755 (executable)
@@ -46,6 +46,7 @@ unset MGMT_VCONNS
 unset COMMANDS
 unset DAEMON_OPTS
 unset CORE_LIMIT
+unset DATAPATH_ID
 default=/etc/default/openflow-switch
 if [ -f $default ] ; then
        . $default
@@ -222,6 +223,20 @@ case "$1" in
             must_succeed "Adding $netdev to datapath" dpctl addif nl:0 $netdev
         done
 
+        xx='[0-9abcdefABCDEF][0-9abcdefABCDEF]'
+        case $DATAPATH_ID in
+            '')
+                ;;
+            $xx:$xx:$xx:$xx:$xx:$xx)
+                ifconfig of0 down
+                must_succeed "Setting of0 MAC address to $DATAPATH_ID" ifconfig of0 hw ether $DATAPATH_ID
+                ifconfig of0 up
+                ;;
+            *)
+                echo "DATAPATH_ID is not a valid MAC address in the form XX:XX:XX:XX:XX:XX, ignoring" >&2
+                ;;
+        esac
+
         if test "$MODE" = in-band; then
             if test "$SWITCH_IP" = dhcp; then
                 must_succeed "Temporarily disabling of0" ifconfig of0 down