17 #include <linux/module.h>
18 #include <linux/random.h>
36 ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
37 spin_lock(&ilb->
lock);
38 __sk_nulls_add_node_rcu(sk, &ilb->
head);
39 spin_unlock(&ilb->
lock);
45 sk->sk_hash = hash = inet6_sk_ehashfn(sk);
47 lock = inet_ehash_lockp(hashinfo, hash);
49 __sk_nulls_add_node_rcu(sk, list);
51 WARN_ON(sk->sk_hash != tw->tw_hash);
57 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
82 unsigned int hash = inet6_ehashfn(net, daddr, hnum, saddr, sport);
91 if (
INET6_MATCH(sk, net, hash, saddr, daddr, ports, dif)) {
94 if (!
INET6_MATCH(sk, net, hash, saddr, daddr, ports, dif)) {
101 if (get_nulls_value(node) != slot)
119 if (get_nulls_value(node) != slot)
128 static inline int compute_score(
struct sock *
sk,
struct net *
net,
129 const unsigned short hnum,
135 if (net_eq(sock_net(sk), net) && inet_sk(sk)->inet_num == hnum &&
141 if (!ipv6_addr_equal(&np->
rcv_saddr, daddr))
145 if (sk->sk_bound_dev_if) {
146 if (sk->sk_bound_dev_if != dif)
156 const unsigned short hnum,
const int dif)
162 unsigned int hash = inet_lhashfn(net, hnum);
170 score = compute_score(sk, net, hnum, daddr, dif);
171 if (score > hiscore) {
186 else if (
unlikely(compute_score(result, net, hnum, daddr,
206 sk = __inet6_lookup(net, hashinfo, saddr, sport, daddr,
ntohs(dport), dif);
223 const int dif = sk->sk_bound_dev_if;
225 struct net *net = sock_net(sk);
226 const unsigned int hash = inet6_ehashfn(net, daddr, lport, saddr,
242 if (twsk_unique(sk, sk2, twp))
252 if (
INET6_MATCH(sk2, net, hash, saddr, daddr, ports, dif))
263 __sk_nulls_add_node_rcu(sk, &head->
chain);
271 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
288 static inline u32 inet6_sk_port_offset(
const struct sock *sk)
290 const struct inet_sock *inet = inet_sk(sk);