[PATCH 5/7] bpf/validate: add get current event API

Marat Khalili marat.khalili at huawei.com
Fri Sep 11 12:40:03 CEST 2026


Add API for retrieving the event currently processed by a callback.
Useful when single callback is registered for multiple events to put
less pressure on the context argument.

Signed-off-by: Marat Khalili <marat.khalili at huawei.com>
---
 lib/bpf/bpf_validate_debug.c     | 13 +++++++++++++
 lib/bpf/rte_bpf_validate_debug.h | 13 +++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/lib/bpf/bpf_validate_debug.c b/lib/bpf/bpf_validate_debug.c
index 098a88026d6d..c8e9e5dd9227 100644
--- a/lib/bpf/bpf_validate_debug.c
+++ b/lib/bpf/bpf_validate_debug.c
@@ -43,6 +43,7 @@ struct rte_bpf_validate_debug {
 	const struct bpf_verifier *verifier;
 	const struct rte_bpf_prm_ex *bpf_prm;
 	struct point_list *breakpoint_lists;
+	enum rte_bpf_validate_debug_event current_event;
 	struct rte_bpf_validate_debug_point *last_point;
 	uint32_t pc;
 	/* Evaluate stage (only tracking `evaluate` part at the moment). */
@@ -236,6 +237,7 @@ debug_trigger_breakpoints(struct rte_bpf_validate_debug *debug, uint32_t pc)
 static int
 debug_send_event(struct rte_bpf_validate_debug *debug, debug_event_t event)
 {
+	debug->current_event = event;
 	return debug_points_call_back(debug, &debug->catchpoint_lists[event]);
 }
 
@@ -342,6 +344,17 @@ rte_bpf_validate_debug_get_ins(const struct rte_bpf_validate_debug *debug,
 	return 0;
 }
 
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_get_event, 26.11)
+enum rte_bpf_validate_debug_event
+rte_bpf_validate_debug_get_event(const struct rte_bpf_validate_debug *debug)
+{
+	if (debug == NULL)
+		/* Just to be fool-proof, not really required by API. */
+		return -EINVAL;
+
+	return debug->current_event;
+}
+
 RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_get_last_point, 26.07)
 struct rte_bpf_validate_debug_point *
 rte_bpf_validate_debug_get_last_point(const struct rte_bpf_validate_debug *debug)
diff --git a/lib/bpf/rte_bpf_validate_debug.h b/lib/bpf/rte_bpf_validate_debug.h
index f1ee8769d06a..6d4bf53589e0 100644
--- a/lib/bpf/rte_bpf_validate_debug.h
+++ b/lib/bpf/rte_bpf_validate_debug.h
@@ -194,6 +194,19 @@ int
 rte_bpf_validate_debug_get_ins(const struct rte_bpf_validate_debug *debug,
 	const struct ebpf_insn **ins, uint32_t *nb_ins);
 
+/**
+ * Get event currently processed by a catchpoint callback.
+ *
+ * @param debug
+ *   Debug instance.
+ * @return
+ *   Event currently processed by a catchpoint callback.
+ *   Undefined if no event is currently being processed.
+ */
+__rte_experimental
+enum rte_bpf_validate_debug_event
+rte_bpf_validate_debug_get_event(const struct rte_bpf_validate_debug *debug);
+
 /**
  * Get last triggered breakpoint or catchpoint.
  *
-- 
2.43.0



More information about the dev mailing list