The command order for bgpctl network bulk add is strange and as a result
soemthing like:
bgpctl network add 127.0.0.1 delete
is valid syntax with strange behaviour. It is actually:
bgpctl network bulk delete
So lets fix this mess and make bulk require add or delete and with that
the attribute set is also cleaned up.
--
:wq Claudio
Index: bgpctl.8
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.8,v
retrieving revision 1.106
diff -u -p -r1.106 bgpctl.8
--- bgpctl.8 13 Mar 2023 16:59:22 -0000 1.106
+++ bgpctl.8 12 Apr 2023 16:15:54 -0000
@@ -133,20 +133,12 @@ It is possible to set various path attri
Adding a prefix will replace an existing equal prefix, including
prefixes loaded from the configuration.
.It Xo
-.Cm network bulk
+.Cm network bulk add
.Op Ar argument ...
-.Op Cm add
.Xc
Bulk add specified prefixes to the list of announced networks.
Prefixes should be sent via stdin.
It is possible to set various path attributes with additional arguments.
-If neither
-.Cm add
-or
-.Cm delete
-is given,
-.Cm add
-is the default.
.It Cm network bulk delete
Bulk remove the specified prefixes from the list of announced networks.
Prefixes should be sent via stdin.
Index: parser.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/parser.c,v
retrieving revision 1.122
diff -u -p -r1.122 parser.c
--- parser.c 13 Mar 2023 16:59:22 -0000 1.122
+++ parser.c 12 Apr 2023 16:17:50 -0000
@@ -98,6 +98,7 @@ static const struct token t_show_extcomm
static const struct token t_show_ext_subtype[];
static const struct token t_show_largecommunity[];
static const struct token t_network[];
+static const struct token t_bulk[];
static const struct token t_network_show[];
static const struct token t_prefix[];
static const struct token t_set[];
@@ -371,10 +372,16 @@ static const struct token t_network[] =
{ KEYWORD, "flush", NETWORK_FLUSH, NULL},
{ KEYWORD, "show", NETWORK_SHOW, t_network_show},
{ KEYWORD, "mrt", NETWORK_MRT, t_show_mrt},
- { KEYWORD, "bulk", NETWORK_BULK_ADD, t_set},
+ { KEYWORD, "bulk", NONE, t_bulk},
{ ENDTOKEN, "", NONE, NULL}
};
+static const struct token t_bulk[] = {
+ { KEYWORD, "add", NETWORK_BULK_ADD, t_set},
+ { KEYWORD, "delete", NETWORK_BULK_REMOVE, NULL},
+ { ENDTOKEN, "", NONE, NULL}
+};
+
static const struct token t_prefix[] = {
{ PREFIX, "", NONE, t_set},
{ ENDTOKEN, "", NONE, NULL}
@@ -405,8 +412,6 @@ static const struct token t_set[] = {
{ KEYWORD, "prepend-self", NONE, t_prepself},
{ KEYWORD, "rd", NONE, t_rd},
{ KEYWORD, "weight", NONE, t_weight},
- { KEYWORD, "add", NETWORK_BULK_ADD, NULL},
- { KEYWORD, "delete", NETWORK_BULK_REMOVE, NULL},
{ ENDTOKEN, "", NONE, NULL}
};