fix(ipsec): инициализация сервера не запечатывает счётчики интерфейсов

Доказательство состояния mm_ipsec_server_init_plan и отката ревизии IPsec включало весь /interface со счётчиками rx/tx-byte. На живом CHR два чтения подряд расходились: подготовка плана отказывала STATE_CONFLICT, а fence и сверка после каждой из 13 записей останавливали бы инициализацию на полпути. Счётчики и время смены линка исключены, конфигурация и running остаются запечатанными.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
DenozordecandClaude Opus 5.5 committed 2026-11-21 10:55:16 +07:00
1 parent ff7e3f278b
commit 2873878530
2 files changed
+9

No files matched your search

@@ -84,4 +84,8 @@ for (const path of ipsecExternalPoolDependencyPaths) {
const system = structuredClone(projected); system.catalogs["/ip/ipsec/profile"][0].dynamic = "true"; assert.throws(() => planIpsecServerInit(system, server, request))
const unknown = structuredClone(projected); unknown.catalogs["/ip/ipsec/profile"][0].opaque = "changed"; assert.notDeepEqual(ipsecServerInitValue(unknown), ipsecServerInitValue(projected))
const expiry = structuredClone(projected); expiry.catalogs["/certificate"][0]["expires-after"] = "123d"; assert.deepEqual(ipsecServerInitValue(expiry), ipsecServerInitValue(projected))
// A live router's interface counters move between any two reads; configuration and link state stay sealed.
const traffic = structuredClone(projected); Object.assign(traffic.catalogs["/interface"][0], { "rx-byte": "1", "tx-byte": "2", "fp-rx-packet": "3", "link-downs": "1", "last-link-up-time": "2026-11-21 03:00:00" })
assert.deepEqual(ipsecServerInitValue(traffic), ipsecServerInitValue(projected))
for (const [key, changed] of [["disabled", "true"], ["running", "false"], ["mtu", "1400"]]) { const link = structuredClone(projected); link.catalogs["/interface"][0][key] = changed; assert.notDeepEqual(ipsecServerInitValue(link), ipsecServerInitValue(projected)) }
console.log("IPsec init model: all REST fields, all raw11 catalogs, NAT egress, owned reuse, foreign/system/dependency denial, ACK-only defaults, new-owned-only sign, full opaque proof")
@@ -13,8 +13,13 @@ import { captureIpsecSnapshot, mapClients, mapServerSummary, type IpsecServerSta
import { ipsecServerInitRequest, planIpsecServerInit, projectIpsecServerInit, validateIpsecServerInitState, type IpsecServerInitState } from "./ipsec-server-init-model.js"
import { ipsecExternalPoolDependencyPaths, ipsecPoolDependencies } from "./ipsec-pool-dependencies.js"
// Interface counters and link timestamps change with every packet; sealing them made two reads of a live
// router disagree, so prepare, fence and per-command read-back refused. Configuration and `running` stay sealed.
const interfaceTelemetry = ["rx-byte", "tx-byte", "rx-packet", "tx-packet", "rx-drop", "tx-drop", "tx-queue-drop", "rx-error", "tx-error",
"fp-rx-byte", "fp-tx-byte", "fp-rx-packet", "fp-tx-packet", "link-downs", "last-link-up-time", "last-link-down-time"]
export function ipsecServerInitValue(state: IpsecServerInitState) {
const value = ipsecPeerDeleteValue(state)
for (const row of value.catalogs["/interface"] ?? []) for (const key of interfaceTelemetry) delete row[key]
for (const rows of Object.values(value.catalogs)) for (const row of rows) for (const key of ["disabled", "responder", "template", "nat-traversal", "passive", "trusted"]) {
if (row[key] === undefined) continue
const boolean = observedBoolean(row[key])