diff options
author | Russ White <russ@riw.us> | 2021-10-26 17:33:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-26 17:33:44 +0200 |
commit | a2b52cbeb43f28daea6363f2fc6962347dfab334 (patch) | |
tree | 7d7b62d44195d08642c826a80720b97635223d6c /nhrpd | |
parent | Merge pull request #9840 from donaldsharp/lu_commands (diff) | |
parent | *: convert zclient callbacks to table (diff) | |
download | frr-a2b52cbeb43f28daea6363f2fc6962347dfab334.tar.xz frr-a2b52cbeb43f28daea6363f2fc6962347dfab334.zip |
Merge pull request #9854 from opensourcerouting/zapi-call-table
*: convert zclient callbacks to table
Diffstat (limited to 'nhrpd')
-rw-r--r-- | nhrpd/netlink_arp.c | 9 | ||||
-rw-r--r-- | nhrpd/nhrp_route.c | 30 | ||||
-rw-r--r-- | nhrpd/nhrpd.h | 4 |
3 files changed, 25 insertions, 18 deletions
diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c index 0a618056d..3658cb16b 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; } diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c index 12a2fc2fa..76e0978cb 100644 --- a/nhrpd/nhrp_route.c +++ b/nhrpd/nhrp_route.c @@ -366,21 +366,25 @@ static void nhrp_zebra_connected(struct zclient *zclient) nhrp_zebra_register_neigh(VRF_DEFAULT, AFI_IP6, true); } +static zclient_handler *const nhrp_handlers[] = { + [ZEBRA_INTERFACE_ADDRESS_ADD] = nhrp_interface_address_add, + [ZEBRA_INTERFACE_ADDRESS_DELETE] = nhrp_interface_address_delete, + [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = nhrp_route_read, + [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = nhrp_route_read, + [ZEBRA_NHRP_NEIGH_ADDED] = nhrp_neighbor_operation, + [ZEBRA_NHRP_NEIGH_REMOVED] = nhrp_neighbor_operation, + [ZEBRA_NHRP_NEIGH_GET] = nhrp_neighbor_operation, + [ZEBRA_GRE_UPDATE] = nhrp_gre_update, +}; + void nhrp_zebra_init(void) { zebra_rib[AFI_IP] = route_table_init(); zebra_rib[AFI_IP6] = route_table_init(); - zclient = zclient_new(master, &zclient_options_default); + zclient = zclient_new(master, &zclient_options_default, nhrp_handlers, + array_size(nhrp_handlers)); zclient->zebra_connected = nhrp_zebra_connected; - zclient->interface_address_add = nhrp_interface_address_add; - zclient->interface_address_delete = nhrp_interface_address_delete; - zclient->redistribute_route_add = nhrp_route_read; - zclient->redistribute_route_del = nhrp_route_read; - zclient->neighbor_added = nhrp_neighbor_operation; - zclient->neighbor_removed = nhrp_neighbor_operation; - zclient->neighbor_get = nhrp_neighbor_operation; - zclient->gre_update = nhrp_gre_update; zclient_init(zclient, ZEBRA_ROUTE_NHRP, 0, &nhrpd_privs); } @@ -476,7 +480,7 @@ void nhrp_zebra_terminate(void) route_table_finish(zebra_rib[AFI_IP6]); } -void nhrp_gre_update(ZAPI_CALLBACK_ARGS) +int nhrp_gre_update(ZAPI_CALLBACK_ARGS) { struct stream *s; struct nhrp_gre_info gre_info, *val; @@ -485,7 +489,7 @@ void nhrp_gre_update(ZAPI_CALLBACK_ARGS) /* result */ s = zclient->ibuf; if (vrf_id != VRF_DEFAULT) - return; + return 0; /* read GRE information */ STREAM_GETL(s, gre_info.ifindex); @@ -516,7 +520,9 @@ void nhrp_gre_update(ZAPI_CALLBACK_ARGS) ifp ? ifp->name : "<none>", gre_info.ifindex, vrf_id); if (ifp) nhrp_interface_update_nbma(ifp, val); - return; + return 0; + stream_failure: zlog_err("%s(): error reading response ..", __func__); + return -1; } diff --git a/nhrpd/nhrpd.h b/nhrpd/nhrpd.h index 63f1cb97e..753c6e9b2 100644 --- a/nhrpd/nhrpd.h +++ b/nhrpd/nhrpd.h @@ -376,8 +376,8 @@ int nhrp_interface_up(ZAPI_CALLBACK_ARGS); int nhrp_interface_down(ZAPI_CALLBACK_ARGS); int nhrp_interface_address_add(ZAPI_CALLBACK_ARGS); int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS); -void nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS); -void nhrp_gre_update(ZAPI_CALLBACK_ARGS); +int nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS); +int nhrp_gre_update(ZAPI_CALLBACK_ARGS); void nhrp_interface_notify_add(struct interface *ifp, struct notifier_block *n, notifier_fn_t fn); |