From 477d056768eb61b38f5236a8a2fdf4ff43b71fd0 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 19 Feb 2020 15:56:07 -0600 Subject: snmp: T1769: fix indentation error and add try clause --- src/conf_mode/snmp.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py index 7cffa5e04..ac94afb1a 100755 --- a/src/conf_mode/snmp.py +++ b/src/conf_mode/snmp.py @@ -710,18 +710,20 @@ def apply(snmp): # Passwords are not available immediately in the configuration file, # after daemon startup - we wait until they have been processed by # snmpd, which we see when a magic line appears in this file. - ready = False - while not ready: + while True: while not os.path.exists(config_file_user): sleep(0.5) - ready = True - with open(config_file_user, 'r') as f: - for line in f: - # Search for our magic string inside the file - if 'usmUser' in line: - ready = True - break + try: + with open(config_file_user, 'r') as f: + for line in f: + # Search for our magic string inside the file + if 'usmUser' in line: + break + except IOError: + continue + else: + break # net-snmp is now regenerating the configuration file in the background # thus we need to re-open and re-read the file as the content changed. -- cgit v1.2.3 From ceb4031b7647de742be078918085732783fad78d Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Fri, 21 Feb 2020 16:46:33 -0600 Subject: [service https] T1443: bug: set HTTPS listen port for listen-address '*' --- src/conf_mode/https.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/https.py b/src/conf_mode/https.py index 5d90b2b53..d8e78c6cd 100755 --- a/src/conf_mode/https.py +++ b/src/conf_mode/https.py @@ -47,8 +47,8 @@ server { # SSL configuration # {% if server.address == '*' %} - listen 443 ssl; - listen [::]:443 ssl; + listen {{ server.port }} ssl; + listen [::]:{{ server.port }} ssl; {% else %} listen {{ server.address }}:{{ server.port }} ssl; {% endif %} -- cgit v1.2.3 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 } --- debian/control | 1 + debian/vyos-1x.install | 4 +- interface-definitions/interfaces-pppoe.xml.in | 185 ++++++++++++++++ src/conf_mode/interfaces-pppoe.py | 293 ++++++++++++++++++++++++++ src/migration-scripts/interfaces/4-to-5 | 105 +++++++++ 5 files changed, 586 insertions(+), 2 deletions(-) create mode 100644 interface-definitions/interfaces-pppoe.xml.in create mode 100755 src/conf_mode/interfaces-pppoe.py create mode 100755 src/migration-scripts/interfaces/4-to-5 (limited to 'src/conf_mode') diff --git a/debian/control b/debian/control index dc6c9a8f4..fbcc3fa2e 100644 --- a/debian/control +++ b/debian/control @@ -84,6 +84,7 @@ Depends: python3, wireless-regdb, pmacct (>= 1.6.0), python3-certbot-nginx, + pppoe, ${shlibs:Depends}, ${misc:Depends} Description: VyOS configuration scripts and data diff --git a/debian/vyos-1x.install b/debian/vyos-1x.install index e1236b75b..eb19dafeb 100644 --- a/debian/vyos-1x.install +++ b/debian/vyos-1x.install @@ -1,7 +1,7 @@ +etc/dhcp etc/init.d -etc/vyos etc/systemd -etc/dhcp +etc/vyos lib/ opt/ usr/ 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 + + + + + + + diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py new file mode 100755 index 000000000..eb64d094b --- /dev/null +++ b/src/conf_mode/interfaces-pppoe.py @@ -0,0 +1,293 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2019 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os + +from sys import exit +from copy import deepcopy + +from jinja2 import Template +from psutil import pid_exists +from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP, S_IROTH, S_IXOTH +from subprocess import Popen, PIPE + +from vyos.config import Config +from vyos import ConfigError +from netifaces import interfaces + +# Please be careful if you edit the template. +config_pppoe_tmpl = """ +### Autogenerated by interfaces-pppoe.py ### + +# Configuration file for PPP, using PPP over Ethernet (PPPOE) +# to connect to a DSL provider. + +# 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 + +# Don't show the password in logfiles: +hide-password + +# Standard Link Control Protocol (LCP) parameters: +lcp-echo-interval 20 +lcp-echo-failure 3 + +# RFC 2516, paragraph 7 mandates that the following options MUST NOT be +# requested and MUST be rejected if requested by the peer: +# Address-and-Control-Field-Compression (ACFC) +noaccomp + +# Asynchronous-Control-Character-Map (ACCM) +default-asyncmap + +# Override any connect script that may have been set in /etc/ppp/options. +connect /bin/true + +# Don't try to authenticate the remote node +noauth + +# Don't try to proxy ARP for the remote endpoint. User can set proxy +# arp entries up manually if they wish. More importantly, having +# the "proxyarp" parameter set disables the "defaultroute" option. +noproxyarp + +plugin rp-pppoe.so +{{ link }} +persist +ifname {{ intf }} +ipparam {{ intf }} +debug +logfile /var/log/vyatta/ppp_{{ intf }}.log +{% if 'auto' in default_route -%} +defaultroute +{% elif 'force' in default_route -%} +defaultroute +replacedefaultroute +{% endif %} +mtu {{ mtu }} +mru {{ mtu }} +user "{{ user_id }}" +password "{{ password }}" +{% if 'auto' in name_server -%} +usepeerdns +{% endif %} +{% if ipv6_enable -%} ++ipv6 +{% endif %} + +""" + +config_pppoe_autoconf_tmpl = """ +#!/bin/sh + +if [ "$6" != "{{ intf }}" ]; then + exit +fi + +echo 0 > /proc/sys/net/ipv6/conf/$1/forwarding +echo 2 > /proc/sys/net/ipv6/conf/$1/accept_ra +echo 1 > /proc/sys/net/ipv6/conf/$1/autoconf +""" + +default_config_data = { + 'access_concentrator': '', + 'on_demand': False, + 'default_route': 'auto', + 'deleted': False, + 'disable': False, + 'intf': '', + 'idle_timeout': '', + 'ipv6_autoconf': False, + 'ipv6_enable': False, + 'link': '', + 'local_address': '', + 'mtu': '1492', + 'name_server': 'auto', + 'password': '', + 'remote_address': '', + 'service_name': '', + 'user_id': '' +} + +def subprocess_cmd(command): + print(command) + p = Popen(command, stdout=PIPE, shell=True) + p.communicate() + +def get_config(): + pppoe = deepcopy(default_config_data) + conf = Config() + + # determine tagNode instance + try: + pppoe['intf'] = os.environ['VYOS_TAGNODE_VALUE'] + except KeyError as E: + print("Interface not specified") + + # Check if interface has been removed + if not conf.exists('interfaces pppoe ' + pppoe['intf']): + pppoe['deleted'] = True + return pppoe + + # set new configuration level + conf.set_level('interfaces pppoe ' + pppoe['intf']) + + # Access concentrator name (only connect to this concentrator) + if conf.exists('access-concentrator'): + pppoe['access_concentrator'] = conf.return_values('access-concentrator') + + # Access concentrator name (only connect to this concentrator) + if conf.exists('connect-on-demand'): + pppoe['on_demand'] = True + + # Enable/Disable default route to peer when link comes up + if conf.exists('default-route'): + pppoe['default_route'] = conf.return_value('default-route') + + # Disable this interface + if conf.exists('disable'): + pppoe['disable'] = True + + # Delay before disconnecting idle session (in seconds) + if conf.exists('idle-timeout'): + pppoe['idle_timeout'] = conf.return_value('idle-timeout') + + # Enable Stateless Address Autoconfiguration (SLAAC) + if conf.exists('ipv6 address autoconf'): + pppoe['ipv6_autoconf'] = True + + # Activate IPv6 support on this connection + if conf.exists('ipv6 enable'): + pppoe['ipv6_enable'] = True + + # IPv4 address of local end of the 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') + + # Maximum Transmission Unit (MTU) + 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') + + # 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 + if conf.exists('remote-address'): + pppoe['remote_address'] = conf.return_value('remote-address') + + # Service name, only connect to access concentrators advertising this + 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): + if pppoe['deleted']: + # bail out early + return None + + return None + + +def generate(pppoe): + config_file_pppoe = '/etc/ppp/peers/{}'.format(pppoe['intf']) + config_file_ifup = '/etc/ppp/ipv6-up.d/50-vyos-{}-autoconf'.format(pppoe['intf']) + + pid = 0 + pidfile = '/var/run/{}.pid'.format(pppoe['intf']) + if os.path.isfile(pidfile): + pid = 0 + with open(pidfile, 'r') as f: + pid = int(f.read()) + + # Always stop OpenVPN service. We can not send a SIGUSR1 for restart of the + # service as the configuration is not re-read. Stop daemon only if it's + # running - it could have died or killed by someone evil + print("pid: {}".format(pid)) + if pid_exists(pid): + cmd = 'start-stop-daemon --stop --quiet' + cmd += ' --pidfile ' + pidfile + subprocess_cmd(cmd) + + if pppoe['deleted']: + # Delete PPP configuration files + if os.path.exists(config_file_pppoe): + os.unlink(config_file_pppoe) + + if os.path.exists(config_file_ifup): + os.unlink(config_file_ifup) + + else: + # Create PPP configuration files + tmpl = Template(config_pppoe_tmpl) + config_text = tmpl.render(pppoe) + with open(config_file_pppoe, 'w') as f: + f.write(config_text) + + tmpl = Template(config_pppoe_autoconf_tmpl) + config_text = tmpl.render(pppoe) + with open(config_file_ifup, 'w') as f: + f.write(config_text) + + os.chmod(config_file_ifup, + S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) + + if not pppoe['disable']: + # No matching PPP process running - spawn a new one + cmd = 'start-stop-daemon --start --quiet' + cmd += ' --pidfile ' + pidfile + cmd += ' --background' + cmd += ' --exec /usr/sbin/pppd' + # now pass arguments to pppd binary + cmd += ' -- ' + cmd += ' call {}'.format(pppoe['intf']) + + # execute assembled command + subprocess_cmd(cmd) + + return None + + +def apply(pppoe): + return None + + +if __name__ == '__main__': + try: + c = get_config() + verify(c) + generate(c) + apply(c) + except ConfigError as e: + print(e) + exit(1) diff --git a/src/migration-scripts/interfaces/4-to-5 b/src/migration-scripts/interfaces/4-to-5 new file mode 100755 index 000000000..a8f9addcf --- /dev/null +++ b/src/migration-scripts/interfaces/4-to-5 @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 + +# Change syntax of wireless interfaces +# Migrate boolean nodes to valueless + +from sys import exit +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] + config.set(new_base) + # format as tag node to avoid loading problems + config.set_tag(['interfaces', 'pppoe']) + + default_route = tree + [pppoe, 'default-route'] + print(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) + + ipv6_enable = tree + [pppoe, 'enable-ipv6'] + if config.exists(ipv6_enable): + config.set(new_base + ['ipv6', 'enable']) + + ipv6_slaac = tree + [pppoe, 'ipv6', 'address', 'autoconf'] + if config.exists(ipv6_slaac): + config.set(new_base + ['ipv6', 'address', 'autoconf']) + + # Delete old PPPoE interface + config.delete(tree + [pppoe]) + + +if __name__ == '__main__': + + if (len(sys.argv) < 1): + print("Must specify file name!") + exit(1) + + file_name = sys.argv[1] + + with open(file_name, 'r') as f: + config_file = f.read() + + config = ConfigTree(config_file) + pppoe_links = ['bonding', 'ethernet'] + + for link_type in pppoe_links: + if not config.exists(['interfaces', link_type]): + continue + + for interface in config.list_nodes(['interfaces', link_type]): + # check if PPPoE exists + pppoe_if = ['interfaces', link_type, interface, 'pppoe'] + if config.exists(pppoe_if): + for dialer in config.list_nodes(pppoe_if): + migrate_dialer(config, pppoe_if, interface) + + # also migrate VLANs + if not config.exists(['interfaces', link_type, interface, 'vif']): + continue + + for vlan in config.list_nodes(['interfaces', link_type, interface, 'vif']): + pppoe_if = ['interfaces', link_type, interface, 'vif', vlan, 'pppoe'] + if config.exists(pppoe_if): + for dialer in config.list_nodes(pppoe_if): + intf = "{}.{}".format(interface, vlan) + migrate_dialer(config, pppoe_if, intf) + + + print(config.to_string()) + exit(1) + + try: + with open(file_name, 'w') as f: + f.write(config.to_string()) + except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) -- cgit v1.2.3 From 858deb599c5fc207d979e9dadf423a17a9c3a2a7 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 30 Nov 2019 09:01:05 +0100 Subject: pppoe: T1318: "link" option is mandatory --- src/conf_mode/interfaces-pppoe.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index eb64d094b..c7eca5056 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -210,14 +210,15 @@ def get_config(): return pppoe - def verify(pppoe): if pppoe['deleted']: # bail out early return None - return None + if not pppoe['link']: + raise ConfigError('Physical link interface for PPPoE missing') + return None def generate(pppoe): config_file_pppoe = '/etc/ppp/peers/{}'.format(pppoe['intf']) -- cgit v1.2.3 From f9120cd8b866cbcd6aaaa48f5fc8303f034cad50 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 30 Nov 2019 09:04:31 +0100 Subject: pppoe: T1318: move process startup to apply() --- src/conf_mode/interfaces-pppoe.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index c7eca5056..16c59b39b 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -224,22 +224,6 @@ def generate(pppoe): config_file_pppoe = '/etc/ppp/peers/{}'.format(pppoe['intf']) config_file_ifup = '/etc/ppp/ipv6-up.d/50-vyos-{}-autoconf'.format(pppoe['intf']) - pid = 0 - pidfile = '/var/run/{}.pid'.format(pppoe['intf']) - if os.path.isfile(pidfile): - pid = 0 - with open(pidfile, 'r') as f: - pid = int(f.read()) - - # Always stop OpenVPN service. We can not send a SIGUSR1 for restart of the - # service as the configuration is not re-read. Stop daemon only if it's - # running - it could have died or killed by someone evil - print("pid: {}".format(pid)) - if pid_exists(pid): - cmd = 'start-stop-daemon --stop --quiet' - cmd += ' --pidfile ' + pidfile - subprocess_cmd(cmd) - if pppoe['deleted']: # Delete PPP configuration files if os.path.exists(config_file_pppoe): @@ -263,8 +247,26 @@ def generate(pppoe): os.chmod(config_file_ifup, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) + return None + +def apply(pppoe): + pid = 0 + pidfile = '/var/run/{}.pid'.format(pppoe['intf']) + if os.path.isfile(pidfile): + pid = 0 + with open(pidfile, 'r') as f: + pid = int(f.read()) + + # Always stop PPPoE dialer first + if pid_exists(pid): + cmd = 'start-stop-daemon --stop --quiet' + cmd += ' --pidfile ' + pidfile + subprocess_cmd(cmd) + if not pppoe['disable']: # No matching PPP process running - spawn a new one + # NOTE: PID file is only created after dial-in is complete. This is bad + # as you could have zombie dialers. cmd = 'start-stop-daemon --start --quiet' cmd += ' --pidfile ' + pidfile cmd += ' --background' @@ -278,11 +280,6 @@ def generate(pppoe): return None - -def apply(pppoe): - return None - - if __name__ == '__main__': try: c = get_config() -- cgit v1.2.3 From 70049969d8e3c28c8ae7a342fa84eb35ed5c9e14 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 30 Nov 2019 09:09:05 +0100 Subject: pppoe: T1318: remove process startup debug output We no longer need to see the command which is used to spawn up PPPd and dial the connection. --- src/conf_mode/interfaces-pppoe.py | 1 - 1 file changed, 1 deletion(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 16c59b39b..6c194f60b 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -126,7 +126,6 @@ default_config_data = { } def subprocess_cmd(command): - print(command) p = Popen(command, stdout=PIPE, shell=True) p.communicate() -- cgit v1.2.3 From 426f9d33d24a163fc1fc169930d7b969abf846b0 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 1 Dec 2019 10:43:02 +0100 Subject: pppoe: T1318: use systemd to manage connection This reduces the amount of self written code to start-stop-daemon and also kill the process if it has no connection yet (there won't be a PID file in this case) and getting the proper PID for multiple processes would require me to walk the /proc//cmdline for every binary involved. --- src/conf_mode/interfaces-pppoe.py | 32 ++++++-------------------------- src/etc/systemd/system/ppp@.service | 11 +++++++++++ 2 files changed, 17 insertions(+), 26 deletions(-) create mode 100644 src/etc/systemd/system/ppp@.service (limited to 'src/conf_mode') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 6c194f60b..219a40dbf 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -20,7 +20,6 @@ from sys import exit from copy import deepcopy from jinja2 import Template -from psutil import pid_exists from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP, S_IROTH, S_IXOTH from subprocess import Popen, PIPE @@ -223,6 +222,10 @@ def generate(pppoe): config_file_pppoe = '/etc/ppp/peers/{}'.format(pppoe['intf']) config_file_ifup = '/etc/ppp/ipv6-up.d/50-vyos-{}-autoconf'.format(pppoe['intf']) + # Always hang-up PPPoE connection prior generating new configuration file + cmd = 'systemctl stop ppp@{}.service'.format(pppoe['intf']) + subprocess_cmd(cmd) + if pppoe['deleted']: # Delete PPP configuration files if os.path.exists(config_file_pppoe): @@ -249,32 +252,9 @@ def generate(pppoe): return None def apply(pppoe): - pid = 0 - pidfile = '/var/run/{}.pid'.format(pppoe['intf']) - if os.path.isfile(pidfile): - pid = 0 - with open(pidfile, 'r') as f: - pid = int(f.read()) - - # Always stop PPPoE dialer first - if pid_exists(pid): - cmd = 'start-stop-daemon --stop --quiet' - cmd += ' --pidfile ' + pidfile - subprocess_cmd(cmd) - if not pppoe['disable']: - # No matching PPP process running - spawn a new one - # NOTE: PID file is only created after dial-in is complete. This is bad - # as you could have zombie dialers. - cmd = 'start-stop-daemon --start --quiet' - cmd += ' --pidfile ' + pidfile - cmd += ' --background' - cmd += ' --exec /usr/sbin/pppd' - # now pass arguments to pppd binary - cmd += ' -- ' - cmd += ' call {}'.format(pppoe['intf']) - - # execute assembled command + # Dial PPPoE connection + cmd = 'systemctl start ppp@{}.service'.format(pppoe['intf']) subprocess_cmd(cmd) return None diff --git a/src/etc/systemd/system/ppp@.service b/src/etc/systemd/system/ppp@.service new file mode 100644 index 000000000..d271efb41 --- /dev/null +++ b/src/etc/systemd/system/ppp@.service @@ -0,0 +1,11 @@ +[Unit] +Description=Dialing PPP connection %I +After=network.target + +[Service] +ExecStart=/usr/sbin/pppd call %I nodetach nolog +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3 From b7c4c202f7f486576151fd0ca1084f8473b2552d Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 1 Dec 2019 13:20:50 +0100 Subject: pppoe: T1318: remove obsolete ipv6-up.d script The generated script was not called at all. Verified in vyOS 1.2.3 and rolling. Looks like a leftover from the past. If this functionality is required - it should be re-implemented the proper way! --- src/conf_mode/interfaces-pppoe.py | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 219a40dbf..0fe4207a7 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -20,7 +20,6 @@ from sys import exit from copy import deepcopy from jinja2 import Template -from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP, S_IROTH, S_IXOTH from subprocess import Popen, PIPE from vyos.config import Config @@ -92,18 +91,6 @@ usepeerdns """ -config_pppoe_autoconf_tmpl = """ -#!/bin/sh - -if [ "$6" != "{{ intf }}" ]; then - exit -fi - -echo 0 > /proc/sys/net/ipv6/conf/$1/forwarding -echo 2 > /proc/sys/net/ipv6/conf/$1/accept_ra -echo 1 > /proc/sys/net/ipv6/conf/$1/autoconf -""" - default_config_data = { 'access_concentrator': '', 'on_demand': False, @@ -220,7 +207,6 @@ def verify(pppoe): def generate(pppoe): config_file_pppoe = '/etc/ppp/peers/{}'.format(pppoe['intf']) - config_file_ifup = '/etc/ppp/ipv6-up.d/50-vyos-{}-autoconf'.format(pppoe['intf']) # Always hang-up PPPoE connection prior generating new configuration file cmd = 'systemctl stop ppp@{}.service'.format(pppoe['intf']) @@ -231,9 +217,6 @@ def generate(pppoe): if os.path.exists(config_file_pppoe): os.unlink(config_file_pppoe) - if os.path.exists(config_file_ifup): - os.unlink(config_file_ifup) - else: # Create PPP configuration files tmpl = Template(config_pppoe_tmpl) @@ -241,14 +224,6 @@ def generate(pppoe): with open(config_file_pppoe, 'w') as f: f.write(config_text) - tmpl = Template(config_pppoe_autoconf_tmpl) - config_text = tmpl.render(pppoe) - with open(config_file_ifup, 'w') as f: - f.write(config_text) - - os.chmod(config_file_ifup, - S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) - return None def apply(pppoe): -- 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 'src/conf_mode') 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 08c37cd40c65ddb2ecc8eed13df59ef11129622c Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 19 Feb 2020 21:47:18 +0100 Subject: pppoe: T1318: use lists rather then strings on Config() --- src/conf_mode/interfaces-pppoe.py | 60 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 8acdf8e29..6ab3fbd95 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -18,7 +18,6 @@ import os from sys import exit from copy import deepcopy - from jinja2 import Template from subprocess import Popen, PIPE @@ -118,6 +117,7 @@ def subprocess_cmd(command): def get_config(): pppoe = deepcopy(default_config_data) conf = Config() + base_path = ['interfaces', 'pppoe'] # determine tagNode instance try: @@ -126,76 +126,76 @@ def get_config(): print("Interface not specified") # Check if interface has been removed - if not conf.exists('interfaces pppoe ' + pppoe['intf']): + if not conf.exists(base_path + [pppoe['intf']]): pppoe['deleted'] = True return pppoe # set new configuration level - conf.set_level('interfaces pppoe ' + pppoe['intf']) + conf.set_level(base_path + [pppoe['intf']]) # Access concentrator name (only connect to this concentrator) - if conf.exists('access-concentrator'): - pppoe['access_concentrator'] = conf.return_values('access-concentrator') + if conf.exists(['access-concentrator']): + pppoe['access_concentrator'] = conf.return_values(['access-concentrator']) # Access concentrator name (only connect to this concentrator) - if conf.exists('connect-on-demand'): + if conf.exists(['connect-on-demand']): pppoe['on_demand'] = True # Enable/Disable default route to peer when link comes up - if conf.exists('default-route'): - pppoe['default_route'] = conf.return_value('default-route') + 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') + if conf.exists(['description']): + pppoe['description'] = conf.return_value(['description']) # Disable this interface - if conf.exists('disable'): + if conf.exists(['disable']): pppoe['disable'] = True # Delay before disconnecting idle session (in seconds) - if conf.exists('idle-timeout'): - pppoe['idle_timeout'] = conf.return_value('idle-timeout') + if conf.exists(['idle-timeout']): + pppoe['idle_timeout'] = conf.return_value(['idle-timeout']) # Enable Stateless Address Autoconfiguration (SLAAC) - if conf.exists('ipv6 address autoconf'): + if conf.exists(['ipv6', 'address', 'autoconf']): pppoe['ipv6_autoconf'] = True # Activate IPv6 support on this connection - if conf.exists('ipv6 enable'): + if conf.exists(['ipv6', 'enable']): pppoe['ipv6_enable'] = True # IPv4 address of local end of the PPPoE link - if conf.exists('local-address'): - pppoe['local_address'] = conf.return_value('local-address') + if conf.exists(['local-address']): + pppoe['local_address'] = conf.return_value(['local-address']) # Physical Interface used for this PPPoE session - if conf.exists('link'): + if conf.exists(['link']): pppoe['link'] = conf.return_value('link') # Maximum Transmission Unit (MTU) - if conf.exists('mtu'): - pppoe['mtu'] = conf.return_value('mtu') + 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') + 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') + if conf.exists(['password']): + pppoe['password'] = conf.return_value(['password']) # IPv4 address of local end of the PPPoE link - if conf.exists('remote-address'): - pppoe['remote_address'] = conf.return_value('remote-address') + if conf.exists(['remote-address']): + pppoe['remote_address'] = conf.return_value(['remote-address']) # Service name, only connect to access concentrators advertising this - if conf.exists('service-name'): - pppoe['service_name'] = conf.return_value('service-name') + 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') + if conf.exists(['user-id']): + pppoe['user_id'] = conf.return_value(['user-id']) return pppoe -- 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 'src/conf_mode') 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 'src/conf_mode') 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 'src/conf_mode') 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 From 9621e4b7552df43876f153db1d1156ad8c4ba72c Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 14:02:09 +0100 Subject: pppoe: T2055: do not try to start a deleted dialer interface --- src/conf_mode/interfaces-pppoe.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/conf_mode') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 4ca7f3ecb..245f5a4b0 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -231,6 +231,10 @@ def generate(pppoe): return None def apply(pppoe): + if pppoe['deleted']: + # bail out early + return None + if not pppoe['disable']: # Dial PPPoE connection cmd = 'systemctl start ppp@{}.service'.format(pppoe['intf']) -- cgit v1.2.3