summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-15 07:25:39 +0100
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-12-15 09:25:07 +0000
commitf4bf213366b50efb6ccc94348ea43073a0cf1a90 (patch)
treee11e6cb502a935d4ca72c2f9a07351ba182cff38
parentdf285b1a0743e23ff110fdd7a8a24d8b4cd568db (diff)
downloadvyos-1x-f4bf213366b50efb6ccc94348ea43073a0cf1a90.tar.gz
vyos-1x-f4bf213366b50efb6ccc94348ea43073a0cf1a90.zip
frr: T4020: add option to define number of open file descriptors
This allows the operator to control the number of open file descriptors each daemon is allowed to start with. The current assumed value on most operating systems is 1024. If the operator plans to run bgp with several thousands of peers then this is where we would modify FRR to allow this to happen. set system frr descriptors <n> (cherry picked from commit 892c28ccf634173d4c4952c248cb03974c560793)
-rw-r--r--data/templates/frr/daemons.frr.tmpl3
-rw-r--r--interface-definitions/system-frr.xml.in14
-rwxr-xr-xsmoketest/scripts/cli/test_system_frr.py26
-rwxr-xr-xsrc/conf_mode/system_frr.py4
4 files changed, 39 insertions, 8 deletions
diff --git a/data/templates/frr/daemons.frr.tmpl b/data/templates/frr/daemons.frr.tmpl
index a65f0868a..c637e18bc 100644
--- a/data/templates/frr/daemons.frr.tmpl
+++ b/data/templates/frr/daemons.frr.tmpl
@@ -108,7 +108,6 @@ valgrind_enable=no
frr_profile="traditional"
-#MAX_FDS=1024
+MAX_FDS={{ descriptors }}
#FRR_NO_ROOT="yes"
-
diff --git a/interface-definitions/system-frr.xml.in b/interface-definitions/system-frr.xml.in
index 9fe23ed75..76001b392 100644
--- a/interface-definitions/system-frr.xml.in
+++ b/interface-definitions/system-frr.xml.in
@@ -15,6 +15,20 @@
<valueless/>
</properties>
</leafNode>
+ <leafNode name="descriptors">
+ <properties>
+ <help>Number of open file descriptors a process is allowed to use</help>
+ <valueHelp>
+ <format>u32:1024-8192</format>
+ <description>Number of file descriptors</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 1024-8192"/>
+ </constraint>
+ <constraintErrorMessage>Port number must be in range 1024 to 8192</constraintErrorMessage>
+ </properties>
+ <defaultValue>1024</defaultValue>
+ </leafNode>
<leafNode name="irdp">
<properties>
<help>Enable ICMP Router Discovery Protocol support</help>
diff --git a/smoketest/scripts/cli/test_system_frr.py b/smoketest/scripts/cli/test_system_frr.py
index 3eb0cd0ab..a2ce58bf6 100755
--- a/smoketest/scripts/cli/test_system_frr.py
+++ b/smoketest/scripts/cli/test_system_frr.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2019-2020 VyOS maintainers and contributors
+# Copyright (C) 2021-2023 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
@@ -16,13 +16,13 @@
import re
import unittest
+
from base_vyostest_shim import VyOSUnitTestSHIM
from vyos.utils.file import read_file
config_file = '/etc/frr/daemons'
base_path = ['system', 'frr']
-
def daemons_config_parse(daemons_config):
# create regex for parsing daemons options
regex_daemon_config = re.compile(
@@ -33,13 +33,20 @@ def daemons_config_parse(daemons_config):
for daemon in regex_daemon_config.finditer(daemons_config):
daemon_name = daemon.group('daemon_name')
daemon_options = daemon.group('daemon_options')
- daemons_config_dict[daemon_name] = daemon_options
+ daemons_config_dict[daemon_name] = daemon_options.lstrip()
# return daemons config
return (daemons_config_dict)
class TestSystemFRR(VyOSUnitTestSHIM.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ super(TestSystemFRR, cls).setUpClass()
+
+ # ensure we can also run this test on a live system - so lets clean
+ # out the current configuration :)
+ cls.cli_delete(cls, base_path)
def tearDown(self):
self.cli_delete(base_path)
@@ -64,7 +71,7 @@ class TestSystemFRR(VyOSUnitTestSHIM.TestCase):
else:
self.assertFalse(snmp_enabled)
- def test_frr_snmp_addandremove(self):
+ def test_frr_snmp_add_remove(self):
# test enabling and disabling of SNMP integration
test_daemon_names = ['ospfd', 'bgpd']
for test_daemon_name in test_daemon_names:
@@ -124,7 +131,7 @@ class TestSystemFRR(VyOSUnitTestSHIM.TestCase):
irdp_enabled = regex_irdp.match(daemons_config_dict['zebra'])
self.assertTrue(irdp_enabled)
- def test_frr_bmpandsnmp(self):
+ def test_frr_bmp_and_snmp(self):
# test empty config section
self.cli_set(base_path + ['bmp'])
self.cli_set(base_path + ['snmp', 'bgpd'])
@@ -141,6 +148,15 @@ class TestSystemFRR(VyOSUnitTestSHIM.TestCase):
self.assertTrue(bmp_enabled)
self.assertTrue(snmp_enabled)
+ def test_frr_file_descriptors(self):
+ file_descriptors = '4096'
+
+ self.cli_set(base_path + ['descriptors', file_descriptors])
+ self.cli_commit()
+
+ # read the config file and check content
+ daemons_config = read_file(config_file)
+ self.assertIn(f'MAX_FDS={file_descriptors}', daemons_config)
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/src/conf_mode/system_frr.py b/src/conf_mode/system_frr.py
index d8224b3c3..d43b172a6 100755
--- a/src/conf_mode/system_frr.py
+++ b/src/conf_mode/system_frr.py
@@ -38,7 +38,9 @@ def get_config(config=None):
conf = Config()
base = ['system', 'frr']
- frr_config = conf.get_config_dict(base, get_first_key=True)
+ frr_config = conf.get_config_dict(base, key_mangling=('-', '_'),
+ get_first_key=True,
+ with_recursive_defaults=True)
return frr_config