| Re: [chrony-dev] [PATCH] refclock: add SENSORS driver for OpenBSD timedelta sensors |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: Atanas Vladimirov <vlado@xxxxxxxxx>
- Subject: Re: [chrony-dev] [PATCH] refclock: add SENSORS driver for OpenBSD timedelta sensors
- From: Miroslav Lichvar <mlichvar@xxxxxxxxxx>
- Date: Thu, 16 Jul 2026 16:43:52 +0200
- Cc: chrony-dev@xxxxxxxxxxxxxxxxxxxx, tom@xxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784213042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vITbwIMfjUe+95YjPlWYWNtztCO9E4V60if9cjNSb10=; b=NS3+rABbaBcdQwCeB6ith22YIdb+6hLXkSlScjRZr7r9l2PClwaL1K75xgEOhf5fZoN4zJ x9Nrql88USm8agefC4e1SypiYFBbvYmWqhR4HiH/9LF56nuKkoJhRY83copKQkJFVdNspb MpckbLwCIkcbPcGniJmr9eM4k8QGGV0=
On Tue, Jul 14, 2026 at 12:12:45AM +0300, Atanas Vladimirov wrote:
> This patch adds a new refclock driver for OpenBSD, which reads timedelta sensors from the hw.sensors sysctl framework.
> Until now (last few months since I test it) the only way to use these sensors with chronyd was an external bridge program feeding the SOCK refclock.
> A native driver removes that extra daemon and process boundary.
Was that a big problem using that bridge? The code looks good (few
comments below), but I hesitate to add and maintain a driver that
will be probably used only by a very small number of users, and that
I cannot even test. I have OpenBSD only as a VM. If it was accepted,
would you stay around and keep an eye on it?
> --- a/configure
> +++ b/configure
> +if [ $feat_refclock = "1" ] && \
> + test_code 'OpenBSD sensors' 'sys/types.h sys/time.h sys/sysctl.h sys/sensors.h' '' '' '
> + struct sensordev sd;
> + struct sensor s;
> + int mib[5] = { CTL_HW, HW_SENSORS, 0, SENSOR_TIMEDELTA, 0 };
> + size_t len = sizeof (s);
> + return sysctl(mib, 5, &s, &len, NULL, 0) + sizeof (sd.xname) +
> + SENSOR_S_OK + SENSOR_FINVALID;'
> +then
> + add_def FEAT_SENSORS
> +fi
This check should run only on OpenBSD (e.g. add a try_sensors
variable).
> @@ -636,6 +636,24 @@ Examples:
> refclock RTC /dev/rtc0:utc
> ----
> +
> +*SENSORS*:::
> +Driver for timedelta sensors provided by the OpenBSD *hw.sensors* framework.
Is the driver name "SENSORS" in plural form not confusing a bit here?
I'd prefer shorter "SENSOR" if you think that is acceptable.
> +static int read_timedelta(int dev, const char *name, struct sensor *s)
> +{
> + struct sensordev sd;
> + int mib[5] = { CTL_HW, HW_SENSORS, dev, SENSOR_TIMEDELTA, 0 };
> + size_t len = sizeof (*s);
Just a cosmetic nit, the decleration of "sd" should be the last one
here as shortest.
> +static int sensors_initialise(RCL_Instance instance)
> +{
> + struct sensors_instance *sensors;
> + struct sensor s;
> + char *name;
> + int dev;
> +
> + RCL_CheckDriverOptions(instance, NULL);
> +
> + name = RCL_GetDriverParameter(instance);
> + if (!name || name[0] == '\0')
> + LOG_FATAL("Missing sensor device");
> +
> + dev = find_sensordev(name);
> + if (dev < 0)
> + LOG_FATAL("Could not find sensor device %s", name);
This should be rebased for the recent changes made for the
"optional" refclock option.
> + if (read_timedelta(dev, name, &s) < 0)
> + LOG_FATAL("Could not read timedelta sensor of device %s", name);
> +
> + sensors = MallocNew(struct sensors_instance);
> + sensors->dev = dev;
> + sensors->name = name;
Better to Strdup() the name here in case it moves to stack, or is
reused/modified for some reason.
--
Miroslav Lichvar
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.