Index: sys/net/if_epair.c =================================================================== --- sys/net/if_epair.c +++ sys/net/if_epair.c @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include @@ -108,7 +107,6 @@ static int epair_clone_destroy(struct if_clone *, struct ifnet *); static const char epairname[] = "epair"; -static unsigned int next_index = 0; /* Netisr related definitions and sysctl. */ static struct netisr_handler epair_nh = { @@ -722,7 +720,8 @@ ifp = scb->ifp; /* Copy epairNa etheraddr and change the last byte. */ memcpy(eaddr, scb->oifp->if_hw_addr, ETHER_ADDR_LEN); - eaddr[5] = 0x0b; + eaddr[5] &= 0xf0; + eaddr[5] |= 0x0b; ether_ifattach(ifp, eaddr); if_clone_addif(ifc, ifp); @@ -735,10 +734,7 @@ struct ifnet *ifp; char *dp; int error, unit, wildcard; - uint64_t hostid; - uint32_t key[3]; - uint32_t hash; - uint8_t eaddr[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */ + struct ether_addr eaddr; /* Try to see if a special unit was requested. */ error = ifc_name2unit(name, &unit); @@ -841,32 +837,10 @@ if_setsendqlen(ifp, ifqmaxlen); if_setsendqready(ifp); - /* - * Calculate the etheraddr hashing the hostid and the - * interface index. The result would be hopefully unique. - * Note that the "a" component of an epair instance may get moved - * to a different VNET after creation. In that case its index - * will be freed and the index can get reused by new epair instance. - * Make sure we do not create same etheraddr again. - */ - getcredhostid(curthread->td_ucred, (unsigned long *)&hostid); - if (hostid == 0) - arc4rand(&hostid, sizeof(hostid), 0); - - if (ifp->if_index > next_index) - next_index = ifp->if_index; - else - next_index++; - - key[0] = (uint32_t)next_index; - key[1] = (uint32_t)(hostid & 0xffffffff); - key[2] = (uint32_t)((hostid >> 32) & 0xfffffffff); - hash = jenkins_hash32(key, 3, 0); - - eaddr[0] = 0x02; - memcpy(&eaddr[1], &hash, 4); - eaddr[5] = 0x0a; - ether_ifattach(ifp, eaddr); + ether_gen_addr(ifp, &eaddr); + eaddr.octet[5] &= 0xf0; + eaddr.octet[5] |= 0x0a; + ether_ifattach(ifp, eaddr.octet); sca->if_qflush = ifp->if_qflush; ifp->if_qflush = epair_qflush; ifp->if_transmit = epair_transmit;