Commit 2064a132 authored by Tobias Klauser's avatar Tobias Klauser Committed by Daniel Borkmann

bpf: Omit superfluous address family check in __bpf_skc_lookup

family is only set to either AF_INET or AF_INET6 based on len. In all
other cases we return early. Thus the check against AF_UNSPEC can be
omitted.
Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220630082618.15649-1-tklauser@distanz.ch
parent b0d93b44
...@@ -6516,8 +6516,8 @@ __bpf_skc_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len, ...@@ -6516,8 +6516,8 @@ __bpf_skc_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
u64 flags) u64 flags)
{ {
struct sock *sk = NULL; struct sock *sk = NULL;
u8 family = AF_UNSPEC;
struct net *net; struct net *net;
u8 family;
int sdif; int sdif;
if (len == sizeof(tuple->ipv4)) if (len == sizeof(tuple->ipv4))
...@@ -6527,8 +6527,7 @@ __bpf_skc_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len, ...@@ -6527,8 +6527,7 @@ __bpf_skc_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
else else
return NULL; return NULL;
if (unlikely(family == AF_UNSPEC || flags || if (unlikely(flags || !((s32)netns_id < 0 || netns_id <= S32_MAX)))
!((s32)netns_id < 0 || netns_id <= S32_MAX)))
goto out; goto out;
if (family == AF_INET) if (family == AF_INET)
......
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