summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospfd
diff options
context:
space:
mode:
authorremi <remi@openbsd.org>2019-07-15 18:26:39 +0000
committerremi <remi@openbsd.org>2019-07-15 18:26:39 +0000
commit25a742ccbe26a14d7558f31cb545061d6cb1ea1f (patch)
treed726e3e9eaa9a0a217cbe422ebdb71fe6e516d7f /usr.sbin/ospfd
parentMake layout_fix_offsets take a window like layout_fix_panes. (diff)
downloadwireguard-openbsd-25a742ccbe26a14d7558f31cb545061d6cb1ea1f.tar.xz
wireguard-openbsd-25a742ccbe26a14d7558f31cb545061d6cb1ea1f.zip
Improve logging when sending a packet fails.
OK claudio@
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r--usr.sbin/ospfd/database.c15
-rw-r--r--usr.sbin/ospfd/hello.c11
-rw-r--r--usr.sbin/ospfd/lsack.c10
-rw-r--r--usr.sbin/ospfd/lsreq.c10
-rw-r--r--usr.sbin/ospfd/lsupdate.c10
-rw-r--r--usr.sbin/ospfd/packet.c6
6 files changed, 32 insertions, 30 deletions
diff --git a/usr.sbin/ospfd/database.c b/usr.sbin/ospfd/database.c
index 39b7ceb94af..aaf1bb3c1a3 100644
--- a/usr.sbin/ospfd/database.c
+++ b/usr.sbin/ospfd/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.33 2016/02/18 15:33:24 bluhm Exp $ */
+/* $OpenBSD: database.c,v 1.34 2019/07/15 18:26:39 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -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 ip))) == NULL)
@@ -66,8 +65,7 @@ send_db_description(struct nbr *nbr)
log_debug("send_db_description: neighbor ID %s: "
"cannot send packet in state %s", inet_ntoa(nbr->id),
nbr_state_name(nbr->state));
- ret = -1;
- goto done;
+ goto fail;
case NBR_STA_XSTRT:
bits |= OSPF_DBD_MS | OSPF_DBD_M | OSPF_DBD_I;
nbr->dd_more = 1;
@@ -150,12 +148,13 @@ 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");
+ log_warn("%s", __func__);
ibuf_free(buf);
return (-1);
}
diff --git a/usr.sbin/ospfd/hello.c b/usr.sbin/ospfd/hello.c
index 59dc14b746b..12339ad0cf0 100644
--- a/usr.sbin/ospfd/hello.c
+++ b/usr.sbin/ospfd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.22 2018/02/22 07:42:38 claudio Exp $ */
+/* $OpenBSD: hello.c,v 1.23 2019/07/15 18:26:39 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -41,7 +41,6 @@ send_hello(struct iface *iface)
struct hello_hdr hello;
struct nbr *nbr;
struct ibuf *buf;
- int ret;
dst.sin_family = AF_INET;
dst.sin_len = sizeof(struct sockaddr_in);
@@ -103,11 +102,13 @@ send_hello(struct iface *iface)
if (auth_gen(buf, iface))
goto fail;
- ret = send_packet(iface, buf, &dst);
+ if (send_packet(iface, buf, &dst) == -1)
+ goto fail;
+
ibuf_free(buf);
- return (ret);
+ return (0);
fail:
- log_warn("send_hello");
+ log_warn("%s", __func__);
ibuf_free(buf);
return (-1);
}
diff --git a/usr.sbin/ospfd/lsack.c b/usr.sbin/ospfd/lsack.c
index 5eed80c4b7f..ca2a7f6a140 100644
--- a/usr.sbin/ospfd/lsack.c
+++ b/usr.sbin/ospfd/lsack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsack.c,v 1.21 2014/10/25 03:23:49 lteo Exp $ */
+/* $OpenBSD: lsack.c,v 1.22 2019/07/15 18:26:39 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -59,7 +59,6 @@ int
send_ls_ack(struct iface *iface, struct in_addr addr, struct ibuf *buf)
{
struct sockaddr_in dst;
- int ret;
/* update authentication and calculate checksum */
if (auth_gen(buf, iface)) {
@@ -71,8 +70,11 @@ send_ls_ack(struct iface *iface, struct in_addr addr, struct ibuf *buf)
dst.sin_len = sizeof(struct sockaddr_in);
dst.sin_addr.s_addr = addr.s_addr;
- ret = send_packet(iface, buf, &dst);
- return (ret);
+ if (send_packet(iface, buf, &dst) == -1) {
+ log_warn("%s", __func__);
+ return (-1);
+ }
+ return (0);
}
int
diff --git a/usr.sbin/ospfd/lsreq.c b/usr.sbin/ospfd/lsreq.c
index fa5569c949c..ea52670a31b 100644
--- a/usr.sbin/ospfd/lsreq.c
+++ b/usr.sbin/ospfd/lsreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsreq.c,v 1.20 2013/01/17 09:02:22 markus Exp $ */
+/* $OpenBSD: lsreq.c,v 1.21 2019/07/15 18:26:39 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -37,7 +37,6 @@ send_ls_req(struct nbr *nbr)
struct ls_req_hdr ls_req_hdr;
struct lsa_entry *le, *nle;
struct ibuf *buf;
- int ret;
if ((buf = ibuf_open(nbr->iface->mtu - sizeof(struct ip))) == NULL)
fatal("send_ls_req");
@@ -80,12 +79,13 @@ send_ls_req(struct nbr *nbr)
if (auth_gen(buf, nbr->iface))
goto fail;
- ret = send_packet(nbr->iface, buf, &dst);
+ if (send_packet(nbr->iface, buf, &dst) == -1)
+ goto fail;
ibuf_free(buf);
- return (ret);
+ return (0);
fail:
- log_warn("send_ls_req");
+ log_warn("%s", __func__);
ibuf_free(buf);
return (-1);
}
diff --git a/usr.sbin/ospfd/lsupdate.c b/usr.sbin/ospfd/lsupdate.c
index 4bec1abad83..2bd4e60ce01 100644
--- a/usr.sbin/ospfd/lsupdate.c
+++ b/usr.sbin/ospfd/lsupdate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsupdate.c,v 1.45 2016/12/26 17:38:14 jca Exp $ */
+/* $OpenBSD: lsupdate.c,v 1.46 2019/07/15 18:26:39 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -210,7 +210,6 @@ send_ls_update(struct ibuf *buf, struct iface *iface, struct in_addr addr,
u_int32_t nlsa)
{
struct sockaddr_in dst;
- int ret;
nlsa = htonl(nlsa);
memcpy(ibuf_seek(buf, sizeof(struct ospf_hdr), sizeof(nlsa)),
@@ -224,12 +223,13 @@ send_ls_update(struct ibuf *buf, struct iface *iface, struct in_addr addr,
dst.sin_len = sizeof(struct sockaddr_in);
dst.sin_addr.s_addr = addr.s_addr;
- ret = send_packet(iface, buf, &dst);
+ if (send_packet(iface, buf, &dst) == -1)
+ goto fail;
ibuf_free(buf);
- return (ret);
+ return (0);
fail:
- log_warn("send_ls_update");
+ log_warn("%s", __func__);
ibuf_free(buf);
return (-1);
}
diff --git a/usr.sbin/ospfd/packet.c b/usr.sbin/ospfd/packet.c
index cf4352bb62d..4a8c64210f0 100644
--- a/usr.sbin/ospfd/packet.c
+++ b/usr.sbin/ospfd/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.31 2014/10/25 03:23:49 lteo Exp $ */
+/* $OpenBSD: packet.c,v 1.32 2019/07/15 18:26:39 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -96,8 +96,8 @@ send_packet(struct iface *iface, struct ibuf *buf, struct sockaddr_in *dst)
return (-1);
if (sendmsg(iface->fd, &msg, 0) == -1) {
- log_warn("send_packet: error sending packet on interface %s",
- iface->name);
+ log_warn("%s: error sending packet to %s on interface %s",
+ __func__, inet_ntoa(ip_hdr.ip_dst), iface->name);
return (-1);
}