mirror of
https://github.com/xen-project/xen.git
synced 2026-10-30 03:00:05 +01:00
bitkeeper revision 1.226 (3ec0df46i6UtPbpFHgTTjTc0tGIKIA)
network.c, kernel.c: Changes to dynamic MAC address calculation -- now based on domain name rather than domain id.
This commit is contained in:
1 parent
08874b8ef4
commit
bcd7d53eb4
2 files changed
+18
-22
No files matched your search
+8
-10
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
+10
-12
@@ -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;
|
||||
|
||||