summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Marchetto <michele@cvs.openbsd.org>2009-08-02 16:19:18 +0000
committerMichele Marchetto <michele@cvs.openbsd.org>2009-08-02 16:19:18 +0000
commitd39d8390343be0240365f612fe409018c18f13d5 (patch)
treeff1fa2b53ec6933319ba077ca0273e368f18218f
parentce067087ed3da82f031e1e2c4a115f2fa3e1a016 (diff)
"ldpctl show lib" output cleanup.
- Show only the remote/local labels of the prefixes currently present in fib. - Write a "-" instead of "0" when a remote label is not present (the prefix is directly connected). It avoids confusion with explicit null label. ok claudio@
-rw-r--r--usr.sbin/ldpctl/ldpctl.c17
-rw-r--r--usr.sbin/ldpd/lde_lib.c10
-rw-r--r--usr.sbin/ldpd/ldpd.h7
3 files changed, 26 insertions, 8 deletions
diff --git a/usr.sbin/ldpctl/ldpctl.c b/usr.sbin/ldpctl/ldpctl.c
index cc49650131e..205da0ac94b 100644
--- a/usr.sbin/ldpctl/ldpctl.c
+++ b/usr.sbin/ldpctl/ldpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpctl.c,v 1.3 2009/08/01 12:47:02 michele Exp $
+/* $OpenBSD: ldpctl.c,v 1.4 2009/08/02 16:19:17 michele Exp $
*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -308,7 +308,7 @@ int
show_lib_msg(struct imsg *imsg)
{
struct ctl_rt *rt;
- char *dstnet;
+ char *dstnet, *remote;
switch (imsg->hdr.type) {
case IMSG_CTL_SHOW_LIB:
@@ -317,10 +317,19 @@ show_lib_msg(struct imsg *imsg)
rt->prefixlen) == -1)
err(1, NULL);
- printf("%-20s %-17s %-17u %u\n", dstnet,
+ if (rt->connected) {
+ if (asprintf(&remote, "-") == -1)
+ err(1, NULL);
+ } else {
+ if (asprintf(&remote, "%u", (ntohl(rt->remote_label) >> MPLS_LABEL_OFFSET)) == -1)
+ err(1, NULL);
+ }
+
+ printf("%-20s %-17s %-17u %s\n", dstnet,
inet_ntoa(rt->nexthop),
(ntohl(rt->local_label) >> MPLS_LABEL_OFFSET),
- (ntohl(rt->remote_label) >> MPLS_LABEL_OFFSET));
+ remote);
+ free(remote);
free(dstnet);
break;
diff --git a/usr.sbin/ldpd/lde_lib.c b/usr.sbin/ldpd/lde_lib.c
index a6a71d53614..cb9bfaf0d93 100644
--- a/usr.sbin/ldpd/lde_lib.c
+++ b/usr.sbin/ldpd/lde_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde_lib.c,v 1.4 2009/07/08 18:59:29 michele Exp $ */
+/* $OpenBSD: lde_lib.c,v 1.5 2009/08/02 16:19:17 michele Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -111,6 +111,9 @@ rt_dump(pid_t pid)
static struct ctl_rt rtctl;
RB_FOREACH(r, rt_tree, &rt) {
+ if (!r->present)
+ continue;
+
rtctl.prefix.s_addr = r->prefix.s_addr;
rtctl.prefixlen = r->prefixlen;
rtctl.nexthop.s_addr = r->nexthop.s_addr;
@@ -118,6 +121,11 @@ rt_dump(pid_t pid)
rtctl.local_label = r->local_label;
rtctl.remote_label = r->remote_label;
+ if (rtctl.nexthop.s_addr == htonl(INADDR_LOOPBACK))
+ rtctl.connected = 1;
+ else
+ rtctl.connected = 0;
+
lde_imsg_compose_ldpe(IMSG_CTL_SHOW_LIB, 0, pid, &rtctl,
sizeof(rtctl));
}
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h
index 8ddd2406bc7..a11a559e420 100644
--- a/usr.sbin/ldpd/ldpd.h
+++ b/usr.sbin/ldpd/ldpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.h,v 1.5 2009/07/13 19:04:26 michele Exp $ */
+/* $OpenBSD: ldpd.h,v 1.6 2009/08/02 16:19:17 michele Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -359,10 +359,11 @@ struct ctl_rt {
struct in_addr lspace;
struct in_addr adv_rtr;
time_t uptime;
- u_int8_t flags;
- u_int8_t prefixlen;
u_int32_t local_label;
u_int32_t remote_label;
+ u_int8_t flags;
+ u_int8_t prefixlen;
+ u_int8_t connected;
};
struct ctl_sum {