summaryrefslogtreecommitdiffstats
path: root/sharpd/sharp_zebra.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2024-01-19 21:13:49 +0100
committerDonald Sharp <sharpd@nvidia.com>2024-01-22 18:19:20 +0100
commit01cb1fb82c54ba54288151e567f2b67c2726526f (patch)
tree2af52fd1c08bb41ae075b5bc1757dd5560d2abac /sharpd/sharp_zebra.c
parentlib, nhrpd: Move neighbor reg/unreg to lib/zclient.c (diff)
downloadfrr-01cb1fb82c54ba54288151e567f2b67c2726526f.tar.xz
frr-01cb1fb82c54ba54288151e567f2b67c2726526f.zip
sharpd: Allow sharpd to listen to neighbor events
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'sharpd/sharp_zebra.c')
-rw-r--r--sharpd/sharp_zebra.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index cbfa0d1cc..6588300da 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -989,6 +989,41 @@ static int sharp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS)
return 0;
}
+static int sharp_zebra_process_neigh(ZAPI_CALLBACK_ARGS)
+{
+ union sockunion addr = {}, lladdr = {};
+ struct zapi_neigh_ip api = {};
+ struct interface *ifp;
+
+ zlog_debug("Received a neighbor event");
+ zclient_neigh_ip_decode(zclient->ibuf, &api);
+
+ if (api.ip_in.ipa_type == AF_UNSPEC)
+ 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));
+
+ sockunion_family(&lladdr) = api.ip_out.ipa_type;
+ if (api.ip_out.ipa_type != AF_UNSPEC)
+ memcpy((uint8_t *)sockunion_get_addr(&lladdr),
+ &api.ip_out.ip.addr,
+ family2addrsize(api.ip_out.ipa_type));
+ ifp = if_lookup_by_index(api.index, vrf_id);
+ if (!ifp) {
+ zlog_debug("Failed to lookup interface for neighbor entry: %u for %u",
+ api.index, vrf_id);
+ return 0;
+ }
+
+ zlog_debug("Received: %s %pSU dev %s lladr %pSU",
+ (cmd = ZEBRA_NEIGH_ADDED) ? "NEW" : "DEL", &addr, ifp->name,
+ &lladdr);
+
+ return 0;
+}
+
int sharp_zebra_send_interface_protodown(struct interface *ifp, bool down)
{
zlog_debug("Sending zebra to set %s protodown %s", ifp->name,
@@ -1059,6 +1094,12 @@ int sharp_zebra_send_tc_filter_rate(struct interface *ifp,
return 0;
}
+void sharp_zebra_register_neigh(vrf_id_t vrf_id, afi_t afi, bool reg)
+{
+ zclient_register_neigh(zclient, vrf_id, afi, reg);
+}
+
+
static zclient_handler *const sharp_handlers[] = {
[ZEBRA_INTERFACE_ADDRESS_ADD] = interface_address_add,
[ZEBRA_INTERFACE_ADDRESS_DELETE] = interface_address_delete,
@@ -1070,6 +1111,8 @@ static zclient_handler *const sharp_handlers[] = {
[ZEBRA_OPAQUE_NOTIFY] = sharp_opq_notify_handler,
[ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK] =
sharp_zebra_process_srv6_locator_chunk,
+ [ZEBRA_NEIGH_ADDED] = sharp_zebra_process_neigh,
+ [ZEBRA_NEIGH_REMOVED] = sharp_zebra_process_neigh,
};
void sharp_zebra_init(void)