Commit 45c7fffa authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller

bpf: use skb_pkt_type_ok helper in bpf_skb_change_type

Since we have a skb_pkt_type_ok() helper for checking the type before
mangling, make use of it instead of open coding. Follow-up to commit
8b10cab6 ("net: simplify and make pkt_type_ok() available for other
users") that came in after d2485c42 ("bpf: add bpf_skb_change_type
helper").
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b3404022
...@@ -1976,8 +1976,8 @@ static u64 bpf_skb_change_type(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) ...@@ -1976,8 +1976,8 @@ static u64 bpf_skb_change_type(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
u32 pkt_type = r2; u32 pkt_type = r2;
/* We only allow a restricted subset to be changed for now. */ /* We only allow a restricted subset to be changed for now. */
if (unlikely(skb->pkt_type > PACKET_OTHERHOST || if (unlikely(!skb_pkt_type_ok(skb->pkt_type) ||
pkt_type > PACKET_OTHERHOST)) !skb_pkt_type_ok(pkt_type)))
return -EINVAL; return -EINVAL;
skb->pkt_type = pkt_type; skb->pkt_type = pkt_type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment