* [PATCH bpf-next] bpf: Avoid unnecessary instruction in conver_bpf_ld_abs()
@ 2018-11-26 21:42 David Miller
2018-11-26 22:07 ` Daniel Borkmann
0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2018-11-26 21:42 UTC (permalink / raw)
To: daniel; +Cc: ast, netdev
'offset' is constant and if it is zero, no need to subtract it
from BPF_REG_TMP.
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/net/core/filter.c b/net/core/filter.c
index aa274679965d..f50ea971f7a9 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -463,7 +463,8 @@ 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);
- *insn++ = BPF_ALU64_IMM(BPF_SUB, BPF_REG_TMP, offset);
+ 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));
if (ldx_off_ok) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] bpf: Avoid unnecessary instruction in conver_bpf_ld_abs()
2018-11-26 21:42 [PATCH bpf-next] bpf: Avoid unnecessary instruction in conver_bpf_ld_abs() David Miller
@ 2018-11-26 22:07 ` Daniel Borkmann
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2018-11-26 22:07 UTC (permalink / raw)
To: David Miller; +Cc: ast, netdev
On 11/26/2018 10:42 PM, David Miller wrote:
>
> 'offset' is constant and if it is zero, no need to subtract it
> from BPF_REG_TMP.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
Applied to bpf-next, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-27 9:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-26 21:42 [PATCH bpf-next] bpf: Avoid unnecessary instruction in conver_bpf_ld_abs() David Miller
2018-11-26 22:07 ` Daniel Borkmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.