Skip to content

Commit

Permalink
wire: call unknown types "UNKNOWN X" not "INVALID X".
Browse files Browse the repository at this point in the history
It's freaking people out when they see things like:

```
 2024-11-11T05:26:41.281Z DEBUG ...53c-connectd: peer_out INVALID 22859
```

Fixes: #7802
Signed-off-by: Rusty Russell <[email protected]>
Changelog-Changed: connectd: log unknown messages as "UNKNOWN" not "INVALID" to avoid freaking people out.
  • Loading branch information
rustyrussell committed Dec 2, 2024
1 parent 1131568 commit b5d1ace
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions channeld/full_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lightningd/subd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions tools/gen/impl_template
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ ${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']:
case ${msg.enum_name()}: return "${msg.enum_name()}";
% endfor
}

snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
snprintf(invalidbuf, sizeof(invalidbuf), "UNKNOWN %i", e);
return invalidbuf;
}

Expand Down

0 comments on commit b5d1ace

Please sign in to comment.