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 /bgpd/rfapi/vnc_zebra.c | |
| parent | bf4af4ffb5e2ffa0b34c5bd67b5b7d4aa912747f (diff) | |
*: 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 'bgpd/rfapi/vnc_zebra.c')
| -rw-r--r-- | bgpd/rfapi/vnc_zebra.c | 11 | 
1 files changed, 7 insertions, 4 deletions
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index ba849e4e0b..672a0e9780 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -895,6 +895,11 @@ int vnc_redistribute_unset(struct bgp *bgp, afi_t afi, int type)  extern struct zebra_privs_t bgpd_privs; +static zclient_handler *const vnc_handlers[] = { +	[ZEBRA_REDISTRIBUTE_ROUTE_ADD] = vnc_zebra_read_route, +	[ZEBRA_REDISTRIBUTE_ROUTE_DEL] = vnc_zebra_read_route, +}; +  /*   * Modeled after bgp_zebra.c'bgp_zebra_init()   * Charriere asks, "Is it possible to carry two?" @@ -902,11 +907,9 @@ extern struct zebra_privs_t bgpd_privs;  void vnc_zebra_init(struct thread_master *master)  {  	/* Set default values. */ -	zclient_vnc = zclient_new(master, &zclient_options_default); +	zclient_vnc = zclient_new(master, &zclient_options_default, +				  vnc_handlers, array_size(vnc_handlers));  	zclient_init(zclient_vnc, ZEBRA_ROUTE_VNC, 0, &bgpd_privs); - -	zclient_vnc->redistribute_route_add = vnc_zebra_read_route; -	zclient_vnc->redistribute_route_del = vnc_zebra_read_route;  }  void vnc_zebra_destroy(void)  | 
