Browse Source

rp-pppoe: add support for logical interface names and fix interface triggers

Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
lilik-openwrt-22.03
Alin Nastac 7 years ago
committed by Alin Nastac
parent
commit
b8e6e7f0e8
3 changed files with 32 additions and 30 deletions
  1. +1
    -1
      net/rp-pppoe/Makefile
  2. +22
    -20
      net/rp-pppoe/files/pppoe-relay.init
  3. +9
    -9
      net/rp-pppoe/files/pppoe-server.init

+ 1
- 1
net/rp-pppoe/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=rp-pppoe
PKG_VERSION:=3.12
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_MAINTAINER:=Daniel Dickinson <lede@cshore.thecshore.com>
PKG_LICENSE:=LGPL-2.0+


+ 22
- 20
net/rp-pppoe/files/pppoe-relay.init View File

@ -13,20 +13,14 @@ pppoe_triggers() {
config_get server_interfaces "$cfg" server_interface
config_get client_interfaces "$cfg" client_interface
config_get both_interfaces "$cfg" both_interfaces
for interface in $server_interfaces; do
append interfaces "$interface" "|"
done
for interface in $client_interfaces; do
append interfaces "$interface" "|"
done
for interface in $both_interfaces; do
append interfaces "$interface" "|"
for interface in $server_interfaces $client_interfaces $both_interfaces; do
procd_add_reload_interface_trigger $interface
done
}
pppoe_relay_instance() {
local cfg="$1"
local enabled interface server_interfaces client_interfaces both_interfaces maxsessions timeout OPTIONS
local enabled interface device server_interfaces client_interfaces both_interfaces maxsessions timeout OPTIONS
config_get_bool enabled "$cfg" enabled 1
[ "$enabled" -gt 0 ] || return 0
config_get server_interfaces "$cfg" server_interface
@ -39,23 +33,34 @@ pppoe_relay_instance() {
if [ "$use_non_uci_config" -gt 0 ]; then
. /etc/default/pppoe-relay
else
[ -z "${server_interfaces}${client_interfaces}${both_interfaces}" ] && return 1
local NEED_INTFS=SC
. /lib/functions/network.sh
for interface in $server_interfaces; do
append OPTIONS "-S $interface"
if network_get_physdev device $interface; then
append OPTIONS "-S $device"
NEED_INTFS=${NEED_INTFS/S/}
fi
done
for interface in $client_interfaces; do
append OPTIONS "-C $interface"
if network_get_physdev device $interface; then
append OPTIONS "-C $device"
NEED_INTFS=${NEED_INTFS/C/}
fi
done
for interface in $both_interfaces; do
append OPTIONS "-B $interface"
if network_get_physdev device $interface; then
append OPTIONS "-B $device"
NEED_INTFS=${NEED_INTFS/?/}
fi
done
[ -z "${NEED_INTFS}" ] || return 1 # need at least 2 interfaces, one for server(s) and one for client(s)
[ -n "$maxsessions" ] && append OPTIONS "-n $maxsessions"
[ -n "$timeout" ] && append OPTIONS "-i $timeout"
fi
procd_open_instance
procd_set_param command /usr/sbin/pppoe-relay -F
procd_append_param command $OPTIONS
procd_set_param command /usr/sbin/pppoe-relay -F $OPTIONS
procd_set_param respawn
procd_close_instance
}
@ -66,12 +71,9 @@ start_service() {
config_foreach pppoe_relay_instance pppoe_relay
}
reload_triggers() {
local interfaces
service_triggers() {
procd_add_reload_trigger "pppoe"
config_load pppoe
config_foreach pppoe_triggers pppoe_relay
procd_add_reload_trigger "pppoe"
procd_add_interface_trigger "$interfaces"
}

+ 9
- 9
net/rp-pppoe/files/pppoe-server.init View File

@ -11,11 +11,12 @@ pppoe_triggers() {
config_get_bool enabled "$cfg" enabled 1
[ "$enabled" -gt 0 ] || return 0
config_get interface "$cfg" interface
procd_add_reload_interface_trigger $interface
}
pppoe_instance() {
local cfg="$1"
local enabled interface ac_name service_names service_name maxsessionsperpeer localip firstremoteip maxsessions optionsfiles randomsession unit offset timeout mss sync OPTIONS
local enabled interface device ac_name service_names service_name maxsessionsperpeer localip firstremoteip maxsessions optionsfiles randomsession unit offset timeout mss sync OPTIONS
config_get_bool enabled "$cfg" enabled 1
[ "$enabled" -gt 0 ] || return 0
config_get interface "$cfg" interface
@ -37,12 +38,13 @@ pppoe_instance() {
if [ "$use_non_uci_config" -gt 0 ]; then
. /etc/default/pppoe-server
else
[ -z "$interface" ] && return 1
. /lib/functions/network.sh
network_get_physdev device $interface || return 1
[ -n "$ac_name" ] && append OPTIONS "-C $ac_name"
for service_name in $service_names; do
append OPTIONS "-S $service_name"
done
append OPTIONS "-I $interface"
append OPTIONS "-I $device"
[ -n "$maxsessionsperpeer" ] && append OPTIONS "-x $maxsessionsperpeer"
[ -n "$localip" ] && append OPTIONS "-L $localip"
[ -n "$firstremoteip" ] && append OPTIONS "-R $firstremoteip"
@ -57,8 +59,8 @@ pppoe_instance() {
fi
procd_open_instance
procd_set_param command /usr/sbin/pppoe-server -F
procd_append_param command -k $OPTIONS
procd_set_param command /usr/sbin/pppoe-server -F -k $OPTIONS
procd_set_param respawn
procd_set_param file /etc/ppp/options
procd_append_param file /etc/ppp/pppoe-server-options
procd_close_instance
@ -70,10 +72,8 @@ start_service() {
}
service_triggers() {
local interface
procd_add_reload_trigger "pppoe"
config_load pppoe
config_foreach pppoe_triggers pppoe_server
procd_add_reload_trigger "pppoe"
procd_add_interface_trigger "$interface"
}

Loading…
Cancel
Save