mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
routing: free entire channel, not just node_connection on PERM error.
And do it by reparenting onto the tmpctx, restoring some simpliciy. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
00194b6130
commit
d0f68ffb15
@@ -1155,8 +1155,11 @@ struct route_hop *get_route(tal_t *ctx, struct routing_state *rstate,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* routing_failure_channel_out - Handle routing failure on a specific channel
|
* routing_failure_channel_out - Handle routing failure on a specific channel
|
||||||
|
*
|
||||||
|
* If we want to delete the channel, we reparent it to disposal_context.
|
||||||
*/
|
*/
|
||||||
static void routing_failure_channel_out(struct node *node,
|
static void routing_failure_channel_out(const tal_t *disposal_context,
|
||||||
|
struct node *node,
|
||||||
enum onion_type failcode,
|
enum onion_type failcode,
|
||||||
struct routing_channel *chan,
|
struct routing_channel *chan,
|
||||||
time_t now)
|
time_t now)
|
||||||
@@ -1176,7 +1179,8 @@ static void routing_failure_channel_out(struct node *node,
|
|||||||
/* Prevent it for 20 seconds. */
|
/* Prevent it for 20 seconds. */
|
||||||
nc->unroutable_until = now + 20;
|
nc->unroutable_until = now + 20;
|
||||||
else
|
else
|
||||||
tal_free(nc);
|
/* Set it up to be pruned. */
|
||||||
|
tal_steal(disposal_context, chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
void routing_failure(struct routing_state *rstate,
|
void routing_failure(struct routing_state *rstate,
|
||||||
@@ -1216,13 +1220,8 @@ void routing_failure(struct routing_state *rstate,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (failcode & NODE) {
|
if (failcode & NODE) {
|
||||||
/* If permanent, we forget entire node and all its channels.
|
for (i = 0; i < tal_count(node->channels); ++i) {
|
||||||
* If we did this in a loop, we might use-after-free. */
|
routing_failure_channel_out(tmpctx, node, failcode,
|
||||||
if (failcode & PERM) {
|
|
||||||
tal_free(node);
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < tal_count(node->channels); ++i)
|
|
||||||
routing_failure_channel_out(node, failcode,
|
|
||||||
node->channels[i],
|
node->channels[i],
|
||||||
now);
|
now);
|
||||||
}
|
}
|
||||||
@@ -1244,7 +1243,8 @@ void routing_failure(struct routing_state *rstate,
|
|||||||
type_to_string(tmpctx, struct pubkey,
|
type_to_string(tmpctx, struct pubkey,
|
||||||
erring_node_pubkey));
|
erring_node_pubkey));
|
||||||
else
|
else
|
||||||
routing_failure_channel_out(node, failcode, chan, now);
|
routing_failure_channel_out(tmpctx,
|
||||||
|
node, failcode, chan, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the channel if UPDATE failcode. Do
|
/* Update the channel if UPDATE failcode. Do
|
||||||
|
|||||||
Reference in New Issue
Block a user