From 38f31c805d7c79df7405a7b65d6775a4d762eb90 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 29 Nov 2019 22:07:05 +0100 Subject: pppoe: T1318: add first version of new XML/Python implementation vyos@vyos# show interfaces pppoe pppoe pppoe0 { default-route force link eth2.7 mtu 400 name-server auto password 12345678 user-id vyos@vyos.io } --- interface-definitions/interfaces-pppoe.xml.in | 185 ++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 interface-definitions/interfaces-pppoe.xml.in (limited to 'interface-definitions') diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in new file mode 100644 index 000000000..f5431852a --- /dev/null +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -0,0 +1,185 @@ + + + + + + + Point-to-Point Protocol over Ethernet (PPPoE) + 320 + + pppoe[0-9]+$ + + + PPPoE interface must be named pppoeN + + pppoeN + PPPoE interface name (1-15) + + + + + + Access concentrator name (only connect to this concentrator) + + [a-zA-Z0-9]+$ + + Access concentrator name must be composed of uppper and lower case letters or numbers only + + + + + Automatic establishment of PPPOE connection when traffic is sent + + + + + + Enable/Disable default route to peer when link comes up + + auto none force + + + auto + Install default route when link comes up + + + none + Do not install default route when link comes up + + + force + Install default route and replace pre-existing when link comes up + + + (auto|none|force) + + Must be either 'auto', 'none' or 'force' + + + + + Disable interface + + + + + + Delay before disconnecting idle session (in seconds) + + n + Idle timeout in seconds + + + + + + + + IPv6 address configuration modes + + + + + Enable Stateless Address Autoconfiguration (SLAAC) + + + + + + + + Activate IPv6 support on this connection + + + + + + + + Physical Interface used for this PPPoE session + + + + + + + + IPv4 address of local end of the PPPoE link + + ipv4 + Address of local end of the PPPoE link + + + + + + + + + Maximum Transmission Unit (MTU) + + 68-1500 + Maximum Transmission Unit (default 1492) + + + + + MTU must be between 68 and 1500 + + + + + Enable/Disable use of name server entries from peer + + auto none + + + auto + Install default route when link comes up + + + none + Do not install default route when link comes up + + + (auto|none) + + Must be either 'auto' or 'none' + + + + + Password for authenticating local machine to PPPoE server + + + + + IPv4 address of remote end of the PPPoE link + + ipv4 + Address of remote end of the PPPoE link + + + + + + + + + Service name, only connect to access concentrators advertising this + + [a-zA-Z0-9]+$ + + Service name must be composed of uppper and lower case letters or numbers only + + + + + Authentication name supplied to PPPoE server + + + + + + + -- cgit v1.2.3 From 7f22cf0f6cdd6e09ae6729d8762ab265ee7bde4c Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 1 Dec 2019 13:28:12 +0100 Subject: pppoe: T1318: support interface description --- interface-definitions/interfaces-pppoe.xml.in | 5 +++++ src/conf_mode/interfaces-pppoe.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'interface-definitions') diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in index f5431852a..7511cc51d 100644 --- a/interface-definitions/interfaces-pppoe.xml.in +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -56,6 +56,11 @@ Must be either 'auto', 'none' or 'force' + + + Interface description + + Disable interface diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 0fe4207a7..8acdf8e29 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -30,11 +30,10 @@ from netifaces import interfaces config_pppoe_tmpl = """ ### Autogenerated by interfaces-pppoe.py ### -# Configuration file for PPP, using PPP over Ethernet (PPPOE) -# to connect to a DSL provider. +{% if description %} +# {{ description }} +{% endif %} -# Default parameters not set by Vyatta templates: -# # Require peer to provide the local IP address if it is not # specified explicitly in the config file. noipdefault @@ -96,6 +95,7 @@ default_config_data = { 'on_demand': False, 'default_route': 'auto', 'deleted': False, + 'description': '', 'disable': False, 'intf': '', 'idle_timeout': '', @@ -145,6 +145,10 @@ def get_config(): if conf.exists('default-route'): pppoe['default_route'] = conf.return_value('default-route') + # Retrieve interface description + if conf.exists('description'): + pppoe['description'] = conf.return_value('description') + # Disable this interface if conf.exists('disable'): pppoe['disable'] = True -- cgit v1.2.3 From 2608adc31dbc3ca93b852549233f8327f2f4c883 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 22 Feb 2020 09:52:16 +0100 Subject: pppoe: T1318: increase priority so PPPoE is run after bond interfaces --- interface-definitions/interfaces-pppoe.xml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'interface-definitions') diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in index 7511cc51d..bd558f01d 100644 --- a/interface-definitions/interfaces-pppoe.xml.in +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -5,7 +5,7 @@ Point-to-Point Protocol over Ethernet (PPPoE) - 320 + 321 pppoe[0-9]+$ -- cgit v1.2.3 From d895f853aaa5c42547067eaf3ca6384968339776 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 12:13:47 +0100 Subject: interface-definitions: include: disable: rephrase help text --- interface-definitions/include/interface-disable.xml.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'interface-definitions') diff --git a/interface-definitions/include/interface-disable.xml.i b/interface-definitions/include/interface-disable.xml.i index c6c24f867..a4778859c 100644 --- a/interface-definitions/include/interface-disable.xml.i +++ b/interface-definitions/include/interface-disable.xml.i @@ -1,6 +1,6 @@ - Set interface to Administratively down + Administratively disable interface -- cgit v1.2.3 From 96a2c2f3e512e3922adc73f1356b48d2ebff2873 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 12:15:43 +0100 Subject: pppoe: T1318: rephrase help text on default-route --- interface-definitions/interfaces-pppoe.xml.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'interface-definitions') diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in index bd558f01d..450d177e5 100644 --- a/interface-definitions/interfaces-pppoe.xml.in +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -34,26 +34,26 @@ - Enable/Disable default route to peer when link comes up + Default route insertion behaviour (default: auto) auto none force + + (auto|none|force) + + PPPoE default-route option must be 'auto', 'none', or 'force' auto - Install default route when link comes up + Automatically install a default route none - Do not install default route when link comes up + Do not install a default route force - Install default route and replace pre-existing when link comes up + Replace existing default route - - (auto|none|force) - - Must be either 'auto', 'none' or 'force' -- cgit v1.2.3 From daca2a39b4d0f4ebdf07463679b9465c64886763 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 12:19:03 +0100 Subject: pppoe: T1318: use include files for disable and descriptionx --- interface-definitions/interfaces-pppoe.xml.in | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'interface-definitions') diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in index 450d177e5..93b07f4e4 100644 --- a/interface-definitions/interfaces-pppoe.xml.in +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -56,17 +56,8 @@ - - - Interface description - - - - - Disable interface - - - + #include + #include Delay before disconnecting idle session (in seconds) -- cgit v1.2.3 From 07273632fcf59d04be988f2c43fe53e7bec8d46a Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 12:22:34 +0100 Subject: pppoe: T1318: rename link to source-interface --- interface-definitions/interfaces-pppoe.xml.in | 4 +- src/conf_mode/interfaces-pppoe.py | 16 ++--- src/migration-scripts/interfaces/4-to-5 | 91 +++++---------------------- 3 files changed, 24 insertions(+), 87 deletions(-) (limited to 'interface-definitions') diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in index 93b07f4e4..8bae0e490 100644 --- a/interface-definitions/interfaces-pppoe.xml.in +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -90,11 +90,11 @@ - + Physical Interface used for this PPPoE session - + diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 6ab3fbd95..49902b989 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -64,7 +64,7 @@ noauth noproxyarp plugin rp-pppoe.so -{{ link }} +{{ source_interface }} persist ifname {{ intf }} ipparam {{ intf }} @@ -100,14 +100,14 @@ default_config_data = { 'idle_timeout': '', 'ipv6_autoconf': False, 'ipv6_enable': False, - 'link': '', 'local_address': '', 'mtu': '1492', 'name_server': 'auto', 'password': '', 'remote_address': '', 'service_name': '', - 'user_id': '' + 'user_id': '', + 'source_interface': '' } def subprocess_cmd(command): @@ -165,13 +165,13 @@ def get_config(): if conf.exists(['ipv6', 'enable']): pppoe['ipv6_enable'] = True - # IPv4 address of local end of the PPPoE link + # IPv4 address of local end of PPPoE link if conf.exists(['local-address']): pppoe['local_address'] = conf.return_value(['local-address']) # Physical Interface used for this PPPoE session - if conf.exists(['link']): - pppoe['link'] = conf.return_value('link') + if conf.exists(['source-interface']): + pppoe['source_interface'] = conf.return_value('source-interface') # Maximum Transmission Unit (MTU) if conf.exists(['mtu']): @@ -204,8 +204,8 @@ def verify(pppoe): # bail out early return None - if not pppoe['link']: - raise ConfigError('Physical link interface for PPPoE missing') + if not pppoe['source_interface']: + raise ConfigError('PPPoE source interface is missing') return None diff --git a/src/migration-scripts/interfaces/4-to-5 b/src/migration-scripts/interfaces/4-to-5 index db2be4a66..0683861f2 100755 --- a/src/migration-scripts/interfaces/4-to-5 +++ b/src/migration-scripts/interfaces/4-to-5 @@ -9,91 +9,28 @@ from vyos.configtree import ConfigTree def migrate_dialer(config, tree, intf): for pppoe in config.list_nodes(tree): # assemble string, 0 -> pppoe0 - new_base = ['interfaces', 'pppoe', 'pppoe' + pppoe] + new_base = ['interfaces', 'pppoe'] + pppoe_base = new_base + ['pppoe' + pppoe] config.set(new_base) # format as tag node to avoid loading problems - config.set_tag(['interfaces', 'pppoe']) - - # - # Firewall migrieren - # - firewall = tree + [pppoe, 'firewall'] - if config.exists(firewall): - config.copy(firewall, new_base + ['firewall']) - - policy = tree + [pppoe, 'policy'] - if config.exists(policy): - config.copy(policy, new_base + ['policy']) - - # - # QoS migrieren - # - redirect = tree + [pppoe, 'redirect'] - if config.exists(redirect): - config.copy(redirect, new_base + ['redirect']) - - traffic_policy = tree + [pppoe, 'traffic-policy'] - if config.exists(traffic_policy): - config.copy(traffic_policy, new_base + ['traffic-policy']) - - # - # Quagga migrieren - # - ip = tree + [pppoe, 'ip'] - if config.exists(ip): - config.copy(ip, new_base + ['ip']) - - ipv6 = tree + [pppoe, 'ipv6'] - if config.exists(ipv6): - config.copy(ipv6, new_base + ['ipv6']) - - # - # Interface migration - # - config.set(new_base + ['link'], value=intf) - - default_route = tree + [pppoe, 'default-route'] - if config.exists(default_route): - tmp = config.return_value(default_route) - config.set(new_base + ['default-route'], value=tmp) - - disable = tree + [pppoe, 'disable'] - if config.exists(disable): - tmp = config.return_value(disable) - config.set(new_base + ['disable'], value=tmp) - - mtu = tree + [pppoe, 'mtu'] - if config.exists(mtu): - tmp = config.return_value(mtu) - config.set(new_base + ['mtu'], value=tmp) - - nameserver = tree + [pppoe, 'name-server'] - if config.exists(nameserver): - tmp = config.return_value(nameserver) - config.set(new_base + ['name-server'], value=tmp) - - password = tree + [pppoe, 'password'] - if config.exists(password): - tmp = config.return_value(password) - config.set(new_base + ['password'], value=tmp) - - userid = tree + [pppoe, 'user-id'] - if config.exists(userid): - tmp = config.return_value(userid) - config.set(new_base + ['user-id'], value=tmp) + config.set_tag(new_base) + + # Copy the entire old node to the new one before migrating individual + # parts + config.copy(tree + [pppoe], pppoe_base) + # remove enable-ipv6 node and rather place it under ipv6 node - ipv6_enable = tree + [pppoe, 'enable-ipv6'] - if config.exists(ipv6_enable): - config.set(new_base + ['ipv6', 'enable']) + if config.exists(pppoe_base + ['enable-ipv6']): + config.set(pppoe_base + ['ipv6', 'enable']) + config.delete(pppoe_base + ['enable-ipv6']) - ipv6_slaac = tree + [pppoe, 'ipv6', 'address', 'autoconf'] - if config.exists(ipv6_slaac): - config.set(new_base + ['ipv6', 'address', 'autoconf']) + # Source interface migration + config.set(pppoe_base + ['source-interface'], value=intf) -if __name__ == '__main__': +if __name__ == '__main__': if (len(sys.argv) < 1): print("Must specify file name!") exit(1) -- cgit v1.2.3 From 3d0162557f9c2217d4a925e6c893863b1af55e58 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 12:26:34 +0100 Subject: pppoe: T1318: migrate user-id and password nodes under an authentication node --- interface-definitions/interfaces-pppoe.xml.in | 27 ++++++++++++++++---------- src/conf_mode/interfaces-pppoe.py | 28 +++++++++++++-------------- src/migration-scripts/interfaces/4-to-5 | 11 +++++++++++ 3 files changed, 42 insertions(+), 24 deletions(-) (limited to 'interface-definitions') diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in index 8bae0e490..933d9edf1 100644 --- a/interface-definitions/interfaces-pppoe.xml.in +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -26,6 +26,23 @@ Access concentrator name must be composed of uppper and lower case letters or numbers only + + + Authentication settings + + + + + User name + + + + + Password + + + + Automatic establishment of PPPOE connection when traffic is sent @@ -143,11 +160,6 @@ Must be either 'auto' or 'none' - - - Password for authenticating local machine to PPPoE server - - IPv4 address of remote end of the PPPoE link @@ -169,11 +181,6 @@ Service name must be composed of uppper and lower case letters or numbers only - - - Authentication name supplied to PPPoE server - - diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 49902b989..d2147fa1f 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -78,9 +78,9 @@ replacedefaultroute {% endif %} mtu {{ mtu }} mru {{ mtu }} -user "{{ user_id }}" -password "{{ password }}" -{% if 'auto' in name_server -%} +user "{{ auth_username }}" +password "{{ auth_password }}" +{% if name_server -%} usepeerdns {% endif %} {% if ipv6_enable -%} @@ -91,6 +91,8 @@ usepeerdns default_config_data = { 'access_concentrator': '', + 'auth_username': '', + 'auth_password': '', 'on_demand': False, 'default_route': 'auto', 'deleted': False, @@ -103,10 +105,8 @@ default_config_data = { 'local_address': '', 'mtu': '1492', 'name_server': 'auto', - 'password': '', 'remote_address': '', 'service_name': '', - 'user_id': '', 'source_interface': '' } @@ -137,6 +137,14 @@ def get_config(): if conf.exists(['access-concentrator']): pppoe['access_concentrator'] = conf.return_values(['access-concentrator']) + # Authentication name supplied to PPPoE server + if conf.exists(['authentication', 'user']): + pppoe['auth_username'] = conf.return_value(['authentication', 'user']) + + # Password for authenticating local machine to PPPoE server + if conf.exists(['authentication', 'password']): + pppoe['auth_password'] = conf.return_value(['authentication', 'password']) + # Access concentrator name (only connect to this concentrator) if conf.exists(['connect-on-demand']): pppoe['on_demand'] = True @@ -181,11 +189,7 @@ def get_config(): if conf.exists(['name-server']): pppoe['name_server'] = conf.return_value(['name-server']) - # Password for authenticating local machine to PPPoE server - if conf.exists(['password']): - pppoe['password'] = conf.return_value(['password']) - - # IPv4 address of local end of the PPPoE link + # IPv4 address for remote end of PPPoE session if conf.exists(['remote-address']): pppoe['remote_address'] = conf.return_value(['remote-address']) @@ -193,10 +197,6 @@ def get_config(): if conf.exists(['service-name']): pppoe['service_name'] = conf.return_value(['service-name']) - # Authentication name supplied to PPPoE server - if conf.exists(['user-id']): - pppoe['user_id'] = conf.return_value(['user-id']) - return pppoe def verify(pppoe): diff --git a/src/migration-scripts/interfaces/4-to-5 b/src/migration-scripts/interfaces/4-to-5 index 0683861f2..19e0352c8 100755 --- a/src/migration-scripts/interfaces/4-to-5 +++ b/src/migration-scripts/interfaces/4-to-5 @@ -19,6 +19,17 @@ def migrate_dialer(config, tree, intf): # parts config.copy(tree + [pppoe], pppoe_base) + # Migrate user-id and password nodes under an 'authentication' + # node + if config.exists(pppoe_base + ['user-id']): + user = config.return_value(pppoe_base + ['user-id']) + config.set(pppoe_base + ['authentication', 'user'], value=user) + config.delete(pppoe_base + ['user-id']) + + if config.exists(pppoe_base + ['password']): + pwd = config.return_value(pppoe_base + ['password']) + config.set(pppoe_base + ['authentication', 'password'], value=pwd) + config.delete(pppoe_base + ['password']) # remove enable-ipv6 node and rather place it under ipv6 node if config.exists(pppoe_base + ['enable-ipv6']): -- cgit v1.2.3 From 2fec7394434f8daace485e97a7287cc8233fa178 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 12:27:55 +0100 Subject: pppoe: T1318: declutter name-server CLI nodes Instead of letting the user choose between auto and none where auto is default, it makes more sesne to just offer an option to disable the default behavior. --- interface-definitions/interfaces-pppoe.xml.in | 20 +++----------------- src/conf_mode/interfaces-pppoe.py | 8 ++++---- src/migration-scripts/interfaces/4-to-5 | 9 +++++++++ 3 files changed, 16 insertions(+), 21 deletions(-) (limited to 'interface-definitions') diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in index 933d9edf1..b6b54c915 100644 --- a/interface-definitions/interfaces-pppoe.xml.in +++ b/interface-definitions/interfaces-pppoe.xml.in @@ -140,24 +140,10 @@ MTU must be between 68 and 1500 - + - Enable/Disable use of name server entries from peer - - auto none - - - auto - Install default route when link comes up - - - none - Do not install default route when link comes up - - - (auto|none) - - Must be either 'auto' or 'none' + Do not use DNS servers provided by the peer + diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index d2147fa1f..4ca7f3ecb 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -104,7 +104,7 @@ default_config_data = { 'ipv6_enable': False, 'local_address': '', 'mtu': '1492', - 'name_server': 'auto', + 'name_server': True, 'remote_address': '', 'service_name': '', 'source_interface': '' @@ -185,9 +185,9 @@ def get_config(): if conf.exists(['mtu']): pppoe['mtu'] = conf.return_value(['mtu']) - # IPv4 address of local end of the PPPoE link - if conf.exists(['name-server']): - pppoe['name_server'] = conf.return_value(['name-server']) + # Do not use DNS servers provided by the peer + if conf.exists(['no-peer-dns']): + pppoe['name_server'] = False # IPv4 address for remote end of PPPoE session if conf.exists(['remote-address']): diff --git a/src/migration-scripts/interfaces/4-to-5 b/src/migration-scripts/interfaces/4-to-5 index dd1e9a51e..2a42c60ff 100755 --- a/src/migration-scripts/interfaces/4-to-5 +++ b/src/migration-scripts/interfaces/4-to-5 @@ -19,6 +19,15 @@ def migrate_dialer(config, tree, intf): # parts config.copy(tree + [pppoe], pppoe_base) + # Instead of letting the user choose between auto and none + # where auto is default, it makes more sesne to just offer + # an option to disable the default behavior (declutter CLI) + if config.exists(pppoe_base + ['name-server']): + tmp = config.return_value(pppoe_base + ['name-server']) + if tmp == "none": + config.set(pppoe_base + ['no-peer-dns']) + config.delete(pppoe_base + ['name-server']) + # Migrate user-id and password nodes under an 'authentication' # node if config.exists(pppoe_base + ['user-id']): -- cgit v1.2.3