summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2006-08-23 08:21:12 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2006-08-23 08:21:12 +0000
commit49b966edc408a9e70c5970d393159ca8c03ebe1c (patch)
tree88d9c296848c5c4ebaec393f42479b69a7b431e2
parentae64b77bf4c8892086dffe7f47515b2fd04d0f1d (diff)
Extend show rib command. Following new options are added:
in: show the unfiltered input of a neighbor aka adj-rib-in out: show only the prefixes that are sent to a specified neighbor (adj-rib-out) neighbor <IP>: limit the output of the command to prefixes sent by the specified neighbor OK henning@ manpage with help by jmc@ but the show rib section needs some rework because it starts to be confusing. Actually the parser needs to get smarter.
-rw-r--r--usr.sbin/bgpctl/bgpctl.832
-rw-r--r--usr.sbin/bgpctl/bgpctl.c8
-rw-r--r--usr.sbin/bgpctl/parser.c36
-rw-r--r--usr.sbin/bgpctl/parser.h3
4 files changed, 59 insertions, 20 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.8 b/usr.sbin/bgpctl/bgpctl.8
index 67255919e41..06bae7c4991 100644
--- a/usr.sbin/bgpctl/bgpctl.8
+++ b/usr.sbin/bgpctl/bgpctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: bgpctl.8,v 1.34 2006/05/26 05:07:15 henning Exp $
+.\" $OpenBSD: bgpctl.8,v 1.35 2006/08/23 08:21:11 claudio Exp $
.\"
.\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
.\"
@@ -132,7 +132,7 @@ Show the BGP timers.
Show the list of BGP nexthops and the result of their validity check.
.It Xo
.Cm show rib
-.Op Ar detail
+.Op Ar options
.Ar filter
.Xc
Show routes from the
@@ -166,25 +166,41 @@ Show all entries with
anywhere but rightmost.
.It Cm empty-as
Show all entries that are internal routes with no AS's in the AS path.
+.It Cm neighbor Ar peer
+Show only entries from the specified peer.
.It Cm summary
This is the same as the
.Ic show summary
command.
.It Cm memory
Show RIB memory statistics.
+.El
+.Pp
+Additionally, the following
+.Ar options
+are defined:
+.Pp
+.Bl -tag -width "detail" -compact
+.It Cm detail
+Show more detailed output for matched routes.
.It Ar family
Limit the output to the given address family.
+.It Cm in
+Show routes from the unfiltered Adj-RIB-In.
+This is only possible if
+.Em softreconfig in
+is enabled for the neighbor.
+.It Cm out
+Show the filtered routes sent to a neighbor also known as Adj-RIB-Out.
.El
.Pp
-If
-.Ar detail
-is specified, a more detailed output of the routes matched by
-.Ar filter
-will be shown.
-It is silently ignored when used together with
+Options are silently ignored when used together with
.Ar summary
or
.Ar memory .
+Multiple options can be used at the same time and the
+.Ar neighbor
+filter can be combined with other filters.
.It Cm show summary
Show a list of all neighbors, including information about the session state
and message counters.
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c
index d4e68070db8..0a9bbe30946 100644
--- a/usr.sbin/bgpctl/bgpctl.c
+++ b/usr.sbin/bgpctl/bgpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpctl.c,v 1.108 2006/07/25 09:38:05 henning Exp $ */
+/* $OpenBSD: bgpctl.c,v 1.109 2006/08/23 08:21:11 claudio Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -126,7 +126,7 @@ main(int argc, char *argv[])
if ((res = parse(argc, argv)) == NULL)
exit(1);
- memcpy(&neighbor.addr, &res->addr, sizeof(neighbor.addr));
+ memcpy(&neighbor.addr, &res->peeraddr, sizeof(neighbor.addr));
strlcpy(neighbor.descr, res->peerdesc, sizeof(neighbor.descr));
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
@@ -185,7 +185,7 @@ main(int argc, char *argv[])
break;
case SHOW_NEIGHBOR:
case SHOW_NEIGHBOR_TIMERS:
- if (res->addr.af || res->peerdesc[0])
+ if (res->peeraddr.af || res->peerdesc[0])
imsg_compose(ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1,
&neighbor, sizeof(neighbor));
else
@@ -204,6 +204,8 @@ main(int argc, char *argv[])
ribreq.prefixlen = res->prefixlen;
type = IMSG_CTL_SHOW_RIB_PREFIX;
}
+ memcpy(&ribreq.neighbor, &neighbor,
+ sizeof(ribreq.neighbor));
ribreq.af = res->af;
ribreq.flags = res->flags;
imsg_compose(ibuf, type, 0, 0, -1, &ribreq, sizeof(ribreq));
diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c
index cdd8cc1fe6f..4173804beb8 100644
--- a/usr.sbin/bgpctl/parser.c
+++ b/usr.sbin/bgpctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.33 2006/06/15 10:04:06 claudio Exp $ */
+/* $OpenBSD: parser.c,v 1.34 2006/08/23 08:21:11 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -34,6 +34,7 @@ enum token_type {
ENDTOKEN,
KEYWORD,
ADDRESS,
+ PEERADDRESS,
FLAG,
ASNUM,
ASTYPE,
@@ -61,7 +62,8 @@ static const struct token t_main[];
static const struct token t_show[];
static const struct token t_show_summary[];
static const struct token t_show_fib[];
-static const struct token t_show_rib[];
+static const struct token t_show_rib[];
+static const struct token t_show_rib_neigh[];
static const struct token t_show_neighbor[];
static const struct token t_show_neighbor_modifiers[];
static const struct token t_fib[];
@@ -127,18 +129,27 @@ static const struct token t_show_rib[] = {
{ ASTYPE, "as", AS_ALL, t_show_as},
{ ASTYPE, "source-as", AS_SOURCE, t_show_as},
{ ASTYPE, "transit-as", AS_TRANSIT, t_show_as},
- { ASTYPE, "empty-as", AS_EMPTY, NULL},
- { KEYWORD, "summary", SHOW_SUMMARY, NULL},
+ { ASTYPE, "empty-as", AS_EMPTY, t_show_rib},
{ FLAG, "detail", F_CTL_DETAIL, t_show_rib},
+ { FLAG, "in", F_CTL_ADJ_IN, t_show_rib},
+ { FLAG, "out", F_CTL_ADJ_OUT, t_show_rib},
+ { KEYWORD, "neighbor", NONE, t_show_rib_neigh},
+ { KEYWORD, "summary", SHOW_SUMMARY, NULL},
{ KEYWORD, "memory", SHOW_RIB_MEM, NULL},
- { FAMILY, "", NONE, NULL},
+ { FAMILY, "", NONE, t_show_rib},
{ PREFIX, "", NONE, t_show_prefix},
{ ENDTOKEN, "", NONE, NULL}
};
+static const struct token t_show_rib_neigh[] = {
+ { PEERADDRESS, "", NONE, t_show_rib},
+ { PEERDESC, "", NONE, t_show_rib},
+ { ENDTOKEN, "", NONE, NULL}
+};
+
static const struct token t_show_neighbor[] = {
{ NOTOKEN, "", NONE, NULL},
- { ADDRESS, "", NONE, t_show_neighbor_modifiers},
+ { PEERADDRESS, "", NONE, t_show_neighbor_modifiers},
{ PEERDESC, "", NONE, t_show_neighbor_modifiers},
{ ENDTOKEN, "", NONE, NULL}
};
@@ -157,7 +168,7 @@ static const struct token t_fib[] = {
};
static const struct token t_neighbor[] = {
- { ADDRESS, "", NONE, t_neighbor_modifiers},
+ { PEERADDRESS, "", NONE, t_neighbor_modifiers},
{ PEERDESC, "", NONE, t_neighbor_modifiers},
{ ENDTOKEN, "", NONE, NULL}
};
@@ -171,7 +182,7 @@ static const struct token t_neighbor_modifiers[] = {
};
static const struct token t_show_as[] = {
- { ASNUM, "", NONE, NULL},
+ { ASNUM, "", NONE, t_show_rib},
{ ENDTOKEN, "", NONE, NULL}
};
@@ -364,6 +375,14 @@ match_token(const char *word, const struct token table[])
res.action = t->value;
}
break;
+ case PEERADDRESS:
+ if (parse_addr(word, &res.peeraddr)) {
+ match++;
+ t = &table[i];
+ if (t->value)
+ res.action = t->value;
+ }
+ break;
case PREFIX:
if (parse_prefix(word, &res.addr, &res.prefixlen)) {
match++;
@@ -468,6 +487,7 @@ show_valid_args(const struct token table[])
fprintf(stderr, " %s\n", table[i].keyword);
break;
case ADDRESS:
+ case PEERADDRESS:
fprintf(stderr, " <address>\n");
break;
case PREFIX:
diff --git a/usr.sbin/bgpctl/parser.h b/usr.sbin/bgpctl/parser.h
index 72d291b8873..a2732c8d9b4 100644
--- a/usr.sbin/bgpctl/parser.h
+++ b/usr.sbin/bgpctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.13 2006/06/15 09:59:48 claudio Exp $ */
+/* $OpenBSD: parser.h,v 1.14 2006/08/23 08:21:11 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -49,6 +49,7 @@ enum actions {
struct parse_result {
struct bgpd_addr addr;
+ struct bgpd_addr peeraddr;
struct filter_as as;
struct filter_set_head set;
char peerdesc[PEER_DESCR_LEN];