status: new message for subdaemons to tell us their versions.

For this patch we simply abort if it's wrong.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-04-08 14:13:46 +09:30
parent a8fde9f11f
commit b36e9fe473
5 changed files with 56 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
#include <ccan/io/fdpass/fdpass.h>
#include <ccan/io/io.h>
@@ -12,6 +13,7 @@
#include <common/peer_status_wiregen.h>
#include <common/per_peer_state.h>
#include <common/status_wiregen.h>
#include <common/version.h>
#include <errno.h>
#include <fcntl.h>
#include <lightningd/lightningd.h>
@@ -402,6 +404,20 @@ static bool handle_set_billboard(struct subd *sd, const u8 *msg)
return true;
}
static bool handle_version(struct subd *sd, const u8 *msg)
{
char *ver;
if (!fromwire_status_version(msg, msg, &ver))
return false;
if (!streq(ver, version())) {
fatal("subdaemon %s version '%s' not '%s'",
sd->name, ver, version());
}
return true;
}
static struct io_plan *sd_msg_read(struct io_conn *conn, struct subd *sd)
{
int type = fromwire_peektype(sd->msg_in);
@@ -455,6 +471,10 @@ static struct io_plan *sd_msg_read(struct io_conn *conn, struct subd *sd)
if (!handle_set_billboard(sd, sd->msg_in))
goto malformed;
goto next;
case WIRE_STATUS_VERSION:
if (!handle_version(sd, sd->msg_in))
goto malformed;
goto next;
}
if (sd->channel) {

View File

@@ -90,6 +90,9 @@ bool fromwire_status_peer_billboard(const tal_t *ctx UNNEEDED, const void *p UNN
/* Generated stub for fromwire_status_peer_error */
bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct channel_id *channel UNNEEDED, wirestring **desc UNNEEDED, bool *warning UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **error_for_them UNNEEDED)
{ fprintf(stderr, "fromwire_status_peer_error called!\n"); abort(); }
/* Generated stub for fromwire_status_version */
bool fromwire_status_version(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, wirestring **version UNNEEDED)
{ fprintf(stderr, "fromwire_status_version called!\n"); abort(); }
/* Generated stub for gossip_init */
void gossip_init(struct lightningd *ld UNNEEDED, int connectd_fd UNNEEDED)
{ fprintf(stderr, "gossip_init called!\n"); abort(); }