From: Matt Corallo Date: Wed, 26 Jan 2022 02:04:20 +0000 (+0000) Subject: Correct handling of `UnknownRequiredFeature` deserialization X-Git-Tag: v0.0.105~25^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=94639137c362ecc41d8ca33374f4c84d87839766;p=rust-lightning Correct handling of `UnknownRequiredFeature` deserialization Quite some time ago, `UnknownRequiredFeature` was only used when a gossip message has a missing required feature. These days, its also used for any required TLV which we do not understand in any message. However, the handling of it was never updated in `PeerManager`, leaving it printing a warning about gossip and ignoring the message entirely. Instead, we send a warning message and disconnect. Closes #1236, as caught by @jkczyz. --- diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 86cd344c..b910d4bf 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -902,7 +902,11 @@ impl P Ok(x) => x, Err(e) => { match e { - (msgs::DecodeError::UnknownRequiredFeature, _) => { + // Note that to avoid recursion we never call + // `do_attempt_write_data` from here, causing + // the messages enqueued here to not actually + // be sent before the peer is disconnected. + (msgs::DecodeError::UnknownRequiredFeature, Some(ty)) if is_gossip_msg(ty) => { log_gossip!(self.logger, "Got a channel/node announcement with an unknown required feature flag, you may want to update!"); continue; } @@ -916,6 +920,11 @@ impl P self.enqueue_message(peer, &msgs::WarningMessage { channel_id: [0; 32], data: "Unreadable/bogus gossip message".to_owned() }); continue; } + (msgs::DecodeError::UnknownRequiredFeature, ty) => { + log_gossip!(self.logger, "Received a message with an unknown required feature flag or TLV, you may want to update!"); + self.enqueue_message(peer, &msgs::WarningMessage { channel_id: [0; 32], data: format!("Received an unknown required feature/TLV in message type {:?}", ty) }); + return Err(PeerHandleError { no_connection_possible: false }); + } (msgs::DecodeError::UnknownVersion, _) => return Err(PeerHandleError { no_connection_possible: false }), (msgs::DecodeError::InvalidValue, _) => { log_debug!(self.logger, "Got an invalid value while deserializing message");