Page MenuHomeFreeBSD

D15329.id42226.diff
No OneTemporary

D15329.id42226.diff

Index: sys/net/if_epair.c
===================================================================
--- sys/net/if_epair.c
+++ sys/net/if_epair.c
@@ -53,10 +53,13 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/jail.h>
#include <sys/kernel.h>
+#include <sys/libkern.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/module.h>
+#include <sys/proc.h>
#include <sys/refcount.h>
#include <sys/queue.h>
#include <sys/smp.h>
@@ -713,6 +716,7 @@
struct ifnet *ifp;
char *dp;
int error, unit, wildcard;
+ unsigned long hostid;
uint8_t eaddr[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */
/*
@@ -722,12 +726,18 @@
* it cannot fail anymore. So just do attach it here.
*/
if (params) {
+ getcredhostid(curthread->td_ucred, &hostid);
+ if (hostid == 0)
+ arc4rand(&hostid, (sizeof(unsigned long)), 0);
+
scb = (struct epair_softc *)params;
ifp = scb->ifp;
/* Assign a hopefully unique, locally administered etheraddr. */
eaddr[0] = 0x02;
- eaddr[3] = (ifp->if_index >> 8) & 0xff;
- eaddr[4] = ifp->if_index & 0xff;
+ eaddr[1] = ((uint8_t *)(scb->oifp->if_hw_addr))[1];
+ eaddr[2] = ((uint8_t *)(scb->oifp->if_hw_addr))[2];
+ eaddr[3] = (scb->oifp->if_index >> 8) & 0xff;
+ eaddr[4] = scb->oifp->if_index & 0xff;
eaddr[5] = 0x0b;
ether_ifattach(ifp, eaddr);
/* Correctly set the name for the cloner list. */
@@ -836,7 +846,13 @@
if_setsendqlen(ifp, ifqmaxlen);
if_setsendqready(ifp);
/* Assign a hopefully unique, locally administered etheraddr. */
+ getcredhostid(curthread->td_ucred, &hostid);
+ if (hostid == 0)
+ arc4rand(&hostid, (sizeof(unsigned long)), 0);
+
eaddr[0] = 0x02;
+ eaddr[1] = (hostid >> 8) & 0xff;
+ eaddr[2] = hostid & 0xff;
eaddr[3] = (ifp->if_index >> 8) & 0xff;
eaddr[4] = ifp->if_index & 0xff;
eaddr[5] = 0x0a;

File Metadata

Mime Type
text/plain
Expires
Fri, May 29, 2:28 AM (6 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33597256
Default Alt Text
D15329.id42226.diff (1 KB)

Event Timeline