diff options
| author | 2009-08-02 16:19:17 +0000 | |
|---|---|---|
| committer | 2009-08-02 16:19:17 +0000 | |
| commit | fe033e8fee68f6e9e59ffeb701d77bc55910746b (patch) | |
| tree | 1e93124cad9b5e27e2555203068f72e9cda7505d /usr.sbin/ldpctl/ldpctl.c | |
| parent | Never return nonzero in a device activate method invoked with DVACT_ACTIVATE, (diff) | |
| download | wireguard-openbsd-fe033e8fee68f6e9e59ffeb701d77bc55910746b.tar.xz wireguard-openbsd-fe033e8fee68f6e9e59ffeb701d77bc55910746b.zip | |
"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@
Diffstat (limited to 'usr.sbin/ldpctl/ldpctl.c')
| -rw-r--r-- | usr.sbin/ldpctl/ldpctl.c | 17 |
1 files changed, 13 insertions, 4 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; |
