summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2010-04-15 15:44:38 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2010-04-15 15:44:38 +0000
commit337460c2973ec381971487a46578087fa8854dd2 (patch)
treed0b8efe9614f934f9d710021fa031f34d711050b
parent29f905afe10502bc39a5c810da14379fd3813002 (diff)
Log recieved notifications in a human understanable way. Makes debugging
a bit easier. OK michele@
-rw-r--r--usr.sbin/ldpd/ldpd.h3
-rw-r--r--usr.sbin/ldpd/log.c66
-rw-r--r--usr.sbin/ldpd/notification.c11
3 files changed, 77 insertions, 3 deletions
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h
index 354e6bc8a80..9a6d335aead 100644
--- a/usr.sbin/ldpd/ldpd.h
+++ b/usr.sbin/ldpd/ldpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.h,v 1.13 2010/04/15 15:39:32 claudio Exp $ */
+/* $OpenBSD: ldpd.h,v 1.14 2010/04/15 15:44:37 claudio Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -424,6 +424,7 @@ in_addr_t prefixlen2mask(u_int8_t);
const char *nbr_state_name(int);
const char *if_state_name(int);
const char *if_type_name(enum iface_type);
+const char *notification_name(u_int32_t);
/* name2id.c */
u_int16_t rtlabel_name2id(const char *);
diff --git a/usr.sbin/ldpd/log.c b/usr.sbin/ldpd/log.c
index 79980e6470e..02a042af5c4 100644
--- a/usr.sbin/ldpd/log.c
+++ b/usr.sbin/ldpd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.3 2010/04/15 15:39:32 claudio Exp $ */
+/* $OpenBSD: log.c,v 1.4 2010/04/15 15:44:37 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -227,3 +227,67 @@ if_type_name(enum iface_type type)
/* NOTREACHED */
return ("UNKNOWN");
}
+
+const char *
+notification_name(u_int32_t status)
+{
+ static char buf[16];
+
+ switch (status) {
+ case S_SUCCESS:
+ return ("Success");
+ case S_BAD_LDP_ID:
+ return ("Bad LDP Identifier");
+ case S_BAD_PROTO_VER:
+ return ("Bad Protocol Version");
+ case S_BAD_PDU_LEN:
+ return ("Bad PDU Length");
+ case S_UNKNOWN_MSG:
+ return ("Unknown Message Type");
+ case S_BAD_MSG_LEN:
+ return ("Bad Message Length");
+ case S_UNKNOWN_TLV:
+ return ("Unknown TLV");
+ case S_BAD_TLV_LEN:
+ return ("Bad TLV Length");
+ case S_BAD_TLV_VAL:
+ return ("Malformed TLV Value");
+ case S_HOLDTIME_EXP:
+ return ("Hold Timer Expired");
+ case S_SHUTDOWN:
+ return ("Shutdown");
+ case S_LOOP_DETECTED:
+ return ("Loop Detected");
+ case S_UNKNOWN_FEC:
+ return ("Unknown FEC");
+ case S_NO_ROUTE:
+ return ("No Route");
+ case S_NO_LABEL_RES:
+ return ("No Label Resources");
+ case S_AVAILABLE:
+ return ("Label Resources Available");
+ case S_NO_HELLO:
+ return ("Session Rejected, No Hello");
+ case S_PARM_ADV_MODE:
+ return ("Rejected Advertisement Mode Parameter");
+ case S_MAX_PDU_LEN:
+ return ("Rejected Max PDU Length Parameter");
+ case S_PARM_L_RANGE:
+ return ("Rejected Label Range Parameter");
+ case S_KEEPALIVE_TMR:
+ return ("KeepAlive Timer Expired");
+ case S_LAB_REQ_ABRT:
+ return ("Label Request Aborted");
+ case S_MISS_MSG:
+ return ("Missing Message Parameters");
+ case S_UNSUP_ADDR:
+ return ("Unsupported Address Family");
+ case S_KEEPALIVE_BAD:
+ return ("Bad KeepAlive Time");
+ case S_INTERN_ERR:
+ return ("Internal Error");
+ default:
+ snprintf(buf, sizeof(buf), "[%08x]", status);
+ return (buf);
+ }
+}
diff --git a/usr.sbin/ldpd/notification.c b/usr.sbin/ldpd/notification.c
index 2df927dd89a..8b1c1edba94 100644
--- a/usr.sbin/ldpd/notification.c
+++ b/usr.sbin/ldpd/notification.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: notification.c,v 1.3 2010/02/20 21:28:39 michele Exp $ */
+/* $OpenBSD: notification.c,v 1.4 2010/04/15 15:44:37 claudio Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -103,6 +103,15 @@ recv_notification(struct nbr *nbr, char *buf, u_int16_t len)
return (-1);
}
+ if (st->status_code & htonl(STATUS_FATAL))
+ log_warnx("recieved notification from neighbor %s: %s",
+ inet_ntoa(nbr->id),
+ notification_name(ntohl(st->status_code)));
+ else
+ log_debug("recieved notification from neighbor %s: %s",
+ inet_ntoa(nbr->id),
+ notification_name(ntohl(st->status_code)));
+
if (st->status_code & htonl(STATUS_FATAL)) {
nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION);
return (-1);