snmp-ups: prefer exact outlet mappings - #3610
Conversation
Look up exact mappings before interpreting outlet names as numbered templates. Return the existing unknown status when a numbered template is absent, update server-side writable values through dstate, and track ownership for instantiated entries. Add a focused hardware-free regression for exact mappings, missing templates, valid numbered templates, unavailable mappings and cleanup. AI assistance: OpenAI Codex gpt-5.6-sol at high reasoning. The human contributor remains responsible for reviewing and validating the change. Signed-off-by: user01010111 <lapses.50.booster@icloud.com>
|
A ZIP file with standard source tarball and another tarball with pre-built docs for commit 48e6877 is temporarily available: NUT-tarballs-PR-3610.zip. |
|
✅ Build nut 2.8.5.5182-master completed (commit 31c4222536 by @)
|
jimklimov
left a comment
There was a problem hiding this comment.
Looks reasonable, but a NEWS.adoc entry would be welcome.
CC @arnaudquette-eaton - would you be able to test this against some SNMP ePDUs?
|
The mentioned "exits 139" I suppose means a SIGSEGV (128 + 11) which is usually linked to a NULL pointer dereference. |
|
This PR commits NUT doesn't have a central location for unit tests, and most drivers are not designed for unit tests, the build system doesn't do unit tests for individual regressions, so an ad-hoc unit test |
|
Thanks @biergaizi - I somehow missed the location. There is precedent for piecemeal parser checks under |
Move the focused SNMP setvar regression from drivers/ to tests/ and wire it through the existing linked-driver-source pattern. Restore drivers/Makefile.am to the normal driver-only build and add the requested NEWS entry for issue networkupstools#3360. AI assistance: OpenAI Codex gpt-5.6-sol at high reasoning. The human contributor remains responsible for reviewing and validating the change. Signed-off-by: user01010111 <lapses.50.booster@icloud.com>
|
Thanks @biergaizi and @jimklimov. This was an agent oversight: it concentrated on proving the runtime behaviour and regression, but did not compare the nearest repository-placement and release-note precedents before preparing the original change. The test should have been placed under The branch has now been updated to:
The regression remains focused on the affected Validation after the relocation:
The regression source itself is byte-for-byte unchanged. Thank you for catching the organisational mismatch. |
|
❌ Build nut 2.8.5.5190-master failed (commit 0c578d38c8 by @) |
|
❌ Build nut 2.8.5.5190-master failed (commit 0c578d38c8 by @) |
Summary
Fixes #3360.
snmp-upssupports mapping tables which combine exactoutlet.*entrieswith numbered outlet templates.
su_setOID()previously sent every outletname through template parsing before consulting exact table entries. A
registered outlet-shaped name with no matching template could therefore
leave
su_find_info()returningNULLand pass that result toinstantiate_info().The same ordering bypassed exact server-side writable values and commands,
while cleanup inferred allocation ownership from the variable-name prefix.
This changes lookup to prefer exact mappings, returns the existing unknown
status when a numbered template is absent, handles writable server-side
values without an SNMP OID through
dstate, and records whether an entry wasinstantiated so only dynamically owned copies are freed.
upsdnormally forwards only registered writable variables and commands;arbitrary unpublished outlet-name parser hardening is outside this patch.
Validation
snmp-upsimplementation with the existing mock driver and a minimal outlet mapping.
outlet.descreproduction exits139. GDB stops at the NULL
su_info_p->dfldereference after the templatelookup fails. The candidate returns
STAT_SET_HANDLEDand the new value isavailable through
dstate.STAT_SET_UNKNOWNwithout aNULL dereference.
the SNMP set path and return the expected failure for the deliberately
invalid test OIDs. An unavailable exact mapping returns the existing
unknown status, and cleanup completes normally.
snmp-upsdriver and focused test.UndefinedBehaviorSanitizer with no candidate findings.
detection was disabled for the ASan/UBSan run rather than claimed as
accepted.
and
git diff --checkpassed.make distcheck-lightpackaged the candidate and included allchanged files, then stopped on pre-existing spellcheck findings in unchanged
NEWS.adocanddocs/man/apcmicrolink.txt.make SPELLCHECK_ERROR_FATAL=no distcheck-lightrun built and extractedthe distribution, and the packaged
snmp-ups-setvar-testpassed 1/1.Overall distcheck remained blocked by unchanged
cppunittestbecause thesandbox denied
socket(AF_INET, SOCK_STREAM, 0)withEPERM. No candidatefile was implicated.
No physical SNMP or UPS hardware is required for this regression.
AI assistance
OpenAI Codex
gpt-5.6-solat high reasoning was used for repositoryanalysis, implementation, review, drafting and validation. The human
contributor remains responsible for reviewing and validating the change.