From aca2aa9ae69d7377d9e7910929702612c74cd4fb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Sep 2023 10:12:41 +0930 Subject: [PATCH] common: remove channel_id check. connectd demuxes for us, so this can never trigger. Signed-off-by: Rusty Russell --- common/read_peer_msg.c | 12 ------------ common/read_peer_msg.h | 12 ------------ openingd/dualopend.c | 20 -------------------- openingd/openingd.c | 21 --------------------- 4 files changed, 65 deletions(-) diff --git a/common/read_peer_msg.c b/common/read_peer_msg.c index 830c51c53..83c937cbb 100644 --- a/common/read_peer_msg.c +++ b/common/read_peer_msg.c @@ -56,18 +56,6 @@ bool is_peer_error(const tal_t *ctx, const u8 *msg, return true; } -bool is_wrong_channel(const u8 *msg, const struct channel_id *expected, - struct channel_id *actual) -{ - if (!expected) - return false; - - if (!extract_channel_id(msg, actual)) - return false; - - return !channel_id_eq(expected, actual); -} - bool handle_peer_error(struct per_peer_state *pps, const struct channel_id *channel_id, const u8 *msg TAKES) diff --git a/common/read_peer_msg.h b/common/read_peer_msg.h index 2719eb2a3..3c6e2faf8 100644 --- a/common/read_peer_msg.h +++ b/common/read_peer_msg.h @@ -23,18 +23,6 @@ bool is_peer_error(const tal_t *ctx, const u8 *msg, const struct channel_id *channel_id, char **desc, bool *warning); -/** - * is_wrong_channel - if it's a message about a different channel, return true - * @msg: the peer message. - * @channel_id: the channel id of the current channel. - * @actual: set to the actual channel id if this returns false. - * - * Note that this only handles some message types, returning false for others. - */ -bool is_wrong_channel(const u8 *msg, const struct channel_id *expected, - struct channel_id *actual); - - /** * handle_peer_error - simple handler for errors * @pps: per-peer state. diff --git a/openingd/dualopend.c b/openingd/dualopend.c index f1e6f0148..d8b0f494b 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -1291,7 +1291,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state) u8 *msg; char *err; bool warning; - struct channel_id actual; enum peer_wire t; /* The event loop is responsible for freeing tmpctx, so our @@ -1331,25 +1330,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state) return NULL; } - /*~ We do not support multiple "live" channels, though the - * protocol has a "channel_id" field in all non-gossip messages - * so it's possible. Our one-process-one-channel mechanism - * keeps things simple: if we wanted to change this, we would - * probably be best with another daemon to de-multiplex them; - * this could be connectd itself, in fact. */ - if (is_wrong_channel(msg, &state->channel_id, &actual)) { - status_debug("Rejecting %s for unknown channel_id %s", - peer_wire_name(fromwire_peektype(msg)), - type_to_string(tmpctx, struct channel_id, - &actual)); - peer_write(state->pps, - take(towire_errorfmt(NULL, &actual, - "Multiple channels" - " unsupported"))); - tal_free(msg); - continue; - } - /* In theory, we're in the middle of an open/RBF, but * it's possible we can get some different messages in * the meantime! */ diff --git a/openingd/openingd.c b/openingd/openingd.c index 84b7a5c09..2958a6c1f 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -187,7 +187,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state, u8 *msg; char *err; bool warning; - struct channel_id actual; /* The event loop is responsible for freeing tmpctx, so our * temporary allocations don't grow unbounded. */ @@ -226,26 +225,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state, return NULL; } - /*~ We do not support multiple "live" channels, though the - * protocol has a "channel_id" field in all non-gossip messages - * so it's possible. Our one-process-one-channel mechanism - * keeps things simple: if we wanted to change this, we would - * probably be best with another daemon to de-multiplex them; - * this could be connectd itself, in fact. */ - if (is_wrong_channel(msg, &state->channel_id, &actual) - && is_wrong_channel(msg, alternate, &actual)) { - status_debug("Rejecting %s for unknown channel_id %s", - peer_wire_name(fromwire_peektype(msg)), - type_to_string(tmpctx, struct channel_id, - &actual)); - peer_write(state->pps, - take(towire_errorfmt(NULL, &actual, - "Multiple channels" - " unsupported"))); - tal_free(msg); - continue; - } - /* If we get here, it's an interesting message. */ return msg; }