aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-05-13 12:04:22 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-05-13 12:04:22 +0000
commitbcd7d53eb4d5e71611e1caef94b05f9da6cf101c (patch)
tree6b11d0d5cdbf637be955a48fede34d69e3d73297
parent08874b8ef46153c23673d8e86bb461519b9ff09d (diff)
downloadxen-bcd7d53eb4d5e71611e1caef94b05f9da6cf101c.tar.gz
xen-bcd7d53eb4d5e71611e1caef94b05f9da6cf101c.tar.bz2
xen-bcd7d53eb4d5e71611e1caef94b05f9da6cf101c.zip
bitkeeper revision 1.226 (3ec0df46i6UtPbpFHgTTjTc0tGIKIA)
network.c, kernel.c: Changes to dynamic MAC address calculation -- now based on domain name rather than domain id.
-rw-r--r--xen/common/kernel.c18
-rw-r--r--xen/common/network.c22
2 files changed, 18 insertions, 22 deletions
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 5b1d0f9804..ecb3e6ebf2 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -41,22 +41,20 @@ unsigned int opt_dom0_mem = 16000; /* default kbytes for DOM0 */
unsigned int opt_ne_base = 0; /* NE2k NICs cannot be probed */
unsigned char opt_ifname[10] = "eth0";
int opt_noht=0, opt_noacpi=0, opt_nosmp=0;
-int opt_phys_bootmac=0; /* Is DOM0/VIF0 allocated the physical MAC address? */
enum { OPT_IP, OPT_STR, OPT_UINT, OPT_BOOL };
static struct {
unsigned char *name;
int type;
void *var;
} opts[] = {
- { "console", OPT_UINT, &opt_console },
- { "ser_baud", OPT_UINT, &opt_ser_baud },
- { "dom0_mem", OPT_UINT, &opt_dom0_mem },
- { "ne_base", OPT_UINT, &opt_ne_base },
- { "ifname", OPT_STR, &opt_ifname },
- { "noht", OPT_BOOL, &opt_noht },
- { "noacpi", OPT_BOOL, &opt_noacpi },
- { "nosmp", OPT_BOOL, &opt_nosmp },
- { "phys_bootmac", OPT_BOOL, &opt_phys_bootmac },
+ { "console", OPT_UINT, &opt_console },
+ { "ser_baud", OPT_UINT, &opt_ser_baud },
+ { "dom0_mem", OPT_UINT, &opt_dom0_mem },
+ { "ne_base", OPT_UINT, &opt_ne_base },
+ { "ifname", OPT_STR, &opt_ifname },
+ { "noht", OPT_BOOL, &opt_noht },
+ { "noacpi", OPT_BOOL, &opt_noacpi },
+ { "nosmp", OPT_BOOL, &opt_nosmp },
{ NULL, 0, NULL }
};
diff --git a/xen/common/network.c b/xen/common/network.c
index 9a2d5eef8a..a2ef951936 100644
--- a/xen/common/network.c
+++ b/xen/common/network.c
@@ -70,8 +70,7 @@ net_vif_t *create_net_vif(int domain)
net_ring_t *new_ring = NULL;
struct task_struct *p = NULL;
unsigned long flags, vmac_hash;
- unsigned char vmac_key[ETH_ALEN + 4 + 2];
- extern int opt_phys_bootmac;
+ unsigned char vmac_key[ETH_ALEN + 2 + MAX_DOMAIN_NAME];
if ( !(p = find_domain_by_id(domain)) )
return NULL;
@@ -106,12 +105,12 @@ net_vif_t *create_net_vif(int domain)
spin_lock_init(&new_vif->rx_lock);
spin_lock_init(&new_vif->tx_lock);
- if ( opt_phys_bootmac && (p->domain == 0) && (dom_vif_idx == 0) )
+ if ( (p->domain == 0) && (dom_vif_idx == 0) )
{
/*
- * DOM0/VIF0 may get the real physical MAC address, so that
- * users can easily get a Xenoserver up and running by using an
- * existing DHCP entry.
+ * DOM0/VIF0 gets the real physical MAC address, so that users can
+ * easily get a Xenoserver up and running by using an existing DHCP
+ * entry.
*/
memcpy(new_vif->vmac, the_dev->dev_addr, ETH_ALEN);
}
@@ -120,9 +119,8 @@ net_vif_t *create_net_vif(int domain)
/*
* Most VIFs get a random MAC address with a "special" vendor id.
* We try to get MAC addresses to be unique across multiple servers
- * by including the physical MAC address in the hash.
- * However, the same machine with the same dom_id and vif_id should
- * always get the same virtual MAC address.
+ * by including the physical MAC address in the hash. The hash also
+ * includes the vif index and the domain's name.
*
* NB. The vendor is currently an "obsolete" one that used to belong
* to DEC (AA-00-00). Using it is probably a bit rude :-)
@@ -132,9 +130,9 @@ net_vif_t *create_net_vif(int domain)
* MAC addresses for some VIFs with no fear of clashes.
*/
memcpy(&vmac_key[0], the_dev->dev_addr, ETH_ALEN);
- *(__u32 *)(&vmac_key[ETH_ALEN+0]) = htonl(p->domain);
- *(__u16 *)(&vmac_key[ETH_ALEN+4]) = htons(dom_vif_idx);
- vmac_hash = hash(vmac_key, ETH_ALEN+4+2);
+ *(__u16 *)(&vmac_key[ETH_ALEN]) = htons(dom_vif_idx);
+ strcpy(&vmac_key[ETH_ALEN+2], p->name);
+ vmac_hash = hash(vmac_key, ETH_ALEN + 2 + strlen(p->name));
memcpy(new_vif->vmac, "\xaa\x00\x00", 3);
new_vif->vmac[3] = (vmac_hash >> 16) & 0xef; /* First bit is zero. */
new_vif->vmac[4] = (vmac_hash >> 8) & 0xff;