Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys add missing files.
details: https://anonhg.NetBSD.org/src/rev/7dd9e78eb93b
branches: trunk
changeset: 351496:7dd9e78eb93b
user: knakahara <knakahara%NetBSD.org@localhost>
date: Thu Feb 16 08:23:35 2017 +0000
description:
add missing files.
diffstat:
sys/modules/if_l2tp/Makefile | 14 +
sys/modules/if_l2tp/l2tp.ioconf | 7 +
sys/net/if_l2tp.c | 1502 +++++++++++++++++++++++++++++++++++++++
sys/net/if_l2tp.h | 210 +++++
sys/netinet/in_l2tp.c | 419 ++++++++++
sys/netinet/in_l2tp.h | 41 +
sys/netinet6/in6_l2tp.c | 414 ++++++++++
sys/netinet6/in6_l2tp.h | 39 +
8 files changed, 2646 insertions(+), 0 deletions(-)
diffs (truncated from 2678 to 300 lines):
diff -r b7f6cb9904a6 -r 7dd9e78eb93b sys/modules/if_l2tp/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/if_l2tp/Makefile Thu Feb 16 08:23:35 2017 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2017/02/16 08:23:35 knakahara Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/net ${S}/netinet ${S}/netinet6
+
+KMOD= if_l2tp
+IOCONF= l2tp.ioconf
+SRCS= if_l2tp.c in_l2tp.c in6_l2tp.c
+
+CPPFLAGS+= -DINET
+CPPFLAGS+= -DINET6
+
+.include <bsd.kmodule.mk>
diff -r b7f6cb9904a6 -r 7dd9e78eb93b sys/modules/if_l2tp/l2tp.ioconf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/if_l2tp/l2tp.ioconf Thu Feb 16 08:23:35 2017 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: l2tp.ioconf,v 1.1 2017/02/16 08:23:35 knakahara Exp $
+
+ioconf l2tp
+
+include "conf/files"
+
+pseudo-device l2tp
diff -r b7f6cb9904a6 -r 7dd9e78eb93b sys/net/if_l2tp.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/net/if_l2tp.c Thu Feb 16 08:23:35 2017 +0000
@@ -0,0 +1,1502 @@
+/* $NetBSD: if_l2tp.c,v 1.1 2017/02/16 08:23:35 knakahara Exp $ */
+
+/*
+ * Copyright (c) 2017 Internet Initiative Japan Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * L2TPv3 kernel interface
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.1 2017/02/16 08:23:35 knakahara Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_inet.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/mbuf.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/syslog.h>
+#include <sys/proc.h>
+#include <sys/conf.h>
+#include <sys/kauth.h>
+#include <sys/cpu.h>
+#include <sys/cprng.h>
+#include <sys/intr.h>
+#include <sys/kmem.h>
+#include <sys/mutex.h>
+#include <sys/atomic.h>
+#include <sys/pserialize.h>
+#include <sys/device.h>
+#include <sys/module.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_ether.h>
+#include <net/if_types.h>
+#include <net/netisr.h>
+#include <net/route.h>
+#include <net/bpf.h>
+#include <net/if_vlanvar.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_encap.h>
+#ifdef INET
+#include <netinet/in_var.h>
+#include <netinet/in_l2tp.h>
+#endif /* INET */
+#ifdef INET6
+#include <netinet6/in6_l2tp.h>
+#endif
+
+#include <net/if_l2tp.h>
+
+#if NVLAN > 0
+#include <net/if_vlanvar.h>
+#endif
+
+/* TODO: IP_TCPMSS support */
+#undef IP_TCPMSS
+#ifdef IP_TCPMSS
+#include <netinet/ip_tcpmss.h>
+#endif
+
+#include <net/bpf.h>
+#include <net/net_osdep.h>
+
+/*
+ * l2tp global variable definitions
+ */
+LIST_HEAD(l2tp_sclist, l2tp_softc);
+static struct {
+ struct l2tp_sclist list;
+ kmutex_t lock;
+} l2tp_softcs __cacheline_aligned;
+
+
+#if !defined(L2TP_ID_HASH_SIZE)
+#define L2TP_ID_HASH_SIZE 64
+#endif
+static struct {
+ kmutex_t lock;
+ struct pslist_head *lists;
+} l2tp_hash __cacheline_aligned = {
+ .lists = NULL,
+};
+
+pserialize_t l2tp_psz __read_mostly;
+struct psref_class *lv_psref_class __read_mostly;
+
+static void l2tp_ro_init_pc(void *, void *, struct cpu_info *);
+static void l2tp_ro_fini_pc(void *, void *, struct cpu_info *);
+
+static int l2tp_clone_create(struct if_clone *, int);
+static int l2tp_clone_destroy(struct ifnet *);
+
+struct if_clone l2tp_cloner =
+ IF_CLONE_INITIALIZER("l2tp", l2tp_clone_create, l2tp_clone_destroy);
+
+static int l2tp_output(struct ifnet *, struct mbuf *,
+ const struct sockaddr *, const struct rtentry *);
+static void l2tpintr(struct l2tp_variant *);
+
+static void l2tp_hash_init(void);
+static int l2tp_hash_fini(void);
+
+static void l2tp_start(struct ifnet *);
+static int l2tp_transmit(struct ifnet *, struct mbuf *);
+
+static int l2tp_set_tunnel(struct ifnet *, struct sockaddr *,
+ struct sockaddr *);
+static void l2tp_delete_tunnel(struct ifnet *);
+
+static int id_hash_func(uint32_t);
+
+static void l2tp_variant_update(struct l2tp_softc *, struct l2tp_variant *);
+static int l2tp_set_session(struct l2tp_softc *, uint32_t, uint32_t);
+static int l2tp_clear_session(struct l2tp_softc *);
+static int l2tp_set_cookie(struct l2tp_softc *, uint64_t, u_int, uint64_t, u_int);
+static void l2tp_clear_cookie(struct l2tp_softc *);
+static void l2tp_set_state(struct l2tp_softc *, int);
+static int l2tp_encap_attach(struct l2tp_variant *);
+static int l2tp_encap_detach(struct l2tp_variant *);
+
+#ifndef MAX_L2TP_NEST
+/*
+ * This macro controls the upper limitation on nesting of l2tp 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 l2tp 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.
+ */
+/*
+ * XXX
+ * Currently, if in_l2tp_output recursively calls, it causes locking against
+ * myself of struct l2tp_ro->lr_lock. So, nested l2tp tunnels is prohibited.
+ */
+#define MAX_L2TP_NEST 0
+#endif
+
+static int max_l2tp_nesting = MAX_L2TP_NEST;
+
+/* ARGSUSED */
+void
+l2tpattach(int count)
+{
+ /*
+ * Nothing to do here, initialization is handled by the
+ * module initialization code in l2tpinit() below).
+ */
+}
+
+static void
+l2tpinit(void)
+{
+
+ mutex_init(&l2tp_softcs.lock, MUTEX_DEFAULT, IPL_NONE);
+ LIST_INIT(&l2tp_softcs.list);
+
+ mutex_init(&l2tp_hash.lock, MUTEX_DEFAULT, IPL_NONE);
+ l2tp_psz = pserialize_create();
+ lv_psref_class = psref_class_create("l2tpvar", IPL_SOFTNET);
+ if_clone_attach(&l2tp_cloner);
+
+ l2tp_hash_init();
+}
+
+static int
+l2tpdetach(void)
+{
+ int error;
+
+ mutex_enter(&l2tp_softcs.lock);
+ if (!LIST_EMPTY(&l2tp_softcs.list)) {
+ mutex_exit(&l2tp_softcs.lock);
+ return EBUSY;
+ }
+ mutex_exit(&l2tp_softcs.lock);
+
+ error = l2tp_hash_fini();
+ if (error)
+ return error;
+
+ if_clone_detach(&l2tp_cloner);
+ psref_class_destroy(lv_psref_class);
+ pserialize_destroy(l2tp_psz);
+ mutex_destroy(&l2tp_hash.lock);
+
+ return error;
+}
+
+static int
+l2tp_clone_create(struct if_clone *ifc, int unit)
+{
+ struct l2tp_softc *sc;
+ struct l2tp_variant *var;
+
+ sc = kmem_zalloc(sizeof(struct l2tp_softc), KM_SLEEP);
+ var = kmem_zalloc(sizeof(struct l2tp_variant), KM_SLEEP);
+
+ var->lv_softc = sc;
+ var->lv_state = L2TP_STATE_DOWN;
+ var->lv_use_cookie = L2TP_COOKIE_OFF;
+ psref_target_init(&var->lv_psref, lv_psref_class);
+
+ sc->l2tp_var = var;
+ mutex_init(&sc->l2tp_lock, MUTEX_DEFAULT, IPL_NONE);
+ PSLIST_ENTRY_INIT(sc, l2tp_hash);
+
+ if_initname(&sc->l2tp_ec.ec_if, ifc->ifc_name, unit);
+
+ l2tpattach0(sc);
+
+ sc->l2tp_ro_percpu = percpu_alloc(sizeof(struct l2tp_ro));
+ KASSERTMSG(sc->l2tp_ro_percpu != NULL,
+ "failed to allocate sc->l2tp_ro_percpu");
+ percpu_foreach(sc->l2tp_ro_percpu, l2tp_ro_init_pc, NULL);
+
+ mutex_enter(&l2tp_softcs.lock);
+ LIST_INSERT_HEAD(&l2tp_softcs.list, sc, l2tp_list);
+ mutex_exit(&l2tp_softcs.lock);
+
+ return (0);
+}
+
+void
+l2tpattach0(struct l2tp_softc *sc)
+{
+
+ sc->l2tp_ec.ec_if.if_addrlen = 0;
+ sc->l2tp_ec.ec_if.if_mtu = L2TP_MTU;
+ sc->l2tp_ec.ec_if.if_flags = IFF_POINTOPOINT|IFF_MULTICAST|IFF_SIMPLEX;
+ sc->l2tp_ec.ec_if.if_ioctl = l2tp_ioctl;
+ sc->l2tp_ec.ec_if.if_output = l2tp_output;
+ sc->l2tp_ec.ec_if.if_type = IFT_L2TP;
Home |
Main Index |
Thread Index |
Old Index