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 /ripd | |
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 'ripd')
-rw-r--r-- | ripd/rip_zebra.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 074370dc2..1f1566863 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -230,17 +230,21 @@ static void rip_zebra_connected(struct zclient *zclient) zclient_send_reg_requests(zclient, VRF_DEFAULT); } +zclient_handler *const rip_handlers[] = { + [ZEBRA_INTERFACE_ADDRESS_ADD] = rip_interface_address_add, + [ZEBRA_INTERFACE_ADDRESS_DELETE] = rip_interface_address_delete, + [ZEBRA_INTERFACE_VRF_UPDATE] = rip_interface_vrf_update, + [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = rip_zebra_read_route, + [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = rip_zebra_read_route, +}; + void rip_zclient_init(struct thread_master *master) { /* Set default value to the zebra client structure. */ - zclient = zclient_new(master, &zclient_options_default); + zclient = zclient_new(master, &zclient_options_default, rip_handlers, + array_size(rip_handlers)); zclient_init(zclient, ZEBRA_ROUTE_RIP, 0, &ripd_privs); zclient->zebra_connected = rip_zebra_connected; - zclient->interface_address_add = rip_interface_address_add; - zclient->interface_address_delete = rip_interface_address_delete; - zclient->interface_vrf_update = rip_interface_vrf_update; - zclient->redistribute_route_add = rip_zebra_read_route; - zclient->redistribute_route_del = rip_zebra_read_route; } void rip_zclient_stop(void) |