aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/acl/elog_acl_trace.h
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2018-03-21 19:53:39 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-22 20:50:09 +0000
commit94f9a6de3f706243d138e05b63fef1d5c8174f6c (patch)
tree5e50ccf062229f3d60b9ec656c6ca53cae0c5455 /src/plugins/acl/elog_acl_trace.h
parent8ced6e1a53d6a828debe7dc2396c7eb7d6866e4a (diff)
acl-plugin: implement ACL lookup contexts for "ACL as a service" use by other plugins
This code implements the functionality required for other plugins wishing to perform ACL lookups in the contexts of their choice, rather than only in the context of the interface in/out. The lookups are the stateless ACLs - there is no concept of "direction" within the context, hence no concept of "connection" either. The plugins need to include the The file acl_lookup_context.md has more info. Change-Id: I91ba97428cc92b24d1517e808dc2fd8e56ea2f8d Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/plugins/acl/elog_acl_trace.h')
-rw-r--r--src/plugins/acl/elog_acl_trace.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/src/plugins/acl/elog_acl_trace.h b/src/plugins/acl/elog_acl_trace.h
new file mode 100644
index 00000000000..0c4f68f7b0f
--- /dev/null
+++ b/src/plugins/acl/elog_acl_trace.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ELOG_ACL_TRACE_H_
+#define _ELOG_ACL_TRACE_H_
+
+
+/* use like: elog_acl_cond_trace_X1(am, (x < 0), "foobar: %d", "i4", int32_value); */
+
+#define elog_acl_cond_trace_X1(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1) \
+do { \
+ if (trace_cond) { \
+ CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1)]; } *static_check); \
+ u16 thread_index = os_get_thread_index (); \
+ vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \
+ ELOG_TYPE_DECLARE (e) = \
+ { \
+ .format = "(%02d) " acl_elog_trace_format_label, \
+ .format_args = "i2" acl_elog_trace_format_args, \
+ }; \
+ CLIB_PACKED(struct \
+ { \
+ u16 thread; \
+ typeof(acl_elog_val1) val1; \
+ }) *ed; \
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \
+ ed->thread = thread_index; \
+ ed->val1 = acl_elog_val1; \
+ } \
+} while (0)
+
+
+/* use like: elog_acl_cond_trace_X2(am, (x<0), "foobar: %d some u64: %lu", "i4i8", int32_value, int64_value); */
+
+#define elog_acl_cond_trace_X2(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, \
+ acl_elog_val1, acl_elog_val2) \
+do { \
+ if (trace_cond) { \
+ CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2)]; } *static_check); \
+ u16 thread_index = os_get_thread_index (); \
+ vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \
+ ELOG_TYPE_DECLARE (e) = \
+ { \
+ .format = "(%02d) " acl_elog_trace_format_label, \
+ .format_args = "i2" acl_elog_trace_format_args, \
+ }; \
+ CLIB_PACKED(struct \
+ { \
+ u16 thread; \
+ typeof(acl_elog_val1) val1; \
+ typeof(acl_elog_val2) val2; \
+ }) *ed; \
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \
+ ed->thread = thread_index; \
+ ed->val1 = acl_elog_val1; \
+ ed->val2 = acl_elog_val2; \
+ } \
+} while (0)
+
+
+/* use like: elog_acl_cond_trace_X3(am, (x<0), "foobar: %d some u64 %lu baz: %d", "i4i8i4", int32_value, u64_value, int_value); */
+
+#define elog_acl_cond_trace_X3(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, \
+ acl_elog_val2, acl_elog_val3) \
+do { \
+ if (trace_cond) { \
+ CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2) \
+ - sizeof(acl_elog_val3)]; } *static_check); \
+ u16 thread_index = os_get_thread_index (); \
+ vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \
+ ELOG_TYPE_DECLARE (e) = \
+ { \
+ .format = "(%02d) " acl_elog_trace_format_label, \
+ .format_args = "i2" acl_elog_trace_format_args, \
+ }; \
+ CLIB_PACKED(struct \
+ { \
+ u16 thread; \
+ typeof(acl_elog_val1) val1; \
+ typeof(acl_elog_val2) val2; \
+ typeof(acl_elog_val3) val3; \
+ }) *ed; \
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \
+ ed->thread = thread_index; \
+ ed->val1 = acl_elog_val1; \
+ ed->val2 = acl_elog_val2; \
+ ed->val3 = acl_elog_val3; \
+ } \
+} while (0)
+
+
+/* use like: elog_acl_cond_trace_X4(am, (x<0), "foobar: %d some int %d baz: %d bar: %d", "i4i4i4i4", int32_value, int32_value2, int_value, int_value); */
+
+#define elog_acl_cond_trace_X4(am, trace_cond, acl_elog_trace_format_label, acl_elog_trace_format_args, acl_elog_val1, \
+ acl_elog_val2, acl_elog_val3, acl_elog_val4) \
+do { \
+ if (trace_cond) { \
+ CLIB_UNUSED(struct { u8 available_space[18 - sizeof(acl_elog_val1) - sizeof(acl_elog_val2) \
+ - sizeof(acl_elog_val3) -sizeof(acl_elog_val4)]; } *static_check); \
+ u16 thread_index = os_get_thread_index (); \
+ vlib_worker_thread_t * w = vlib_worker_threads + thread_index; \
+ ELOG_TYPE_DECLARE (e) = \
+ { \
+ .format = "(%02d) " acl_elog_trace_format_label, \
+ .format_args = "i2" acl_elog_trace_format_args, \
+ }; \
+ CLIB_PACKED(struct \
+ { \
+ u16 thread; \
+ typeof(acl_elog_val1) val1; \
+ typeof(acl_elog_val2) val2; \
+ typeof(acl_elog_val3) val3; \
+ typeof(acl_elog_val4) val4; \
+ }) *ed; \
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); \
+ ed->thread = thread_index; \
+ ed->val1 = acl_elog_val1; \
+ ed->val2 = acl_elog_val2; \
+ ed->val3 = acl_elog_val3; \
+ ed->val4 = acl_elog_val4; \
+ } \
+} while (0)
+
+
+#endif