diff options
author | Esben Norby <norby@cvs.openbsd.org> | 2006-02-19 21:48:57 +0000 |
---|---|---|
committer | Esben Norby <norby@cvs.openbsd.org> | 2006-02-19 21:48:57 +0000 |
commit | 3a61b876ed54ba4e1ce03ecea21b28c40c4dce23 (patch) | |
tree | ae1caaefece4e0eaf1b6e67f0189d73cd221369a | |
parent | acd11f0a841e26b98d96e0d4bf0c332918a4c61f (diff) |
Keep track of the duration of our relationships with neighbors.
Displayed in "ospfctl show neighbor".
ok claudio@
-rw-r--r-- | usr.sbin/ospfctl/ospfctl.c | 35 | ||||
-rw-r--r-- | usr.sbin/ospfd/neighbor.c | 11 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfe.h | 3 |
4 files changed, 32 insertions, 20 deletions
diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c index 4406f36c984..e7fbc7b827c 100644 --- a/usr.sbin/ospfctl/ospfctl.c +++ b/usr.sbin/ospfctl/ospfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfctl.c,v 1.23 2006/02/10 18:31:49 claudio Exp $ */ +/* $OpenBSD: ospfctl.c,v 1.24 2006/02/19 21:48:56 norby Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -135,8 +135,8 @@ main(int argc, char *argv[]) &ifidx, sizeof(ifidx)); break; case SHOW_NBR: - printf("%-15s %-3s %-17s %-9s %-15s %s\n", "ID", "Pri", - "State", "DeadTime", "Address", "Interface"); + printf("%-15s %-3s %-12s %-8s %-15s %-9s %s\n", "ID", "Pri", + "State", "DeadTime", "Address", "Iface","Uptime"); case SHOW_NBR_DTAIL: imsg_compose(ibuf, IMSG_CTL_SHOW_NBR, 0, 0, NULL, 0); break; @@ -353,7 +353,7 @@ show_interface_msg(struct imsg *imsg) case AUTH_CRYPT: printf(" Message digest authentication " "enabled\n"); - printf(" Primary key id is %d\n", + printf(" Primary key id is %d\n", iface->auth_keyid); break; default: @@ -397,19 +397,19 @@ print_if_state(int state) case IF_STA_DOWN: return ("DOWN"); case IF_STA_LOOPBACK: - return ("LOOPBACK"); + return ("LOOP"); case IF_STA_WAITING: - return ("WAITING"); + return ("WAIT"); case IF_STA_POINTTOPOINT: return ("P2P"); case IF_STA_DROTHER: - return ("DROTHER"); + return ("OTHER"); case IF_STA_BACKUP: - return ("BACKUP"); + return ("BCKUP"); case IF_STA_DR: return ("DR"); default: - return ("UNKNOWN"); + return ("UNKNW"); } } @@ -420,23 +420,23 @@ print_nbr_state(int state) case NBR_STA_DOWN: return ("DOWN"); case NBR_STA_ATTEMPT: - return ("ATTEMPT"); + return ("ATTMP"); case NBR_STA_INIT: return ("INIT"); case NBR_STA_2_WAY: return ("2-WAY"); case NBR_STA_XSTRT: - return ("EXSTART"); + return ("EXSTA"); case NBR_STA_SNAP: - return ("SNAPSHOT"); + return ("SNAP"); case NBR_STA_XCHNG: - return ("EXCHANGE"); + return ("EXCHG"); case NBR_STA_LOAD: - return ("LOADING"); + return ("LOAD"); case NBR_STA_FULL: return ("FULL"); default: - return ("UNKNOWN"); + return ("UNKNW"); } } @@ -842,9 +842,10 @@ show_nbr_msg(struct imsg *imsg) if (asprintf(&state, "%s/%s", print_nbr_state(nbr->nbr_state), print_if_state(nbr->iface_state)) == -1) err(1, NULL); - printf("%-15s %-3d %-17s %-9s ", inet_ntoa(nbr->id), + printf("%-15s %-3d %-12s %-9s", inet_ntoa(nbr->id), nbr->priority, state, fmt_timeframe_core(nbr->dead_timer)); - printf("%-15s %s\n", inet_ntoa(nbr->addr), nbr->name); + printf("%-15s %-9s %s\n", inet_ntoa(nbr->addr), nbr->name, + nbr->uptime == 0 ? "-" : fmt_timeframe_core(nbr->uptime)); free(state); break; case IMSG_CTL_END: diff --git a/usr.sbin/ospfd/neighbor.c b/usr.sbin/ospfd/neighbor.c index da9755dcea4..b703e7da138 100644 --- a/usr.sbin/ospfd/neighbor.c +++ b/usr.sbin/ospfd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.29 2006/02/19 19:23:17 norby Exp $ */ +/* $OpenBSD: neighbor.c,v 1.30 2006/02/19 21:48:56 norby Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -117,6 +117,7 @@ const char * const nbr_action_names[] = { int nbr_fsm(struct nbr *nbr, enum nbr_event event) { + struct timeval now; int old_state; int new_state = 0; int i, ret = 0; @@ -206,6 +207,9 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event) orig_rtr_lsa(nbr->iface->area); if (nbr->iface->state & IF_STA_DR) orig_net_lsa(nbr->iface); + + gettimeofday(&now, NULL); + nbr->uptime = now.tv_sec; } /* bidirectional communication lost */ @@ -685,6 +689,11 @@ nbr_to_ctl(struct nbr *nbr) } else nctl.dead_timer = 0; + if (nbr->state == NBR_STA_FULL) { + nctl.uptime = now.tv_sec - nbr->uptime; + } else + nctl.uptime = 0; + return (&nctl); } diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 869042bfff7..f5ba8cac402 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.44 2006/02/10 18:30:47 claudio Exp $ */ +/* $OpenBSD: ospfd.h,v 1.45 2006/02/19 21:48:56 norby Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -416,6 +416,7 @@ struct ctl_nbr { struct in_addr bdr; struct in_addr area; time_t dead_timer; + time_t uptime; u_int32_t db_sum_lst_cnt; u_int32_t ls_req_lst_cnt; u_int32_t ls_retrans_lst_cnt; diff --git a/usr.sbin/ospfd/ospfe.h b/usr.sbin/ospfd/ospfe.h index 7e21d84a4e7..e874edda521 100644 --- a/usr.sbin/ospfd/ospfe.h +++ b/usr.sbin/ospfd/ospfe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.h,v 1.23 2006/02/19 18:55:47 norby Exp $ */ +/* $OpenBSD: ospfe.h,v 1.24 2006/02/19 21:48:56 norby Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -136,6 +136,7 @@ struct nbr { u_int32_t ls_ret_cnt; u_int32_t crypt_seq_num; + time_t uptime; int state; u_int8_t priority; u_int8_t options; |