From: Steven Barth Date: Mon, 18 Aug 2014 09:36:19 +0000 (+0200) Subject: Revert "xl2tpd: rename netifd protocol handler to l2tpv2 to avoid clashes with l2tpv3" X-Git-Tag: v14.07~28 X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=7c3d7ca550c950193d9700d44ec32413f8a27ead;p=feed%2Fpackages.git Revert "xl2tpd: rename netifd protocol handler to l2tpv2 to avoid clashes with l2tpv3" This reverts commit 981f2da45747df72c5ae2c45f265fe8f29af3d52. OpenWrt wiki knew l2tp from l2tpv3tun, but luci knew l2tp from xl2tpd --- diff --git a/net/xl2tpd/Makefile b/net/xl2tpd/Makefile index 4e108ab809..7d1f932f35 100644 --- a/net/xl2tpd/Makefile +++ b/net/xl2tpd/Makefile @@ -65,7 +65,7 @@ define Package/xl2tpd/install $(INSTALL_DATA) ./files/options.xl2tpd $(1)/etc/ppp/ $(INSTALL_DIR) $(1)/lib/netifd/proto - $(INSTALL_BIN) ./files/l2tpv2.sh $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/l2tp.sh $(1)/lib/netifd/proto endef $(eval $(call BuildPackage,xl2tpd)) diff --git a/net/xl2tpd/files/l2tp.sh b/net/xl2tpd/files/l2tp.sh new file mode 100644 index 0000000000..867234dbe1 --- /dev/null +++ b/net/xl2tpd/files/l2tp.sh @@ -0,0 +1,107 @@ +#!/bin/sh + +[ -x /usr/sbin/xl2tpd ] || exit 0 + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_l2tp_init_config() { + proto_config_add_string "username" + proto_config_add_string "password" + proto_config_add_string "keepalive" + proto_config_add_string "pppd_options" + proto_config_add_boolean "ipv6" + proto_config_add_int "mtu" + proto_config_add_string "server" + available=1 + no_device=1 +} + +proto_l2tp_setup() { + local config="$1" + local iface="$2" + local optfile="/tmp/l2tp/options.${config}" + + local ip serv_addr server + json_get_var server server && { + for ip in $(resolveip -t 5 "$server"); do + ( proto_add_host_dependency "$config" "$ip" ) + serv_addr=1 + done + } + [ -n "$serv_addr" ] || { + echo "Could not resolve server address" + sleep 5 + proto_setup_failed "$config" + exit 1 + } + + if [ ! -p /var/run/xl2tpd/l2tp-control ]; then + /etc/init.d/xl2tpd start + fi + + json_get_vars ipv6 demand keepalive username password pppd_options + [ "$ipv6" = 1 ] || ipv6="" + if [ "${demand:-0}" -gt 0 ]; then + demand="precompiled-active-filter /etc/ppp/filter demand idle $demand" + else + demand="persist" + fi + + [ -n "$mtu" ] || json_get_var mtu mtu + + local interval="${keepalive##*[, ]}" + [ "$interval" != "$keepalive" ] || interval=5 + + mkdir -p /tmp/l2tp + + echo "${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}}" > "${optfile}" + echo "usepeerdns" >> "${optfile}" + echo "nodefaultroute" >> "${optfile}" + echo "${username:+user \"$username\" password \"$password\"}" >> "${optfile}" + echo "ipparam \"$config\"" >> "${optfile}" + echo "ifname \"l2tp-$config\"" >> "${optfile}" + echo "ip-up-script /lib/netifd/ppp-up" >> "${optfile}" + echo "ipv6-up-script /lib/netifd/ppp-up" >> "${optfile}" + echo "ip-down-script /lib/netifd/ppp-down" >> "${optfile}" + 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() { + local interface="$1" + local optfile="/tmp/l2tp/options.${interface}" + + case "$ERROR" in + 11|19) + proto_notify_error "$interface" AUTH_FAILED + proto_block_restart "$interface" + ;; + 2) + proto_notify_error "$interface" INVALID_OPTIONS + proto_block_restart "$interface" + ;; + esac + + xl2tpd-control disconnect l2tp-${interface} + # Wait for interface to go down + while [ -d /sys/class/net/l2tp-${interface} ]; do + sleep 1 + done + + xl2tpd-control remove l2tp-${interface} + rm -f ${optfile} +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol l2tp +} diff --git a/net/xl2tpd/files/l2tpv2.sh b/net/xl2tpd/files/l2tpv2.sh deleted file mode 100644 index 6466cf0be1..0000000000 --- a/net/xl2tpd/files/l2tpv2.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/sh - -[ -x /usr/sbin/xl2tpd ] || exit 0 - -[ -n "$INCLUDE_ONLY" ] || { - . /lib/functions.sh - . ../netifd-proto.sh - init_proto "$@" -} - -proto_l2tpv2_init_config() { - proto_config_add_string "username" - proto_config_add_string "password" - proto_config_add_string "keepalive" - proto_config_add_string "pppd_options" - proto_config_add_boolean "ipv6" - proto_config_add_int "mtu" - proto_config_add_string "server" - available=1 - no_device=1 -} - -proto_l2tpv2_setup() { - local config="$1" - local iface="$2" - local optfile="/tmp/l2tp/options.${config}" - - local ip serv_addr server - json_get_var server server && { - for ip in $(resolveip -t 5 "$server"); do - ( proto_add_host_dependency "$config" "$ip" ) - serv_addr=1 - done - } - [ -n "$serv_addr" ] || { - echo "Could not resolve server address" - sleep 5 - proto_setup_failed "$config" - exit 1 - } - - if [ ! -p /var/run/xl2tpd/l2tp-control ]; then - /etc/init.d/xl2tpd start - fi - - json_get_vars ipv6 demand keepalive username password pppd_options - [ "$ipv6" = 1 ] || ipv6="" - if [ "${demand:-0}" -gt 0 ]; then - demand="precompiled-active-filter /etc/ppp/filter demand idle $demand" - else - demand="persist" - fi - - [ -n "$mtu" ] || json_get_var mtu mtu - - local interval="${keepalive##*[, ]}" - [ "$interval" != "$keepalive" ] || interval=5 - - mkdir -p /tmp/l2tp - - echo "${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}}" > "${optfile}" - echo "usepeerdns" >> "${optfile}" - echo "nodefaultroute" >> "${optfile}" - echo "${username:+user \"$username\" password \"$password\"}" >> "${optfile}" - echo "ipparam \"$config\"" >> "${optfile}" - echo "ifname \"l2tp-$config\"" >> "${optfile}" - echo "ip-up-script /lib/netifd/ppp-up" >> "${optfile}" - echo "ipv6-up-script /lib/netifd/ppp-up" >> "${optfile}" - echo "ip-down-script /lib/netifd/ppp-down" >> "${optfile}" - 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_l2tpv2_teardown() { - local interface="$1" - local optfile="/tmp/l2tp/options.${interface}" - - case "$ERROR" in - 11|19) - proto_notify_error "$interface" AUTH_FAILED - proto_block_restart "$interface" - ;; - 2) - proto_notify_error "$interface" INVALID_OPTIONS - proto_block_restart "$interface" - ;; - esac - - xl2tpd-control disconnect l2tp-${interface} - # Wait for interface to go down - while [ -d /sys/class/net/l2tp-${interface} ]; do - sleep 1 - done - - xl2tpd-control remove l2tp-${interface} - rm -f ${optfile} -} - -[ -n "$INCLUDE_ONLY" ] || { - add_protocol l2tpv2 -}