summaryrefslogtreecommitdiffstats
path: root/ospf6d/ospf6_zebra.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2021-10-20 13:07:47 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2021-10-20 13:28:46 +0200
commita243d1db93aaa123413a754fe69fbad36d810ae7 (patch)
tree3d2e74c2b3f4d4862f7a7029c2ff5d18d71999ae /ospf6d/ospf6_zebra.c
parentMerge pull request #9848 from ton31337/feature/as-path_autocomplete (diff)
downloadfrr-a243d1db93aaa123413a754fe69fbad36d810ae7.tar.xz
frr-a243d1db93aaa123413a754fe69fbad36d810ae7.zip
*: convert zclient callbacks to table
This removes a giant `switch { }` block from lib/zclient.c and harmonizes all zclient callback function types to be the same (some had a subset of the args, some had a void return, now they all have ZAPI_CALLBACK_ARGS and int return.) Apart from getting rid of the giant switch, this is a minor security benefit since the function pointers are now in a `const` array, so they can't be overwritten by e.g. heap overflows for code execution anymore. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'ospf6d/ospf6_zebra.c')
-rw-r--r--ospf6d/ospf6_zebra.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 81573da3a..5e50a6cc5 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -709,19 +709,22 @@ static void ospf6_zebra_connected(struct zclient *zclient)
zclient_send_reg_requests(zclient, VRF_DEFAULT);
}
+static zclient_handler *const ospf6_handlers[] = {
+ [ZEBRA_ROUTER_ID_UPDATE] = ospf6_router_id_update_zebra,
+ [ZEBRA_INTERFACE_ADDRESS_ADD] = ospf6_zebra_if_address_update_add,
+ [ZEBRA_INTERFACE_ADDRESS_DELETE] = ospf6_zebra_if_address_update_delete,
+ [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = ospf6_zebra_read_route,
+ [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = ospf6_zebra_read_route,
+ [ZEBRA_NEXTHOP_UPDATE] = ospf6_zebra_import_check_update,
+};
+
void ospf6_zebra_init(struct thread_master *master)
{
/* Allocate zebra structure. */
- zclient = zclient_new(master, &zclient_options_default);
+ zclient = zclient_new(master, &zclient_options_default, ospf6_handlers,
+ array_size(ospf6_handlers));
zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs);
zclient->zebra_connected = ospf6_zebra_connected;
- zclient->router_id_update = ospf6_router_id_update_zebra;
- zclient->interface_address_add = ospf6_zebra_if_address_update_add;
- zclient->interface_address_delete =
- ospf6_zebra_if_address_update_delete;
- zclient->redistribute_route_add = ospf6_zebra_read_route;
- zclient->redistribute_route_del = ospf6_zebra_read_route;
- zclient->nexthop_update = ospf6_zebra_import_check_update;
/* Install command element for zebra node. */
install_element(VIEW_NODE, &show_ospf6_zebra_cmd);