From adb49ae0de788674a30830d351657913610e22ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Dupr=C3=A9?= Date: Mon, 12 Feb 2024 15:49:39 +0100 Subject: [PATCH 1/3] cluster_setup_network: allow any interface to be used for PTP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch allows the use of any interface for PTP, not only the main interface. Signed-off-by: Mathieu Dupré --- playbooks/cluster_setup_network.yaml | 5 +---- vars/network_vars.yml | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/playbooks/cluster_setup_network.yaml b/playbooks/cluster_setup_network.yaml index f5c78f5a3..b570e09ed 100644 --- a/playbooks/cluster_setup_network.yaml +++ b/playbooks/cluster_setup_network.yaml @@ -80,7 +80,6 @@ - not apply_config - ptp_interface.changed when: - - ptp_vlan_interface is defined - ptp_vlan is defined - ptp_vlan_address is defined - name: Restart systemd-networkd @@ -123,9 +122,7 @@ state: started when: apply_config or (need_reboot is defined and not need_reboot) - when: - - ptp_vlan_interface is defined - - ptp_vlan is defined + when: ptp_vlan is defined - name: Configure hostname hosts: diff --git a/vars/network_vars.yml b/vars/network_vars.yml index 0c4dbe303..e86271394 100644 --- a/vars/network_vars.yml +++ b/vars/network_vars.yml @@ -4,7 +4,7 @@ _systemd_networkd_network_custom: ["{{ custom_network | default([]) }}"] _systemd_networkd_netdev_custom: ["{{ custom_netdev | default([]) }}"] -_vlan_conditionnal: "{% if ptp_vlan is defined %}[{'VLAN': 'ptp'}]{% else %}[]{% endif %}" +_vlan_conditionnal: "{% if ptp_vlan is defined and ptp_vlan_interface and ptp_vlan_interface == network_interface %}[{'VLAN': 'ptp'}]{% else %}[]{% endif %}" _network_common: - Gateway: "{{ gateway_addr }}" From a04b45aebc839289b85a69ba9f54f71dcdc6fac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Dupr=C3=A9?= Date: Mon, 12 Feb 2024 17:23:59 +0100 Subject: [PATCH 2/3] playbooks/cluster_setup_network: configure ptp4l MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a configure file for ptp4l which respects the IEC 61850-9-3. Signed-off-by: Mathieu Dupré --- playbooks/cluster_setup_network.yaml | 22 ++++++++++++++++++++++ src/ptp4l.conf | 26 ++++++++++++++++++++++++++ src/ptp4l.service.override | 3 +++ 3 files changed, 51 insertions(+) create mode 100644 src/ptp4l.conf create mode 100644 src/ptp4l.service.override diff --git a/playbooks/cluster_setup_network.yaml b/playbooks/cluster_setup_network.yaml index b570e09ed..2ae154157 100644 --- a/playbooks/cluster_setup_network.yaml +++ b/playbooks/cluster_setup_network.yaml @@ -103,10 +103,32 @@ name: systemd-timesyncd.service enabled: no state: stopped + - name: Add the ptp4l configuration file + copy: + src: ../src/ptp4l.conf + dest: /etc/ptp4l.conf + owner: root + group: root + mode: 0644 + - name: Ensure /etc/systemd/system/ptp4l@.service.d directory exists + file: + path: /etc/systemd/system/ptp4l@.service.d + state: directory + owner: root + group: root + mode: 0755 + - name: Configure ptp4l service to use a configuration file + copy: + src: ../src/ptp4l.service.override + dest: /etc/systemd/system/ptp4l@.service.d/override.conf + owner: root + group: root + mode: 0644 - name: Enable ptp service ansible.builtin.systemd: name: ptp4l@ptp.service enabled: yes + daemon_reload: yes - name: Start ptp service ansible.builtin.systemd: name: ptp4l@ptp.service diff --git a/src/ptp4l.conf b/src/ptp4l.conf new file mode 100644 index 000000000..b063c6b3d --- /dev/null +++ b/src/ptp4l.conf @@ -0,0 +1,26 @@ +[Global] +slaveOnly 1 +gmCapable 1 + +domainNumber 0 + +# Announce interval: 1s +logAnnounceInterval 0 + +# Sync interval: 1 s +logSyncInterval 0 + +# Pdelay interval: 1 s +logMinPdelayReqInterval 0 + +# Announce receipt time-out: 3 s (fixed) +announceReceiptTimeout 3 + +priority1 255 +priority2 255 +# Default clock class : any specialised clock will be better (ie a GPS Grand Master Clock) +network_transport L2 +delay_mechanism P2P +clockClass 248 +clockAccuracy 0xFE +offsetScaledLogVariance 0xFFFF diff --git a/src/ptp4l.service.override b/src/ptp4l.service.override new file mode 100644 index 000000000..1bb8d9100 --- /dev/null +++ b/src/ptp4l.service.override @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/sbin/ptp4l -q -m -f /etc/ptp4l.conf -i %I From 393a9dc0d6f9d93e6f70becbc157c693bbd9ee3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Dupr=C3=A9?= Date: Mon, 12 Feb 2024 17:25:13 +0100 Subject: [PATCH 3/3] playbooks/cluster_setup_network: restart ptp4l and phc2sys services MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the ptp4l and phc2sys services are already running, and the playbook is executed, the services are not restarted. This is problematic when the configuration of the ptp4l and phc2sys services is changed, and the services need to be restarted to apply the new configuration. Signed-off-by: Mathieu Dupré --- playbooks/cluster_setup_network.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playbooks/cluster_setup_network.yaml b/playbooks/cluster_setup_network.yaml index 2ae154157..6c7e38ad7 100644 --- a/playbooks/cluster_setup_network.yaml +++ b/playbooks/cluster_setup_network.yaml @@ -132,7 +132,7 @@ - name: Start ptp service ansible.builtin.systemd: name: ptp4l@ptp.service - state: started + state: restarted when: apply_config or (need_reboot is defined and not need_reboot) - name: Enable phc2sys service ansible.builtin.systemd: @@ -141,7 +141,7 @@ - name: Start phc2sys service ansible.builtin.systemd: name: phc2sys@ptp.service - state: started + state: restarted when: apply_config or (need_reboot is defined and not need_reboot) when: ptp_vlan is defined