Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
5970890fae
  1. 54
      gossipd/gossip.c
  2. 12
      gossipd/handshake.c
  3. 53
      gossipd/routing.c

54
gossipd/gossip.c

@ -1223,20 +1223,20 @@ static int make_listen_fd(int domain, void *addr, socklen_t len, bool reportfail
/* Re-use, please.. */ /* Re-use, please.. */
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
status_trace("Failed setting socket reuse: %s", status_unusual("Failed setting socket reuse: %s",
strerror(errno)); strerror(errno));
if (bind(fd, addr, len) != 0) { if (bind(fd, addr, len) != 0) {
if (reportfail) if (reportfail)
status_trace("Failed to bind on %u socket: %s", status_broken("Failed to bind on %u socket: %s",
domain, strerror(errno)); domain, strerror(errno));
goto fail; goto fail;
} }
} }
if (listen(fd, 5) != 0) { if (listen(fd, 5) != 0) {
status_trace("Failed to listen on %u socket: %s", status_broken("Failed to listen on %u socket: %s",
domain, strerror(errno)); domain, strerror(errno));
goto fail; goto fail;
} }
return fd; return fd;
@ -1386,7 +1386,8 @@ static struct io_plan *connection_in(struct io_conn *conn, struct daemon *daemon
socklen_t len = sizeof(s); socklen_t len = sizeof(s);
if (getpeername(io_conn_fd(conn), (struct sockaddr *)&s, &len) != 0) { 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); 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)); BUILD_ASSERT(sizeof(s4->sin_addr) <= sizeof(addr.addr));
memcpy(addr.addr, &s4->sin_addr, addr.addrlen); memcpy(addr.addr, &s4->sin_addr, addr.addrlen);
addr.port = ntohs(s4->sin_port); addr.port = ntohs(s4->sin_port);
} else { } else {
status_trace("Unknown socket type %i for incoming conn", status_broken("Unknown socket type %i for incoming conn",
s.ss_family); s.ss_family);
return io_close(conn); return io_close(conn);
} }
@ -1423,7 +1424,7 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
int fd1, fd2; int fd1, fd2;
if (!portnum) { if (!portnum) {
status_trace("Zero portnum, not listening for incoming"); status_info("Zero portnum, not listening for incoming");
return; return;
} }
@ -1444,8 +1445,8 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
len = sizeof(in6); len = sizeof(in6);
if (getsockname(fd1, (void *)&in6, &len) != 0) { if (getsockname(fd1, (void *)&in6, &len) != 0) {
status_trace("Failed get IPv6 sockname: %s", status_broken("Failed get IPv6 sockname: %s",
strerror(errno)); strerror(errno));
close_noerr(fd1); close_noerr(fd1);
fd1 = -1; fd1 = -1;
} else { } else {
@ -1462,8 +1463,8 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
if (fd2 >= 0) { if (fd2 >= 0) {
len = sizeof(addr); len = sizeof(addr);
if (getsockname(fd2, (void *)&addr, &len) != 0) { if (getsockname(fd2, (void *)&addr, &len) != 0) {
status_trace("Failed get IPv4 sockname: %s", status_broken("Failed get IPv4 sockname: %s",
strerror(errno)); strerror(errno));
close_noerr(fd2); close_noerr(fd2);
fd2 = -1; fd2 = -1;
} else { } else {
@ -1568,9 +1569,9 @@ static void connect_failed(struct io_conn *conn, struct reaching *reach)
reach->attempts++; reach->attempts++;
if (reach->attempts >= reach->max_attempts) { if (reach->attempts >= reach->max_attempts) {
status_trace("Failed to connect after %d attempts, giving up " status_info("Failed to connect after %d attempts, giving up "
"after %d seconds", "after %d seconds",
reach->attempts, diff); reach->attempts, diff);
daemon_conn_send( daemon_conn_send(
&reach->daemon->master, &reach->daemon->master,
take(towire_gossip_peer_connection_failed( take(towire_gossip_peer_connection_failed(
@ -1641,9 +1642,8 @@ static void try_connect(struct reaching *reach)
a = find_addrhint(reach->daemon, &reach->id); a = find_addrhint(reach->daemon, &reach->id);
if (!a) { if (!a) {
/* FIXME: now try node table, dns lookups... */ /* FIXME: now try node table, dns lookups... */
/* FIXME: add reach_failed message */ status_info("No address known for %s, giving up",
status_trace("No address known for %s, giving up", type_to_string(trc, struct pubkey, &reach->id));
type_to_string(trc, struct pubkey, &reach->id));
daemon_conn_send( daemon_conn_send(
&reach->daemon->master, &reach->daemon->master,
take(towire_gossip_peer_connection_failed( take(towire_gossip_peer_connection_failed(
@ -1669,10 +1669,10 @@ static void try_connect(struct reaching *reach)
} }
if (fd < 0) { if (fd < 0) {
status_trace("Can't open %i socket for %s (%s), giving up", status_broken("Can't open %i socket for %s (%s), giving up",
a->addr.type, a->addr.type,
type_to_string(trc, struct pubkey, &reach->id), type_to_string(trc, struct pubkey, &reach->id),
strerror(errno)); strerror(errno));
tal_free(reach); tal_free(reach);
return; return;
} }
@ -1812,8 +1812,8 @@ static struct io_plan *handle_disable_channel(struct io_conn *conn,
u64 htlc_minimum_msat; u64 htlc_minimum_msat;
if (!fromwire_gossip_disable_channel(msg, &scid, &direction, &active) ) { if (!fromwire_gossip_disable_channel(msg, &scid, &direction, &active) ) {
status_trace("Unable to parse %s", status_unusual("Unable to parse %s",
gossip_wire_type_name(fromwire_peektype(msg))); gossip_wire_type_name(fromwire_peektype(msg)));
goto fail; goto fail;
} }

12
gossipd/handshake.c

@ -447,7 +447,7 @@ static struct io_plan *act_three_initiator(struct io_conn *conn,
u8 spub[PUBKEY_DER_LEN]; u8 spub[PUBKEY_DER_LEN];
size_t len = sizeof(spub); size_t len = sizeof(spub);
status_trace("Initiator: Act 3"); SUPERVERBOSE("Initiator: Act 3");
/* BOLT #8: /* BOLT #8:
* * `c = encryptWithAD(temp_k2, 1, h, s.pub.serializeCompressed())` * * `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, static struct io_plan *act_two_initiator(struct io_conn *conn,
struct handshake *h) struct handshake *h)
{ {
status_trace("Initiator: Act 2"); SUPERVERBOSE("Initiator: Act 2");
/* BOLT #8: /* BOLT #8:
* *
@ -609,7 +609,7 @@ static struct io_plan *act_one_initiator(struct io_conn *conn,
{ {
size_t len; size_t len;
status_trace("Initiator: Act 1"); SUPERVERBOSE("Initiator: Act 1");
/* BOLT #8: /* 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, static struct io_plan *act_three_responder(struct io_conn *conn,
struct handshake *h) struct handshake *h)
{ {
status_trace("Responder: Act 3"); SUPERVERBOSE("Responder: Act 3");
/* BOLT #8: /* BOLT #8:
* *
@ -786,7 +786,7 @@ static struct io_plan *act_two_responder(struct io_conn *conn,
{ {
size_t len; size_t len;
status_trace("Responder: Act 2"); SUPERVERBOSE("Responder: Act 2");
/* BOLT #8: /* BOLT #8:
* *
@ -946,7 +946,7 @@ static struct io_plan *act_one_responder(struct io_conn *conn,
struct handshake *h) struct handshake *h)
{ {
status_trace("Responder: Act 1"); SUPERVERBOSE("Responder: Act 1");
/* BOLT #8: /* BOLT #8:
* *

53
gossipd/routing.c

@ -414,22 +414,22 @@ find_route(const tal_t *ctx, struct routing_state *rstate,
src = get_node(rstate, to); src = get_node(rstate, to);
if (!src) { if (!src) {
status_trace("find_route: cannot find %s", status_info("find_route: cannot find %s",
type_to_string(trc, struct pubkey, to)); type_to_string(trc, struct pubkey, to));
return NULL; return NULL;
} else if (!dst) { } else if (!dst) {
status_trace("find_route: cannot find myself (%s)", status_info("find_route: cannot find myself (%s)",
type_to_string(trc, struct pubkey, to)); type_to_string(trc, struct pubkey, to));
return NULL; return NULL;
} else if (dst == src) { } else if (dst == src) {
status_trace("find_route: this is %s, refusing to create empty route", status_info("find_route: this is %s, refusing to create empty route",
type_to_string(trc, struct pubkey, to)); type_to_string(trc, struct pubkey, to));
return NULL; return NULL;
} }
if (msatoshi >= MAX_MSATOSHI) { if (msatoshi >= MAX_MSATOSHI) {
status_trace("find_route: can't route huge amount %"PRIu64, status_info("find_route: can't route huge amount %"PRIu64,
msatoshi); msatoshi);
return NULL; return NULL;
} }
@ -1248,10 +1248,9 @@ void routing_failure(struct routing_state *rstate,
node = get_node(rstate, erring_node_pubkey); node = get_node(rstate, erring_node_pubkey);
if (!node) { if (!node) {
status_trace("UNUSUAL routing_failure: " status_unusual("routing_failure: Erring node %s not in map",
"Erring node %s not in map", type_to_string(tmpctx, struct pubkey,
type_to_string(tmpctx, struct pubkey, erring_node_pubkey));
erring_node_pubkey));
/* No node, so no channel, so any channel_update /* No node, so no channel, so any channel_update
* can also be ignored. */ * can also be ignored. */
goto out; goto out;
@ -1294,27 +1293,27 @@ void routing_failure(struct routing_state *rstate,
if (structeq(&erring_node_pubkey->pubkey, if (structeq(&erring_node_pubkey->pubkey,
&rstate->local_id.pubkey)) &rstate->local_id.pubkey))
goto out; goto out;
status_trace("UNUSUAL routing_failure: " status_unusual("routing_failure: "
"UPDATE bit set, no channel_update. " "UPDATE bit set, no channel_update. "
"failcode: 0x%04x", "failcode: 0x%04x",
(int) failcode); (int) failcode);
goto out; goto out;
} }
t = fromwire_peektype(channel_update); t = fromwire_peektype(channel_update);
if (t != WIRE_CHANNEL_UPDATE) { if (t != WIRE_CHANNEL_UPDATE) {
status_trace("UNUSUAL routing_failure: " status_unusual("routing_failure: "
"not a channel_update. " "not a channel_update. "
"type: %d", "type: %d",
(int) t); (int) t);
goto out; goto out;
} }
handle_channel_update(rstate, channel_update); handle_channel_update(rstate, channel_update);
} else { } else {
if (tal_len(channel_update) != 0) if (tal_len(channel_update) != 0)
status_trace("UNUSUAL routing_failure: " status_unusual("routing_failure: "
"UPDATE bit clear, channel_update given. " "UPDATE bit clear, channel_update given. "
"failcode: 0x%04x", "failcode: 0x%04x",
(int) failcode); (int) failcode);
} }
out: out:
@ -1337,9 +1336,9 @@ void mark_channel_unroutable(struct routing_state *rstate,
short_channel_id_to_uint(channel)); short_channel_id_to_uint(channel));
if (!chan) { if (!chan) {
status_trace("UNUSUAL mark_channel_unroutable: " status_unusual("mark_channel_unroutable: "
"channel %s not in routemap", "channel %s not in routemap",
scid); scid);
tal_free(tmpctx); tal_free(tmpctx);
return; return;
} }

Loading…
Cancel
Save