提交 84ff56a8 编写于 作者: K Kozlov Dmitry

due to libnl-1 is not thread safe, l2tp and shaper updated to use libnl-2

上级 763fe9e3
......@@ -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
......
ADD_SUBDIRECTORY(pptp)
ADD_SUBDIRECTORY(pppoe)
ADD_SUBDIRECTORY(l2tp)
IF (L2TP)
ADD_SUBDIRECTORY(l2tp)
ENDIF (L2TP)
......@@ -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)
......@@ -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);
}
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)
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
# 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
}
......@@ -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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册