diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2021-10-20 13:07:47 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2021-10-20 13:28:46 +0200 |
commit | a243d1db93aaa123413a754fe69fbad36d810ae7 (patch) | |
tree | 3d2e74c2b3f4d4862f7a7029c2ff5d18d71999ae /eigrpd | |
parent | Merge pull request #9848 from ton31337/feature/as-path_autocomplete (diff) | |
download | frr-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 'eigrpd')
-rw-r--r-- | eigrpd/eigrp_zebra.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index 7c765248c..89dd5be27 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -102,20 +102,24 @@ static void eigrp_zebra_connected(struct zclient *zclient) zclient_send_reg_requests(zclient, VRF_DEFAULT); } +static zclient_handler *const eigrp_handlers[] = { + [ZEBRA_ROUTER_ID_UPDATE] = eigrp_router_id_update_zebra, + [ZEBRA_INTERFACE_ADDRESS_ADD] = eigrp_interface_address_add, + [ZEBRA_INTERFACE_ADDRESS_DELETE] = eigrp_interface_address_delete, + [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = eigrp_zebra_read_route, + [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = eigrp_zebra_read_route, + [ZEBRA_ROUTE_NOTIFY_OWNER] = eigrp_zebra_route_notify_owner, +}; + void eigrp_zebra_init(void) { struct zclient_options opt = {.receive_notify = false}; - zclient = zclient_new(master, &opt); + zclient = zclient_new(master, &opt, eigrp_handlers, + array_size(eigrp_handlers)); zclient_init(zclient, ZEBRA_ROUTE_EIGRP, 0, &eigrpd_privs); zclient->zebra_connected = eigrp_zebra_connected; - zclient->router_id_update = eigrp_router_id_update_zebra; - zclient->interface_address_add = eigrp_interface_address_add; - zclient->interface_address_delete = eigrp_interface_address_delete; - zclient->redistribute_route_add = eigrp_zebra_read_route; - zclient->redistribute_route_del = eigrp_zebra_read_route; - zclient->route_notify_owner = eigrp_zebra_route_notify_owner; } |