Lines 107-112
static int epair_clone_create(struct if_
Link Here
|
107 |
static int epair_clone_destroy(struct if_clone *, struct ifnet *); |
107 |
static int epair_clone_destroy(struct if_clone *, struct ifnet *); |
108 |
|
108 |
|
109 |
static const char epairname[] = "epair"; |
109 |
static const char epairname[] = "epair"; |
|
|
110 |
static unsigned int next_index = 0; |
110 |
|
111 |
|
111 |
/* Netisr related definitions and sysctl. */ |
112 |
/* Netisr related definitions and sysctl. */ |
112 |
static struct netisr_handler epair_nh = { |
113 |
static struct netisr_handler epair_nh = { |
Lines 843-854
epair_clone_create(struct if_clone *ifc,
Link Here
|
843 |
|
844 |
|
844 |
/* |
845 |
/* |
845 |
* Calculate the etheraddr hashing the hostid and the |
846 |
* Calculate the etheraddr hashing the hostid and the |
846 |
* interface index. The result would be hopefully unique |
847 |
* interface index. The result would be hopefully unique. |
|
|
848 |
* Note that epair(4) may be created then "a" part moved to another |
849 |
* VNET freeing if_index so next epair obtains same if_index. |
850 |
* Make sure we do not create same etheraddr again. |
847 |
*/ |
851 |
*/ |
848 |
getcredhostid(curthread->td_ucred, (unsigned long *)&hostid); |
852 |
getcredhostid(curthread->td_ucred, (unsigned long *)&hostid); |
849 |
if (hostid == 0) |
853 |
if (hostid == 0) |
850 |
arc4rand(&hostid, sizeof(hostid), 0); |
854 |
arc4rand(&hostid, sizeof(hostid), 0); |
851 |
key[0] = (uint32_t)ifp->if_index; |
855 |
|
|
|
856 |
if (ifp->if_index > next_index) |
857 |
next_index = ifp->if_index; |
858 |
else |
859 |
next_index++; |
860 |
|
861 |
key[0] = (uint32_t)next_index; |
852 |
key[1] = (uint32_t)(hostid & 0xffffffff); |
862 |
key[1] = (uint32_t)(hostid & 0xffffffff); |
853 |
key[2] = (uint32_t)((hostid >> 32) & 0xfffffffff); |
863 |
key[2] = (uint32_t)((hostid >> 32) & 0xfffffffff); |
854 |
hash = jenkins_hash32(key, 3, 0); |
864 |
hash = jenkins_hash32(key, 3, 0); |