Refactoring: combine filter bytecode attach functions
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 1 Nov 2021 18:16:07 +0000 (14:16 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 1 Nov 2021 19:04:35 +0000 (15:04 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idd9f50a2e2fc38b16732ada4a33dba4ba14258d8

include/lttng/events-internal.h
src/lttng-abi.c
src/lttng-events.c

index 19e188153a47e359595062440fe64f297cecee40..a9121a1b8c4f5d1470986f3fbf6072e82830cee5 100644 (file)
@@ -799,10 +799,7 @@ int lttng_event_notifier_enabler_enable(
 int lttng_event_notifier_enabler_disable(
                struct lttng_event_notifier_enabler *event_notifier_enabler);
 
-int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_recorder_enabler *event_enabler,
-               struct lttng_kernel_abi_filter_bytecode __user *bytecode);
-int lttng_event_notifier_enabler_attach_filter_bytecode(
-               struct lttng_event_notifier_enabler *event_notifier_enabler,
+int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler_common *event_enabler,
                struct lttng_kernel_abi_filter_bytecode __user *bytecode);
 int lttng_event_notifier_enabler_attach_capture_bytecode(
                struct lttng_event_notifier_enabler *event_notifier_enabler,
index 2fec42378c4a97f858af8c0c97b4e195e4a19ebf..6a1954d3e918c6be6b5a2317459bf15fbc20cb26 100644 (file)
@@ -1991,8 +1991,7 @@ long lttng_event_notifier_enabler_ioctl(struct file *file, unsigned int cmd, uns
        case LTTNG_KERNEL_ABI_DISABLE:
                return lttng_event_notifier_enabler_disable(event_notifier_enabler);
        case LTTNG_KERNEL_ABI_FILTER:
-               return lttng_event_notifier_enabler_attach_filter_bytecode(
-                               event_notifier_enabler,
+               return lttng_event_enabler_attach_filter_bytecode(&event_notifier_enabler->parent,
                        (struct lttng_kernel_abi_filter_bytecode __user *) arg);
        case LTTNG_KERNEL_ABI_CAPTURE:
                return lttng_event_notifier_enabler_attach_capture_bytecode(
@@ -2720,8 +2719,7 @@ long lttng_event_recorder_enabler_ioctl(struct file *file, unsigned int cmd, uns
        case LTTNG_KERNEL_ABI_DISABLE:
                return lttng_event_enabler_disable(event_enabler);
        case LTTNG_KERNEL_ABI_FILTER:
-               return lttng_event_enabler_attach_filter_bytecode(
-                       event_enabler,
+               return lttng_event_enabler_attach_filter_bytecode(&event_enabler->parent,
                        (struct lttng_kernel_abi_filter_bytecode __user *) arg);
        case LTTNG_KERNEL_ABI_ADD_CALLSITE:
                return -EINVAL;
index 5bd357fcf30b1b46adc8752e7d6741f865c67663..ffec2b85b24cc319f9efc1007106dd21527aff2b 100644 (file)
@@ -2554,16 +2554,33 @@ error_free:
        return ret;
 }
 
-int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_recorder_enabler *event_enabler,
+int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler_common *event_enabler,
                struct lttng_kernel_abi_filter_bytecode __user *bytecode)
 {
        int ret;
-       ret = lttng_enabler_attach_filter_bytecode(
-               lttng_event_recorder_enabler_as_enabler(event_enabler), bytecode);
+       ret = lttng_enabler_attach_filter_bytecode(event_enabler, bytecode);
        if (ret)
                goto error;
 
-       lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent.session);
+       switch (event_enabler->enabler_type) {
+       case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+       {
+               struct lttng_event_recorder_enabler *event_recorder_enabler =
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+               lttng_session_lazy_sync_event_enablers(event_recorder_enabler->chan->parent.session);
+               break;
+       }
+       case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
+       {
+               struct lttng_event_notifier_enabler *event_notifier_enabler =
+                       container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
+               lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
+               break;
+       }
+       default:
+               WARN_ON_ONCE(1);
+               return -ENOSYS;
+       }
        return 0;
 
 error:
@@ -2658,25 +2675,6 @@ int lttng_event_notifier_enabler_disable(
        return 0;
 }
 
-int lttng_event_notifier_enabler_attach_filter_bytecode(
-               struct lttng_event_notifier_enabler *event_notifier_enabler,
-               struct lttng_kernel_abi_filter_bytecode __user *bytecode)
-{
-       int ret;
-
-       ret = lttng_enabler_attach_filter_bytecode(
-               lttng_event_notifier_enabler_as_enabler(event_notifier_enabler),
-               bytecode);
-       if (ret)
-               goto error;
-
-       lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
-       return 0;
-
-error:
-       return ret;
-}
-
 int lttng_event_notifier_enabler_attach_capture_bytecode(
                struct lttng_event_notifier_enabler *event_notifier_enabler,
                struct lttng_kernel_abi_capture_bytecode __user *bytecode)
This page took 0.030661 seconds and 4 git commands to generate.