zebra: Add some extra safety for route_info

The route_info[X].meta_q_map *must* be less than MQ_SIZE
or we will do some strange stuff, so assert on it at startup.

The distance in route_info is a uint8_t so let's keep the data
structure the same.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2019-05-03 20:14:39 -04:00
parent b705b4578e
commit 8dc7a75918

View File

@ -71,7 +71,7 @@ extern int allow_delete;
/* Each route type's string and default distance value. */
static const struct {
int key;
int distance;
uint8_t distance;
uint8_t meta_q_map;
} route_info[ZEBRA_ROUTE_MAX] = {
[ZEBRA_ROUTE_SYSTEM] = {ZEBRA_ROUTE_SYSTEM, 0, 4},
@ -3407,6 +3407,7 @@ static void check_route_info(void)
if (i == ZEBRA_ROUTE_SYSTEM || i == ZEBRA_ROUTE_ALL)
continue;
assert(route_info[i].key);
assert(route_info[i].meta_q_map < MQ_SIZE);
}
}