mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 09:30:30 +00:00
Merge pull request #856 from opensourcerouting/cli-fuzzer-fixes
bgpd/eigrpd: fix crashes found by the CLI fuzzer
This commit is contained in:
commit
ff9f629d47
@ -207,8 +207,6 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
schedule_neighbours_check(5000, 1);
|
schedule_neighbours_check(5000, 1);
|
||||||
|
|
||||||
zlog_notice ("BABELd %s starting: vty@%d", BABEL_VERSION, babel_vty_port);
|
|
||||||
|
|
||||||
frr_config_fork();
|
frr_config_fork();
|
||||||
frr_run(master);
|
frr_run(master);
|
||||||
|
|
||||||
|
@ -55,25 +55,6 @@ static struct {
|
|||||||
{0, 0, NULL}
|
{0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct {
|
|
||||||
int str_min_len;
|
|
||||||
const char *str;
|
|
||||||
} proto_redistnum_type[ZEBRA_ROUTE_MAX] = {
|
|
||||||
[ZEBRA_ROUTE_BABEL] = {2, "babel"},
|
|
||||||
[ZEBRA_ROUTE_BGP] = {2, "bgp"},
|
|
||||||
[ZEBRA_ROUTE_CONNECT] = {1, "connected"},
|
|
||||||
[ZEBRA_ROUTE_HSLS] = {1, "hsls"},
|
|
||||||
[ZEBRA_ROUTE_ISIS] = {1, "isis"},
|
|
||||||
[ZEBRA_ROUTE_KERNEL] = {1, "kernel"},
|
|
||||||
[ZEBRA_ROUTE_OLSR] = {2, "olsr"},
|
|
||||||
[ZEBRA_ROUTE_OSPF] = {2, "ospf"},
|
|
||||||
[ZEBRA_ROUTE_OSPF6] = {5, "ospf6"},
|
|
||||||
[ZEBRA_ROUTE_RIP] = {1, "rip"},
|
|
||||||
[ZEBRA_ROUTE_RIPNG] = {4, "ripng"},
|
|
||||||
[ZEBRA_ROUTE_STATIC] = {2, "static"},
|
|
||||||
[ZEBRA_ROUTE_SYSTEM] = {2, "system"},
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Zebra node structure. */
|
/* Zebra node structure. */
|
||||||
struct cmd_node zebra_node =
|
struct cmd_node zebra_node =
|
||||||
{
|
{
|
||||||
@ -191,66 +172,46 @@ babel_zebra_read_ipv4 (int command, struct zclient *zclient,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
babel_proto_redistnum(const char *s)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (! s)
|
|
||||||
return -1;
|
|
||||||
int len = strlen(s);
|
|
||||||
|
|
||||||
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
|
||||||
if (len <= (int)strlen(proto_redistnum_type[i].str) &&
|
|
||||||
strncmp(proto_redistnum_type[i].str, s,
|
|
||||||
proto_redistnum_type[i].str_min_len) == 0) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [Babel Command] */
|
/* [Babel Command] */
|
||||||
DEFUN (babel_redistribute_type,
|
DEFUN (babel_redistribute_type,
|
||||||
babel_redistribute_type_cmd,
|
babel_redistribute_type_cmd,
|
||||||
"redistribute " FRR_REDIST_STR_BABELD,
|
"[no] redistribute <ipv4 " FRR_IP_REDIST_STR_BABELD "|ipv6 " FRR_IP6_REDIST_STR_BABELD ">",
|
||||||
"Redistribute\n"
|
|
||||||
FRR_REDIST_HELP_STR_BABELD)
|
|
||||||
{
|
|
||||||
int type;
|
|
||||||
|
|
||||||
type = babel_proto_redistnum(argv[1]->arg);
|
|
||||||
|
|
||||||
if (type < 0) {
|
|
||||||
vty_out (vty, "Invalid type %s\n", argv[1]->arg);
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT);
|
|
||||||
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [Babel Command] */
|
|
||||||
DEFUN (no_babel_redistribute_type,
|
|
||||||
no_babel_redistribute_type_cmd,
|
|
||||||
"no redistribute " FRR_REDIST_STR_BABELD,
|
|
||||||
NO_STR
|
NO_STR
|
||||||
"Redistribute\n"
|
"Redistribute\n"
|
||||||
FRR_REDIST_HELP_STR_BABELD)
|
"Redistribute IPv4 routes\n"
|
||||||
|
FRR_IP_REDIST_HELP_STR_BABELD
|
||||||
|
"Redistribute IPv6 routes\n"
|
||||||
|
FRR_IP6_REDIST_HELP_STR_BABELD)
|
||||||
{
|
{
|
||||||
|
int negate = 0;
|
||||||
|
int family;
|
||||||
|
int afi;
|
||||||
int type;
|
int type;
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
type = babel_proto_redistnum(argv[2]->arg);
|
if (argv_find(argv, argc, "no", &idx))
|
||||||
|
negate = 1;
|
||||||
|
argv_find(argv, argc, "redistribute", &idx);
|
||||||
|
family = str2family(argv[idx + 1]->text);
|
||||||
|
if (family < 0)
|
||||||
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
|
|
||||||
|
afi = family2afi(family);
|
||||||
|
if (!afi)
|
||||||
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
|
|
||||||
|
type = proto_redistnum(afi, argv[idx + 2]->text);
|
||||||
if (type < 0) {
|
if (type < 0) {
|
||||||
vty_out (vty, "Invalid type %s\n", argv[2]->arg);
|
vty_out (vty, "Invalid type %s\n", argv[idx + 2]->arg);
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
|
if (!negate)
|
||||||
zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
|
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, 0, VRF_DEFAULT);
|
||||||
|
else {
|
||||||
|
zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, 0, VRF_DEFAULT);
|
||||||
/* perhaps should we remove xroutes having the same type... */
|
/* perhaps should we remove xroutes having the same type... */
|
||||||
|
}
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +335,6 @@ void babelz_zebra_init(void)
|
|||||||
|
|
||||||
install_node (&zebra_node, zebra_config_write);
|
install_node (&zebra_node, zebra_config_write);
|
||||||
install_element(BABEL_NODE, &babel_redistribute_type_cmd);
|
install_element(BABEL_NODE, &babel_redistribute_type_cmd);
|
||||||
install_element(BABEL_NODE, &no_babel_redistribute_type_cmd);
|
|
||||||
install_element(ENABLE_NODE, &debug_babel_cmd);
|
install_element(ENABLE_NODE, &debug_babel_cmd);
|
||||||
install_element(ENABLE_NODE, &no_debug_babel_cmd);
|
install_element(ENABLE_NODE, &no_debug_babel_cmd);
|
||||||
install_element(CONFIG_NODE, &debug_babel_cmd);
|
install_element(CONFIG_NODE, &debug_babel_cmd);
|
||||||
|
@ -76,6 +76,7 @@ static int
|
|||||||
babel_config_write (struct vty *vty)
|
babel_config_write (struct vty *vty)
|
||||||
{
|
{
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
|
int afi;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* list enabled debug modes */
|
/* list enabled debug modes */
|
||||||
@ -108,13 +109,17 @@ babel_config_write (struct vty *vty)
|
|||||||
/* list enabled interfaces */
|
/* list enabled interfaces */
|
||||||
lines = 1 + babel_enable_if_config_write (vty);
|
lines = 1 + babel_enable_if_config_write (vty);
|
||||||
/* list redistributed protocols */
|
/* list redistributed protocols */
|
||||||
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
|
for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
|
||||||
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
||||||
if (i != zclient->redist_default &&
|
if (i != zclient->redist_default &&
|
||||||
vrf_bitmap_check (zclient->redist[AFI_IP][i], VRF_DEFAULT))
|
vrf_bitmap_check (zclient->redist[afi][i], VRF_DEFAULT)) {
|
||||||
{
|
vty_out (vty, " redistribute %s %s\n",
|
||||||
vty_out (vty, " redistribute %s\n", zebra_route_string(i));
|
(afi == AFI_IP) ? "ipv4" : "ipv6",
|
||||||
|
zebra_route_string(i));
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lines += config_write_distribute (vty);
|
lines += config_write_distribute (vty);
|
||||||
|
|
||||||
|
@ -90,7 +90,6 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
#define BABEL_VTY_PORT 2609
|
#define BABEL_VTY_PORT 2609
|
||||||
#define BABEL_DEFAULT_CONFIG "babeld.conf"
|
#define BABEL_DEFAULT_CONFIG "babeld.conf"
|
||||||
#define BABEL_VERSION "0.1 for quagga"
|
|
||||||
|
|
||||||
/* Values in milliseconds */
|
/* Values in milliseconds */
|
||||||
#define BABEL_DEFAULT_HELLO_INTERVAL 4000
|
#define BABEL_DEFAULT_HELLO_INTERVAL 4000
|
||||||
|
@ -347,6 +347,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
|
|||||||
if (bgp == NULL) {
|
if (bgp == NULL) {
|
||||||
if (!use_json)
|
if (!use_json)
|
||||||
vty_out(vty, "No BGP process is configured\n");
|
vty_out(vty, "No BGP process is configured\n");
|
||||||
|
else
|
||||||
|
vty_out(vty, "{}\n");
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,6 +374,8 @@ int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd,
|
|||||||
if (bgp == NULL) {
|
if (bgp == NULL) {
|
||||||
if (!use_json)
|
if (!use_json)
|
||||||
vty_out(vty, "No BGP process is configured\n");
|
vty_out(vty, "No BGP process is configured\n");
|
||||||
|
else
|
||||||
|
vty_out(vty, "{}\n");
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8257,6 +8257,8 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
|
|||||||
if (bgp == NULL) {
|
if (bgp == NULL) {
|
||||||
if (!use_json)
|
if (!use_json)
|
||||||
vty_out(vty, "No BGP process is configured\n");
|
vty_out(vty, "No BGP process is configured\n");
|
||||||
|
else
|
||||||
|
vty_out(vty, "{}\n");
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8617,8 +8619,16 @@ static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str,
|
|||||||
int prefix_check, enum bgp_path_type pathtype,
|
int prefix_check, enum bgp_path_type pathtype,
|
||||||
u_char use_json)
|
u_char use_json)
|
||||||
{
|
{
|
||||||
if (!bgp)
|
if (!bgp) {
|
||||||
bgp = bgp_get_default();
|
bgp = bgp_get_default();
|
||||||
|
if (!bgp) {
|
||||||
|
if (!use_json)
|
||||||
|
vty_out(vty, "No BGP process is configured\n");
|
||||||
|
else
|
||||||
|
vty_out(vty, "{}\n");
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* labeled-unicast routes live in the unicast table */
|
/* labeled-unicast routes live in the unicast table */
|
||||||
if (safi == SAFI_LABELED_UNICAST)
|
if (safi == SAFI_LABELED_UNICAST)
|
||||||
|
@ -51,6 +51,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
|
|||||||
if (bgp == NULL) {
|
if (bgp == NULL) {
|
||||||
if (!use_json)
|
if (!use_json)
|
||||||
vty_out(vty, "No BGP process is configured\n");
|
vty_out(vty, "No BGP process is configured\n");
|
||||||
|
else
|
||||||
|
vty_out(vty, "{}\n");
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2236,9 +2236,12 @@ void rfapiRibShowResponsesSummary(void *stream)
|
|||||||
struct rfapi_descriptor *rfd;
|
struct rfapi_descriptor *rfd;
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
|
|
||||||
|
|
||||||
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
|
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
|
||||||
return;
|
return;
|
||||||
|
if (!bgp) {
|
||||||
|
fp(out, "Unable to find default BGP instance\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fp(out, "%-24s ", "Responses: (Prefixes)");
|
fp(out, "%-24s ", "Responses: (Prefixes)");
|
||||||
fp(out, "%-8s %-8u ", "Active:", bgp->rfapi->rib_prefix_count_total);
|
fp(out, "%-8s %-8u ", "Active:", bgp->rfapi->rib_prefix_count_total);
|
||||||
@ -2388,6 +2391,11 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
|
|||||||
|
|
||||||
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
|
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
|
||||||
return;
|
return;
|
||||||
|
if (!bgp) {
|
||||||
|
fp(out, "Unable to find default BGP instance\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loop over NVEs
|
* loop over NVEs
|
||||||
*/
|
*/
|
||||||
|
@ -237,6 +237,11 @@ DEFUN (no_router_eigrp,
|
|||||||
struct eigrp *eigrp;
|
struct eigrp *eigrp;
|
||||||
|
|
||||||
eigrp = eigrp_lookup();
|
eigrp = eigrp_lookup();
|
||||||
|
if (eigrp == NULL) {
|
||||||
|
vty_out(vty, " EIGRP Routing Process not enabled\n");
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (eigrp->AS != atoi(argv[3]->arg)) {
|
if (eigrp->AS != atoi(argv[3]->arg)) {
|
||||||
vty_out(vty, "%% Attempting to deconfigure non-existent AS\n");
|
vty_out(vty, "%% Attempting to deconfigure non-existent AS\n");
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
@ -1000,9 +1005,11 @@ DEFUN (eigrp_redistribute_source_metric,
|
|||||||
|
|
||||||
/* Get distribute source. */
|
/* Get distribute source. */
|
||||||
argv_find(argv, argc, "redistribute", &idx);
|
argv_find(argv, argc, "redistribute", &idx);
|
||||||
source = proto_redistnum(AFI_IP, argv[idx + 1]->arg);
|
source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
|
||||||
if (source < 0)
|
if (source < 0) {
|
||||||
|
vty_out(vty, "%% Invalid route type\n");
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get metrics values */
|
/* Get metrics values */
|
||||||
|
|
||||||
@ -1029,9 +1036,11 @@ DEFUN (no_eigrp_redistribute_source_metric,
|
|||||||
|
|
||||||
/* Get distribute source. */
|
/* Get distribute source. */
|
||||||
argv_find(argv, argc, "redistribute", &idx);
|
argv_find(argv, argc, "redistribute", &idx);
|
||||||
source = proto_redistnum(AFI_IP, argv[idx + 1]->arg);
|
source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
|
||||||
if (source < 0)
|
if (source < 0) {
|
||||||
|
vty_out(vty, "%% Invalid route type\n");
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get metrics values */
|
/* Get metrics values */
|
||||||
|
|
||||||
|
@ -4402,6 +4402,10 @@ static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
|
|||||||
if (!ret) {
|
if (!ret) {
|
||||||
if (!use_json)
|
if (!use_json)
|
||||||
vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n");
|
vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n");
|
||||||
|
else {
|
||||||
|
vty_out(vty, "{}\n");
|
||||||
|
json_object_free(json);
|
||||||
|
}
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4682,6 +4686,10 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
|
|||||||
if (!ifp) {
|
if (!ifp) {
|
||||||
if (!use_json)
|
if (!use_json)
|
||||||
vty_out(vty, "No such interface.\n");
|
vty_out(vty, "No such interface.\n");
|
||||||
|
else {
|
||||||
|
vty_out(vty, "{}\n");
|
||||||
|
json_object_free(json);
|
||||||
|
}
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user