Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d1f12b8 authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

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: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents d04fb13c 5ef0ae84
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -265,6 +265,11 @@ extern const struct ipv6_stub *ipv6_stub __read_mostly;
struct ipv6_bpf_stub {
	int (*inet6_bind)(struct sock *sk, struct sockaddr *uaddr, int addr_len,
			  bool force_bind_address_no_port, bool with_lock);
	struct sock *(*udp6_lib_lookup)(struct net *net,
					const struct in6_addr *saddr, __be16 sport,
					const struct in6_addr *daddr, __be16 dport,
					int dif, int sdif, struct udp_table *tbl,
					struct sk_buff *skb);
};
extern const struct ipv6_bpf_stub *ipv6_bpf_stub __read_mostly;

+9 −6
Original line number Diff line number Diff line
@@ -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
	}

+1 −0
Original line number Diff line number Diff line
@@ -901,6 +901,7 @@ static const struct ipv6_stub ipv6_stub_impl = {

static const struct ipv6_bpf_stub ipv6_bpf_stub_impl = {
	.inet6_bind = __inet6_bind,
	.udp6_lib_lookup = __udp6_lib_lookup,
};

static int __init inet6_init(void)