diff options
| author | Daniil Baturin <daniil@vyos.io> | 2026-07-03 15:19:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-03 15:19:31 +0100 |
| commit | 9b9b6a847de6e4f50778d6466f555865900ae1b1 (patch) | |
| tree | 3268f8248ec7ffc513736a61623f1a76772273ba /smoketest/scripts/cli | |
| parent | 279f785efb15667c266da9ea73d016b5d5f0f403 (diff) | |
| parent | f56f37924f05bcfebd05342ccb40c53001b3409a (diff) | |
| download | vyos-1x-9b9b6a847de6e4f50778d6466f555865900ae1b1.tar.gz vyos-1x-9b9b6a847de6e4f50778d6466f555865900ae1b1.zip | |
Merge pull request #5307 from natali-rs1985/T9002
T9002: grant CAP_NET_RAW to blackbox-exporter when ICMP modules are configured
Diffstat (limited to 'smoketest/scripts/cli')
| -rwxr-xr-x | smoketest/scripts/cli/test_service_monitoring_prometheus.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_service_monitoring_prometheus.py b/smoketest/scripts/cli/test_service_monitoring_prometheus.py index df27162ef..a60e92842 100755 --- a/smoketest/scripts/cli/test_service_monitoring_prometheus.py +++ b/smoketest/scripts/cli/test_service_monitoring_prometheus.py @@ -158,6 +158,52 @@ class TestMonitoringPrometheus(VyOSUnitTestSHIM.TestCase): # Check for running process self.assertTrue(process_named_running(BLACKBOX_EXPORTER_PROCESS_NAME)) + def test_05_blackbox_exporter_with_icmp(self): + vrf_name = 'bbx' + be_path = base_path + ['blackbox-exporter'] + self.cli_set(be_path + ['listen-address', listen_ip]) + self.cli_set( + be_path + + ['modules', 'icmp', 'name', 'ping4', 'preferred-ip-protocol', 'ipv4'] + ) + + self.cli_commit() + + # Verify CAP_NET_RAW is granted when ICMP module is configured (no VRF case) + file_content = read_file(blackbox_exporter_service_file) + self.assertIn('AmbientCapabilities=CAP_NET_RAW', file_content) + self.assertIn('CapabilityBoundingSet=CAP_NET_RAW', file_content) + + # Check for running process + self.assertTrue(process_named_running(BLACKBOX_EXPORTER_PROCESS_NAME)) + + self.cli_delete(be_path + ['modules', 'icmp']) + self.cli_commit() + + # Verify CAP_NET_RAW is removed when ICMP module is deleted + file_content = read_file(blackbox_exporter_service_file) + self.assertNotIn('CAP_NET_RAW', file_content) + self.assertTrue(process_named_running(BLACKBOX_EXPORTER_PROCESS_NAME)) + + # VRF + ICMP should use setpriv with net_raw capabilities + self.cli_set(['vrf', 'name', vrf_name, 'table', '1111']) + self.cli_set(be_path + ['vrf', vrf_name]) + self.cli_set( + be_path + + ['modules', 'icmp', 'name', 'ping4', 'preferred-ip-protocol', 'ipv4'] + ) + self.cli_commit() + + # Verify VRF uses setpriv instead of systemd capabilities + file_content = read_file(blackbox_exporter_service_file) + self.assertIn('setpriv', file_content) + self.assertIn('--ambient-caps=+net_raw', file_content) + self.assertIn('--inh-caps=+net_raw', file_content) + self.assertNotIn('AmbientCapabilities=CAP_NET_RAW', file_content) + + # Cleanup VRF + self.cli_delete(['vrf', 'name', vrf_name]) + if __name__ == '__main__': unittest.main(verbosity=2, failfast=VyOSUnitTestSHIM.TestCase.debug_on()) |
