summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/gentoo/net-dialup/accel-pptp/accel-pptp-0.8.1.ebuild112
-rw-r--r--driver/gre.c136
2 files changed, 108 insertions, 140 deletions
diff --git a/contrib/gentoo/net-dialup/accel-pptp/accel-pptp-0.8.1.ebuild b/contrib/gentoo/net-dialup/accel-pptp/accel-pptp-0.8.1.ebuild
deleted file mode 100644
index 06204b0d..00000000
--- a/contrib/gentoo/net-dialup/accel-pptp/accel-pptp-0.8.1.ebuild
+++ /dev/null
@@ -1,112 +0,0 @@
-# Copyright 1999-2006 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-dialup/pptpd/pptpd-1.3.1.ebuild,v 1.1 2006/03/26 09:13:06 mrness Exp $
-
-inherit linux-mod eutils autotools
-
-DESCRIPTION="Point-to-Point Tunnelling Protocol Client/Server for Linux"
-SRC_URI="mirror://sourceforge/accel-pptp/${P}.tar.bz2"
-HOMEPAGE="http://accel-pptp.sourceforge.net/"
-
-SLOT="0"
-LICENSE="GPL"
-KEYWORDS="~amd64 ~x86"
-IUSE="tcpd server"
-
-DEPEND="server? (!net-dialup/pptpd)
- >=net-dialup/ppp-2.4.2
- >=virtual/linux-sources-2.6.15
- tcpd? ( sys-apps/tcp-wrappers )"
-RDEPEND="virtual/modutils"
-
-MODULE_NAMES="pptp(misc:${S}/kernel/driver)"
-BUILD_TARGETS="default"
-BUILD_PARAMS="KDIR=${KERNEL_DIR}"
-CONFIG_CHECK="PPP PPPOE"
-MODULESD_PPTP_ALIASES=("net-pf-24 pptp")
-
-src_unpack() {
- unpack ${A}
-
- local PPPD_VER=`best_version net-dialup/ppp`
- PPPD_VER=${PPPD_VER#*/*-} #reduce it to ${PV}-${PR}
- PPPD_VER=${PPPD_VER%%[_-]*} # main version without beta/pre/patch/revision
- #Match pptpd-logwtmp.so's version with pppd's version (#89895)
- #sed -i -e "s:\\(#define[ \\t]*VERSION[ \\t]*\\)\".*\":\\1\"${PPPD_VER}\":" "${S}/pptpd-1.3.3/plugins/patchlevel.h"
- #sed -i -e "s:\\(#define[ \\t]*PPP_VERSION[ \\t]*\\)\".*\":\\1\"${PPPD_VER}\":" "${S}/pppd_plugin/src/pppd/patchlevel.h"
-
- convert_to_m ${S}/kernel/driver/Makefile
-
- cd ${S}/pppd_plugin
- eautoreconf
-
- if use server; then
- cd ${S}/pptpd-1.3.3
- eautoreconf
- fi
-}
-
-src_compile() {
-
- if use server; then
- cd ${S}/pptpd-1.3.3
- local myconf
- use tcpd && myconf="--with-libwrap"
- econf --with-bcrelay \
- ${myconf} || die "configure failed"
- emake COPTS="${CFLAGS}" || die "make failed"
- fi
-
- cd ${S}/pppd_plugin
- local myconf
- econf ${myconf} || die "configure failed"
- emake COPTS="${CFLAGS}" || die "make failed"
-
- cd ${S}/kernel/driver
- linux-mod_src_compile || die "failed to build driver"
-}
-
-src_install () {
- if use server; then
- cd ${S}/pptpd-1.3.3
- einstall || die "make install failed"
-
- insinto /etc
- doins samples/pptpd.conf
-
- insinto /etc/ppp
- doins samples/options.pptpd
-
- exeinto /etc/init.d
- newexe "${FILESDIR}/pptpd-init" pptpd
-
- insinto /etc/conf.d
- newins "${FILESDIR}/pptpd-confd" pptpd
- fi
-
- if use client; then
- cd ${S}/example
- insinto /etc/ppp
- doins ppp/options.pptp
- insinto /etc/ppp/peers
- doins ppp/peers/pptp_test
- fi
-
- cd ${S}/pppd_plugin/src/.libs
- local PPPD_VER=`best_version net-dialup/ppp`
- PPPD_VER=${PPPD_VER#*/*-} #reduce it to ${PV}-${PR}
- PPPD_VER=${PPPD_VER%%[_-]*} # main version without beta/pre/patch/revision
- insinto /usr/lib/pppd/${PPPD_VER}
- newins pptp.so.0.0.0 pptp.so
-
- cd ${S}/kernel/driver
- linux-mod_src_install
-
- cd ${S}
- dodoc README
- cp -R example "${D}/usr/share/doc/${P}/exmaple"
-}
-
-pkg_postinst () {
- modules-update
-}
diff --git a/driver/gre.c b/driver/gre.c
index cda0576b..77886d5d 100644
--- a/driver/gre.c
+++ b/driver/gre.c
@@ -1,6 +1,6 @@
#include <linux/module.h>
#include <linux/kernel.h>
-#include <linux/kmod.h>
+#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/in.h>
#include <linux/netdevice.h>
@@ -10,50 +10,85 @@
#include "gre.h"
-
struct gre_protocol *gre_proto[GREPROTO_MAX] ____cacheline_aligned_in_smp;
-static DEFINE_RWLOCK(gre_proto_lock);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+static rwlock_t gre_proto_lock=RW_LOCK_UNLOCKED;
+#else
+static DEFINE_SPINLOCK(gre_proto_lock);
+#endif
int gre_add_protocol(struct gre_protocol *proto, u8 version)
{
int ret;
if (version >= GREPROTO_MAX)
- return -1;
+ return -EINVAL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
write_lock_bh(&gre_proto_lock);
+#else
+ spin_lock(&gre_proto_lock);
+#endif
if (gre_proto[version]) {
- ret = -1;
+ ret = -EAGAIN;
} else {
- gre_proto[version]=proto;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ gre_proto[version] = proto;
+#else
+ rcu_assign_pointer(gre_proto[version], proto);
+#endif
ret = 0;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
write_unlock_bh(&gre_proto_lock);
+#else
+ spin_unlock(&gre_proto_lock);
+#endif
return ret;
}
+
int gre_del_protocol(struct gre_protocol *proto, u8 version)
{
- int ret;
-
if (version >= GREPROTO_MAX)
- return -1;
+ goto out_err;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
write_lock_bh(&gre_proto_lock);
- if (gre_proto[version] == proto) {
+#else
+ spin_lock(&gre_proto_lock);
+#endif
+ if (gre_proto[version] == proto)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
gre_proto[version] = NULL;
- ret = 0;
- } else {
- ret = -1;
- }
+#else
+ rcu_assign_pointer(gre_proto[version], NULL);
+#endif
+ else
+ goto out_err_unlock;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
write_unlock_bh(&gre_proto_lock);
+#else
+ spin_unlock(&gre_proto_lock);
+ synchronize_rcu();
+#endif
+ return 0;
- return ret;
+out_err_unlock:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ write_unlock_bh(&gre_proto_lock);
+#else
+ spin_unlock(&gre_proto_lock);
+#endif
+out_err:
+ return -EINVAL;
}
+
static int gre_rcv(struct sk_buff *skb)
{
u8 ver;
int ret;
+ struct gre_protocol *proto;
if (!pskb_may_pull(skb, 12))
goto drop_nolock;
@@ -62,71 +97,117 @@ static int gre_rcv(struct sk_buff *skb)
if (ver >= GREPROTO_MAX)
goto drop_nolock;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
read_lock(&gre_proto_lock);
- if (!gre_proto[ver] || !gre_proto[ver]->handler)
+ proto = gre_proto[ver];
+#else
+ rcu_read_lock();
+ proto = rcu_dereference(gre_proto[ver]);
+#endif
+ if (!proto || !proto->handler)
goto drop;
- ret = gre_proto[ver]->handler(skb);
+ ret = proto->handler(skb);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
read_unlock(&gre_proto_lock);
+#else
+ rcu_read_unlock();
+#endif
return ret;
drop:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
read_unlock(&gre_proto_lock);
+#else
+ rcu_read_unlock();
+#endif
drop_nolock:
kfree_skb(skb);
return NET_RX_DROP;
}
+
static void gre_err(struct sk_buff *skb, u32 info)
{
u8 ver;
-
- printk("err\n");
+ struct gre_protocol *proto;
if (!pskb_may_pull(skb, 12))
goto drop_nolock;
- ver=skb->data[1];
+ ver=skb->data[1]&0x7f;
if (ver>=GREPROTO_MAX)
goto drop_nolock;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
read_lock(&gre_proto_lock);
- if (!gre_proto[ver] || !gre_proto[ver]->err_handler)
+ proto = gre_proto[ver];
+#else
+ rcu_read_lock();
+ proto = rcu_dereference(gre_proto[ver]);
+#endif
+ if (!proto || !proto->err_handler)
goto drop;
- gre_proto[ver]->err_handler(skb,info);
+ proto->err_handler(skb, info);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
read_unlock(&gre_proto_lock);
+#else
+ rcu_read_unlock();
+#endif
return;
drop:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
read_unlock(&gre_proto_lock);
+#else
+ rcu_read_unlock();
+#endif
drop_nolock:
kfree_skb(skb);
}
-
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+static struct inet_protocol net_gre_protocol = {
+ .handler = gre_rcv,
+ .err_handler = gre_err,
+ .protocol = IPPROTO_GRE,
+ .name = "GRE",
+};
+#else
static struct net_protocol net_gre_protocol = {
.handler = gre_rcv,
- .err_handler = gre_err,
-// .netns_ok=1,
+ .err_handler = gre_err,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)
+ .netns_ok=1,
+#endif
};
+#endif
static int __init gre_init(void)
{
printk(KERN_INFO "GRE over IPv4 demultiplexor driver");
-
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ inet_add_protocol(&net_gre_protocol);
+#else
if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
printk(KERN_INFO "gre: can't add protocol\n");
return -EAGAIN;
}
-
+#endif
return 0;
}
static void __exit gre_exit(void)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ inet_del_protocol(&net_gre_protocol);
+#else
inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
+#endif
}
module_init(gre_init);
@@ -137,4 +218,3 @@ MODULE_AUTHOR("Kozlov D. (xeb@mail.ru)");
MODULE_LICENSE("GPL");
EXPORT_SYMBOL_GPL(gre_add_protocol);
EXPORT_SYMBOL_GPL(gre_del_protocol);
-