Example #1
0
#define GRE_RECURSION_LIMIT	3   /* How many levels of recursion allowed */
#endif /* GRE_RECURSION_LIMIT */

/*
 * It is not easy to calculate the right value for a GRE MTU.
 * We leave this task to the admin and use the same default that
 * other vendors use.
 */
#define GREMTU 1476

int	gre_clone_create(struct if_clone *, int);
int	gre_clone_destroy(struct ifnet *);

struct gre_softc_head gre_softc_list;
struct if_clone gre_cloner =
    IF_CLONE_INITIALIZER("gre", gre_clone_create, gre_clone_destroy);

/*
 * We can control the acceptance of GRE and MobileIP packets by
 * altering the sysctl net.inet.gre.allow and net.inet.mobileip.allow values
 * respectively. Zero means drop them, all else is acceptance.  We can also
 * control acceptance of WCCPv1-style GRE packets through the
 * net.inet.gre.wccp value, but be aware it depends upon normal GRE being
 * allowed as well.
 * 
 */
int gre_allow = 0;
int gre_wccp = 0;
int ip_mobile_allow = 0;

void gre_keepalive(void *);
Example #2
0
struct compressor *ppp_compressors[8] = {
#if DO_BSD_COMPRESS && defined(PPP_BSDCOMP)
    &ppp_bsd_compress,
#endif
#if DO_DEFLATE && defined(PPP_DEFLATE)
    &ppp_deflate,
    &ppp_deflate_draft,
#endif
    NULL
};
#endif /* PPP_COMPRESS */

LIST_HEAD(, ppp_softc) ppp_softc_list;
struct if_clone ppp_cloner =
    IF_CLONE_INITIALIZER("ppp", ppp_clone_create, ppp_clone_destroy);

/*
 * Called from boot code to establish ppp interfaces.
 */
void
pppattach()
{
    LIST_INIT(&ppp_softc_list);
    if_clone_attach(&ppp_cloner);
}

int
ppp_clone_create(ifc, unit)
    struct if_clone *ifc;
    int unit;
Example #3
0
#include <netinet/in.h>
#include <netinet/in_var.h>

#include <rump/rump.h>
#include <rump/rumpuser.h>

#include "rump_private.h"
#include "rump_net_private.h"
#include "shmif_user.h"

static int shmif_clone(struct if_clone *, int);
static int shmif_unclone(struct ifnet *);

struct if_clone shmif_cloner =
    IF_CLONE_INITIALIZER("shmif", shmif_clone, shmif_unclone);

/*
 * Do r/w prefault for backend pages when attaching the interface.
 * At least logically thinking improves performance (although no
 * mlocking is done, so they might go away).
 */
#define PREFAULT_RW

/*
 * A virtual ethernet interface which uses shared memory from a
 * memory mapped file as the bus.
 */

static int	shmif_init(struct ifnet *);
static int	shmif_ioctl(struct ifnet *, u_long, void *);
Example #4
0
File: if_pflog.c Project: argp/xnu
static int pflog_remove(struct ifnet *);
static int pflog_clone_create(struct if_clone *, u_int32_t, void *);
static int pflog_clone_destroy(struct ifnet *);
static errno_t pflogoutput(struct ifnet *, struct mbuf *);
static errno_t pflogioctl(struct ifnet *, unsigned long, void *);
static errno_t pflogdemux(struct ifnet *, struct mbuf *, char *,
    protocol_family_t *);
static errno_t pflogaddproto(struct ifnet *, protocol_family_t,
    const struct ifnet_demux_desc *, u_int32_t);
static errno_t pflogdelproto(struct ifnet *, protocol_family_t);
static void pflogfree(struct ifnet *);

static LIST_HEAD(, pflog_softc)	pflogif_list;
static struct if_clone pflog_cloner =
    IF_CLONE_INITIALIZER(PFLOGNAME, pflog_clone_create, pflog_clone_destroy,
        0, (PFLOGIFS_MAX - 1), PFLOGIF_ZONE_MAX_ELEM, sizeof(struct pflog_softc));

struct ifnet *pflogifs[PFLOGIFS_MAX];	/* for fast access */

