Skip to content

fix(strongswan-connections): check fails with AEAD algorithms#1386

Merged
markuslf merged 1 commit into
Linuxfabrik:mainfrom
teissler:main
Jul 17, 2026
Merged

fix(strongswan-connections): check fails with AEAD algorithms#1386
markuslf merged 1 commit into
Linuxfabrik:mainfrom
teissler:main

Conversation

@teissler

Copy link
Copy Markdown
Contributor

The vici interface omits several (integ-alg, encr-alg, encr-keysize, prf-alg, dh-group) keys when using AEAD algorithms or connections are in connecting state.

The vici interface omits several (integ-alg, encr-alg, encr-keysize, prf-alg,
dh-group) keys when using AEAD algorithms or connections are in connecting state.

@markuslf markuslf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up on #806. Merging this because it fixes a real crash: the plugin raises KeyError whenever the IKE SA carries no proposal yet, and also on fixed-key ciphers (3DES/DES/NULL), where vici omits encr-keysize.

I will polish a few things in a follow-up commit rather than block this PR on them:

  • if row['established'] is not None never fires, because 'None' is assigned as a string a few lines above. The result is invalid perfdata ('conn_established'=Nones;;;0, 'conn_rekey-time'=n/as;;;0). Perfdata values have to match [-0-9.], so these need a real None sentinel and a skip.
  • The continue in the loop is dead code (it already was in #806): data[key] is assigned before it, so the setdefault() calls never take effect for a present-but-empty value.
  • On the rationale: with AEAD, vici only omits integ-alg/integ-keysize (vici_query.c:622), while encr-alg, prf-alg and dh-group are still emitted. What your patch actually fixes is the if (proposal) guard at vici_query.c:612 (SA not negotiated yet) and the if (ks) guard at vici_query.c:617 (fixed-key ciphers). Same for established/rekey-time, which are gated on IKE_ESTABLISHED at vici_query.c:642 and therefore also missing in REKEYING/DELETING, not just CONNECTING.

@markuslf
markuslf enabled auto-merge (squash) July 17, 2026 12:21
@markuslf
markuslf merged commit 2c788de into Linuxfabrik:main Jul 17, 2026
4 checks passed
markuslf added a commit that referenced this pull request Jul 17, 2026
…established SA

#1386 stopped the KeyError on a connection whose IKE SA has no negotiated
proposal yet, but left three problems behind:

* The `established` guard never fired, because the string 'None' was assigned
  instead of None, and `rekey-time` had no guard at all. Both rendered
  non-numeric performance data ('conn_established'=Nones,
  'conn_rekey-time'=n/as), which breaks ingestion.
* The empty-value `continue` was dead code, as it already was in #806: the
  value is assigned before it, so the setdefault() calls never applied to a key
  that is present but empty.
* `rekey-time-hr` was left unset whenever `rekey-time` was absent.

Also drop the dangling dash that a fixed-key cipher such as 3DES rendered
("3DES-/...") on both the IKE and the CHILD SA, and correct the comment
claiming `reauth-time`/`rekey-time` are a 5.7-vs-5.9 difference: vici_query.c
has emitted both unchanged since 5.2.0, and their presence depends on the peer
configuration and on the SA being established, not on the version.

Add fixtures for a connecting SA and for a fixed-key cipher.
markuslf added a commit that referenced this pull request Jul 17, 2026
…zero

Two problems predating #1386, both found while checking the previous commit
against the vici_query.c source:

* `format_child_data()` defaulted an absent `install-time`, `life-time` or
  `rekey-time` to 0. VICI only sends the timers of an installed CHILD SA, and
  sends the two lifetimes only if the SA expires at all (vici_query.c:412-423),
  so an absent timer is unknown, not zero. A CHILD SA without a configured
  lifetime graphed a life-time of 0 and rendered "Expires: <now>", which reads
  as if the tunnel were about to drop. Report them as None and skip their
  performance data instead, as the IKE SA timers already do.
* `rekey-time` and `life-time` are `t - now` and go negative once the deadline
  has passed, but their performance data declared `_min=0`, so an RRD backend
  could reject exactly the overdue values worth alerting on. Upstream formats
  both with PRId64 while the byte counters use PRIu64, which is the giveaway.
  Drop the bogus minimum; `established` and `install-time` are `now - t` and
  keep theirs.

Add a fixture for a CHILD SA that never expires.
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.

2 participants