[DTrace-devel] [PATCH] Add 'endianness conversion' BPF instruction macro

eugene.loh at oracle.com eugene.loh at oracle.com
Wed Jul 7 13:46:39 PDT 2021


From: Eugene Loh <eugene.loh at oracle.com>

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 include/bpf_asm.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/bpf_asm.h b/include/bpf_asm.h
index cac60c24..11e8ad93 100644
--- a/include/bpf_asm.h
+++ b/include/bpf_asm.h
@@ -36,6 +36,15 @@
 		.imm = 0						\
 	})
 
+#define BPF_END_REG(dst, dir, sz)					\
+	((struct bpf_insn) {						\
+		.code = BPF_ALU | BPF_END | (dir),			\
+		.dst_reg = (dst),					\
+		.src_reg = 0,						\
+		.off = 0,						\
+		.imm = (sz)						\
+	})
+
 #define BPF_NEG_REG(dst)						\
 	((struct bpf_insn) {						\
 		.code = BPF_ALU64 | BPF_NEG,				\
-- 
2.18.4




More information about the DTrace-devel mailing list