diff options
author | 2019-01-20 23:30:15 +0000 | |
---|---|---|
committer | 2019-01-20 23:30:15 +0000 | |
commit | 903de74abd300e36df0c1afb2eb214f3c77d3d25 (patch) | |
tree | 0d8af7f9ddd017b26e52658359967d6253495911 | |
parent | Support group descriptions in control messages that accept a neighbor (diff) | |
download | wireguard-openbsd-903de74abd300e36df0c1afb2eb214f3c77d3d25.tar.xz wireguard-openbsd-903de74abd300e36df0c1afb2eb214f3c77d3d25.zip |
Allow 'neighbor descripton' to be used like neighbor group description
which will match all neighbors in that group. Works for
bgpctl neighbor group <name> [clear|destroy|down|refresh|up]
bgpctl show neighbor group <name> [messages|terse|timers]
bgpctl show rib neighbor group <name> ...
Manpage bits from sthen@
OK benno@ sthen@
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.8 | 31 | ||||
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 3 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.c | 39 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.h | 3 |
4 files changed, 58 insertions, 18 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.8 b/usr.sbin/bgpctl/bgpctl.8 index d6fd7d3edb8..fe8b9698854 100644 --- a/usr.sbin/bgpctl/bgpctl.8 +++ b/usr.sbin/bgpctl/bgpctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgpctl.8,v 1.84 2018/12/12 20:21:04 jmc Exp $ +.\" $OpenBSD: bgpctl.8,v 1.85 2019/01/20 23:30:15 claudio Exp $ .\" .\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 12 2018 $ +.Dd $Mdocdate: January 20 2019 $ .Dt BGPCTL 8 .Os .Sh NAME @@ -116,12 +116,16 @@ The .Ar reason cannot exceed 128 octets. .Ar peer -may be the neighbor's address or description. +may be the neighbor's address, description or the word +.Cm group +followed by a group description. .It Cm neighbor Ar peer Cm destroy Destroy a previously cloned peer. The peer must be down before calling this function. .Ar peer -may be the neighbor's address or description. +may be the neighbor's address, description or the word +.Cm group +followed by a group description. .It Cm neighbor Ar peer Cm down Op Ar reason Take the BGP session to the specified neighbor down. If a @@ -133,17 +137,23 @@ The .Ar reason cannot exceed 128 octets. .Ar peer -may be the neighbor's address or description. +may be the neighbor's address, description or the word +.Cm group +followed by a group description. .It Cm neighbor Ar peer Cm refresh Request the neighbor to re-send all routes. Note that the neighbor is not obliged to re-send all routes, or any routes at all, even if it announced the route refresh capability. .Ar peer -may be the neighbor's address or description. +may be the neighbor's address, description or the word +.Cm group +followed by a group description. .It Cm neighbor Ar peer Cm up Bring the BGP session to the specified neighbor up. .Ar peer -may be the neighbor's address or description. +may be the neighbor's address, description or the word +.Cm group +followed by a group description. .It Cm network add Ar prefix Op Ar arguments Add the specified prefix to the list of announced networks. It is possible to set various path attributes with additional @@ -283,7 +293,6 @@ Multiple options and filters can be used at the same time. .It Cm show neighbor Ar peer modifier Show detailed information about the neighbor identified by .Ar peer , -which may be the neighbor's address or description, according to the given .Ar modifier : .Pp @@ -299,6 +308,10 @@ prefix count, the number of sent and received updates, and withdraws. .It Cm timers Show the BGP timers. .El +.Ar peer +may be the neighbor's address, description or the word +.Cm group +followed by a group description. .It Cm show nexthop Show the list of BGP nexthops and the result of their validity check. .It Xo @@ -339,6 +352,8 @@ Show all entries that are internal routes with no AS's in the AS path. Show RIB memory statistics. .It Cm neighbor Ar peer Show only entries from the specified peer. +.It Cm neighbor group Ar description +Show only entries from the specified peer group. .It Cm peer-as Ar as Show all entries with .Ar as diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 95ade2feb23..22eb0deda84 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.227 2018/12/19 15:27:29 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.228 2019/01/20 23:30:15 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -156,6 +156,7 @@ main(int argc, char *argv[]) memcpy(&neighbor.addr, &res->peeraddr, sizeof(neighbor.addr)); strlcpy(neighbor.descr, res->peerdesc, sizeof(neighbor.descr)); + neighbor.is_group = res->is_group; strlcpy(neighbor.shutcomm, res->shutcomm, sizeof(neighbor.shutcomm)); switch (res->action) { diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index 211ac8772ba..44d73d41fb5 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.88 2018/12/19 15:27:29 claudio Exp $ */ +/* $OpenBSD: parser.c,v 1.89 2019/01/20 23:30:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -44,6 +44,7 @@ enum token_type { ASTYPE, PREFIX, PEERDESC, + GROUPDESC, RIBNAME, SHUTDOWN_COMMUNICATION, COMMUNITY, @@ -220,7 +221,13 @@ static const struct token t_show_mrt_file[] = { { ENDTOKEN, "", NONE, NULL} }; +static const struct token t_show_rib_neigh_group[] = { + { GROUPDESC, "", NONE, t_show_rib}, + { ENDTOKEN, "", NONE, NULL} +}; + static const struct token t_show_rib_neigh[] = { + { KEYWORD, "group", NONE, t_show_rib_neigh_group}, { PEERADDRESS, "", NONE, t_show_rib}, { PEERDESC, "", NONE, t_show_rib}, { ENDTOKEN, "", NONE, NULL} @@ -236,13 +243,6 @@ static const struct token t_show_rib_rib[] = { { ENDTOKEN, "", NONE, NULL} }; -static const struct token t_show_neighbor[] = { - { NOTOKEN, "", NONE, NULL}, - { PEERADDRESS, "", NONE, t_show_neighbor_modifiers}, - { PEERDESC, "", NONE, t_show_neighbor_modifiers}, - { ENDTOKEN, "", NONE, NULL} -}; - static const struct token t_show_neighbor_modifiers[] = { { NOTOKEN, "", NONE, NULL}, { KEYWORD, "timers", SHOW_NEIGHBOR_TIMERS, NULL}, @@ -251,6 +251,19 @@ static const struct token t_show_neighbor_modifiers[] = { { ENDTOKEN, "", NONE, NULL} }; +static const struct token t_show_neighbor_group[] = { + { GROUPDESC, "", NONE, t_show_neighbor_modifiers}, + { ENDTOKEN, "", NONE, NULL} +}; + +static const struct token t_show_neighbor[] = { + { NOTOKEN, "", NONE, NULL}, + { KEYWORD, "group", NONE, t_show_neighbor_group}, + { PEERADDRESS, "", NONE, t_show_neighbor_modifiers}, + { PEERDESC, "", NONE, t_show_neighbor_modifiers}, + { ENDTOKEN, "", NONE, NULL} +}; + static const struct token t_fib[] = { { KEYWORD, "couple", FIB_COUPLE, NULL}, { KEYWORD, "decouple", FIB_DECOUPLE, NULL}, @@ -258,7 +271,13 @@ static const struct token t_fib[] = { { ENDTOKEN, "", NONE, NULL} }; +static const struct token t_neighbor_group[] = { + { GROUPDESC, "", NONE, t_neighbor_modifiers}, + { ENDTOKEN, "", NONE, NULL} +}; + static const struct token t_neighbor[] = { + { KEYWORD, "group", NONE, t_neighbor_group}, { PEERADDRESS, "", NONE, t_neighbor_modifiers}, { PEERDESC, "", NONE, t_neighbor_modifiers}, { ENDTOKEN, "", NONE, NULL} @@ -622,6 +641,9 @@ match_token(int *argc, char **argv[], const struct token table[]) t = &table[i]; } break; + case GROUPDESC: + res.is_group = 1; + /* FALLTHROUGH */ case PEERDESC: if (!match && word != NULL && wordlen > 0) { if (strlcpy(res.peerdesc, word, @@ -788,6 +810,7 @@ show_valid_args(const struct token table[]) case ASNUM: fprintf(stderr, " <asnum>\n"); break; + case GROUPDESC: case PEERDESC: fprintf(stderr, " <neighbor description>\n"); break; diff --git a/usr.sbin/bgpctl/parser.h b/usr.sbin/bgpctl/parser.h index e534716a723..236dea8467e 100644 --- a/usr.sbin/bgpctl/parser.h +++ b/usr.sbin/bgpctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.33 2018/12/19 15:27:29 claudio Exp $ */ +/* $OpenBSD: parser.h,v 1.34 2019/01/20 23:30:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -68,6 +68,7 @@ struct parse_result { char shutcomm[SHUT_COMM_LEN]; char *irr_outdir; int flags; + int is_group; u_int8_t validation_state; u_int rtableid; enum actions action; |