ia64/xen-unstable
changeset 445:53f6ba7cee5d
bitkeeper revision 1.226 (3ec0df46i6UtPbpFHgTTjTc0tGIKIA)
network.c, kernel.c:
Changes to dynamic MAC address calculation -- now based on domain name rather than domain id.
network.c, kernel.c:
Changes to dynamic MAC address calculation -- now based on domain name rather than domain id.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Tue May 13 12:04:22 2003 +0000 (2003-05-13) |
parents | 5c7227b5427c |
children | 553dadf99bbc |
files | xen/common/kernel.c xen/common/network.c |
line diff
1.1 --- a/xen/common/kernel.c Tue May 13 11:31:46 2003 +0000 1.2 +++ b/xen/common/kernel.c Tue May 13 12:04:22 2003 +0000 1.3 @@ -41,22 +41,20 @@ unsigned int opt_dom0_mem = 16000; /* de 1.4 unsigned int opt_ne_base = 0; /* NE2k NICs cannot be probed */ 1.5 unsigned char opt_ifname[10] = "eth0"; 1.6 int opt_noht=0, opt_noacpi=0, opt_nosmp=0; 1.7 -int opt_phys_bootmac=0; /* Is DOM0/VIF0 allocated the physical MAC address? */ 1.8 enum { OPT_IP, OPT_STR, OPT_UINT, OPT_BOOL }; 1.9 static struct { 1.10 unsigned char *name; 1.11 int type; 1.12 void *var; 1.13 } opts[] = { 1.14 - { "console", OPT_UINT, &opt_console }, 1.15 - { "ser_baud", OPT_UINT, &opt_ser_baud }, 1.16 - { "dom0_mem", OPT_UINT, &opt_dom0_mem }, 1.17 - { "ne_base", OPT_UINT, &opt_ne_base }, 1.18 - { "ifname", OPT_STR, &opt_ifname }, 1.19 - { "noht", OPT_BOOL, &opt_noht }, 1.20 - { "noacpi", OPT_BOOL, &opt_noacpi }, 1.21 - { "nosmp", OPT_BOOL, &opt_nosmp }, 1.22 - { "phys_bootmac", OPT_BOOL, &opt_phys_bootmac }, 1.23 + { "console", OPT_UINT, &opt_console }, 1.24 + { "ser_baud", OPT_UINT, &opt_ser_baud }, 1.25 + { "dom0_mem", OPT_UINT, &opt_dom0_mem }, 1.26 + { "ne_base", OPT_UINT, &opt_ne_base }, 1.27 + { "ifname", OPT_STR, &opt_ifname }, 1.28 + { "noht", OPT_BOOL, &opt_noht }, 1.29 + { "noacpi", OPT_BOOL, &opt_noacpi }, 1.30 + { "nosmp", OPT_BOOL, &opt_nosmp }, 1.31 { NULL, 0, NULL } 1.32 }; 1.33
2.1 --- a/xen/common/network.c Tue May 13 11:31:46 2003 +0000 2.2 +++ b/xen/common/network.c Tue May 13 12:04:22 2003 +0000 2.3 @@ -70,8 +70,7 @@ net_vif_t *create_net_vif(int domain) 2.4 net_ring_t *new_ring = NULL; 2.5 struct task_struct *p = NULL; 2.6 unsigned long flags, vmac_hash; 2.7 - unsigned char vmac_key[ETH_ALEN + 4 + 2]; 2.8 - extern int opt_phys_bootmac; 2.9 + unsigned char vmac_key[ETH_ALEN + 2 + MAX_DOMAIN_NAME]; 2.10 2.11 if ( !(p = find_domain_by_id(domain)) ) 2.12 return NULL; 2.13 @@ -106,12 +105,12 @@ net_vif_t *create_net_vif(int domain) 2.14 spin_lock_init(&new_vif->rx_lock); 2.15 spin_lock_init(&new_vif->tx_lock); 2.16 2.17 - if ( opt_phys_bootmac && (p->domain == 0) && (dom_vif_idx == 0) ) 2.18 + if ( (p->domain == 0) && (dom_vif_idx == 0) ) 2.19 { 2.20 /* 2.21 - * DOM0/VIF0 may get the real physical MAC address, so that 2.22 - * users can easily get a Xenoserver up and running by using an 2.23 - * existing DHCP entry. 2.24 + * DOM0/VIF0 gets the real physical MAC address, so that users can 2.25 + * easily get a Xenoserver up and running by using an existing DHCP 2.26 + * entry. 2.27 */ 2.28 memcpy(new_vif->vmac, the_dev->dev_addr, ETH_ALEN); 2.29 } 2.30 @@ -120,9 +119,8 @@ net_vif_t *create_net_vif(int domain) 2.31 /* 2.32 * Most VIFs get a random MAC address with a "special" vendor id. 2.33 * We try to get MAC addresses to be unique across multiple servers 2.34 - * by including the physical MAC address in the hash. 2.35 - * However, the same machine with the same dom_id and vif_id should 2.36 - * always get the same virtual MAC address. 2.37 + * by including the physical MAC address in the hash. The hash also 2.38 + * includes the vif index and the domain's name. 2.39 * 2.40 * NB. The vendor is currently an "obsolete" one that used to belong 2.41 * to DEC (AA-00-00). Using it is probably a bit rude :-) 2.42 @@ -132,9 +130,9 @@ net_vif_t *create_net_vif(int domain) 2.43 * MAC addresses for some VIFs with no fear of clashes. 2.44 */ 2.45 memcpy(&vmac_key[0], the_dev->dev_addr, ETH_ALEN); 2.46 - *(__u32 *)(&vmac_key[ETH_ALEN+0]) = htonl(p->domain); 2.47 - *(__u16 *)(&vmac_key[ETH_ALEN+4]) = htons(dom_vif_idx); 2.48 - vmac_hash = hash(vmac_key, ETH_ALEN+4+2); 2.49 + *(__u16 *)(&vmac_key[ETH_ALEN]) = htons(dom_vif_idx); 2.50 + strcpy(&vmac_key[ETH_ALEN+2], p->name); 2.51 + vmac_hash = hash(vmac_key, ETH_ALEN + 2 + strlen(p->name)); 2.52 memcpy(new_vif->vmac, "\xaa\x00\x00", 3); 2.53 new_vif->vmac[3] = (vmac_hash >> 16) & 0xef; /* First bit is zero. */ 2.54 new_vif->vmac[4] = (vmac_hash >> 8) & 0xff;