xl2tpd: fix by backporting the version from master branch

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
This commit is contained in:
Yousong Zhou 2015-09-17 17:40:59 +08:00
parent 5fd21e2305
commit 77e4444a27
6 changed files with 110 additions and 71 deletions

View file

@ -1,5 +1,5 @@
# #
# Copyright (C) 2006-2014 OpenWrt.org # Copyright (C) 2006-2015 OpenWrt.org
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
@ -8,18 +8,16 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=xl2tpd PKG_NAME:=xl2tpd
PKG_VERSION:=1.3.6 PKG_VERSION:=devel-20150812
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org> PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=LICENSE PKG_LICENSE_FILES:=LICENSE
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/xelerance/xl2tpd.git PKG_SOURCE_URL:=https://github.com/xelerance/xl2tpd.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=5619e1771048e74b729804e8602f409af0f3faea PKG_SOURCE_VERSION:=5674a5835e9b89b7438917a380f3a6d68528fa3e
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_INSTALL:=1 PKG_INSTALL:=1
@ -32,7 +30,7 @@ define Package/xl2tpd
TITLE:=An L2TP (Layer 2 Tunneling Protocol) daemon TITLE:=An L2TP (Layer 2 Tunneling Protocol) daemon
URL:=http://www.xelerance.com/software/xl2tpd/ URL:=http://www.xelerance.com/software/xl2tpd/
SUBMENU:=VPN SUBMENU:=VPN
DEPENDS:=+ppp-mod-pppol2tp +ip +resolveip DEPENDS:=+ppp-mod-pppol2tp +resolveip
endef endef
define Package/xl2tpd/description define Package/xl2tpd/description
@ -41,9 +39,28 @@ It does implement both LAC and LNS role in a L2TP networking architecture. The
main goal of this protocol is to tunnel PPP frame trough an IP network. main goal of this protocol is to tunnel PPP frame trough an IP network.
endef endef
# XXX: CFLAGS are already set by Build/Compile/Default # Use optimization options from OpenWrt build system
MAKE_FLAGS+= \ MAKE_FLAGS += OFLAGS=""
OFLAGS=""
ifneq (0,0)
# debugging options from Makefile of xl2tpd package
EXTRA_CFLAGS += \
-DDEBUG_ZLB \
-DDEBUG_HELLO \
-DDEBUG_CLOSE \
-DDEBUG_FLOW \
-DDEBUG_FILE \
-DDEBUG_AAA \
-DDEBUG_PAYLOAD \
-DDEBUG_CONTROL \
-DDEBUG_PPPD \
-DDEBUG_HIDDEN \
-DDEBUG_ENTROPY \
-DDEBUG_CONTROL_XMIT \
-DDEBUG_MAGIC \
-DDEBUG_FLOW_MORE \
-DDEBUG_AUTH
endif
define Package/xl2tpd/conffiles define Package/xl2tpd/conffiles
/etc/xl2tpd/xl2tpd.conf /etc/xl2tpd/xl2tpd.conf

View file

