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 /nhrpd/netlink_arp.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 'nhrpd/netlink_arp.c')
| -rw-r--r-- | nhrpd/netlink_arp.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c index 0a618056d5..3658cb16bb 100644 --- a/nhrpd/netlink_arp.c +++ b/nhrpd/netlink_arp.c @@ -147,7 +147,7 @@ void netlink_set_nflog_group(int nlgroup) } } -void nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS) +int nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS) { union sockunion addr = {}, lladdr = {}; struct interface *ifp; @@ -157,7 +157,7 @@ void nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS) zclient_neigh_ip_decode(zclient->ibuf, &api); if (api.ip_in.ipa_type == AF_UNSPEC) - return; + return 0; sockunion_family(&addr) = api.ip_in.ipa_type; memcpy((uint8_t *)sockunion_get_addr(&addr), &api.ip_in.ip.addr, family2addrsize(api.ip_in.ipa_type)); @@ -172,10 +172,10 @@ void nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS) ndm_state = api.ndm_state; if (!ifp) - return; + return 0; c = nhrp_cache_get(ifp, &addr, 0); if (!c) - return; + return 0; debugf(NHRP_DEBUG_KERNEL, "Netlink: %s %pSU dev %s lladdr %pSU nud 0x%x cache used %u type %u", (cmd == ZEBRA_NHRP_NEIGH_GET) @@ -200,4 +200,5 @@ void nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS) : ZEBRA_NEIGH_STATE_FAILED; nhrp_cache_set_used(c, state == ZEBRA_NEIGH_STATE_REACHABLE); } + return 0; } |
