mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
gossipd: use status levels for unusual reporting.
Now we have them, let's use them. I missed one case deliberately, since that causes merge conflicts when I replace it in a following patch. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
04eb101aa6
commit
5970890fae
@ -1223,20 +1223,20 @@ static int make_listen_fd(int domain, void *addr, socklen_t len, bool reportfail
|
||||
|
||||
/* Re-use, please.. */
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
|
||||
status_trace("Failed setting socket reuse: %s",
|
||||
strerror(errno));
|
||||
status_unusual("Failed setting socket reuse: %s",
|
||||
strerror(errno));
|
||||
|
||||
if (bind(fd, addr, len) != 0) {
|
||||
if (reportfail)
|
||||
status_trace("Failed to bind on %u socket: %s",
|
||||
domain, strerror(errno));
|
||||
status_broken("Failed to bind on %u socket: %s",
|
||||
domain, strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (listen(fd, 5) != 0) {
|
||||
status_trace("Failed to listen on %u socket: %s",
|
||||
domain, strerror(errno));
|
||||
status_broken("Failed to listen on %u socket: %s",
|
||||
domain, strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
return fd;
|
||||
@ -1386,7 +1386,8 @@ static struct io_plan *connection_in(struct io_conn *conn, struct daemon *daemon
|
||||
socklen_t len = sizeof(s);
|
||||
|
||||
if (getpeername(io_conn_fd(conn), (struct sockaddr *)&s, &len) != 0) {
|
||||
status_trace("Failed to get peername for incoming conn");
|
||||
status_unusual("Failed to get peername for incoming conn: %s",
|
||||
strerror(errno));
|
||||
return io_close(conn);
|
||||
}
|
||||
|
||||
@ -1404,9 +1405,9 @@ static struct io_plan *connection_in(struct io_conn *conn, struct daemon *daemon
|
||||
BUILD_ASSERT(sizeof(s4->sin_addr) <= sizeof(addr.addr));
|
||||
memcpy(addr.addr, &s4->sin_addr, addr.addrlen);
|
||||
addr.port = ntohs(s4->sin_port);
|
||||
} else {
|
||||
status_trace("Unknown socket type %i for incoming conn",
|
||||
s.ss_family);
|
||||
} else {
|
||||
status_broken("Unknown socket type %i for incoming conn",
|
||||
s.ss_family);
|
||||
return io_close(conn);
|
||||
}
|
||||
|
||||
@ -1423,7 +1424,7 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
|
||||
int fd1, fd2;
|
||||
|
||||
if (!portnum) {
|
||||
status_trace("Zero portnum, not listening for incoming");
|
||||
status_info("Zero portnum, not listening for incoming");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1444,8 +1445,8 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
|
||||
|
||||
len = sizeof(in6);
|
||||
if (getsockname(fd1, (void *)&in6, &len) != 0) {
|
||||
status_trace("Failed get IPv6 sockname: %s",
|
||||
strerror(errno));
|
||||
status_broken("Failed get IPv6 sockname: %s",
|
||||
strerror(errno));
|
||||
close_noerr(fd1);
|
||||
fd1 = -1;
|
||||
} else {
|
||||
@ -1462,8 +1463,8 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
|
||||
if (fd2 >= 0) {
|
||||
len = sizeof(addr);
|
||||
if (getsockname(fd2, (void *)&addr, &len) != 0) {
|
||||
status_trace("Failed get IPv4 sockname: %s",
|
||||
strerror(errno));
|
||||
status_broken("Failed get IPv4 sockname: %s",
|
||||
strerror(errno));
|
||||
close_noerr(fd2);
|
||||
fd2 = -1;
|
||||
} else {
|
||||
@ -1568,9 +1569,9 @@ static void connect_failed(struct io_conn *conn, struct reaching *reach)
|
||||
reach->attempts++;
|
||||
|
||||
if (reach->attempts >= reach->max_attempts) {
|
||||
status_trace("Failed to connect after %d attempts, giving up "
|
||||
"after %d seconds",
|
||||
reach->attempts, diff);
|
||||
status_info("Failed to connect after %d attempts, giving up "
|
||||
"after %d seconds",
|
||||
reach->attempts, diff);
|
||||
daemon_conn_send(
|
||||
&reach->daemon->master,
|
||||
take(towire_gossip_peer_connection_failed(
|
||||
@ -1641,9 +1642,8 @@ static void try_connect(struct reaching *reach)
|
||||
a = find_addrhint(reach->daemon, &reach->id);
|
||||
if (!a) {
|
||||
/* FIXME: now try node table, dns lookups... */
|
||||
/* FIXME: add reach_failed message */
|
||||
status_trace("No address known for %s, giving up",
|
||||
type_to_string(trc, struct pubkey, &reach->id));
|
||||
status_info("No address known for %s, giving up",
|
||||
type_to_string(trc, struct pubkey, &reach->id));
|
||||
daemon_conn_send(
|
||||
&reach->daemon->master,
|
||||
take(towire_gossip_peer_connection_failed(
|
||||
@ -1669,10 +1669,10 @@ static void try_connect(struct reaching *reach)
|
||||
}
|
||||
|
||||
if (fd < 0) {
|
||||
status_trace("Can't open %i socket for %s (%s), giving up",
|
||||
a->addr.type,
|
||||
type_to_string(trc, struct pubkey, &reach->id),
|
||||
strerror(errno));
|
||||
status_broken("Can't open %i socket for %s (%s), giving up",
|
||||
a->addr.type,
|
||||
type_to_string(trc, struct pubkey, &reach->id),
|
||||
strerror(errno));
|
||||
tal_free(reach);
|
||||
return;
|
||||
}
|
||||
@ -1812,8 +1812,8 @@ static struct io_plan *handle_disable_channel(struct io_conn *conn,
|
||||
u64 htlc_minimum_msat;
|
||||
|
||||
if (!fromwire_gossip_disable_channel(msg, &scid, &direction, &active) ) {
|
||||
status_trace("Unable to parse %s",
|
||||
gossip_wire_type_name(fromwire_peektype(msg)));
|
||||
status_unusual("Unable to parse %s",
|
||||
gossip_wire_type_name(fromwire_peektype(msg)));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -447,7 +447,7 @@ static struct io_plan *act_three_initiator(struct io_conn *conn,
|
||||
u8 spub[PUBKEY_DER_LEN];
|
||||
size_t len = sizeof(spub);
|
||||
|
||||
status_trace("Initiator: Act 3");
|
||||
SUPERVERBOSE("Initiator: Act 3");
|
||||
|
||||
/* BOLT #8:
|
||||
* * `c = encryptWithAD(temp_k2, 1, h, s.pub.serializeCompressed())`
|
||||
@ -589,7 +589,7 @@ static struct io_plan *act_two_initiator2(struct io_conn *conn,
|
||||
static struct io_plan *act_two_initiator(struct io_conn *conn,
|
||||
struct handshake *h)
|
||||
{
|
||||
status_trace("Initiator: Act 2");
|
||||
SUPERVERBOSE("Initiator: Act 2");
|
||||
|
||||
/* BOLT #8:
|
||||
*
|
||||
@ -609,7 +609,7 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
|
||||
{
|
||||
size_t len;
|
||||
|
||||
status_trace("Initiator: Act 1");
|
||||
SUPERVERBOSE("Initiator: Act 1");
|
||||
|
||||
/* BOLT #8:
|
||||
*
|
||||
@ -770,7 +770,7 @@ static struct io_plan *act_three_responder2(struct io_conn *conn,
|
||||
static struct io_plan *act_three_responder(struct io_conn *conn,
|
||||
struct handshake *h)
|
||||
{
|
||||
status_trace("Responder: Act 3");
|
||||
SUPERVERBOSE("Responder: Act 3");
|
||||
|
||||
/* BOLT #8:
|
||||
*
|
||||
@ -786,7 +786,7 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
|
||||
{
|
||||
size_t len;
|
||||
|
||||
status_trace("Responder: Act 2");
|
||||
SUPERVERBOSE("Responder: Act 2");
|
||||
|
||||
/* BOLT #8:
|
||||
*
|
||||
@ -946,7 +946,7 @@ static struct io_plan *act_one_responder(struct io_conn *conn,
|
||||
struct handshake *h)
|
||||
{
|
||||
|
||||
status_trace("Responder: Act 1");
|
||||
SUPERVERBOSE("Responder: Act 1");
|
||||
|
||||
/* BOLT #8:
|
||||
*
|
||||
|
@ -414,22 +414,22 @@ find_route(const tal_t *ctx, struct routing_state *rstate,
|
||||
src = get_node(rstate, to);
|
||||
|
||||
if (!src) {
|
||||
status_trace("find_route: cannot find %s",
|
||||
type_to_string(trc, struct pubkey, to));
|
||||
status_info("find_route: cannot find %s",
|
||||
type_to_string(trc, struct pubkey, to));
|
||||
return NULL;
|
||||
} else if (!dst) {
|
||||
status_trace("find_route: cannot find myself (%s)",
|
||||
type_to_string(trc, struct pubkey, to));
|
||||
status_info("find_route: cannot find myself (%s)",
|
||||
type_to_string(trc, struct pubkey, to));
|
||||
return NULL;
|
||||
} else if (dst == src) {
|
||||
status_trace("find_route: this is %s, refusing to create empty route",
|
||||
type_to_string(trc, struct pubkey, to));
|
||||
status_info("find_route: this is %s, refusing to create empty route",
|
||||
type_to_string(trc, struct pubkey, to));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (msatoshi >= MAX_MSATOSHI) {
|
||||
status_trace("find_route: can't route huge amount %"PRIu64,
|
||||
msatoshi);
|
||||
status_info("find_route: can't route huge amount %"PRIu64,
|
||||
msatoshi);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1248,10 +1248,9 @@ void routing_failure(struct routing_state *rstate,
|
||||
|
||||
node = get_node(rstate, erring_node_pubkey);
|
||||
if (!node) {
|
||||
status_trace("UNUSUAL routing_failure: "
|
||||
"Erring node %s not in map",
|
||||
type_to_string(tmpctx, struct pubkey,
|
||||
erring_node_pubkey));
|
||||
status_unusual("routing_failure: Erring node %s not in map",
|
||||
type_to_string(tmpctx, struct pubkey,
|
||||
erring_node_pubkey));
|
||||
/* No node, so no channel, so any channel_update
|
||||
* can also be ignored. */
|
||||
goto out;
|
||||
@ -1294,27 +1293,27 @@ void routing_failure(struct routing_state *rstate,
|
||||
if (structeq(&erring_node_pubkey->pubkey,
|
||||
&rstate->local_id.pubkey))
|
||||
goto out;
|
||||
status_trace("UNUSUAL routing_failure: "
|
||||
"UPDATE bit set, no channel_update. "
|
||||
"failcode: 0x%04x",
|
||||
(int) failcode);
|
||||
status_unusual("routing_failure: "
|
||||
"UPDATE bit set, no channel_update. "
|
||||
"failcode: 0x%04x",
|
||||
(int) failcode);
|
||||
goto out;
|
||||
}
|
||||
t = fromwire_peektype(channel_update);
|
||||
if (t != WIRE_CHANNEL_UPDATE) {
|
||||
status_trace("UNUSUAL routing_failure: "
|
||||
"not a channel_update. "
|
||||
"type: %d",
|
||||
(int) t);
|
||||
status_unusual("routing_failure: "
|
||||
"not a channel_update. "
|
||||
"type: %d",
|
||||
(int) t);
|
||||
goto out;
|
||||
}
|
||||
handle_channel_update(rstate, channel_update);
|
||||
} else {
|
||||
if (tal_len(channel_update) != 0)
|
||||
status_trace("UNUSUAL routing_failure: "
|
||||
"UPDATE bit clear, channel_update given. "
|
||||
"failcode: 0x%04x",
|
||||
(int) failcode);
|
||||
status_unusual("routing_failure: "
|
||||
"UPDATE bit clear, channel_update given. "
|
||||
"failcode: 0x%04x",
|
||||
(int) failcode);
|
||||
}
|
||||
|
||||
out:
|
||||
@ -1337,9 +1336,9 @@ void mark_channel_unroutable(struct routing_state *rstate,
|
||||
short_channel_id_to_uint(channel));
|
||||
|
||||
if (!chan) {
|
||||
status_trace("UNUSUAL mark_channel_unroutable: "
|
||||
"channel %s not in routemap",
|
||||
scid);
|
||||
status_unusual("mark_channel_unroutable: "
|
||||
"channel %s not in routemap",
|
||||
scid);
|
||||
tal_free(tmpctx);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user