Update to FreeBSD head 2016-08-23

Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
This commit is contained in:
Sebastian Huber
2016-10-07 15:10:20 +02:00
parent 8c0eebac7d
commit c40e45b75e
1040 changed files with 156866 additions and 67039 deletions

View File

@@ -48,10 +48,14 @@
#include <net/bpf.h> /* bpf(9) */
#include <net/ethernet.h> /* Ethernet related constants and types */
#include <net/if.h> /* basic part of ifnet(9) */
#include <net/if.h>
#include <net/if_var.h> /* basic part of ifnet(9) */
#include <net/if_clone.h> /* network interface cloning */
#include <net/if_types.h> /* IFT_ETHER and friends */
#include <net/if_var.h> /* kernel-only part of ifnet(9) */
#include <net/vnet.h>
static const char edscname[] = "edsc";
/*
* Software configuration of an interface specific to this device type.
@@ -66,9 +70,10 @@ struct edsc_softc {
};
/*
* Simple cloning methods.
* IFC_SIMPLE_DECLARE() expects precisely these names.
* Attach to the interface cloning framework.
*/
static VNET_DEFINE(struct if_clone *, edsc_cloner);
#define V_edsc_cloner VNET(edsc_cloner)
static int edsc_clone_create(struct if_clone *, int, caddr_t);
static void edsc_clone_destroy(struct ifnet *);
@@ -83,15 +88,7 @@ static void edsc_start(struct ifnet *ifp);
/*
* We'll allocate softc instances from this.
*/
static MALLOC_DEFINE(M_EDSC, "edsc", "Ethernet discard interface");
/*
* Attach to the interface cloning framework under the name of "edsc".
* The second argument is the number of units to be created from
* the outset. It's also the minimum number of units allowed.
* We don't want any units created as soon as the driver is loaded.
*/
IFC_SIMPLE_DECLARE(edsc, 0);
static MALLOC_DEFINE(M_EDSC, edscname, "Ethernet discard interface");
/*
* Create an interface instance.
@@ -118,7 +115,7 @@ edsc_clone_create(struct if_clone *ifc, int unit, caddr_t params)
/*
* Get a name for this particular interface in its ifnet structure.
*/
if_initname(ifp, ifc->ifc_name, unit);
if_initname(ifp, edscname, unit);
/*
* Typical Ethernet interface flags: we can do broadcast and
@@ -298,8 +295,8 @@ edsc_start(struct ifnet *ifp)
/*
* Update the interface counters.
*/
ifp->if_obytes += m->m_pkthdr.len;
ifp->if_opackets++;
if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
/*
* Finally, just drop the packet.
@@ -314,6 +311,36 @@ edsc_start(struct ifnet *ifp)
*/
}
static void
vnet_edsc_init(const void *unused __unused)
{
/*
* Connect to the network interface cloning framework.
* The last argument is the number of units to be created
* from the outset. It's also the minimum number of units
* allowed. We don't want any units created as soon as the
* driver is loaded.
*/
V_edsc_cloner = if_clone_simple(edscname, edsc_clone_create,
edsc_clone_destroy, 0);
}
VNET_SYSINIT(vnet_edsc_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
vnet_edsc_init, NULL);
static void
vnet_edsc_uninit(const void *unused __unused)
{
/*
* Disconnect from the cloning framework.
* Existing interfaces will be disposed of properly.
*/
if_clone_detach(V_edsc_cloner);
}
VNET_SYSUNINIT(vnet_edsc_uninit, SI_SUB_INIT_IF, SI_ORDER_ANY,
vnet_edsc_uninit, NULL);
/*
* This function provides handlers for module events, namely load and unload.
*/
@@ -323,20 +350,8 @@ edsc_modevent(module_t mod, int type, void *data)
switch (type) {
case MOD_LOAD:
/*
* Connect to the network interface cloning framework.
*/
if_clone_attach(&edsc_cloner);
break;
case MOD_UNLOAD:
/*
* Disconnect from the cloning framework.
* Existing interfaces will be disposed of properly.
*/
if_clone_detach(&edsc_cloner);
break;
default:
/*
* There are other event types, but we don't handle them.