diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-08 08:55:54 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-10 23:22:14 +0100 |
commit | 2899aac46a8d8d5cf1aa5cbf04f755ef7b9f9643 (patch) | |
tree | 631bea3d4dafc91d7df69ebf2b61b40170f376b9 /src/core/bpf-firewall.c | |
parent | 754499fab2392f8405025aead36ebc79dd59780b (diff) | |
download | systemd-2899aac46a8d8d5cf1aa5cbf04f755ef7b9f9643.tar.gz |
core: constify bpf program arrays
In cases where the programs were modified after being initially declared,
reorder operations so that the declaration is already in final form.
Diffstat (limited to 'src/core/bpf-firewall.c')
-rw-r--r-- | src/core/bpf-firewall.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/bpf-firewall.c b/src/core/bpf-firewall.c index 424162f445..96c1a28b4f 100644 --- a/src/core/bpf-firewall.c +++ b/src/core/bpf-firewall.c @@ -132,7 +132,7 @@ static int add_instructions_for_ip_any( assert(p); - struct bpf_insn insn[] = { + const struct bpf_insn insn[] = { BPF_ALU32_IMM(BPF_OR, BPF_REG_8, verdict), }; @@ -150,7 +150,7 @@ static int bpf_firewall_compile_bpf( bool ip_allow_any, bool ip_deny_any) { - struct bpf_insn pre_insn[] = { + const struct bpf_insn pre_insn[] = { /* * When the eBPF program is entered, R1 contains the address of the skb. * However, R1-R5 are scratch registers that are not preserved when calling @@ -186,7 +186,7 @@ static int bpf_firewall_compile_bpf( * This means that if both ACCESS_DENIED and ACCESS_ALLOWED are set, the packet * is allowed to pass. */ - struct bpf_insn post_insn[] = { + const struct bpf_insn post_insn[] = { BPF_MOV64_IMM(BPF_REG_0, 1), BPF_JMP_IMM(BPF_JNE, BPF_REG_8, ACCESS_DENIED, 1), BPF_MOV64_IMM(BPF_REG_0, 0), @@ -321,7 +321,7 @@ static int bpf_firewall_compile_bpf( * Exit from the eBPF program, R0 contains the verdict. * 0 means the packet is denied, 1 means the packet may pass. */ - struct bpf_insn insn[] = { + const struct bpf_insn insn[] = { BPF_EXIT_INSN() }; @@ -795,7 +795,7 @@ int bpf_firewall_reset_accounting(int map_fd) { static int bpf_firewall_unsupported_reason = 0; int bpf_firewall_supported(void) { - struct bpf_insn trivial[] = { + const struct bpf_insn trivial[] = { BPF_MOV64_IMM(BPF_REG_0, 1), BPF_EXIT_INSN() }; |