From 4a8a3e1325bcfe4f6fcbb328cdd1eb67b3b0d86a Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 4 Mar 2020 08:55:53 +0100 Subject: pppoe: T1318: IPv6 support --- src/conf_mode/interfaces-pppoe.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/conf_mode/interfaces-pppoe.py') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 8ec78bab3..90d34fa4a 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -23,6 +23,7 @@ from subprocess import Popen, PIPE from time import sleep from pwd import getpwnam from grp import getgrnam +from stat import S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IXGRP, S_IROTH, S_IXOTH from vyos.config import Config from vyos.ifconfig import Interface @@ -99,6 +100,21 @@ rp_pppoe_service "{{ service_name }}" """ +config_pppoe_ipv6_up_tmpl = """ +#!/bin/sh + +logger -t PPPoE/{{ intf }} "1:$1 2:$2 3:$3 4:$4 5:$5 6:$6 " + +if [ "$6" != "{{ intf }}" ]; then + exit +fi + +echo 0 > /proc/sys/net/ipv6/conf/{{ intf }}/forwarding +echo 2 > /proc/sys/net/ipv6/conf/{{ intf }}/accept_ra +echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/autoconf + +""" + PPP_LOGFILE = '/var/log/vyatta/ppp_{}.log' default_config_data = { @@ -228,6 +244,7 @@ def verify(pppoe): def generate(pppoe): config_file_pppoe = '/etc/ppp/peers/{}'.format(pppoe['intf']) + script_file = '/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']) @@ -238,6 +255,9 @@ def generate(pppoe): if os.path.exists(config_file_pppoe): os.unlink(config_file_pppoe) + if os.path.exists(script_file) + os.unlink(config_file_pppoe) + else: # Create PPP configuration files tmpl = Template(config_pppoe_tmpl) @@ -245,6 +265,15 @@ def generate(pppoe): with open(config_file_pppoe, 'w') as f: f.write(config_text) + if pppoe['ipv6_enable']: + script_file = '/etc/ppp/ipv6-up.d/50-vyos-{}-autoconf'.format(pppoe['intf']) + tmpl = Template(config_pppoe_ipv6_up_tmpl) + config_text = tmpl.render(pppoe) + with open(script_file, 'w') as f: + f.write(config_text) + + os.chmod(script_file, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) + return None def apply(pppoe): -- cgit v1.2.3