Skip to content

Commit

Permalink
Add 'endianness conversion' BPF instruction macro
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Sep 24, 2021
1 parent c39672f commit a7d2234
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion include/bpf_asm.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -36,6 +36,17 @@
.imm = 0 \
})

#define BPF_END_REG(sz, dst, dir) \
((struct bpf_insn) { \
.code = BPF_ALU | BPF_END | (dir), \
.dst_reg = (dst), \
.src_reg = 0, \
.off = 0, \
.imm = (sz) == BPF_DW ? 64 : \
(sz) == BPF_W ? 32 : \
(sz) == BPF_H ? 16 : 0 \
})

#define BPF_NEG_REG(dst) \
((struct bpf_insn) { \
.code = BPF_ALU64 | BPF_NEG, \
Expand Down

0 comments on commit a7d2234

Please sign in to comment.