From 9d34c488251c0d5111b4a3c880f2291548645db3 Mon Sep 17 00:00:00 2001 From: aapostoliuk Date: Fri, 22 Mar 2024 16:10:59 +0200 Subject: T6150: Fixed setting a static IP address by Radius in IPoE Fixed setting a static IP address by Radius in IPoE Allowing using named pools by default Allowed adding 'gateway-address' without named pool. --- data/templates/accel-ppp/ipoe.config.tmpl | 29 ++++++++++++++-------- .../include/accel-ppp/gateway-address-multi.xml.i | 17 +++++++++++++ interface-definitions/service_ipoe-server.xml.in | 1 + src/conf_mode/service_ipoe-server.py | 13 ++++++++++ 4 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 interface-definitions/include/accel-ppp/gateway-address-multi.xml.i diff --git a/data/templates/accel-ppp/ipoe.config.tmpl b/data/templates/accel-ppp/ipoe.config.tmpl index 0599b5501..976cddd52 100644 --- a/data/templates/accel-ppp/ipoe.config.tmpl +++ b/data/templates/accel-ppp/ipoe.config.tmpl @@ -32,20 +32,29 @@ interface={{ ifname }},shared={{ interface.shared }},mode={{ interface.mode }},i {% endfor %} {% if auth_mode == 'noauth' %} noauth=1 -{% if client_named_ip_pool %} -{% for pool in client_named_ip_pool %} -{% if pool.subnet is defined %} -ip-pool={{ pool.name }} -{% endif %} -{% if pool.gateway_address is defined %} -gw-ip-address={{ pool.gateway_address }}/{{ pool.subnet.split('/')[1] }} -{% endif %} -{% endfor%} -{% endif %} {% elif auth_mode == 'local' %} username=ifname password=csid +{% elif auth_mode == 'radius' %} +attr-dhcp-client-ip=Framed-IP-Address +attr-dhcp-mask=Framed-IP-Netmask +{% endif %} +{% if gateway_address %} +{% for gw in gateway_address %} +gw-ip-address={{ gw }} +{% endfor %} +{% endif %} +{% if client_named_ip_pool %} +{% for pool in client_named_ip_pool %} +{% if pool.subnet is defined %} +ip-pool={{ pool.name }} +{% endif %} +{% if pool.gateway_address is defined %} +gw-ip-address={{ pool.gateway_address }}/{{ pool.subnet.split('/')[1] }} +{% endif %} +{% endfor%} {% endif %} + proxy-arp=1 {% for interface in interfaces %} diff --git a/interface-definitions/include/accel-ppp/gateway-address-multi.xml.i b/interface-definitions/include/accel-ppp/gateway-address-multi.xml.i new file mode 100644 index 000000000..dcc58b97a --- /dev/null +++ b/interface-definitions/include/accel-ppp/gateway-address-multi.xml.i @@ -0,0 +1,17 @@ + + + + Gateway IP address + invalid IPv4 address + + ipv4net + Default Gateway, mask send to the client + + + + + + + + + diff --git a/interface-definitions/service_ipoe-server.xml.in b/interface-definitions/service_ipoe-server.xml.in index d81ec99f9..a084d8c07 100644 --- a/interface-definitions/service_ipoe-server.xml.in +++ b/interface-definitions/service_ipoe-server.xml.in @@ -121,6 +121,7 @@ #include + #include Client authentication methods diff --git a/src/conf_mode/service_ipoe-server.py b/src/conf_mode/service_ipoe-server.py index 42cfd0f12..86185f37f 100755 --- a/src/conf_mode/service_ipoe-server.py +++ b/src/conf_mode/service_ipoe-server.py @@ -44,6 +44,7 @@ default_config_data = { 'client_named_ip_pool': [], 'client_ipv6_pool': [], 'client_ipv6_delegate_prefix': [], + 'gateway_address':[], 'radius_server': [], 'radius_acct_inter_jitter': '', 'radius_acct_tmo': '3', @@ -275,9 +276,14 @@ def get_config(config=None): ipoe['client_ipv6_delegate_prefix'].append(tmp) + if conf.exists(['gateway-address']): + for gw in conf.return_values(['gateway-address']): + ipoe['gateway_address'].append(gw) + return ipoe + def verify(ipoe): if not ipoe: return None @@ -303,6 +309,13 @@ def verify(ipoe): if ipoe['client_ipv6_delegate_prefix'] and not ipoe['client_ipv6_pool']: raise ConfigError('IPoE IPv6 deletate-prefix requires IPv6 prefix to be configured!') + if ipoe['gateway_address']: + if ipoe['client_named_ip_pool']: + ipoe_gateways = ' '.join(ipoe['gateway_address']) + for pool in ipoe['client_named_ip_pool']: + if f'{pool["gateway_address"]}/' in ipoe_gateways: + raise ConfigError( + 'IPoE "gateway-address" exists in IPoE "client-ip-pool"!') return None -- cgit v1.2.3