#include <linux/rcupdate.h>
#include <linux/skbuff.h>
#include <linux/workqueue.h>
-#include <linux/dmi.h>
#include "datapath.h"
#include "dp_dev.h"
return 0;
}
-/* Check if the DMI UUID contains a Nicira mac address that should be
- * used for this interface. The UUID is assumed to be RFC 4122
- * compliant. */
-static void
-set_uuid_mac(struct net_device *netdev)
-{
- const char *uuid = dmi_get_system_info(DMI_PRODUCT_UUID);
- const char *uptr;
- uint8_t mac[ETH_ALEN];
- int i;
-
- if (!uuid || *uuid == '\0' || strlen(uuid) != 36)
- return;
-
- /* We are only interested version 1 UUIDs, since the last six bytes
- * are an IEEE 802 MAC address. */
- if (uuid[14] != '1')
- return;
-
- /* Pull out the embedded MAC address. The kernel's sscanf doesn't
- * support field widths on hex digits, so we use this hack. */
- uptr = uuid + 24;
- for (i=0; i<ETH_ALEN; i++) {
- unsigned char d[3];
-
- d[0] = *uptr++;
- d[1] = *uptr++;
- d[2] = '\0';
-
- mac[i] = simple_strtoul(d, NULL, 16);
- }
-
- /* If this is a Nicira one, then use it. */
- if (mac[0] != 0x00 || mac[1] != 0x23 || mac[2] != 0x20)
- return;
-
- memcpy(netdev->dev_addr, mac, ETH_ALEN);
-}
-
static void dp_getinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
strcpy(info->driver, "openflow");
return err;
}
- /* For the first datapath, we check the DMI UUID to see if a Nicira
- * mac address is available to use instead of the random one just
- * generated. */
- if (dp->dp_idx == 0)
- set_uuid_mac(netdev);
-
dp_dev = dp_dev_priv(netdev);
dp_dev->dp = dp;
skb_queue_head_init(&dp_dev->xmit_queue);
test -x $DAEMON || exit 0
+NICIRA_OUI="002320"
+
LOGDIR=/var/log/openflow
PIDFILE=/var/run/$NAME.pid
DHCLIENT_PIDFILE=/var/run/dhclient.of0.pid
xx='[0-9abcdefABCDEF][0-9abcdefABCDEF]'
case $DATAPATH_ID in
'')
+ # Check if the DMI System UUID contains a Nicira mac address
+ # that should be used for this datapath. The UUID is assumed
+ # to be RFC 4122 compliant.
+ DMIDECODE=`which dmidecode`
+ if [ -n $DMIDECODE ]; then
+ UUID_MAC=`$DMIDECODE -s system-uuid | cut -d'-' -f 5`
+ case $UUID_MAC in
+ $NICIRA_OUI*)
+ ifconfig of0 down
+ must_succeed "Setting of0 MAC address to $UUID_MAC" ifconfig of0 hw ether $UUID_MAC
+ ifconfig of0 up
+ ;;
+ esac
+ fi
;;
$xx:$xx:$xx:$xx:$xx:$xx)
ifconfig of0 down
# 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.
+# By default, the switch checks if the DMI System UUID contains a Nicira
+# mac address to use as a datapath ID. If not, then the switch generates
+# a new, random datapath ID every time it starts up. By setting this
+# value, the supplied datapath ID will always be used.
#
# 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).