diff options
| author | Nataliia S. <81954790+natali-rs1985@users.noreply.github.com> | 2026-05-20 13:43:13 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-20 13:43:13 +0300 |
| commit | c1ed45ccb328807ae55b21f1cf5c956bda5e7e84 (patch) | |
| tree | b91f9ffc9c0686995a78c917d9fc57f010ff1764 /src | |
| parent | 3498a7a4ff8637f32922df9bf8742f2e2031859d (diff) | |
| download | vyos-1x-c1ed45ccb328807ae55b21f1cf5c956bda5e7e84.tar.gz vyos-1x-c1ed45ccb328807ae55b21f1cf5c956bda5e7e84.zip | |
T7880: Add NTP hardware timestamp receive-filter compatibility check (#5160)
Add a check to determine whether the NIC supports hardware
timestamp receive filters required for NTP timestamping.
Implement the query in a new python/vyos/netlink/timestamp.py module
using pyroute2 generic netlink ETHTOOL_MSG_TSINFO_GET,
avoiding ethtool output parsing.
Diffstat (limited to 'src')
| -rwxr-xr-x | src/conf_mode/service_ntp.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/conf_mode/service_ntp.py b/src/conf_mode/service_ntp.py index e58da2737..38e0df079 100755 --- a/src/conf_mode/service_ntp.py +++ b/src/conf_mode/service_ntp.py @@ -21,6 +21,7 @@ from vyos.config import config_dict_merge from vyos.configdict import is_node_changed from vyos.configverify import verify_vrf from vyos.configverify import verify_interface_exists +from vyos.netlink import timestamp from vyos.utils.process import call from vyos.utils.permission import chmod_750 from vyos.utils.network import get_interface_config @@ -105,6 +106,35 @@ def verify(ntp): else: break + if 'timestamp' in ntp: + for iface, iface_config in ntp['timestamp'].get('interface', {}).items(): + rx_filter = iface_config.get('receive_filter') + if iface != 'all': + verify_interface_exists(ntp, iface) + if rx_filter and rx_filter != 'none': + if iface == 'all': + any_supported = False + for real_iface in os.listdir('/sys/class/net'): + supported = timestamp.get_hw_timestamp_filters(real_iface) + if rx_filter in supported or 'all' in supported: + any_supported = True + break + if not any_supported: + raise ConfigError( + f'No interface supports hardware timestamp receive-filter "{rx_filter}"' + ) + else: + supported = timestamp.get_hw_timestamp_filters(iface) + if not supported: + raise ConfigError( + f'Interface "{iface}" does not support hardware timestamping' + ) + if rx_filter not in supported and 'all' not in supported: + raise ConfigError( + f'Interface "{iface}" does not support hardware timestamp ' + f'receive-filter "{rx_filter}", supported: {", ".join(sorted(supported))}' + ) + return None def generate(ntp): |
