From: Michael Tremer Date: Sun, 24 Jun 2012 13:20:40 +0000 (+0000) Subject: pppoe-server: Add option to limit sessions per MAC. X-Git-Tag: 004~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f94b87ab3e8539405b1ab55fcde9046e8370f975;p=people%2Fms%2Fnetwork.git pppoe-server: Add option to limit sessions per MAC. --- diff --git a/hooks/zones/bridge.configs/pppoe-server b/hooks/zones/bridge.configs/pppoe-server index b6ba0ea6..0b1cd4cc 100755 --- a/hooks/zones/bridge.configs/pppoe-server +++ b/hooks/zones/bridge.configs/pppoe-server @@ -21,7 +21,7 @@ . /usr/lib/network/header-config -HOOK_SETTINGS="HOOK MTU SERVICE_NAME SUBNET" +HOOK_SETTINGS="HOOK MTU SERVICE_NAME SUBNET MAX_SESSIONS" # Maximum Transmission Unit. MTU=1492 @@ -33,9 +33,14 @@ SERVICE_NAME= # The net address will be the gateway address for the PPPoE server. SUBNET= +# Defines the max. number of sessions per MAC address. +# 0 = unlimited. +MAX_SESSIONS=0 + function _check() { assert isset MTU assert isset SUBNET + assert isset MAX_SESSIONS } function _create() { @@ -44,6 +49,9 @@ function _create() { while [ $# -gt 0 ]; do case "${1}" in + --max-sessions=*) + MAX_SESSIONS=$(cli_get_val ${1}) + ;; --mtu=*) MTU=$(cli_get_val ${1}) ;; @@ -121,5 +129,12 @@ function _status() { "${start_address}-${end_address}" cli_space + local max_sessions=${MAX_SESSIONS} + if [ "${max_sessions}" = "0" ]; then + max_sessions="unlimited" + fi + cli_print_fmt1 3 "${max_sessions} session(s) per MAC" + cli_space + exit ${EXIT_OK} } diff --git a/ppp/pppoe-server b/ppp/pppoe-server index 01538ba7..33da580e 100644 --- a/ppp/pppoe-server +++ b/ppp/pppoe-server @@ -66,6 +66,11 @@ case "${action}" in pppoe_cmdline="${pppoe_cmdline} -S ${SERVICE_NAME// /_}" fi + # Add the max. number of sessions per MAC address. + if [ ${MAX_SESSIONS} -gt 0 ]; then + pppoe_cmdline="${pppoe_cmdline} -x ${MAX_SESSIONS}" + fi + # Create the pppoe-server-options file. pppoe_server_options ${pppd_options} ${zone} pppoe_cmdline="${pppoe_cmdline} -O ${pppd_options}"