summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2005-03-28 14:19:57 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2005-03-28 14:19:57 +0000
commite864e49b4a8543559ea54df2ac83056f13874a76 (patch)
treefb47526c8c5fea6f092d1200ede60aaa9833c79e
parent78d9ea970f23689c30229e5d5ee515d9fef1ef71 (diff)
better diagnostics on bind() failure
-rw-r--r--usr.sbin/bgpd/config.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/config.c b/usr.sbin/bgpd/config.c
index 31f72ff775e..9facf8734a0 100644
--- a/usr.sbin/bgpd/config.c
+++ b/usr.sbin/bgpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.43 2005/03/26 23:04:34 claudio Exp $ */
+/* $OpenBSD: config.c,v 1.44 2005/03/28 14:19:56 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -255,8 +255,24 @@ prepare_listeners(struct bgpd_config *conf)
if (bind(la->fd, (struct sockaddr *)&la->sa, la->sa.ss_len) ==
-1) {
- log_warn("cannot bind to %s",
- log_sockaddr((struct sockaddr *)&la->sa));
+ switch (la->sa.ss_family) {
+ case AF_INET:
+ log_warn("cannot bind to %s:%u",
+ log_sockaddr((struct sockaddr *)&la->sa),
+ ntohs(((struct sockaddr_in *)
+ &la->sa)->sin_port));
+ break;
+ case AF_INET6:
+ log_warn("cannot bind to [%s]:%u",
+ log_sockaddr((struct sockaddr *)&la->sa),
+ ntohs(((struct sockaddr_in6 *)
+ &la->sa)->sin6_port));
+ break;
+ default:
+ log_warn("cannot bind to %s",
+ log_sockaddr((struct sockaddr *)&la->sa));
+ break;
+ }
close(la->fd);
TAILQ_REMOVE(conf->listen_addrs, la, entry);
free(la);