diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2024-01-19 14:51:34 -0500 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2024-01-22 12:14:59 -0500 |
| commit | a0d38a7ac61ba122e3821fc05a0e7ae98a6cd4a9 (patch) | |
| tree | 9924b9d686d5dad46f816ccc109cebbdfe04dbdd /nhrpd | |
| parent | 275edb5c160a384043e2ad3d8e3eebe709c60bd1 (diff) | |
lib, nhrpd: Move neighbor reg/unreg to lib/zclient.c
This is needed to be generic. Let's make it so.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'nhrpd')
| -rw-r--r-- | nhrpd/netlink_arp.c | 4 | ||||
| -rw-r--r-- | nhrpd/nhrp_route.c | 36 |
2 files changed, 13 insertions, 27 deletions
diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c index c0d77e62d2..88628999ab 100644 --- a/nhrpd/netlink_arp.c +++ b/nhrpd/netlink_arp.c @@ -154,6 +154,10 @@ int nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS) struct zapi_neigh_ip api = {}; zclient_neigh_ip_decode(zclient->ibuf, &api); + + if (api.ip_len != IPV4_MAX_BYTELEN && api.ip_len != 0) + return 0; + if (api.ip_in.ipa_type == AF_UNSPEC) return 0; sockunion_family(&addr) = api.ip_in.ipa_type; diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c index edc3629723..c05a8a3ba2 100644 --- a/nhrpd/nhrp_route.c +++ b/nhrpd/nhrp_route.c @@ -75,25 +75,6 @@ static void nhrp_route_update_zebra(const struct prefix *p, } } -static void nhrp_zebra_register_neigh(vrf_id_t vrf_id, afi_t afi, bool reg) -{ - struct stream *s; - - if (!zclient || zclient->sock < 0) - return; - - s = zclient->obuf; - stream_reset(s); - - zclient_create_header(s, - reg ? ZEBRA_NEIGH_REGISTER - : ZEBRA_NEIGH_UNREGISTER, - vrf_id); - stream_putw(s, afi); - stream_putw_at(s, 0, stream_get_endp(s)); - zclient_send_message(zclient); -} - void nhrp_route_update_nhrp(const struct prefix *p, struct interface *ifp) { struct route_node *rn; @@ -369,8 +350,8 @@ static void nhrp_zebra_connected(struct zclient *zclient) ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT); zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT); - nhrp_zebra_register_neigh(VRF_DEFAULT, AFI_IP, true); - nhrp_zebra_register_neigh(VRF_DEFAULT, AFI_IP6, true); + zclient_register_neigh(zclient, VRF_DEFAULT, AFI_IP, true); + zclient_register_neigh(zclient, VRF_DEFAULT, AFI_IP6, true); } static zclient_handler *const nhrp_handlers[] = { @@ -457,10 +438,11 @@ void nhrp_send_zebra_nbr(union sockunion *in, return; s = zclient->obuf; stream_reset(s); - zclient_neigh_ip_encode(s, out ? ZEBRA_NEIGH_IP_ADD : - ZEBRA_NEIGH_IP_DEL, in, out, - ifp, out ? ZEBRA_NEIGH_STATE_REACHABLE - : ZEBRA_NEIGH_STATE_FAILED); + zclient_neigh_ip_encode(s, out ? ZEBRA_NEIGH_IP_ADD : ZEBRA_NEIGH_IP_DEL, + in, out, ifp, + out ? ZEBRA_NEIGH_STATE_REACHABLE + : ZEBRA_NEIGH_STATE_FAILED, + 0); stream_putw_at(s, 0, stream_get_endp(s)); zclient_send_message(zclient); } @@ -472,8 +454,8 @@ int nhrp_send_zebra_gre_request(struct interface *ifp) void nhrp_zebra_terminate(void) { - nhrp_zebra_register_neigh(VRF_DEFAULT, AFI_IP, false); - nhrp_zebra_register_neigh(VRF_DEFAULT, AFI_IP6, false); + zclient_register_neigh(zclient, VRF_DEFAULT, AFI_IP, false); + zclient_register_neigh(zclient, VRF_DEFAULT, AFI_IP6, false); zclient_stop(zclient); zclient_free(zclient); |
