bpf: Simplify insn rewrite on BPF_READ __sk_buff->tstamp
authorMartin KaFai Lau <kafai@fb.com>
Wed, 9 Mar 2022 09:04:56 +0000 (01:04 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 10 Mar 2022 21:57:05 +0000 (22:57 +0100)
commit539de9328e3ab444efe51ddc7416ce2a3f0f23b2
treef072bd14ec814bc1f408d924b7c138a753c215be
parent3b5d4ddf8fe1f60082513f94bae586ac80188a03
bpf: Simplify insn rewrite on BPF_READ __sk_buff->tstamp

The skb->tc_at_ingress and skb->mono_delivery_time are at the same
byte offset.  Thus, only one BPF_LDX_MEM(BPF_B) is needed
and both bits can be tested together.

/* BPF_READ: a = __sk_buff->tstamp */
if (skb->tc_at_ingress && skb->mono_delivery_time)
a = 0;
else
a = skb->tstamp;

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220309090456.3711530-1-kafai@fb.com
net/core/filter.c