summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2013-03-07 21:28:35 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2013-03-07 21:28:35 +0000
commite81980dcd09ba78a2ed1e7759be1cd9c6fab754d (patch)
tree09db7449cd367e4e3d0503cad2b33562af7e3401
parentbbc36091a439968012b5b5bc303451041597204b (diff)
Implement a bgpctl nei foo destroy that will remove the specified cloned
neighbor. The neighbor must be set down before calling this function. OK phessler
-rw-r--r--usr.sbin/bgpctl/bgpctl.821
-rw-r--r--usr.sbin/bgpctl/bgpctl.c14
-rw-r--r--usr.sbin/bgpctl/parser.c3
-rw-r--r--usr.sbin/bgpctl/parser.h3
4 files changed, 27 insertions, 14 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.8 b/usr.sbin/bgpctl/bgpctl.8
index 3e538dc55e4..bd6830efca0 100644
--- a/usr.sbin/bgpctl/bgpctl.8
+++ b/usr.sbin/bgpctl/bgpctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: bgpctl.8,v 1.60 2012/09/26 16:19:44 jmc Exp $
+.\" $OpenBSD: bgpctl.8,v 1.61 2013/03/07 21:28:34 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: September 26 2012 $
+.Dd $Mdocdate: March 7 2013 $
.Dt BGPCTL 8
.Os
.Sh NAME
@@ -95,16 +95,17 @@ Fetch only IPv6 prefixes from the registry.
Disable verbose debug logging.
.It Cm log verbose
Enable verbose debug logging.
-.It Cm neighbor Ar peer Cm up
-Take the BGP session to the specified neighbor up.
+.It Cm neighbor Ar peer Cm clear
+Stop and restart the BGP session to the specified neighbor.
.Ar peer
may be the neighbor's address or description.
-.It Cm neighbor Ar peer Cm down
-Take the BGP session to the specified neighbor down.
+.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.
-.It Cm neighbor Ar peer Cm clear
-Stop and restart the BGP session to the specified neighbor.
+.It Cm neighbor Ar peer Cm down
+Take the BGP session to the specified neighbor down.
.Ar peer
may be the neighbor's address or description.
.It Cm neighbor Ar peer Cm refresh
@@ -113,6 +114,10 @@ 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.
+.It Cm neighbor Ar peer Cm up
+Take the BGP session to the specified neighbor up.
+.Ar peer
+may be the neighbor's address or 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
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c
index 250b18bf751..888e0de4717 100644
--- a/usr.sbin/bgpctl/bgpctl.c
+++ b/usr.sbin/bgpctl/bgpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpctl.c,v 1.168 2012/11/27 05:38:08 guenther Exp $ */
+/* $OpenBSD: bgpctl.c,v 1.169 2013/03/07 21:28:34 claudio Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -310,6 +310,10 @@ main(int argc, char *argv[])
imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_RREFRESH, 0, 0, -1,
&neighbor, sizeof(neighbor));
break;
+ case NEIGHBOR_DESTROY:
+ imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_DESTROY, 0, 0, -1,
+ &neighbor, sizeof(neighbor));
+ break;
case NETWORK_ADD:
case NETWORK_REMOVE:
bzero(&net, sizeof(net));
@@ -436,6 +440,7 @@ main(int argc, char *argv[])
case NEIGHBOR_DOWN:
case NEIGHBOR_CLEAR:
case NEIGHBOR_RREFRESH:
+ case NEIGHBOR_DESTROY:
case NONE:
case RELOAD:
case FIB:
@@ -625,7 +630,7 @@ show_neighbor_msg(struct imsg *imsg, enum neighbor_views nv)
printf("remote AS %s", log_as(p->conf.remote_as));
if (p->conf.template)
printf(", Template");
- if (p->conf.cloned)
+ if (p->template)
printf(", Cloned");
if (p->conf.passive)
printf(", Passive");
@@ -1604,8 +1609,9 @@ show_result(struct imsg *imsg)
else {
if (rescode >
sizeof(ctl_res_strerror)/sizeof(ctl_res_strerror[0]))
- errx(1, "illegal error code %u", rescode);
- printf("%s\n", ctl_res_strerror[rescode]);
+ printf("unknown result error code %u\n", rescode);
+ else
+ printf("%s\n", ctl_res_strerror[rescode]);
}
return (1);
diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c
index a31074c9527..1f544f0942b 100644
--- a/usr.sbin/bgpctl/parser.c
+++ b/usr.sbin/bgpctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.65 2012/05/27 18:53:50 claudio Exp $ */
+/* $OpenBSD: parser.c,v 1.66 2013/03/07 21:28:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -243,6 +243,7 @@ static const struct token t_neighbor_modifiers[] = {
{ KEYWORD, "down", NEIGHBOR_DOWN, NULL},
{ KEYWORD, "clear", NEIGHBOR_CLEAR, NULL},
{ KEYWORD, "refresh", NEIGHBOR_RREFRESH, NULL},
+ { KEYWORD, "destroy", NEIGHBOR_DESTROY, NULL},
{ ENDTOKEN, "", NONE, NULL}
};
diff --git a/usr.sbin/bgpctl/parser.h b/usr.sbin/bgpctl/parser.h
index dc1d2335b4f..80c1e37b9c8 100644
--- a/usr.sbin/bgpctl/parser.h
+++ b/usr.sbin/bgpctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.24 2012/05/27 18:53:50 claudio Exp $ */
+/* $OpenBSD: parser.h,v 1.25 2013/03/07 21:28:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -46,6 +46,7 @@ enum actions {
NEIGHBOR_DOWN,
NEIGHBOR_CLEAR,
NEIGHBOR_RREFRESH,
+ NEIGHBOR_DESTROY,
NETWORK_ADD,
NETWORK_REMOVE,
NETWORK_FLUSH,