eclipse-score / eclipse-score/time

QNX QEMU time_slave ClockIdentity fails on vtnet0

Open
#217 0 comments 0 reactions 1 assignee Claimed by @ryan-steel View on GitHub
Dominant language
C++
Stars
2
Forks
12
Avg merge
3d 10h
Merged PRs (30d)
24

Description

### Description

## Summary
On QNX 8.0 x86_64 and ARM64 QEMU, time_slave can fail during ClockIdentity resolution on vtnet0 when SOCK env is reused for BPF path selection.

## Impact
time_slave exits during Initialize.
gPTP engine does not start.
Reference integration flow on QEMU vtnet0 blocked.

## Environment
- OS: QNX 8.0 x86_64 in QEMU
- OS: QNX 8.0 ARM64 in QEMU
- Interface: vtnet0
- App: time_slave

## Acceptance criteria
1. ClockIdentity resolves on QNX QEMU vtnet0 with SOCK not repurposed by app.
2. BPF path remains configurable through QNX_BPF_DEVICE_PREFIX.
3. No regression in QNX raw socket bring-up.
4. Reference integration startup succeeds on validated QNX image.

### Analysis results

SOCK env is already used in `qnx/usr/include/net/netmap_user.h`, setting it from time_slave seems to have broken the getifaddrs call in [network_identity.cpp](https://github.com/etas-contrib/score_time/blob/3a305aece44cd4c10a9342248f5e3ec72119a732/score/time_slave/src/gptp/platform/qnx/network_identity.cpp#L40).

### Solution

- Stop writing SOCK from time_slave init.
- Introduce dedicated env variable QNX_BPF_DEVICE_PREFIX for BPF path wiring.
- Update QNX raw shim to consume dedicated BPF env variable.

### Error Occurrence Rate

None

### How to reproduce

On a QEMU QNX guest:

1. Configure time_slave with vtnet0 and QNX BPF settings
2. Run time_slave
3. Observe startup logs

## Actual result
ClockIdentity resolution fails. Typical logs:
- socket(AF_INET, SOCK_DGRAM) failed, errno=247 (`EAFNOSUPPORT`)
- getifaddrs failed, errno=247
- failed to resolve ClockIdentity for vtnet0

## Expected result
ClockIdentity resolves from vtnet0 MAC and app continues initialization.

### Supporting Information

## On a QNX x86_64 QEMU guest after the fix applied:

### Setting SOCK manually while running `time_slave`:
```
# SOCK=/dev/bpf ./time_slave --config etc/time_slave_config_qnx.json
2026/09/11 12:26:11.9571611 109746206 000 ECU1 VTEX DFLT log info verbose 1 Initializing LifeCycleManager
2026/09/11 12:26:11.9571629 109746297 000 ECU1 VTEX DFLT log info verbose 1 LifeCycleManager started
2026/09/11 12:26:11.9571631 109746336 000 ECU1 VTEX DFLT log info verbose 1 Signal handler started
2026/09/11 12:26:11.9571661 109746633 000 ECU1 VTEX TSAP log info verbose 7 Loaded config from etc/time_slave_config_qnx.json (iface= vtnet0 , phc= disabled )
2026/09/11 12:26:11.9571669 109746704 000 ECU1 VTEX TSAP log error verbose 2 GptpEngine: failed to resolve ClockIdentity for vtnet0
2026/09/11 12:26:11.9571671 109746724 000 ECU1 VTEX TSAP log error verbose 1 TimeSlave: GptpEngine initialization failed
2026/09/11 12:26:11.9571673 109746746 000 ECU1 VTEX DFLT log error verbose 1 Error occurred during Initialize
2026/09/11 12:26:11.9571677 109746782 000 ECU1 VTEX DFLT log error verbose 4 Application ./time_slave initialize finished with -1
2026/09/11 12:26:11.9571681 109746822 000 ECU1 VTEX DFLT log info verbose 1 Signal SIGTERM received, requesting to stop the app
2026/09/11 12:26:11.9571687 109746886 000 ECU1 VTEX TSAP log info verbose 1 GptpEngine deinitialized
```

### Clean run:
```
# ./time_slave --config etc/time_slave_config_qnx.json
2026/09/11 12:27:39.9659820 110628272 000 ECU1 VTEX DFLT log info verbose 1 Initializing LifeCycleManager
2026/09/11 12:27:39.9659833 110628340 000 ECU1 VTEX DFLT log info verbose 1 LifeCycleManager started
2026/09/11 12:27:39.9659834 110628363 000 ECU1 VTEX DFLT log info verbose 1 Signal handler started
2026/09/11 12:27:39.9659857 110628585 000 ECU1 VTEX TSAP log info verbose 7 Loaded config from etc/time_slave_config_qnx.json (iface= vtnet0 , phc= disabled )
2026/09/11 12:27:39.9659877 110628784 000 ECU1 VTEX TSAP log info verbose 2 GptpEngine initialized on vtnet0
2026/09/11 12:27:39.9659883 110628847 000 ECU1 VTEX shm log warn verbose 4 Remove 359 Unexpected error while trying to remove /gptp_ptp_info
2026/09/11 12:27:39.9659915 110629166 000 ECU1 VTEX TSAP log info verbose 1 TimeSlave initialized
2026/09/11 12:27:39.9659918 110629189 000 ECU1 VTEX DFLT log info verbose 1 Running Application
2026/09/11 12:27:39.9659920 110629209 000 ECU1 VTEX DFLT log info verbose 1 Reporting kRunning to Launch Manager
2026/09/11 12:27:39.9659925 110629268 000 ECU1 VTEX LM log error verbose 3 [Lifecycle client] FD 111 is invalid for kRunning report
2026/09/11 12:27:39.9659928 110629291 000 ECU1 VTEX TSAP log info verbose 1 TimeSlave running
[t1] CLOCK_RT ts=1789129660.701938180 (fallback)
[t1] CLOCK_RT ts=1789129660.807811561 (fallback)
...
```

### Classification

Minor

### First Affected Release

not released (main)

### Last Affected Release

not released (main)

### Expected Fixed Release

before release (main)

### Category

- [ ] Safety Relevant
- [ ] Security Relevant

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.