summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-10-14 14:30:53 +0400
committerKozlov Dmitry <dima@server>2010-10-14 14:30:53 +0400
commit84ff56a83a9f6b29d3300aff13ede9afc73b5a68 (patch)
tree9284cb5b797dd7d68350cd937da11cc2f579114f
parent763fe9e3ba0faeea25cc423152a065900f901a53 (diff)
downloadaccel-ppp-84ff56a83a9f6b29d3300aff13ede9afc73b5a68.tar.gz
accel-ppp-84ff56a83a9f6b29d3300aff13ede9afc73b5a68.zip
due to libnl-1 is not thread safe, l2tp and shaper updated to use libnl-2
-rw-r--r--README8
-rw-r--r--accel-pptpd/ctrl/CMakeLists.txt6
-rw-r--r--accel-pptpd/ctrl/l2tp/CMakeLists.txt2
-rw-r--r--accel-pptpd/ctrl/l2tp/netlink.c22
-rw-r--r--accel-pptpd/extra/CMakeLists.txt8
-rw-r--r--accel-pptpd/extra/shaper_tbf.c26
-rw-r--r--accel-pptpd/ppp/ppp_ccp.c3
-rw-r--r--accel-pptpd/ppp/ppp_lcp.c7
-rw-r--r--contrib/gentoo/dev-libs/libnl/libnl-9999.ebuild19
-rw-r--r--contrib/gentoo/net-dialup/accel-pptp/accel-pptp-9999.ebuild16
10 files changed, 81 insertions, 36 deletions
diff --git a/README b/README
index e17ba1de..4dff39b7 100644
--- a/README
+++ b/README
@@ -23,7 +23,7 @@ Features
11. Extensible user/password database, implemented only Radius source
12. Extensible IP pool, implemented Radius and static pools
13. Supported pppd compatible ip-up/ip-down scripts
-(Work on L2TP is in progress)
+14. Builtin tbf shaper manager
Requirment
@@ -32,7 +32,7 @@ Requirment
2. kernel-2.6.25 or later
3. glibc-2.8 or later
4. cmake-2.6 or later
-5. libnl-1.1 or probably later
+5. libnl-2.0 or probably later (required for l2tp and builtin shaper)
Compilation and instalation
@@ -42,9 +42,9 @@ or specify other location via KDIR.
1. cd /path/to/accel-pptp-1.0
2. mkdir build
3. cd build
-4. cmake [ -D BUILD_DRIVER=TRUE ] [ -D KDIR=/usr/src/linux ] [ -D CMAKE_INSTALL_PREFIX=/usr/local ] [ -D CMAKE_BUILD_TYPE=Debug ] [ -DLOG_PGSQL=TRUE ] ..
+4. cmake [-DBUILD_DRIVER=TRUE] [-DKDIR=/usr/src/linux] [-DCMAKE_INSTALL_PREFIX=/usr/local] [-DCMAKE_BUILD_TYPE=Debug] [-DLOG_PGSQL=TRUE] [-DL2TP=TRUE] [-DSHAPER=TRUE] ..
Please note that the double dot record in the end of the command is essential. You'll get error if you miss it.
- BUILD_DRIVER, KDIR, CMAKE_INSTALL_PREFIX, CMAKE_BUILD_TYPE, LOG_PGSQL are optional,
+ BUILD_DRIVER, KDIR, CMAKE_INSTALL_PREFIX, CMAKE_BUILD_TYPE, LOG_PGSQL, L2TP, SHAPER are optional,
but while pptp is not present in mainline kernel you probably need BUILD_DRIVER.
5. make
6. make install
diff --git a/accel-pptpd/ctrl/CMakeLists.txt b/accel-pptpd/ctrl/CMakeLists.txt
index 6b37bc4a..1ba3b2a6 100644
--- a/accel-pptpd/ctrl/CMakeLists.txt
+++ b/accel-pptpd/ctrl/CMakeLists.txt
@@ -1,3 +1,7 @@
ADD_SUBDIRECTORY(pptp)
ADD_SUBDIRECTORY(pppoe)
-ADD_SUBDIRECTORY(l2tp)
+
+IF (L2TP)
+ ADD_SUBDIRECTORY(l2tp)
+ENDIF (L2TP)
+
diff --git a/accel-pptpd/ctrl/l2tp/CMakeLists.txt b/accel-pptpd/ctrl/l2tp/CMakeLists.txt
index edff55dc..c9b483d3 100644
--- a/accel-pptpd/ctrl/l2tp/CMakeLists.txt
+++ b/accel-pptpd/ctrl/l2tp/CMakeLists.txt
@@ -8,6 +8,6 @@ ADD_LIBRARY(l2tp SHARED
packet.c
netlink.c
)
-TARGET_LINK_LIBRARIES(l2tp nl)
+TARGET_LINK_LIBRARIES(l2tp nl-genl)
INSTALL(TARGETS l2tp LIBRARY DESTINATION usr/lib/accel-pptp)
diff --git a/accel-pptpd/ctrl/l2tp/netlink.c b/accel-pptpd/ctrl/l2tp/netlink.c
index 0cc5b34b..7c8c79a6 100644
--- a/accel-pptpd/ctrl/l2tp/netlink.c
+++ b/accel-pptpd/ctrl/l2tp/netlink.c
@@ -9,10 +9,10 @@ static int family;
void l2tp_nl_delete_tunnel(int tid)
{
- struct nl_handle *nl_sock;
+ struct nl_sock *nl_sock;
struct nl_msg *msg;
- nl_sock = nl_handle_alloc();
+ nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
genl_connect(nl_sock);
@@ -25,15 +25,15 @@ void l2tp_nl_delete_tunnel(int tid)
nlmsg_free(msg);
nl_close(nl_sock);
- nl_handle_destroy(nl_sock);
+ nl_socket_free(nl_sock);
}
void l2tp_nl_create_tunnel(int fd, int tid, int peer_tid)
{
- struct nl_handle *nl_sock;
+ struct nl_sock *nl_sock;
struct nl_msg *msg;
- nl_sock = nl_handle_alloc();
+ nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
genl_connect(nl_sock);
@@ -51,15 +51,15 @@ void l2tp_nl_create_tunnel(int fd, int tid, int peer_tid)
nlmsg_free(msg);
nl_close(nl_sock);
- nl_handle_destroy(nl_sock);
+ nl_socket_free(nl_sock);
}
void l2tp_nl_create_session(int tid, int sid, int peer_sid)
{
- struct nl_handle *nl_sock;
+ struct nl_sock *nl_sock;
struct nl_msg *msg;
- nl_sock = nl_handle_alloc();
+ nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
genl_connect(nl_sock);
@@ -77,18 +77,18 @@ void l2tp_nl_create_session(int tid, int sid, int peer_sid)
nlmsg_free(msg);
nl_close(nl_sock);
- nl_handle_destroy(nl_sock);
+ nl_socket_free(nl_sock);
}
static void __init init(void)
{
- struct nl_handle *nl_sock = nl_handle_alloc();
+ struct nl_sock *nl_sock = nl_socket_alloc();
genl_connect(nl_sock);
family = genl_ctrl_resolve(nl_sock, L2TP_GENL_NAME);
nl_close(nl_sock);
- nl_handle_destroy(nl_sock);
+ nl_socket_free(nl_sock);
}
diff --git a/accel-pptpd/extra/CMakeLists.txt b/accel-pptpd/extra/CMakeLists.txt
index 600c8613..9d58b8ee 100644
--- a/accel-pptpd/extra/CMakeLists.txt
+++ b/accel-pptpd/extra/CMakeLists.txt
@@ -1,10 +1,14 @@
ADD_LIBRARY(pppd_compat SHARED pppd_compat.c)
ADD_LIBRARY(ippool SHARED ippool.c)
ADD_LIBRARY(sigchld SHARED sigchld.c)
-ADD_LIBRARY(shaper_tbf SHARED shaper_tbf.c)
-TARGET_LINK_LIBRARIES(shaper_tbf nl)
INSTALL(TARGETS pppd_compat ippool sigchld
LIBRARY DESTINATION usr/lib/accel-pptp
)
+IF (SHAPER)
+ ADD_LIBRARY(shaper_tbf SHARED shaper_tbf.c)
+ TARGET_LINK_LIBRARIES(shaper_tbf nl-route)
+ INSTALL(TARGETS shaper_tbf LIBRARY DESTINATION usr/lib/accel-pptp)
+ENDIF (SHAPER)
+
diff --git a/accel-pptpd/extra/shaper_tbf.c b/accel-pptpd/extra/shaper_tbf.c
index 7ed68f5e..cd1a88a6 100644
--- a/accel-pptpd/extra/shaper_tbf.c
+++ b/accel-pptpd/extra/shaper_tbf.c
@@ -92,7 +92,7 @@ static void tc_calc_rtable(struct tc_ratespec *r, uint32_t *rtab, int cell_log,
r->cell_log=cell_log;
}
-static int install_tbf(struct nl_handle *h, int ifindex, int speed)
+static int install_tbf(struct nl_sock *h, int ifindex, int speed)
{
struct tc_tbf_qopt opt;
struct nl_msg *msg;
@@ -159,7 +159,7 @@ nla_put_failure:
return -1;
}
-static int install_ingress(struct nl_handle *h, int ifindex)
+static int install_ingress(struct nl_sock *h, int ifindex)
{
struct nl_msg *pmsg;
@@ -200,7 +200,7 @@ nla_put_failure:
return -1;
}
-static int install_filter(struct nl_handle *h, int ifindex, int speed)
+static int install_filter(struct nl_sock *h, int ifindex, int speed)
{
double rate = speed*1000/8;
double bucket = rate*conf_burst_factor;
@@ -323,7 +323,7 @@ nla_put_failure:
static int install_shaper(const char *ifname, int down_speed, int up_speed)
{
- struct nl_handle *h;
+ struct nl_sock *h;
struct ifreq ifr;
int err;
@@ -335,9 +335,9 @@ static int install_shaper(const char *ifname, int down_speed, int up_speed)
return -1;
}
- h = nl_handle_alloc();
+ h = nl_socket_alloc();
if (!h) {
- log_ppp_error("tbf: nl_handle_alloc failed\n");
+ log_ppp_error("tbf: nl_socket_alloc failed\n");
return -1;
}
@@ -360,7 +360,7 @@ static int install_shaper(const char *ifname, int down_speed, int up_speed)
nl_close(h);
out:
- nl_handle_destroy(h);
+ nl_socket_free(h);
return 0;
}
@@ -395,7 +395,7 @@ static struct shaper_pd_t *find_pd(struct ppp_t *ppp, int create)
static int remove_shaper(const char *ifname)
{
- struct nl_handle *h;
+ struct nl_sock *h;
struct ifreq ifr;
struct nl_msg *pmsg;
int err;
@@ -422,16 +422,16 @@ static int remove_shaper(const char *ifname)
.tcm_parent = TC_H_INGRESS,
};
- h = nl_handle_alloc();
+ h = nl_socket_alloc();
if (!h) {
- log_ppp_error("tbf: nl_handle_alloc failed\n");
+ log_ppp_error("tbf: nl_socket_alloc failed\n");
return -1;
}
err = nl_connect(h, NETLINK_ROUTE);
if (err < 0) {
log_ppp_error("tbf: nl_connect: %s", strerror(errno));
- nl_handle_destroy(h);
+ nl_socket_free(h);
return -1;
}
@@ -466,7 +466,7 @@ static int remove_shaper(const char *ifname)
nlmsg_free(pmsg);
nl_close(h);
- nl_handle_destroy(h);
+ nl_socket_free(h);
return 0;
out_err:
@@ -476,7 +476,7 @@ out_err:
nlmsg_free(pmsg);
nl_close(h);
- nl_handle_destroy(h);
+ nl_socket_free(h);
return -1;
}
diff --git a/accel-pptpd/ppp/ppp_ccp.c b/accel-pptpd/ppp/ppp_ccp.c
index 4f30aa99..9f8419fd 100644
--- a/accel-pptpd/ppp/ppp_ccp.c
+++ b/accel-pptpd/ppp/ppp_ccp.c
@@ -607,7 +607,8 @@ static void ccp_recv(struct ppp_handler_t*h)
if (ccp->fsm.fsm_state == FSM_Initial || ccp->fsm.fsm_state == FSM_Closed) {
if (conf_ppp_verbose)
log_ppp_warn("CCP: discaring packet\n");
- lcp_send_proto_rej(ccp->ppp, htons(PPP_CCP));
+ if (ccp->fsm.fsm_state == FSM_Closed)
+ lcp_send_proto_rej(ccp->ppp, htons(PPP_CCP));
return;
}
diff --git a/accel-pptpd/ppp/ppp_lcp.c b/accel-pptpd/ppp/ppp_lcp.c
index 0eae8fc9..e5063f3f 100644
--- a/accel-pptpd/ppp/ppp_lcp.c
+++ b/accel-pptpd/ppp/ppp_lcp.c
@@ -690,6 +690,13 @@ static void lcp_recv(struct ppp_handler_t*h)
int r;
char *term_msg;
+ if (lcp->fsm.fsm_state == FSM_Initial || lcp->fsm.fsm_state == FSM_Closed) {
+ /*if (conf_ppp_verbose)
+ log_ppp_warn("LCP: discaring packet\n");
+ lcp_send_proto_rej(ccp->ppp, htons(PPP_CCP));*/
+ return;
+ }
+
if (lcp->ppp->chan_buf_size < PPP_HEADERLEN + 2) {
log_ppp_warn("LCP: short packet received\n");
return;
diff --git a/contrib/gentoo/dev-libs/libnl/libnl-9999.ebuild b/contrib/gentoo/dev-libs/libnl/libnl-9999.ebuild
new file mode 100644
index 00000000..56db00db
--- /dev/null
+++ b/contrib/gentoo/dev-libs/libnl/libnl-9999.ebuild
@@ -0,0 +1,19 @@
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/polylib/polylib-9999.ebuild,v 1.1 2008/09/21 08:46:58 vapier Exp $
+
+EGIT_REPO_URI="git://git.kernel.org/pub/scm/libs/netlink/libnl.git"
+EGIT_BOOTSTRAP="eautoreconf"
+inherit git autotools eutils
+
+DESCRIPTION="Netlink library"
+HOMEPAGE="http://infradead.org/~tgr/libnl"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE=""
+
+src_install() {
+ emake DESTDIR=${D} install || die
+}
diff --git a/contrib/gentoo/net-dialup/accel-pptp/accel-pptp-9999.ebuild b/contrib/gentoo/net-dialup/accel-pptp/accel-pptp-9999.ebuild
index 06ae2b81..7632da83 100644
--- a/contrib/gentoo/net-dialup/accel-pptp/accel-pptp-9999.ebuild
+++ b/contrib/gentoo/net-dialup/accel-pptp/accel-pptp-9999.ebuild
@@ -14,11 +14,13 @@ HOMEPAGE="http://accel-pptp.sourceforge.net/"
SLOT="0"
LICENSE="GPL"
KEYWORDS="~amd64 ~x86"
-IUSE="postgres debug"
+IUSE="postgres debug l2tp shaper"
-DEPEND="dev-libs/openssl
+DEPEND=">=sys-libs/glibc-2.8
+ dev-libs/openssl
dev-libs/libaio
- dev-libs/libnl
+ l2tp? ( =dev-libs/libnl-9999 )
+ shaper? ( =dev-libs/libnl-9999 )
postgres? ( >=dev-db/postgresql-base-8.1 )"
RDEPEND="$DEPEND
@@ -47,6 +49,14 @@ src_configure() {
if use postgres; then
mycmakeargs+=( "-DLOG_PGSQL=TRUE" )
fi
+
+ if use l2tp; then
+ mycmakeargs+=( "-DL2TP=TRUE" )
+ fi
+
+ if use shaper; then
+ mycmakeargs+=( "-DSHAPER=TRUE" )
+ fi
cmake-utils_src_configure
}