2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * Generic INET6 transport hashtables
8 * Authors: Lotsa people, from code originally in tcp
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
16 #include <linux/config.h>
18 #include <linux/module.h>
20 #include <net/inet_connection_sock.h>
21 #include <net/inet_hashtables.h>
22 #include <net/inet6_hashtables.h>
24 struct sock
*inet6_lookup_listener(struct inet_hashinfo
*hashinfo
,
25 const struct in6_addr
*daddr
,
26 const unsigned short hnum
, const int dif
)
29 const struct hlist_node
*node
;
30 struct sock
*result
= NULL
;
31 int score
, hiscore
= 0;
33 read_lock(&hashinfo
->lhash_lock
);
34 sk_for_each(sk
, node
, &hashinfo
->listening_hash
[inet_lhashfn(hnum
)]) {
35 if (inet_sk(sk
)->num
== hnum
&& sk
->sk_family
== PF_INET6
) {
36 const struct ipv6_pinfo
*np
= inet6_sk(sk
);
39 if (!ipv6_addr_any(&np
->rcv_saddr
)) {
40 if (!ipv6_addr_equal(&np
->rcv_saddr
, daddr
))
44 if (sk
->sk_bound_dev_if
) {
45 if (sk
->sk_bound_dev_if
!= dif
)
53 if (score
> hiscore
) {
61 read_unlock(&hashinfo
->lhash_lock
);
65 EXPORT_SYMBOL_GPL(inet6_lookup_listener
);
67 struct sock
*inet6_lookup(struct inet_hashinfo
*hashinfo
,
68 const struct in6_addr
*saddr
, const u16 sport
,
69 const struct in6_addr
*daddr
, const u16 dport
,
75 sk
= __inet6_lookup(hashinfo
, saddr
, sport
, daddr
, ntohs(dport
), dif
);
81 EXPORT_SYMBOL_GPL(inet6_lookup
);