Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142002097
D1858.id3797.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D1858.id3797.diff
View Options
Index: sys/net/if_epair.c
===================================================================
--- sys/net/if_epair.c
+++ sys/net/if_epair.c
@@ -51,6 +51,7 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/mbuf.h>
#include <sys/module.h>
@@ -61,6 +62,9 @@
#include <sys/sockio.h>
#include <sys/sysctl.h>
#include <sys/types.h>
+#include <sys/ucred.h>
+#include <sys/systm.h>
+#include <sys/counter.h>
#include <net/bpf.h>
#include <net/ethernet.h>
@@ -138,6 +142,9 @@
/* Original if_qflush routine. */
};
+/* A system-wide conter for the number of epair interfaces. */
+static counter_u64_t epair_cnt;
+
/*
* Per-CPU list of ifps with data in the ifq that needs to be flushed
* to the netisr ``hw'' queue before we allow any further direct queuing
@@ -709,7 +716,7 @@
struct epair_softc *sca, *scb;
struct ifnet *ifp;
char *dp;
- int error, unit, wildcard;
+ int error, unit, wildcard, jid;
uint8_t eaddr[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */
/*
@@ -718,15 +725,20 @@
* for it to do the official insertion procedure the moment we knew
* it cannot fail anymore. So just do attach it here.
*/
+ bzero(eaddr, sizeof(eaddr));
+ jid = curthread->td_ucred->cr_prison->pr_id;
if (params) {
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] = (jid >> 8) & 0xff;
+ eaddr[2] = jid & 0xff;
+ eaddr[3] = (counter_u64_fetch(epair_cnt) >> 8) & 0xff;
+ eaddr[4] = counter_u64_fetch(epair_cnt) & 0xff;
eaddr[5] = 0x0b;
ether_ifattach(ifp, eaddr);
+ counter_u64_add(epair_cnt, 1);
/* Correctly set the name for the cloner list. */
strlcpy(name, scb->ifp->if_xname, len);
return (0);
@@ -825,10 +837,13 @@
ifp->if_snd.ifq_maxlen = ifqmaxlen;
/* 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] = (jid >> 8) & 0xff;
+ eaddr[2] = jid & 0xff;
+ eaddr[3] = (counter_u64_fetch(epair_cnt) >> 8) & 0xff;
+ eaddr[4] = counter_u64_fetch(epair_cnt) & 0xff;
eaddr[5] = 0x0a;
ether_ifattach(ifp, eaddr);
+ counter_u64_add(epair_cnt, 1);
sca->if_qflush = ifp->if_qflush;
ifp->if_qflush = epair_qflush;
ifp->if_transmit = epair_transmit;
@@ -919,6 +934,7 @@
*/
CURVNET_SET_QUIET(oifp->if_vnet);
ether_ifdetach(oifp);
+ counter_u64_add(epair_cnt, -1);
/*
* Wait for all packets to be dispatched to if_input.
* The numbers can only go down as the interface is
@@ -938,6 +954,7 @@
CURVNET_RESTORE();
ether_ifdetach(ifp);
+ counter_u64_add(epair_cnt, -1);
/*
* Wait for all packets to be dispatched to if_input.
*/
@@ -978,6 +995,7 @@
switch (type) {
case MOD_LOAD:
+ epair_cnt = counter_u64_alloc(M_WAITOK);
/* For now limit us to one global mutex and one inq. */
epair_dpcpu_init();
epair_nh.nh_qlimit = 42 * ifqmaxlen; /* 42 shall be the number. */
@@ -990,6 +1008,7 @@
case MOD_UNLOAD:
netisr_unregister(&epair_nh);
epair_dpcpu_detach();
+ counter_u64_free(epair_cnt);
if (bootverbose)
printf("%s unloaded.\n", epairname);
break;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 15, 6:20 PM (14 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27650061
Default Alt Text
D1858.id3797.diff (3 KB)
Attached To
Mode
D1858: Improvement for MAC address uniqueness of if_epair(4)
Attached
Detach File
Event Timeline
Log In to Comment