aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2018-10-15 16:08:39 -0700
committerAlexei Starovoitov <ast@kernel.org>2018-10-15 16:08:40 -0700
commit7d1f12b8b2abab0a7af240b89b5ad68bf7f183e7 (patch)
treec2c999f53cdc4e8cb346d825b2d64af9a4056dea /net/core
parentMerge branch 'sockmap_and_ktls' (diff)
parentbpf: Fix IPv6 dport byte-order in bpf_sk_lookup (diff)
downloadlinux-dev-7d1f12b8b2abab0a7af240b89b5ad68bf7f183e7.tar.xz
linux-dev-7d1f12b8b2abab0a7af240b89b5ad68bf7f183e7.zip
Merge branch 'ipv6_sk_lookup_fixes'
Joe Stringer says: ==================== This series includes a couple of fixups for the IPv6 socket lookup helper, to make the API more consistent (always supply all arguments in network byte-order) and to allow its use when IPv6 is compiled as a module. ==================== Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/filter.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index 0f5260b04bfe..2e1476536b92 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4717,21 +4717,24 @@ static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple,
sk = __udp4_lib_lookup(net, src4, tuple->ipv4.sport,
dst4, tuple->ipv4.dport,
dif, sdif, &udp_table, skb);
-#if IS_REACHABLE(CONFIG_IPV6)
+#if IS_ENABLED(CONFIG_IPV6)
} else {
struct in6_addr *src6 = (struct in6_addr *)&tuple->ipv6.saddr;
struct in6_addr *dst6 = (struct in6_addr *)&tuple->ipv6.daddr;
+ u16 hnum = ntohs(tuple->ipv6.dport);
int sdif = inet6_sdif(skb);
if (proto == IPPROTO_TCP)
sk = __inet6_lookup(net, &tcp_hashinfo, skb, 0,
src6, tuple->ipv6.sport,
- dst6, tuple->ipv6.dport,
+ dst6, hnum,
dif, sdif, &refcounted);
- else
- sk = __udp6_lib_lookup(net, src6, tuple->ipv6.sport,
- dst6, tuple->ipv6.dport,
- dif, sdif, &udp_table, skb);
+ else if (likely(ipv6_bpf_stub))
+ sk = ipv6_bpf_stub->udp6_lib_lookup(net,
+ src6, tuple->ipv6.sport,
+ dst6, hnum,
+ dif, sdif,
+ &udp_table, skb);
#endif
}