]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Add initial zebra tracepoint support
authorDonald Sharp <sharpd@nvidia.com>
Wed, 6 Oct 2021 12:22:48 +0000 (08:22 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 20 Apr 2022 13:39:47 +0000 (09:39 -0400)
Add initial zebra tracepoint support infrastructure
as well as add a frr_zebra:netlink_interface
callback.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/if_netlink.c
zebra/subdir.am
zebra/zebra_trace.c [new file with mode: 0644]
zebra/zebra_trace.h [new file with mode: 0644]

index 873aea236d4addb510ed2f50df628394854e8d0f..9810ede1929ae50ede571e9172ee6194e7944fda 100644 (file)
@@ -75,6 +75,7 @@
 #include "zebra/zebra_evpn_mh.h"
 #include "zebra/zebra_l2.h"
 #include "zebra/netconf_netlink.h"
+#include "zebra/zebra_trace.h"
 
 extern struct zebra_privs_t zserv_privs;
 uint8_t frr_protodown_r_bit = FRR_PROTODOWN_REASON_DEFAULT_BIT;
@@ -965,6 +966,8 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        ns_id_t link_nsid = ns_id;
        uint8_t bypass = 0;
 
+       frrtrace(3, frr_zebra, netlink_interface, h, ns_id, startup);
+
        zns = zebra_ns_lookup(ns_id);
        ifi = NLMSG_DATA(h);
 
index 8cb1237c2239d7b050c00fabafe9ddaa9601add1..a09b895cee289b9d20f26d7caad352e3aa6dd7bb 100644 (file)
@@ -50,7 +50,7 @@ man8 += $(MANBUILD)/frr-zebra.8
 ## endif ZEBRA
 endif
 
-zebra_zebra_LDADD = lib/libfrr.la $(LIBCAP)
+zebra_zebra_LDADD = lib/libfrr.la $(LIBCAP) $(UST_LIBS)
 if HAVE_PROTOBUF3
 zebra_zebra_LDADD += mlag/libmlag_pb.la $(PROTOBUF_C_LIBS)
 zebra/zebra_mlag.$(OBJEXT): mlag/mlag.pb-c.h
@@ -120,6 +120,7 @@ zebra_zebra_SOURCES = \
        zebra/zebra_routemap_nb_config.c \
        zebra/zebra_script.c \
        zebra/zebra_srte.c \
+       zebra/zebra_trace.c \
        zebra/zebra_vrf.c \
        zebra/zebra_vty.c \
        zebra/zebra_vxlan.c \
@@ -191,6 +192,7 @@ noinst_HEADERS += \
        zebra/zebra_router.h \
        zebra/zebra_script.h \
        zebra/zebra_srte.h \
+       zebra/zebra_trace.h \
        zebra/zebra_vrf.h \
        zebra/zebra_vxlan.h \
        zebra/zebra_vxlan_private.h \
diff --git a/zebra/zebra_trace.c b/zebra/zebra_trace.c
new file mode 100644 (file)
index 0000000..fef5ad2
--- /dev/null
@@ -0,0 +1,6 @@
+#define TRACEPOINT_CREATE_PROBES
+#define TRACEPOINT_DEFINE
+
+#include <zebra.h>
+
+#include "zebra_trace.h"
diff --git a/zebra/zebra_trace.h b/zebra/zebra_trace.h
new file mode 100644 (file)
index 0000000..14be95d
--- /dev/null
@@ -0,0 +1,57 @@
+/* Tracing for zebra
+ *
+ * Copyright (C) 2020  NVIDIA Corporation
+ * Donald Sharp
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined(__ZEBRA_TRACE_H__) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define __ZEBRA_TRACE_H__
+
+#include "lib/trace.h"
+
+#ifdef HAVE_LTTNG
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER frr_zebra
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "zebra/zebra_trace.h"
+
+#include <lttng/tracepoint.h>
+
+#include <lib/ns.h>
+#include <lib/table.h>
+
+TRACEPOINT_EVENT(
+       frr_zebra,
+       netlink_interface,
+       TP_ARGS(
+               struct nlmsghdr *, h,
+               ns_id_t, ns_id,
+               int, startup),
+       TP_FIELDS(
+               ctf_integer_hex(intptr_t, h, h)
+               ctf_integer(uint32_t, ns_id, ns_id)
+               ctf_integer(uint32_t, startup, startup)
+               )
+       )
+
+#include <lttng/tracepoint-event.h>
+
+#endif /* HAVE_LTTNG */
+
+#endif /* __ZEBRA_TRACE_H__ */