bpf: omit superfluous address family check in __bpf_skc_lookup
Subsystems (4)
PATCH 1/1 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 <[email protected]>
--- net/core/filter.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/core/filter.c +2 -3
@@ -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 )
Signature · 1 line
2.36.1
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 8 lines · On Thu, 30 Jun 2022 10:26:18 +0200 you wrote:
family is only set to either
AF_INETorAF_INET6based on len. In all other cases we return early. Thus the check againstAF_UNSPECcan be omitted.Signed-off-by Tobias Klauser <[email protected]>--- net/core/filter.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Here is the summary with links:
- [bpf-next] bpf: omit superfluous address family check in __bpf_skc_lookup
https://git.kernel.org/bpf/bpf-next/c/2064a132c0de
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html