From b5d1acee452ccb603fec8cb0d7c2a9eac9e3cff8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 2 Dec 2024 09:16:53 +1030 Subject: [PATCH] wire: call unknown types "UNKNOWN X" not "INVALID X". It's freaking people out when they see things like: ``` 2024-11-11T05:26:41.281Z DEBUG ...53c-connectd: peer_out INVALID 22859 ``` Fixes: https://github.com/ElementsProject/lightning/issues/7802 Signed-off-by: Rusty Russell Changelog-Changed: connectd: log unknown messages as "UNKNOWN" not "INVALID" to avoid freaking people out. --- channeld/full_channel.c | 4 ++-- lightningd/pay.c | 2 +- lightningd/subd.c | 2 +- tools/gen/impl_template | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/channeld/full_channel.c b/channeld/full_channel.c index 79c0b2da3ce5..e434bd4c8977 100644 --- a/channeld/full_channel.c +++ b/channeld/full_channel.c @@ -1658,13 +1658,13 @@ bool channel_force_htlcs(struct channel *channel, const char *channel_add_err_name(enum channel_add_err e) { - static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)]; + static char invalidbuf[sizeof("UNKNOWN ") + STR_MAX_CHARS(e)]; for (size_t i = 0; enum_channel_add_err_names[i].name; i++) { if (enum_channel_add_err_names[i].v == e) return enum_channel_add_err_names[i].name; } - snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e); + snprintf(invalidbuf, sizeof(invalidbuf), "UNKNOWN %i", e); return invalidbuf; } diff --git a/lightningd/pay.c b/lightningd/pay.c index d3c4141684bf..972181bd376a 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -219,7 +219,7 @@ json_add_routefail_info(struct json_stream *js, json_add_num(js, "erring_index", erring_index); json_add_num(js, "failcode", failcode); /* FIXME: Better way to detect this? */ - if (!strstarts(failcodename, "INVALID ")) + if (!strstarts(failcodename, "UNKNOWN ")) json_add_string(js, "failcodename", failcodename); if (erring_node != NULL) diff --git a/lightningd/subd.c b/lightningd/subd.c index 79534c373040..091f2d139cda 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -839,7 +839,7 @@ void subd_send_msg(struct subd *sd, const u8 *msg_out) u16 type = fromwire_peektype(msg_out); /* FIXME: We should use unique upper bits for each daemon, then * have generate-wire.py add them, just assert here. */ - if (strstarts(sd->msgname(type), "INVALID")) + if (strstarts(sd->msgname(type), "UNKNOWN")) fatal("Sending %s an invalid message %s", sd->name, tal_hex(tmpctx, msg_out)); msg_enqueue(sd->outq, msg_out); } diff --git a/tools/gen/impl_template b/tools/gen/impl_template index a6a16669455f..4ce2dcb37bbf 100644 --- a/tools/gen/impl_template +++ b/tools/gen/impl_template @@ -24,7 +24,7 @@ ${i} const char *${enum_set['name']}_name(int e) { - static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)]; + static char invalidbuf[sizeof("UNKNOWN ") + STR_MAX_CHARS(e)]; switch ((enum ${enum_set['name']})e) { % for msg in enum_set['set']: @@ -32,7 +32,7 @@ const char *${enum_set['name']}_name(int e) % endfor } - snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e); + snprintf(invalidbuf, sizeof(invalidbuf), "UNKNOWN %i", e); return invalidbuf; }