Page MenuHomeFreeBSD

random: add boot id sysctl
AbandonedPublic

Authored by corvink on Dec 6 2023, 7:52 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 19, 4:45 AM
Unknown Object (File)
Sun, May 19, 4:45 AM
Unknown Object (File)
Sat, May 18, 9:46 AM
Unknown Object (File)
Tue, May 14, 12:54 PM
Unknown Object (File)
Wed, Apr 24, 10:19 AM
Unknown Object (File)
Dec 24 2023, 12:16 PM
Unknown Object (File)
Dec 17 2023, 2:49 PM
Subscribers

Details

Summary

It's hard to reliable reboot a system over ssh. A common workflow is to
call reboot in a ssh session and then wait until you're able to
reconnect over ssh. Unfortunately, it's sometimes possible to reconnect
before the system has actually rebooted. For that reason, we need an
identifier which is different on each boot to check if the system was
already rebooted or not. E.g. ansible is using the boottime as
identifier [1]. Unfortunately, FreeBSD uses an unintuitive definition
of the bootime. It's not a fixed value, it's adjusted from time to time
[2]. In contrast to FreeBSD, Linux provides a unique boot identifier
called boot_id. Add a similar identifier to sysctl. We're using the same
format for the boot id to make it reusable it in linuxkpi.

[1] https://github.com/ansible/ansible/blob/6ebefaceb6cd0d4961776a94d63a71fc1fc28bc0/lib/ansible/plugins/action/reboot.py#L53
[2] https://cgit.freebsd.org/src/commit/?id=a512d0ab009eedf2f1876fce86d6386bfee626d8

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 54811
Build 51700: arc lint + arc unit

Event Timeline

I'm not sure who's the right person to review this. I've found you in the git log of dev/random and linprocfs.

  • firstboot handling in linprocfs is not required anymore

I just don't understand why it's under kern.random and in the random driver? It would make sense to me for this to just be under kern and probably live in sys/kern/kern_mib.c instead with a SYSINIT to initialize it?

In D42921#978988, @jhb wrote:

I just don't understand why it's under kern.random and in the random driver? It would make sense to me for this to just be under kern and probably live in sys/kern/kern_mib.c instead with a SYSINIT to initialize it?

Sorry for the noise.

While looking at kern_mib, I've noticed that FreeBSD already has kern.boot_id. I have no idea how I could missed that. Maybe I've missed it because it's not show by sysctl -a.

In D42921#978988, @jhb wrote:

I just don't understand why it's under kern.random and in the random driver? It would make sense to me for this to just be under kern and probably live in sys/kern/kern_mib.c instead with a SYSINIT to initialize it?

Sorry for the noise.

While looking at kern_mib, I've noticed that FreeBSD already has kern.boot_id. I have no idea how I could missed that. Maybe I've missed it because it's not show by sysctl -a.

The MIB kern.boot_id has type CTLTYPE_STRUCT , and the option -a will excluded MIBs with opaque type.

Try sysctl -A | grep boot_id or sysctl -ao | grep boot_id

# sysctl -A kern | grep boot_id
kern.boot_id: Format: Length:16 Dump:0x......