From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Fco Javier Felix <ffelix@inode64.com>
Date: Tue, 1 Dec 2026 13:12:47 +0100
Subject: [PATCH] drivers/ietf-mib.c: keep zero readings of the index-0 current
 and powers

SU_FLAG_ZEROINVALID on the .0 copies of input.current, input.realpower
and output.realpower disabled each entry on its first 0 until the
driver restarted: a value already published stayed frozen, and one that
started at 0 never appeared. A 0 is a valid live reading (no load, or
input power while on battery), so publish it, as the .1 entries do.

The RTCS 03.02.00 card, which does not measure these three, now
publishes them as 0 again. It cannot be told apart reliably (sysObjectID
.0.0, generic sysDescr), so there is no quirk to bound the filter to.

Bump IETF_MIB_VERSION to 1.58.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
Upstream: proposed to NUT from branch snmp-ups-ietf-zero-index of github.com/inode64/nut.
Overlay copy of that commit.

 drivers/ietf-mib.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/ietf-mib.c b/drivers/ietf-mib.c
index 0a1ac6300..d4b899349 100644
--- a/drivers/ietf-mib.c
+++ b/drivers/ietf-mib.c
@@ -26,7 +26,7 @@
 
 #include "ietf-mib.h"
 
-#define IETF_MIB_VERSION	"1.57"
+#define IETF_MIB_VERSION	"1.58"
 
 /* SNMP OIDs set */
 #define IETF_OID_UPS_MIB	"1.3.6.1.2.1.33.1."
@@ -151,9 +151,7 @@ static snmp_info_t ietf_mib[] = {
 	/* Some agents (RTCS 03.02.00 cards, for one) number the line tables
 	 * from 0 instead of 1. The .0 entries come first so that an agent
 	 * answering both still publishes the RFC 1628 instance, read last;
-	 * the one that does not answer is disabled at startup. That card
-	 * returns 0 for the input current and power and the output power,
-	 * which it does not measure, so those .0 entries ignore 0. */
+	 * the one that does not answer is disabled at startup. */
 	snmp_info_default("input.frequency", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.2.0", "", SU_INPUT_1, NULL), /* upsInputFrequency.0 */
 	snmp_info_default("input.frequency", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.2.1", "", SU_INPUT_1, NULL), /* upsInputFrequency */
 	snmp_info_default("input.L1.frequency", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.2.1", "", SU_INPUT_3, NULL),
@@ -164,12 +162,12 @@ static snmp_info_t ietf_mib[] = {
 	snmp_info_default("input.L1-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.3.1", "", SU_INPUT_3, NULL),
 	snmp_info_default("input.L2-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.3.2", "", SU_INPUT_3, NULL),
 	snmp_info_default("input.L3-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.3.3", "", SU_INPUT_3, NULL),
-	snmp_info_default("input.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.0", "", SU_INPUT_1 | SU_FLAG_NEGINVALID | SU_FLAG_ZEROINVALID, NULL), /* upsInputCurrent.0 */
+	snmp_info_default("input.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.0", "", SU_INPUT_1 | SU_FLAG_NEGINVALID, NULL), /* upsInputCurrent.0 */
 	snmp_info_default("input.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.1", "", SU_INPUT_1 |SU_FLAG_NEGINVALID, NULL), /* upsInputCurrent */
 	snmp_info_default("input.L1.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.1", "", SU_INPUT_3, NULL),
 	snmp_info_default("input.L2.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.2", "", SU_INPUT_3, NULL),
 	snmp_info_default("input.L3.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.3", "", SU_INPUT_3, NULL),
-	snmp_info_default("input.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.0", "", SU_INPUT_1 | SU_FLAG_NEGINVALID | SU_FLAG_ZEROINVALID, NULL), /* upsInputTruePower.0 */
+	snmp_info_default("input.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.0", "", SU_INPUT_1 | SU_FLAG_NEGINVALID, NULL), /* upsInputTruePower.0 */
 	snmp_info_default("input.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.1", "", SU_INPUT_1 | SU_FLAG_NEGINVALID, NULL), /* upsInputTruePower */
 	snmp_info_default("input.L1.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.1", "", SU_INPUT_3, NULL),
 	snmp_info_default("input.L2.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.2", "", SU_INPUT_3, NULL),
@@ -195,7 +193,7 @@ static snmp_info_t ietf_mib[] = {
 	snmp_info_default("output.L1.current", 0, 0.1, IETF_OID_UPS_MIB "4.4.1.3.1", "", SU_OUTPUT_3, NULL),
 	snmp_info_default("output.L2.current", 0, 0.1, IETF_OID_UPS_MIB "4.4.1.3.2", "", SU_OUTPUT_3, NULL),
 	snmp_info_default("output.L3.current", 0, 0.1, IETF_OID_UPS_MIB "4.4.1.3.3", "", SU_OUTPUT_3, NULL),
-	snmp_info_default("output.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.0", "", SU_OUTPUT_1 | SU_FLAG_NEGINVALID | SU_FLAG_ZEROINVALID, NULL), /* upsOutputPower.0 */
+	snmp_info_default("output.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.0", "", SU_OUTPUT_1 | SU_FLAG_NEGINVALID, NULL), /* upsOutputPower.0 */
 	snmp_info_default("output.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.1", "", SU_OUTPUT_1 | SU_FLAG_NEGINVALID, NULL), /* upsOutputPower */
 	snmp_info_default("output.L1.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.1", "", SU_OUTPUT_3, NULL),
 	snmp_info_default("output.L2.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.2", "", SU_OUTPUT_3, NULL),