void
pfloginit(void)
{
	int i;

	LIST_INIT(&pflogif_list);
	for (i = 0; i < PFLOGIFS_MAX; i++)
		pflogifs[i] = NULL;

	(void) if_clone_attach(&pflog_cloner);
}
Example #5
0
static void	virtif_start(struct ifnet *);
static void	virtif_stop(struct ifnet *, int);

struct virtif_sc {
	struct ethercom sc_ec;
	struct virtif_user *sc_viu;

	int sc_num;
	char *sc_linkstr;
};

static int  virtif_clone(struct if_clone *, int);
static int  virtif_unclone(struct ifnet *);

struct if_clone VIF_CLONER =
    IF_CLONE_INITIALIZER(VIF_NAME, virtif_clone, virtif_unclone);

static int
virtif_create(struct ifnet *ifp)
{
	uint8_t enaddr[ETHER_ADDR_LEN] = { 0xb2, 0x0a, 0x00, 0x0b, 0x0e, 0x01 };
	char enaddrstr[3*ETHER_ADDR_LEN];
	struct virtif_sc *sc = ifp->if_softc;
	int error;

	if (sc->sc_viu)
		panic("%s: already created", ifp->if_xname);

	enaddr[2] = cprng_fast32() & 0xff;
	enaddr[5] = sc->sc_num & 0xff;
Example #6
0
int	pairioctl(struct ifnet *, u_long, caddr_t);
void	pairstart(struct ifnet *);
int	pair_clone_create(struct if_clone *, int);
int	pair_clone_destroy(struct ifnet *);
int	pair_media_change(struct ifnet *);
void	pair_media_status(struct ifnet *, struct ifmediareq *);
void	pair_link_state(struct ifnet *);

struct pair_softc {
	struct arpcom		sc_ac;
	struct ifmedia		sc_media;
	unsigned int		sc_pairedif;
};

struct if_clone	pair_cloner =
    IF_CLONE_INITIALIZER("pair", pair_clone_create, pair_clone_destroy);

int
pair_media_change(struct ifnet *ifp)
{
	return (0);
}

void
pair_media_status(struct ifnet *ifp, struct ifmediareq *imr)
{
	struct pair_softc	*sc = ifp->if_softc;
	struct ifnet		*pairedifp;

	imr->ifm_active = IFM_ETHER | IFM_AUTO;
Example #7
0
int faithoutput (struct ifnet *, struct mbuf *, struct sockaddr *,
	struct rtentry *);
static void faithrtrequest (int, struct rtentry *, struct rt_addrinfo *);
#ifdef INET6
static int faithprefix (struct in6_addr *);
#endif

static int faithmodevent (module_t, int, void *);

static MALLOC_DEFINE(M_FAITH, FAITHNAME, "Firewall Assisted Tunnel Interface");
LIST_HEAD(, faith_softc) faith_softc_list;

int	faith_clone_create (struct if_clone *, int, caddr_t);
int	faith_clone_destroy (struct ifnet *);

struct if_clone faith_cloner = IF_CLONE_INITIALIZER(FAITHNAME,
    faith_clone_create, faith_clone_destroy, NFAITH, IF_MAXUNIT);

#define	FAITHMTU	1500

static int
faithmodevent(module_t mod, int type, void *data)
{

	switch (type) {
	case MOD_LOAD:
		LIST_INIT(&faith_softc_list);
		if_clone_attach(&faith_cloner);

#ifdef INET6
		faithprefix_p = faithprefix;
#endif
Example #8
0
#define DPRINTF(x)    do { if (pflogdebug) printf x ; } while (0)
#else
#define DPRINTF(x)
#endif

void	pflogattach(int);
int	pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
	    	       struct rtentry *);
int	pflogioctl(struct ifnet *, u_long, caddr_t);
void	pflogstart(struct ifnet *);
int	pflog_clone_create(struct if_clone *, int);
int	pflog_clone_destroy(struct ifnet *);

LIST_HEAD(, pflog_softc)	pflogif_list;
struct if_clone	pflog_cloner =
    IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy);

struct ifnet	*pflogifs[PFLOGIFS_MAX];	/* for fast access */

void
pflogattach(int npflog)
{
	int	i;
	LIST_INIT(&pflogif_list);
	for (i = 0; i < PFLOGIFS_MAX; i++)
		pflogifs[i] = NULL;
	if_clone_attach(&pflog_cloner);
}

int
pflog_clone_create(struct if_clone *ifc, int unit)
Example #9
0

#define FRAME_END	 	0xc0		/* Frame End */
#define FRAME_ESCAPE		0xdb		/* Frame Esc */
#define TRANS_FRAME_END	 	0xdc		/* transposed frame end */
#define TRANS_FRAME_ESCAPE 	0xdd		/* transposed frame esc */

static int slinit(struct sl_softc *);
static struct mbuf *sl_btom(struct sl_softc *, int);

int	sl_clone_create(struct if_clone *, int);
int	sl_clone_destroy(struct ifnet *);

LIST_HEAD(, sl_softc) sl_softc_list;
struct if_clone sl_cloner =
    IF_CLONE_INITIALIZER("sl", sl_clone_create, sl_clone_destroy);

/*
 * Called from boot code to establish sl interfaces.
 */
void
slattach(n)
	int n;
{
	LIST_INIT(&sl_softc_list);
	if_clone_attach(&sl_cloner);
}

int
sl_clone_create(ifc, unit)
	struct if_clone *ifc;
Example #10
0
 */
#define GREMTU	1476

#define GRENAME	"gre"

static MALLOC_DEFINE(M_GRE, GRENAME, "Generic Routing Encapsulation");

struct gre_softc_head gre_softc_list;

static int	gre_clone_create(struct if_clone *, int, caddr_t);
static int	gre_clone_destroy(struct ifnet *);
static int	gre_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
static int	gre_output(struct ifnet *, struct mbuf *, struct sockaddr *,
		    struct rtentry *rt);

static struct if_clone gre_cloner = IF_CLONE_INITIALIZER("gre",
    gre_clone_create, gre_clone_destroy, 0, IF_MAXUNIT);

static int	gre_compute_route(struct gre_softc *sc, struct route *);
static int	gre_check_route(struct gre_softc *sc);

static void	greattach(void);

#ifdef INET

extern struct domain inetdomain;

static const struct protosw in_gre_protosw =
    {
	.pr_type = SOCK_RAW,
	.pr_domain = &inetdomain,
	.pr_protocol = IPPROTO_GRE,
Example #11
0
	if (log_if_table[unit] == NULL) {
		return EINVAL;
	}
	LOGIF_WLOCK();
	log_if_table[unit] = NULL;
	bpfdetach(ifp);
	if_detach(ifp);
	if_free(ifp);
	log_if_count--;
	LOGIF_WUNLOCK();

	return (0);
}

static eventhandler_tag ipfw_log_ifdetach_cookie;
static struct if_clone ipfw_log_cloner = IF_CLONE_INITIALIZER(ipfw_log_ifname,
		ipfw_log_clone_create, ipfw_log_clone_destroy, 0, 9);


void ipfw3_log_modevent(int type){
	struct ifnet *tmpif;
	int i;

	switch (type) {
	case MOD_LOAD:
		LOGIF_LOCK_INIT();
		log_if_count = 0;
		if_clone_attach(&ipfw_log_cloner);
		ipfw_log_ifdetach_cookie =
			EVENTHANDLER_REGISTER(ifnet_detach_event,
				ipfw_log_clone_destroy, &ipfw_log_cloner,
				EVENTHANDLER_PRI_ANY);
Example #12
0
static void	lo_altqstart(struct ifnet *, struct ifaltq_subque *);
#endif

#if defined(TINY_LOMTU)
#define	LOMTU	(1024+512)
#elif defined(LARGE_LOMTU)
#define LOMTU	131072
#else
#define LOMTU	16384
#endif

#define LO_CSUM_FEATURES	(CSUM_IP | CSUM_UDP | CSUM_TCP)

struct ifnet	*loif;

static struct if_clone lo_cloner = IF_CLONE_INITIALIZER("lo",
    lo_clone_create, lo_clone_destroy, NLOOP, IF_MAXUNIT);

static void
lo_sysinit(void *dummy __unused)
{
	if_clone_attach(&lo_cloner);
}
SYSINIT(lo_sysinit, SI_SUB_PSEUDO, SI_ORDER_ANY, lo_sysinit, NULL);

static int
lo_clone_create(struct if_clone *ifc, int unit, caddr_t param __unused)
{
	struct ifnet *ifp;

	ifp = kmalloc(sizeof(*ifp), M_IFNET, M_WAITOK | M_ZERO);
	if_initname(ifp, ifc->ifc_name, unit);
Example #13
0
int	tundebug = 0;

extern int ifqmaxlen;
void	tunattach __P((int));
LIST_HEAD(, tun_softc) tun_softc_list;
LIST_HEAD(, tun_softc) tunz_softc_list;
static struct simplelock tun_softc_lock;

int	tun_ioctl __P((struct ifnet *, u_long, caddr_t));
int	tun_output __P((struct ifnet *, struct mbuf *, struct sockaddr *,
		       struct rtentry *rt));
int	tun_clone_create __P((struct if_clone *, int));
void	tun_clone_destroy __P((struct ifnet *));

struct if_clone tun_cloner =
    IF_CLONE_INITIALIZER("tun", tun_clone_create, tun_clone_destroy);

static void tunattach0 __P((struct tun_softc *));
static void tuninit __P((struct tun_softc *));
#ifdef ALTQ
static void tunstart __P((struct ifnet *));
#endif
static struct tun_softc *tun_find_unit __P((dev_t));
static struct tun_softc *tun_find_zunit __P((int));

dev_type_open(tunopen);
dev_type_close(tunclose);
dev_type_read(tunread);
dev_type_write(tunwrite);
dev_type_ioctl(tunioctl);
dev_type_poll(tunpoll);
Example #14
0
#define TRIM_LABEL do { \
	m_adj(m, sizeof(union mpls_shim)); \
	if (m->m_len < sizeof(union mpls_shim) && \
	    (m = m_pullup(m, sizeof(union mpls_shim))) == NULL) \
		goto done; \
	dst.smpls_addr.s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr); \
	} while (/* CONSTCOND */ 0)


void ifmplsattach(int);

static int mpls_clone_create(struct if_clone *, int);
static int mpls_clone_destroy(struct ifnet *);

static struct if_clone mpls_if_cloner =
	IF_CLONE_INITIALIZER("mpls", mpls_clone_create, mpls_clone_destroy);


static void mpls_input(struct ifnet *, struct mbuf *);
static int mpls_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
	struct rtentry *);
static int mpls_ioctl(struct ifnet *, u_long, void *);
static int mpls_send_frame(struct mbuf *, struct ifnet *, struct rtentry *);
static int mpls_lse(struct mbuf *);

#ifdef INET
static int mpls_unlabel_inet(struct mbuf *);
static struct mbuf *mpls_label_inet(struct mbuf *, union mpls_shim *, uint);
#endif

#ifdef INET6
Example #15
0
/* Internal functions */
static int	tap_lifaddr(struct ifnet *, u_long, struct ifaliasreq *);
static void	tap_softintr(void *);

/*
 * tap is a clonable interface, although it is highly unrealistic for
 * an Ethernet device.
 *
 * Here are the bits needed for a clonable interface.
 */
static int	tap_clone_create(struct if_clone *, int);
static int	tap_clone_destroy(struct ifnet *);

struct if_clone tap_cloners = IF_CLONE_INITIALIZER("tap",
					tap_clone_create,
					tap_clone_destroy);

/* Helper functionis shared by the two cloning code paths */
static struct tap_softc *	tap_clone_creator(int);
int	tap_clone_destroyer(device_t);

static struct sysctllog *tap_sysctl_clog;

#ifdef _MODULE
devmajor_t tap_bmajor = -1, tap_cmajor = -1;
#endif

static u_int tap_count;

void
Example #16
0
#define LOMTU	(131072 +  MHLEN + MLEN)
#define LOMTU_MAX LOMTU
#else
#define	LOMTU	(32768 +  MHLEN + MLEN)
#define	LOMTU_MAX	(65536 +  MHLEN + MLEN)
#endif

#ifdef ALTQ
static void	lostart(struct ifnet *);
#endif

static int	loop_clone_create(struct if_clone *, int);
static int	loop_clone_destroy(struct ifnet *);

static struct if_clone loop_cloner =
    IF_CLONE_INITIALIZER("lo", loop_clone_create, loop_clone_destroy);

void
loopattach(int n)
{

    (void)loop_clone_create(&loop_cloner, 0);	/* lo0 always exists */
    if_clone_attach(&loop_cloner);
}

static int
loop_clone_create(struct if_clone *ifc, int unit)
{
    struct ifnet *ifp;

    ifp = if_alloc(IFT_LOOP);
Example #17
0
static void	gifintr(void *);
#ifdef ISO
static struct mbuf *gif_eon_encap(struct mbuf *);
static struct mbuf *gif_eon_decap(struct ifnet *, struct mbuf *);
#endif

/*
 * gif global variable definitions
 */
LIST_HEAD(, gif_softc) gif_softc_list;	/* XXX should be static */

static int	gif_clone_create(struct if_clone *, int);
static int	gif_clone_destroy(struct ifnet *);

static struct if_clone gif_cloner =
    IF_CLONE_INITIALIZER("gif", gif_clone_create, gif_clone_destroy);

#ifndef MAX_GIF_NEST
/*
 * This macro controls the upper limitation on nesting of gif tunnels.
 * Since, setting a large value to this macro with a careless configuration
 * may introduce system crash, we don't allow any nestings by default.
 * If you need to configure nested gif tunnels, you can define this macro
 * in your kernel configuration file.  However, if you do so, please be
 * careful to configure the tunnels so that it won't make a loop.
 */
#define MAX_GIF_NEST 1
#endif
static int max_gif_nesting = MAX_GIF_NEST;

/* ARGSUSED */
Example #18
0
#include <net/net_osdep.h>

static int	faithioctl(struct ifnet *, u_long, void *);
static int	faithoutput(struct ifnet *, struct mbuf *,
		            const struct sockaddr *, struct rtentry *);
static void	faithrtrequest(int, struct rtentry *,
		               const struct rt_addrinfo *);

void	faithattach(int);

static int	faith_clone_create(struct if_clone *, int);
static int	faith_clone_destroy(struct ifnet *);

static struct if_clone faith_cloner =
    IF_CLONE_INITIALIZER("faith", faith_clone_create, faith_clone_destroy);

#define	FAITHMTU	1500

/* ARGSUSED */
void
faithattach(int count)
{

	if_clone_attach(&faith_cloner);
}

static int
faith_clone_create(struct if_clone *ifc, int unit)
{
	struct ifnet *ifp;
Example #19
0
#endif

static int pflog_clone_create(struct if_clone *, u_int32_t, void *);
static int pflog_clone_destroy(struct ifnet *);
static errno_t pflogoutput(struct ifnet *, struct mbuf *);
static errno_t pflogioctl(struct ifnet *, unsigned long, void *);
static errno_t pflogdemux(struct ifnet *, struct mbuf *, char *,
    protocol_family_t *);
static errno_t pflogaddproto(struct ifnet *, protocol_family_t,
    const struct ifnet_demux_desc *, u_int32_t);
static errno_t pflogdelproto(struct ifnet *, protocol_family_t);
static void pflogfree(struct ifnet *);

static LIST_HEAD(, pflog_softc)	pflogif_list;
static struct if_clone pflog_cloner =
    IF_CLONE_INITIALIZER(PFLOGNAME, pflog_clone_create, pflog_clone_destroy,
        0, (PFLOGIFS_MAX - 1));

struct ifnet *pflogifs[PFLOGIFS_MAX];	/* for fast access */

void
pfloginit(void)
{
	int i;

	if (pf_perim_lock == NULL || pf_lock == NULL) {
		panic("%s: called before PF is initialized", __func__);
		/* NOTREACHED */
	}
	LIST_INIT(&pflogif_list);
	for (i = 0; i < PFLOGIFS_MAX; i++)
		pflogifs[i] = NULL;