This is mostly log messages sync.
Index: database.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/database.c,v
retrieving revision 1.18
diff -u -p -r1.18 database.c
--- database.c 23 Dec 2019 07:33:49 -0000 1.18
+++ database.c 2 Jan 2020 14:31:46 -0000
@@ -43,7 +43,6 @@ send_db_description(struct nbr *nbr)
struct db_dscrp_hdr dd_hdr;
struct lsa_entry *le, *nle;
struct ibuf *buf;
- int ret = 0;
u_int8_t bits = 0;
if ((buf = ibuf_open(nbr->iface->mtu - sizeof(struct ip6_hdr))) == NULL)
@@ -63,11 +62,10 @@ send_db_description(struct nbr *nbr)
case NBR_STA_INIT:
case NBR_STA_2_WAY:
case NBR_STA_SNAP:
- log_debug("send_db_description: cannot send packet in state %s,"
- " neighbor ID %s", nbr_state_name(nbr->state),
- inet_ntoa(nbr->id));
- ret = -1;
- goto done;
+ log_debug("send_db_description: neighbor ID %s: "
+ "cannot send packet in state %s", inet_ntoa(nbr->id),
+ nbr_state_name(nbr->state));
+ goto fail;
case NBR_STA_XSTRT:
bits |= OSPF_DBD_MS | OSPF_DBD_M | OSPF_DBD_I;
nbr->dd_more = 1;
@@ -90,7 +88,7 @@ send_db_description(struct nbr *nbr)
/* build LSA list */
for (le = TAILQ_FIRST(&nbr->db_sum_list); le != NULL &&
- buf->wpos + sizeof(struct lsa_hdr) < buf->max; le = nle) {
+ ibuf_left(buf) >= sizeof(struct lsa_hdr); le = nle) {
nbr->dd_end = nle = TAILQ_NEXT(le, entry);
if (ibuf_add(buf, le->le_lsa, sizeof(struct lsa_hdr)))
goto fail;
@@ -146,10 +144,11 @@ send_db_description(struct nbr *nbr)
goto fail;
/* transmit packet */
- ret = send_packet(nbr->iface, buf, &dst);
-done:
+ if (send_packet(nbr->iface, buf, &dst) == -1)
+ goto fail;
+
ibuf_free(buf);
- return (ret);
+ return (0);
fail:
log_warn("send_db_description");
ibuf_free(buf);
@@ -163,8 +162,8 @@ recv_db_description(struct nbr *nbr, cha
int dupe = 0;
if (len < sizeof(dd_hdr)) {
- log_warnx("recv_db_description: "
- "bad packet size, neighbor ID %s", inet_ntoa(nbr->id));
+ log_warnx("recv_db_description: neighbor ID %s: "
+ "bad packet size", inet_ntoa(nbr->id));
return;
}
memcpy(&dd_hdr, buf, sizeof(dd_hdr));
@@ -173,9 +172,9 @@ recv_db_description(struct nbr *nbr, cha
/* db description packet sanity checks */
if (ntohs(dd_hdr.iface_mtu) > nbr->iface->mtu) {
- log_warnx("recv_db_description: invalid MTU %d sent by "
- "neighbor ID %s, expected %d", ntohs(dd_hdr.iface_mtu),
- inet_ntoa(nbr->id), nbr->iface->mtu);
+ log_warnx("recv_db_description: neighbor ID %s: "
+ "invalid MTU %d expected %d", inet_ntoa(nbr->id),
+ ntohs(dd_hdr.iface_mtu), nbr->iface->mtu);
return;
}
@@ -183,7 +182,7 @@ recv_db_description(struct nbr *nbr, cha
nbr->last_rx_bits == dd_hdr.bits &&
ntohl(dd_hdr.dd_seq_num) == nbr->dd_seq_num - nbr->dd_master ?
1 : 0) {
- log_debug("recv_db_description: dupe from ID %s",
+ log_debug("recv_db_description: dupe from neighbor ID %s",
inet_ntoa(nbr->id));
dupe = 1;
}
@@ -193,9 +192,9 @@ recv_db_description(struct nbr *nbr, cha
case NBR_STA_ATTEMPT:
case NBR_STA_2_WAY:
case NBR_STA_SNAP:
- log_debug("recv_db_description: packet ignored in state %s, "
- "neighbor ID %s", nbr_state_name(nbr->state),
- inet_ntoa(nbr->id));
+ log_debug("recv_db_description: neighbor ID %s: "
+ "packet ignored in state %s", inet_ntoa(nbr->id),
+ nbr_state_name(nbr->state));
return;
case NBR_STA_INIT:
/* evaluate dr and bdr after issuing a 2-Way event */
@@ -224,9 +223,11 @@ recv_db_description(struct nbr *nbr, cha
} else if (!(dd_hdr.bits & (OSPF_DBD_I | OSPF_DBD_MS))) {
/* M only case: we are master */
if (ntohl(dd_hdr.dd_seq_num) != nbr->dd_seq_num) {
- log_warnx("recv_db_description: invalid "
- "seq num, mine %x his %x",
- nbr->dd_seq_num, ntohl(dd_hdr.dd_seq_num));
+ log_warnx("recv_db_description: "
+ "neighbor ID %s: "
+ "invalid seq num, mine %x his %x",
+ inet_ntoa(nbr->id), nbr->dd_seq_num,
+ ntohl(dd_hdr.dd_seq_num));
return;
}
nbr->dd_seq_num++;
@@ -242,9 +243,9 @@ recv_db_description(struct nbr *nbr, cha
}
} else {
/* ignore packet */
- log_debug("recv_db_description: packet ignored in "
- "state %s (bad flags), neighbor ID %s",
- nbr_state_name(nbr->state), inet_ntoa(nbr->id));
+ log_debug("recv_db_description: neighbor ID %s: "
+ "packet ignored in state %s (bad flags)",
+ inet_ntoa(nbr->id), nbr_state_name(nbr->state));
}
break;
case NBR_STA_XCHNG:
@@ -252,15 +253,16 @@ recv_db_description(struct nbr *nbr, cha
case NBR_STA_FULL:
if (dd_hdr.bits & OSPF_DBD_I ||
!(dd_hdr.bits & OSPF_DBD_MS) == !nbr->dd_master) {
- log_warnx("recv_db_description: seq num mismatch, "
- "bad flags");
+ log_warnx("recv_db_description: neighbor ID %s: "
+ "seq num mismatch, bad flags", inet_ntoa(nbr->id));
nbr_fsm(nbr, NBR_EVT_SEQ_NUM_MIS);
return;
}
if (nbr->last_rx_options != dd_hdr.opts) {
- log_warnx("recv_db_description: seq num mismatch, "
- "bad options");
+ log_warnx("recv_db_description: neighbor ID %s: "
+ "seq num mismatch, bad options",
+ inet_ntoa(nbr->id));
nbr_fsm(nbr, NBR_EVT_SEQ_NUM_MIS);
return;
}
@@ -273,9 +275,10 @@ recv_db_description(struct nbr *nbr, cha
}
if (nbr->state != NBR_STA_XCHNG) {
- log_warnx("recv_db_description: invalid "
- "seq num, mine %x his %x",
- nbr->dd_seq_num, ntohl(dd_hdr.dd_seq_num));
+ log_warnx("recv_db_description: neighbor ID %s: "
+ "invalid seq num, mine %x his %x",
+ inet_ntoa(nbr->id), nbr->dd_seq_num,
+ ntohl(dd_hdr.dd_seq_num));
nbr_fsm(nbr, NBR_EVT_SEQ_NUM_MIS);
return;
}
@@ -284,9 +287,11 @@ recv_db_description(struct nbr *nbr, cha
if (nbr->dd_master) {
/* master */
if (ntohl(dd_hdr.dd_seq_num) != nbr->dd_seq_num) {
- log_warnx("recv_db_description: invalid "
- "seq num, mine %x his %x",
- nbr->dd_seq_num, ntohl(dd_hdr.dd_seq_num));
+ log_warnx("recv_db_description: "
+ "neighbor ID %s: "
+ "invalid seq num, mine %x his %x, master",
+ inet_ntoa(nbr->id), nbr->dd_seq_num,
+ ntohl(dd_hdr.dd_seq_num));
nbr_fsm(nbr, NBR_EVT_SEQ_NUM_MIS);
return;
}
@@ -294,9 +299,11 @@ recv_db_description(struct nbr *nbr, cha
} else {
/* slave */
if (ntohl(dd_hdr.dd_seq_num) != nbr->dd_seq_num + 1) {
- log_warnx("recv_db_description: invalid "
- "seq num, mine %x his %x",
- nbr->dd_seq_num, ntohl(dd_hdr.dd_seq_num));
+ log_warnx("recv_db_description: "
+ "neighbor ID %s: "
+ "invalid seq num, mine %x his %x, slave",
+ inet_ntoa(nbr->id), nbr->dd_seq_num,
+ ntohl(dd_hdr.dd_seq_num));
nbr_fsm(nbr, NBR_EVT_SEQ_NUM_MIS);
return;
}
@@ -380,8 +387,8 @@ db_tx_timer(int fd, short event, void *a
send_db_description(nbr);
break;
default:
- log_debug("db_tx_timer: unknown neighbor state, "
- "neighbor ID %s", inet_ntoa(nbr->id));
+ log_debug("db_tx_timer: neighbor ID %s: unknown neighbor state",
+ inet_ntoa(nbr->id));
break;
}