aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/filter.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2022-06-30 10:26:18 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2022-07-05 11:51:30 +0200
commit2064a132c0de3426d5ba43023200994e0c77e652 (patch)
treec6514f108386fd60ce0450ac34c5ae767036e6e6 /net/core/filter.c
parentselftests/bpf: Skip lsm_cgroup when we don't have trampolines (diff)
downloadlinux-dev-2064a132c0de3426d5ba43023200994e0c77e652.tar.xz
linux-dev-2064a132c0de3426d5ba43023200994e0c77e652.zip
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: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20220630082618.15649-1-tklauser@distanz.ch
Diffstat (limited to 'net/core/filter.c')
-rw-r--r--net/core/filter.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index c6941ab0eb52..4fae91984359 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -6516,8 +6516,8 @@ __bpf_skc_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
u64 flags)
{
struct sock *sk = NULL;
- u8 family = AF_UNSPEC;
struct net *net;
+ u8 family;
int sdif;
if (len == sizeof(tuple->ipv4))
@@ -6527,8 +6527,7 @@ __bpf_skc_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
else
return NULL;
- if (unlikely(family == AF_UNSPEC || flags ||
- !((s32)netns_id < 0 || netns_id <= S32_MAX)))
+ if (unlikely(flags || !((s32)netns_id < 0 || netns_id <= S32_MAX)))
goto out;
if (family == AF_INET)