@ -15,35 +15,49 @@ proto_l2tp_init_config() {
proto_config_add_string "pppd_options" proto_config_add_string "pppd_options"
proto_config_add_boolean "ipv6" proto_config_add_boolean "ipv6"
proto_config_add_int "mtu" proto_config_add_int "mtu"
proto_config_add_int "checkup_interval"
proto_config_add_string "server" proto_config_add_string "server"
available=1 available=1
no_device=1 no_device=1
no_proto_task=1
} }
proto_l2tp_setup() { proto_l2tp_setup() {
local config="$1" local interface="$1"
local iface="$2" local optfile="/tmp/l2tp/options.${interface}"
local optfile="/tmp/l2tp/options.${config}"
local ip serv_addr server local ip serv_addr server
json_get_var server server && { json_get_var server server && {
for ip in $(resolveip -t 5 "$server"); do for ip in $(resolveip -t 5 "$server"); do
( proto_add_host_dependency "$config" "$ip" ) ( proto_add_host_dependency "$interface" "$ip" )
serv_addr=1 serv_addr=1
done done
} }
[ -n "$serv_addr" ] || { [ -n "$serv_addr" ] || {
echo "Could not resolve server address" echo "Could not resolve server address" >&2
sleep 5 sleep 5
proto_setup_failed "$config" proto_setup_failed "$interface"
exit 1 exit 1
} }
if [ ! -p /var/run/xl2tpd/l2tp-control ]; then # Start and wait for xl2tpd
/etc/init.d/xl2tpd start if [ ! -p /var/run/xl2tpd/l2tp-control -o -z "$(pidof xl2tpd)" ]; then
/etc/init.d/xl2tpd restart
local wait_timeout=0
while [ ! -p /var/run/xl2tpd/l2tp-control ]; do
wait_timeout=$(($wait_timeout + 1))
[ "$wait_timeout" -gt 5 ] && {
echo "Cannot find xl2tpd control file." >&2
proto_setup_failed "$interface"
exit 1
}
sleep 1
done
fi fi
json_get_vars ipv6 demand keepalive username password pppd_options local ipv6 demand keepalive username password pppd_options mtu
json_get_vars ipv6 demand keepalive username password pppd_options mtu
[ "$ipv6" = 1 ] || ipv6="" [ "$ipv6" = 1 ] || ipv6=""
if [ "${demand:-0}" -gt 0 ]; then if [ "${demand:-0}" -gt 0 ]; then
demand="precompiled-active-filter /etc/ppp/filter demand idle $demand" demand="precompiled-active-filter /etc/ppp/filter demand idle $demand"
@ -51,55 +65,59 @@ proto_l2tp_setup() {
demand="persist" demand="persist"
fi fi
[ -n "$mtu" ] || json_get_var mtu mtu
local interval="${keepalive##*[, ]}" local interval="${keepalive##*[, ]}"
[ "$interval" != "$keepalive" ] || interval=5 [ "$interval" != "$keepalive" ] || interval=5
keepalive="${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}}"
username="${username:+user \"$username\" password \"$password\"}"
ipv6="${ipv6:++ipv6}"
mtu="${mtu:+mtu $mtu mru $mtu}"
mkdir -p /tmp/l2tp mkdir -p /tmp/l2tp
cat <<EOF >"$optfile"
usepeerdns
nodefaultroute
ipparam "$interface"
ifname "l2tp-$interface"
ip-up-script /lib/netifd/ppp-up
ipv6-up-script /lib/netifd/ppp-up
ip-down-script /lib/netifd/ppp-down
ipv6-down-script /lib/netifd/ppp-down
# Don't wait for LCP term responses; exit immediately when killed.
lcp-max-terminate 0
$keepalive
$username
$ipv6
$mtu
$pppd_options
EOF
echo "${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}}" > "${optfile}" xl2tpd-control add l2tp-${interface} pppoptfile=${optfile} lns=${server} || {
echo "usepeerdns" >> "${optfile}" echo "xl2tpd-control: Add l2tp-$interface failed" >&2
echo "nodefaultroute" >> "${optfile}" proto_setup_failed "$interface"
echo "${username:+user \"$username\" password \"$password\"}" >> "${optfile}" exit 1
echo "ipparam \"$config\"" >> "${optfile}" }
echo "ifname \"l2tp-$config\"" >> "${optfile}" xl2tpd-control connect l2tp-${interface} || {
echo "ip-up-script /lib/netifd/ppp-up" >> "${optfile}" echo "xl2tpd-control: Connect l2tp-$interface failed" >&2
echo "ipv6-up-script /lib/netifd/ppp-up" >> "${optfile}" proto_setup_failed "$interface"
echo "ip-down-script /lib/netifd/ppp-down" >> "${optfile}" exit 1
echo "ipv6-down-script /lib/netifd/ppp-down" >> "${optfile}" }
# Don't wait for LCP term responses; exit immediately when killed.
echo "lcp-max-terminate 0" >> "${optfile}"
echo "${ipv6:++ipv6} ${pppd_options}" >> "${optfile}"
echo "${mtu:+mtu $mtu mru $mtu}" >> "${optfile}"
xl2tpd-control add l2tp-${config} pppoptfile=${optfile} lns=${server} redial=yes redial timeout=20
xl2tpd-control connect l2tp-${config}
} }
proto_l2tp_teardown() { proto_l2tp_teardown() {
local interface="$1" local interface="$1"
local optfile="/tmp/l2tp/options.${interface}" local optfile="/tmp/l2tp/options.${interface}"
case "$ERROR" in rm -f ${optfile}
11|19) if [ -p /var/run/xl2tpd/l2tp-control ]; then
proto_notify_error "$interface" AUTH_FAILED xl2tpd-control remove l2tp-${interface} || {
proto_block_restart "$interface" echo "xl2tpd-control: Remove l2tp-$interface failed" >&2
;; }
2) fi
proto_notify_error "$interface" INVALID_OPTIONS
proto_block_restart "$interface"
;;
esac
xl2tpd-control disconnect l2tp-${interface}
# Wait for interface to go down # Wait for interface to go down
while [ -d /sys/class/net/l2tp-${interface} ]; do while [ -d /sys/class/net/l2tp-${interface} ]; do
sleep 1 sleep 1
done done
xl2tpd-control remove l2tp-${interface}
rm -f ${optfile}
} }
[ -n "$INCLUDE_ONLY" ] || { [ -n "$INCLUDE_ONLY" ] || {

View file

@ -1,18 +1,24 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
# Copyright (C) 2006-2010 OpenWrt.org # Copyright (C) 2006-2015 OpenWrt.org
START=60 START=60
USE_PROCD=1
BIN=xl2tpd BIN=xl2tpd
DEFAULT=/etc/default/$BIN RUN_D="/var/run/xl2tpd"
RUN_D=/var/run PID_F="/var/run/xl2tpd.pid"
PID_F=$RUN_D/$BIN.pid
start() { start_service() {
mkdir -p $RUN_D/$BIN rm -rf "$RUN_D"
[ -f $DEFAULT ] && . $DEFAULT mkdir -p "$RUN_D"
$BIN $OPTIONS
procd_open_instance
procd_set_param command $BIN -D -l -p "$PID_F"
procd_set_param respawn
procd_close_instance
} }
stop() { stop_service() {
[ -f $PID_F ] && kill $(cat $PID_F) rm -rf "$RUN_D"
rm -rf "$PID_F"
} }

View file

@ -1,6 +1,6 @@
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@@ -91,7 +91,8 @@ OSFLAGS+= -DUSE_KERNEL @@ -97,7 +97,8 @@ OSFLAGS+= -DUSE_KERNEL
IPFLAGS?= -DIP_ALLOCATION IPFLAGS?= -DIP_ALLOCATION

View file

@ -1,6 +1,6 @@
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@@ -107,10 +107,10 @@ BINDIR?=$(DESTDIR)${PREFIX}/bin @@ -113,10 +113,10 @@ BINDIR?=$(DESTDIR)${PREFIX}/bin
MANDIR?=$(DESTDIR)${PREFIX}/share/man MANDIR?=$(DESTDIR)${PREFIX}/share/man
@ -13,7 +13,7 @@
$(EXEC): $(OBJS) $(HDRS) $(EXEC): $(OBJS) $(HDRS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
@@ -118,14 +118,10 @@ $(EXEC): $(OBJS) $(HDRS) @@ -124,14 +124,10 @@ $(EXEC): $(OBJS) $(HDRS)
$(CONTROL_EXEC): $(CONTROL_SRCS) $(CONTROL_EXEC): $(CONTROL_SRCS)
$(CC) $(CFLAGS) $(LDFLAGS) $(CONTROL_SRCS) -o $@ $(CC) $(CFLAGS) $(LDFLAGS) $(CONTROL_SRCS) -o $@
@ -29,7 +29,7 @@
install -d -m 0755 ${SBINDIR} install -d -m 0755 ${SBINDIR}
install -m 0755 $(EXEC) ${SBINDIR}/$(EXEC) install -m 0755 $(EXEC) ${SBINDIR}/$(EXEC)
install -d -m 0755 ${MANDIR}/man5 install -d -m 0755 ${MANDIR}/man5
@@ -133,11 +129,6 @@ install: ${EXEC} pfc ${CONTROL_EXEC} @@ -139,11 +135,6 @@ install: ${EXEC} pfc ${CONTROL_EXEC}
install -m 0644 doc/xl2tpd.8 ${MANDIR}/man8/ install -m 0644 doc/xl2tpd.8 ${MANDIR}/man8/
install -m 0644 doc/xl2tpd.conf.5 doc/l2tp-secrets.5 \ install -m 0644 doc/xl2tpd.conf.5 doc/l2tp-secrets.5 \
${MANDIR}/man5/ ${MANDIR}/man5/

View file

@ -1,7 +1,5 @@
Index: xl2tpd-1.3.6/xl2tpd.c --- a/xl2tpd.c
=================================================================== +++ b/xl2tpd.c
--- xl2tpd-1.3.6.orig/xl2tpd.c
+++ xl2tpd-1.3.6/xl2tpd.c
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>