diff options
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 12 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.c | 20 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.h | 7 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 7 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 12 |
5 files changed, 43 insertions, 15 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 5ae75f431d1..5ddcb10404a 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.70 2004/11/18 16:57:28 henning Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.71 2004/12/23 17:26:51 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -87,6 +87,7 @@ main(int argc, char *argv[]) struct imsg imsg; struct network_config net; struct parse_result *res; + struct ctl_neighbor neighbor; while ((ch = getopt(argc, argv, "n")) != -1) { switch (ch) { @@ -105,6 +106,9 @@ main(int argc, char *argv[]) if ((res = parse(argc, argv)) == NULL) exit(1); + memcpy(&neighbor.addr, &res->addr, sizeof(neighbor.addr)); + strlcpy(neighbor.descr, res->peerdesc, sizeof(neighbor.descr)); + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) err(1, "control_init: socket"); @@ -195,19 +199,19 @@ main(int argc, char *argv[]) break; case NEIGHBOR_UP: imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_UP, 0, 0, -1, - &res->addr, sizeof(res->addr)); + &neighbor, sizeof(neighbor)); printf("request sent.\n"); done = 1; break; case NEIGHBOR_DOWN: imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_DOWN, 0, 0, -1, - &res->addr, sizeof(res->addr)); + &neighbor, sizeof(neighbor)); printf("request sent.\n"); done = 1; break; case NEIGHBOR_CLEAR: imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_CLEAR, 0, 0, -1, - &res->addr, sizeof(res->addr)); + &neighbor, sizeof(neighbor)); printf("request sent.\n"); done = 1; break; diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index e8b587e33e6..43bb718c1e6 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.9 2004/10/26 13:12:22 henning Exp $ */ +/* $OpenBSD: parser.c,v 1.10 2004/12/23 17:26:51 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -33,7 +33,8 @@ enum token_type { FLAG, ASNUM, ASTYPE, - PREFIX + PREFIX, + PEERDESC }; struct token { @@ -121,6 +122,7 @@ static const struct token t_fib[] = { static const struct token t_neighbor[] = { { ADDRESS, "", NONE, t_neighbor_modifiers}, + { PEERDESC, "", NONE, t_neighbor_modifiers}, { ENDTOKEN, "", NONE, NULL} }; @@ -265,6 +267,16 @@ match_token(const char *word, const struct token table[]) t = &table[i]; } break; + case PEERDESC: + if (word != NULL && strlen(word) > 0) { + if (strlcpy(res.peerdesc, word, + sizeof(res.peerdesc)) >= + sizeof(res.peerdesc)) + err(1, "neighbor description too long"); + match++; + t = &table[i]; + } + break; case ENDTOKEN: break; } @@ -305,6 +317,9 @@ show_valid_args(const struct token table[]) case ASNUM: fprintf(stderr, " <asnum>\n"); break; + case PEERDESC: + fprintf(stderr, " <neighbor description>\n"); + break; case ENDTOKEN: break; } @@ -379,4 +394,3 @@ parse_asnum(const char *word, u_int16_t *asnum) *asnum = (u_int16_t)ulval; return (1); } - diff --git a/usr.sbin/bgpctl/parser.h b/usr.sbin/bgpctl/parser.h index cc8a3e6b5f2..44b0706affb 100644 --- a/usr.sbin/bgpctl/parser.h +++ b/usr.sbin/bgpctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.6 2004/11/19 14:45:57 claudio Exp $ */ +/* $OpenBSD: parser.h,v 1.7 2004/12/23 17:26:51 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -45,11 +45,12 @@ enum actions { }; struct parse_result { + struct bgpd_addr addr; + struct filter_as as; + char peerdesc[PEER_DESCR_LEN]; enum actions action; int flags; - struct bgpd_addr addr; u_int8_t prefixlen; - struct filter_as as; }; struct parse_result *parse(int, char *[]); diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index c88d4739102..41586b4128a 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.153 2004/12/23 15:39:22 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.154 2004/12/23 17:26:51 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -409,6 +409,11 @@ struct ctl_show_nexthop { u_int8_t valid; }; +struct ctl_neighbor { + struct bgpd_addr addr; + char descr[PEER_DESCR_LEN]; +}; + #define F_RIB_ELIGIBLE 0x01 #define F_RIB_ACTIVE 0x02 #define F_RIB_INTERNAL 0x04 diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 55d365cbc81..b7c4ed27807 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.39 2004/11/23 13:07:01 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.40 2004/12/23 17:26:51 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -186,6 +186,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) int n; struct peer *p; struct bgpd_addr *addr; + struct ctl_neighbor *neighbor; if ((c = control_connbyfd(pfd->fd)) == NULL) { log_warn("control_dispatch_msg: fd %d: not found", pfd->fd); @@ -242,9 +243,12 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) case IMSG_CTL_NEIGHBOR_DOWN: case IMSG_CTL_NEIGHBOR_CLEAR: if (imsg.hdr.len == IMSG_HEADER_SIZE + - sizeof(struct bgpd_addr)) { - addr = imsg.data; - p = getpeerbyaddr(addr); + sizeof(struct ctl_neighbor)) { + neighbor = imsg.data; + neighbor->descr[PEER_DESCR_LEN - 1] = 0; + p = getpeerbyaddr(&neighbor->addr); + if (p == NULL) + p = getpeerbydesc(neighbor->descr); if (p == NULL) { log_warnx("IMSG_CTL_NEIGHBOR_ " "with unknown neighbor"); |