summaryrefslogtreecommitdiff
path: root/src/conf_mode/protocols_mpls.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-04-19 22:45:50 +0200
committerChristian Breunig <christian@breunig.cc>2026-04-21 06:13:21 +0200
commit754635c257b1860ce393cdc342c1b7ca7e65da1f (patch)
tree0fbb50cbf62c7ceb09a1a5f4568318ff0314f5c4 /src/conf_mode/protocols_mpls.py
parent1d81dd0c6190d9fd36d01014f3b0a2d4bb91a919 (diff)
downloadvyos-1x-754635c257b1860ce393cdc342c1b7ca7e65da1f.tar.gz
vyos-1x-754635c257b1860ce393cdc342c1b7ca7e65da1f.zip
T8534: refactor sysctl_(read|write) to accept key parts
Interface names can contain dots (e.g. VLAN subinterfaces like eth0.10), which conflicts with sysctl's dot-separated key syntax. Change sysctl_read() and sysctl_write() to take key components as a list and normalize each component by replacing . with / before invoking sysctl. This fixes sysctl lookups/updates for VLAN subinterfaces. Extend the SR-TE smoketest to cover a VLAN subinterface. Previous error raising this issue: vyos-configd: sysctl: cannot stat /proc/sys/net/ipv6/conf/eth0/10/seg6_enabled: No such file or directory vyos-configd: sysctl: cannot stat /proc/sys/net/ipv6/conf/eth0/201/seg6_enabled: No such file or directory
Diffstat (limited to 'src/conf_mode/protocols_mpls.py')
-rwxr-xr-xsrc/conf_mode/protocols_mpls.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/conf_mode/protocols_mpls.py b/src/conf_mode/protocols_mpls.py
index d534ad2e3..841e5406f 100755
--- a/src/conf_mode/protocols_mpls.py
+++ b/src/conf_mode/protocols_mpls.py
@@ -85,21 +85,21 @@ def apply(config_dict):
labels = '0'
if 'interface' in mpls:
labels = '1048575'
- sysctl_write('net.mpls.platform_labels', labels)
+ sysctl_write(['net', 'mpls', 'platform_labels'], labels)
# Check for changes in global MPLS options
if 'parameters' in mpls:
# Choose whether to copy IP TTL to MPLS header TTL
if 'no_propagate_ttl' in mpls['parameters']:
- sysctl_write('net.mpls.ip_ttl_propagate', 0)
+ sysctl_write(['net', 'mpls', 'ip_ttl_propagate'], 0)
# Choose whether to limit maximum MPLS header TTL
if 'maximum_ttl' in mpls['parameters']:
ttl = mpls['parameters']['maximum_ttl']
- sysctl_write('net.mpls.default_ttl', ttl)
+ sysctl_write(['net', 'mpls', 'default_ttl'], ttl)
else:
# Set default global MPLS options if not defined.
- sysctl_write('net.mpls.ip_ttl_propagate', 1)
- sysctl_write('net.mpls.default_ttl', 255)
+ sysctl_write(['net', 'mpls', 'ip_ttl_propagate'], 1)
+ sysctl_write(['net', 'mpls', 'default_ttl'], 255)
# Enable and disable MPLS processing on interfaces per configuration
if 'interface' in mpls:
@@ -112,20 +112,17 @@ def apply(config_dict):
interface_state = read_file(f'/proc/sys/net/mpls/conf/{system_interface}/input')
if '1' in interface_state:
if system_interface not in mpls['interface']:
- system_interface = system_interface.replace('.', '/')
- sysctl_write(f'net.mpls.conf.{system_interface}.input', 0)
+ sysctl_write(['net', 'mpls', 'conf', system_interface, 'input'], 0)
elif '0' in interface_state:
if system_interface in mpls['interface']:
- system_interface = system_interface.replace('.', '/')
- sysctl_write(f'net.mpls.conf.{system_interface}.input', 1)
+ sysctl_write(['net', 'mpls', 'conf', system_interface, 'input'], 1)
else:
system_interfaces = []
# If MPLS interfaces are not configured, set MPLS processing disabled
for interface in glob('/proc/sys/net/mpls/conf/*'):
system_interfaces.append(os.path.basename(interface))
for system_interface in system_interfaces:
- system_interface = system_interface.replace('.', '/')
- sysctl_write(f'net.mpls.conf.{system_interface}.input', 0)
+ sysctl_write(['net', 'mpls', 'conf', system_interface, 'input'], 0)
return None