summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-05 17:22:19 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-05 17:22:21 +0100
commit2242f7d8abcafcd1c1f33ad6b59e2b22979adb69 (patch)
tree8bffb964f39e384415dd9d84d4bb78c3aac76c53 /src/conf_mode
parent4affc8b2fde2f0883632f163db5961ae34faccc4 (diff)
downloadvyos-1x-2242f7d8abcafcd1c1f33ad6b59e2b22979adb69.tar.gz
vyos-1x-2242f7d8abcafcd1c1f33ad6b59e2b22979adb69.zip
pppoe: T1493: support IPv6 address negotiation which is required for DHCPv6-PD
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/interfaces-pppoe.py88
1 files changed, 51 insertions, 37 deletions
diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py
index 90d34fa4a..0622e4c9a 100755
--- a/src/conf_mode/interfaces-pppoe.py
+++ b/src/conf_mode/interfaces-pppoe.py
@@ -31,9 +31,7 @@ from vyos import ConfigError
from netifaces import interfaces
# Please be careful if you edit the template.
-config_pppoe_tmpl = """
-### Autogenerated by interfaces-pppoe.py ###
-
+config_pppoe_tmpl = """### Autogenerated by interfaces-pppoe.py ###
{% if description %}
# {{ description }}
{% endif %}
@@ -93,6 +91,7 @@ usepeerdns
{% endif %}
{% if ipv6_enable -%}
+ipv6
+ipv6cp-use-ipaddr
{% endif %}
{% if service_name -%}
rp_pppoe_service "{{ service_name }}"
@@ -100,19 +99,53 @@ rp_pppoe_service "{{ service_name }}"
"""
-config_pppoe_ipv6_up_tmpl = """
-#!/bin/sh
+# Please be careful if you edit the template.
+# There must be no blank line at the top pf the script file
+config_pppoe_ipv6_up_tmpl = """#!/bin/sh
-logger -t PPPoE/{{ intf }} "1:$1 2:$2 3:$3 4:$4 5:$5 6:$6 "
+# As PPPoE is an "on demand" interface we need to re-configure it when it
+# becomes up
if [ "$6" != "{{ intf }}" ]; then
exit
fi
-echo 0 > /proc/sys/net/ipv6/conf/{{ intf }}/forwarding
+# add some info to syslog
+DIALER_PID=$(cat /var/run/{{ intf }}.pid)
+logger -t pppd[$DIALER_PID] "executing $0"
+logger -t pppd[$DIALER_PID] "configuring dialer interface $6 via $2"
+
+echo "{{ description }}" > /sys/class/net/{{ intf }}/ifalias
+
+{% if ipv6_autoconf -%}
+
+
+# Configure interface-specific Host/Router behaviour.
+# Note: It is recommended to have the same setting on all interfaces; mixed
+# router/host scenarios are rather uncommon. Possible values are:
+#
+# 0 Forwarding disabled
+# 1 Forwarding enabled
+#
+echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/forwarding
+
+# Accept Router Advertisements; autoconfigure using them.
+#
+# It also determines whether or not to transmit Router
+# Solicitations. If and only if the functional setting is to
+# accept Router Advertisements, Router Solicitations will be
+# transmitted. Possible values are:
+#
+# 0 Do not accept Router Advertisements.
+# 1 Accept Router Advertisements if forwarding is disabled.
+# 2 Overrule forwarding behaviour. Accept Router Advertisements
+# even if forwarding is enabled.
+#
echo 2 > /proc/sys/net/ipv6/conf/{{ intf }}/accept_ra
-echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/autoconf
+# Autoconfigure addresses using Prefix Information in Router Advertisements.
+echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/autoconfigure
+{% endif %}
"""
PPP_LOGFILE = '/var/log/vyatta/ppp_{}.log'
@@ -124,7 +157,7 @@ default_config_data = {
'on_demand': False,
'default_route': 'auto',
'deleted': False,
- 'description': '',
+ 'description': '\0',
'disable': False,
'intf': '',
'idle_timeout': '',
@@ -235,9 +268,9 @@ def verify(pppoe):
return None
if not pppoe['source_interface']:
- raise ConfigError('PPPoE source interface is missing')
+ raise ConfigError('PPPoE source interface missing')
- if pppoe['source_interface'] not in interfaces():
+ if not pppoe['source_interface'] in interfaces():
raise ConfigError('PPPoE source interface does not exist')
return None
@@ -255,7 +288,7 @@ def generate(pppoe):
if os.path.exists(config_file_pppoe):
os.unlink(config_file_pppoe)
- if os.path.exists(script_file)
+ if os.path.exists(script_file):
os.unlink(config_file_pppoe)
else:
@@ -265,14 +298,13 @@ 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)
+ 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)
+ os.chmod(script_file, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
return None
@@ -292,24 +324,6 @@ def apply(pppoe):
gid = getgrnam('vyattacfg').gr_gid
os.chown(pppoe['logfile'], uid, gid)
- # better late then sorry ... but we can only set interface alias after
- # pppd has been launched and created the interface
- cnt = 0
- while pppoe['intf'] not in interfaces():
- cnt += 1
- if cnt == 50:
- break
-
- # sleep 250ms
- sleep(0.250)
-
- try:
- # we need to catch the exception if the interface is not up due to
- # reason stated above
- Interface(pppoe['intf']).set_alias(pppoe['description'])
- except:
- pass
-
return None
if __name__ == '__main__':