Skip to content

Finalize ietf-interfaces.yang: last-change, higher-layer-if, lower-layer-if - #1635

Merged
troglobit merged 4 commits into
mainfrom
ifaces
Sep 21, 2026
Merged

troglobit merged 4 commits into
mainfrom
ifaces

Conversation

@troglobit

@troglobit troglobit commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Last interface change

Completes #514 with the remaining ietf-interfaces.yang status leaves. Both CLI and WebUI support.

  • higher-layer-if and lower-layer-if come from the kernel's
    upper_/lower_ links in sysfs, covering bridge ports, LAG
    members, VLAN parents and any other netdev adjacency.
  • last-change is tracked by statd over rtnetlink in an in-memory
    map keyed by interface name. Interfaces whose state predates
    statd have no last-change, per RFC 8343.
  • show interface <name> prints last change and the layer lists.

Note

As per RFC8343, the last-change node is not shown (included) "If the current state was entered prior to the last re-initialization of the local network management subsystem". I.e., on startup.

Checklist

Tick relevant boxes, this PR is-a or has-a:

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe):

@jovatn

jovatn commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

@troglobit Great enhancement!!

Some comments:

  • I do not see any update to yang among the changed files. I suppose I look at the wrong place?!
  • I also note that there are no updates to doc except for changelog, and it's because we do not have any show interface br0or show interface veth0a examples. Should we add that? (separate issue)
  • How is it with link aggregates, does "lower-layer" status apply to that? (suppose not, but I am unsure)

@troglobit

troglobit commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@troglobit Great enhancement!!

thx 😎

Some comments:

  • I do not see any update to yang among the changed files. I suppose I look at the wrong place?!

These nodes were never deviated, just missing backend code.

  • I also note that there are no updates to doc except for changelog, and it's because we do not have any show interface br0or show interface veth0a examples. Should we add that? (separate issue)

It's honestly such a minor thing, I think we can skip it for now. There's a lot of bridge changes coming, and possibly even veth if we do the podman swap, so the docs will be updated over time anyway.

  • How is it with link aggregates, does "lower-layer" status apply to that? (suppose not, but I am unsure)

It does, the data comes from the kernel's netdev adjacency, and the bonding driver registers exactly that link when a port joins a LAG, the same call the bridge uses for its ports. So a LAG member shows the LAG under higher-layer-if, and the LAG lists its members under lower-layer-if.

The ietf-interfaces leaf-lists higher-layer-if and lower-layer-if were
never populated, so operational data gave no general view of how
interfaces stack.  Only the VLAN augment carried its lower-layer-if.

The kernel already keeps this adjacency in sysfs, as upper_<name> and
lower_<name> links in each interface directory.  Read them per
interface and drop references to interfaces hidden from operational
(group internal, CAN) so no leafref points at a missing entry.

Fixes part of issue #514

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The mDNS neighbor code has a private formatter for YANG date-and-time
strings.  More operational leaves need the same encoding, so give it a
home in shared.c and let callers pass the time to format.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The ietf-interfaces leaf last-change, the time an interface entered its
current operational state, was missing.  Nothing on the system keeps it:
the kernel has no ifLastChange and statd only reads state on demand.

Track it in statd.  A netlink socket in the RTMGRP_LINK group feeds an
in-memory map keyed by interface name, stamping every operational state
change with the monotonic clock.  The interfaces callback adds the leaf
to yanger's output for each interface with a recorded change, converting
to wall-clock time at that point so a later NTP step does not skew old
stamps.  Interfaces whose state predates statd get no last-change, as
RFC 8343 requires.

Fixes #514

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The interface detail page lists a fixed set of status fields, so the
new ietf-interfaces leaves did not show up.  Add last change with its
age, and the lower and higher layer interfaces linked to their own
pages.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
@troglobit
troglobit merged commit b0bd729 into main Sep 21, 2026
11 checks passed
@troglobit
troglobit deleted the ifaces branch September 21, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants