Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8f3e978 authored by David Miller's avatar David Miller Committed by Daniel Borkmann
Browse files

bpf: Avoid unnecessary instruction in convert_bpf_ld_abs()



'offset' is constant and if it is zero, no need to subtract it
from BPF_REG_TMP.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 4afe60a9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -463,6 +463,7 @@ static bool convert_bpf_ld_abs(struct sock_filter *fp, struct bpf_insn **insnp)
		bool ldx_off_ok = offset <= S16_MAX;

		*insn++ = BPF_MOV64_REG(BPF_REG_TMP, BPF_REG_H);
		if (offset)
			*insn++ = BPF_ALU64_IMM(BPF_SUB, BPF_REG_TMP, offset);
		*insn++ = BPF_JMP_IMM(BPF_JSLT, BPF_REG_TMP,
				      size, 2 + endian + (!ldx_off_ok * 2));