inet_hashtables.c (39d8cda76cfb1178455f9d196b39e773878e6c05) inet_hashtables.c (3b1e0a655f8eba44ab1ee2a1068d169ccfb853b9)
1/*
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.
5 *
6 * Generic INET transport hashtables
7 *
8 * Authors: Lotsa people, from code originally in tcp

--- 125 unchanged lines hidden (view full) ---

134{
135 struct sock *result = NULL, *sk;
136 const struct hlist_node *node;
137 int hiscore = -1;
138
139 sk_for_each(sk, node, head) {
140 const struct inet_sock *inet = inet_sk(sk);
141
1/*
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.
5 *
6 * Generic INET transport hashtables
7 *
8 * Authors: Lotsa people, from code originally in tcp

--- 125 unchanged lines hidden (view full) ---

134{
135 struct sock *result = NULL, *sk;
136 const struct hlist_node *node;
137 int hiscore = -1;
138
139 sk_for_each(sk, node, head) {
140 const struct inet_sock *inet = inet_sk(sk);
141
142 if (sk->sk_net == net && inet->num == hnum &&
142 if (sock_net(sk) == net && inet->num == hnum &&
143 !ipv6_only_sock(sk)) {
144 const __be32 rcv_saddr = inet->rcv_saddr;
145 int score = sk->sk_family == PF_INET ? 1 : 0;
146
147 if (rcv_saddr) {
148 if (rcv_saddr != daddr)
149 continue;
150 score += 2;

--- 26 unchanged lines hidden (view full) ---

177 read_lock(&hashinfo->lhash_lock);
178 head = &hashinfo->listening_hash[inet_lhashfn(hnum)];
179 if (!hlist_empty(head)) {
180 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
181
182 if (inet->num == hnum && !sk->sk_node.next &&
183 (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
184 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
143 !ipv6_only_sock(sk)) {
144 const __be32 rcv_saddr = inet->rcv_saddr;
145 int score = sk->sk_family == PF_INET ? 1 : 0;
146
147 if (rcv_saddr) {
148 if (rcv_saddr != daddr)
149 continue;
150 score += 2;

--- 26 unchanged lines hidden (view full) ---

177 read_lock(&hashinfo->lhash_lock);
178 head = &hashinfo->listening_hash[inet_lhashfn(hnum)];
179 if (!hlist_empty(head)) {
180 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
181
182 if (inet->num == hnum && !sk->sk_node.next &&
183 (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
184 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
185 !sk->sk_bound_dev_if && sk->sk_net == net)
185 !sk->sk_bound_dev_if && sock_net(sk) == net)
186 goto sherry_cache;
187 sk = inet_lookup_listener_slow(net, head, daddr, hnum, dif);
188 }
189 if (sk) {
190sherry_cache:
191 sock_hold(sk);
192 }
193 read_unlock(&hashinfo->lhash_lock);

--- 55 unchanged lines hidden (view full) ---

249 INET_ADDR_COOKIE(acookie, saddr, daddr)
250 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
251 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
252 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
253 rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
254 struct sock *sk2;
255 const struct hlist_node *node;
256 struct inet_timewait_sock *tw;
186 goto sherry_cache;
187 sk = inet_lookup_listener_slow(net, head, daddr, hnum, dif);
188 }
189 if (sk) {
190sherry_cache:
191 sock_hold(sk);
192 }
193 read_unlock(&hashinfo->lhash_lock);

--- 55 unchanged lines hidden (view full) ---

249 INET_ADDR_COOKIE(acookie, saddr, daddr)
250 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
251 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
252 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
253 rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
254 struct sock *sk2;
255 const struct hlist_node *node;
256 struct inet_timewait_sock *tw;
257 struct net *net = sk->sk_net;
257 struct net *net = sock_net(sk);
258
259 prefetch(head->chain.first);
260 write_lock(lock);
261
262 /* Check TIME-WAIT sockets first. */
263 sk_for_each(sk2, node, &head->twchain) {
264 tw = inet_twsk(sk2);
265

--- 135 unchanged lines hidden (view full) ---

401 struct sock *, __u16, struct inet_timewait_sock **),
402 void (*hash)(struct sock *sk))
403{
404 struct inet_hashinfo *hinfo = death_row->hashinfo;
405 const unsigned short snum = inet_sk(sk)->num;
406 struct inet_bind_hashbucket *head;
407 struct inet_bind_bucket *tb;
408 int ret;
258
259 prefetch(head->chain.first);
260 write_lock(lock);
261
262 /* Check TIME-WAIT sockets first. */
263 sk_for_each(sk2, node, &head->twchain) {
264 tw = inet_twsk(sk2);
265

--- 135 unchanged lines hidden (view full) ---

401 struct sock *, __u16, struct inet_timewait_sock **),
402 void (*hash)(struct sock *sk))
403{
404 struct inet_hashinfo *hinfo = death_row->hashinfo;
405 const unsigned short snum = inet_sk(sk)->num;
406 struct inet_bind_hashbucket *head;
407 struct inet_bind_bucket *tb;
408 int ret;
409 struct net *net = sk->sk_net;
409 struct net *net = sock_net(sk);
410
411 if (!snum) {
412 int i, remaining, low, high, port;
413 static u32 hint;
414 u32 offset = hint + port_offset;
415 struct hlist_node *node;
416 struct inet_timewait_sock *tw = NULL;
417

--- 89 unchanged lines hidden ---
410
411 if (!snum) {
412 int i, remaining, low, high, port;
413 static u32 hint;
414 u32 offset = hint + port_offset;
415 struct hlist_node *node;
416 struct inet_timewait_sock *tw = NULL;
417

--- 89 unchanged lines hidden ---