summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-pppoe.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-04 08:55:53 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-04 22:16:24 +0100
commit4a8a3e1325bcfe4f6fcbb328cdd1eb67b3b0d86a (patch)
tree0757a3f376f699a496f07893315e5090917d7d16 /src/conf_mode/interfaces-pppoe.py
parent359ac4cb1b1503d3889e0b84893abdd00db62197 (diff)
downloadvyos-1x-4a8a3e1325bcfe4f6fcbb328cdd1eb67b3b0d86a.tar.gz
vyos-1x-4a8a3e1325bcfe4f6fcbb328cdd1eb67b3b0d86a.zip
pppoe: T1318: IPv6 support
Diffstat (limited to 'src/conf_mode/interfaces-pppoe.py')
-rwxr-xr-xsrc/conf_mode/interfaces-pppoe.py29
1 files changed, 29 insertions, 0 deletions
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):