aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/inet_hashtables.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-01-31 08:04:45 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-31 22:28:17 -0500
commit5ee31fc1ecdcbc234c8c56dcacef87c8e09909d8 (patch)
tree5fe73acbcf784f9ee326d7d10ae217c7b4eb13ee /net/ipv4/inet_hashtables.c
parent535174efbe0f0454f0595c31b823498c197eeb4f (diff)
[INET]: Consolidate inet(6)_hash_connect.
These two functions are the same except for what they call to "check_established" and "hash" for a socket. This saves half-a-kilo for ipv4 and ipv6. add/remove: 1/0 grow/shrink: 1/4 up/down: 582/-1128 (-546) function old new delta __inet_hash_connect - 577 +577 arp_ignore 108 113 +5 static.hint 8 4 -4 rt_worker_func 376 372 -4 inet6_hash_connect 584 25 -559 inet_hash_connect 586 25 -561 Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_hashtables.c')
-rw-r--r--net/ipv4/inet_hashtables.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 619c63c6948a..b93d40ff6ef4 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -348,11 +348,11 @@ void __inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk)
348} 348}
349EXPORT_SYMBOL_GPL(__inet_hash); 349EXPORT_SYMBOL_GPL(__inet_hash);
350 350
351/* 351int __inet_hash_connect(struct inet_timewait_death_row *death_row,
352 * Bind a port for a connect operation and hash it. 352 struct sock *sk,
353 */ 353 int (*check_established)(struct inet_timewait_death_row *,
354int inet_hash_connect(struct inet_timewait_death_row *death_row, 354 struct sock *, __u16, struct inet_timewait_sock **),
355 struct sock *sk) 355 void (*hash)(struct inet_hashinfo *, struct sock *))
356{ 356{
357 struct inet_hashinfo *hinfo = death_row->hashinfo; 357 struct inet_hashinfo *hinfo = death_row->hashinfo;
358 const unsigned short snum = inet_sk(sk)->num; 358 const unsigned short snum = inet_sk(sk)->num;
@@ -385,9 +385,8 @@ int inet_hash_connect(struct inet_timewait_death_row *death_row,
385 BUG_TRAP(!hlist_empty(&tb->owners)); 385 BUG_TRAP(!hlist_empty(&tb->owners));
386 if (tb->fastreuse >= 0) 386 if (tb->fastreuse >= 0)
387 goto next_port; 387 goto next_port;
388 if (!__inet_check_established(death_row, 388 if (!check_established(death_row, sk,
389 sk, port, 389 port, &tw))
390 &tw))
391 goto ok; 390 goto ok;
392 goto next_port; 391 goto next_port;
393 } 392 }
@@ -415,7 +414,7 @@ ok:
415 inet_bind_hash(sk, tb, port); 414 inet_bind_hash(sk, tb, port);
416 if (sk_unhashed(sk)) { 415 if (sk_unhashed(sk)) {
417 inet_sk(sk)->sport = htons(port); 416 inet_sk(sk)->sport = htons(port);
418 __inet_hash_nolisten(hinfo, sk); 417 hash(hinfo, sk);
419 } 418 }
420 spin_unlock(&head->lock); 419 spin_unlock(&head->lock);
421 420
@@ -432,17 +431,28 @@ ok:
432 tb = inet_csk(sk)->icsk_bind_hash; 431 tb = inet_csk(sk)->icsk_bind_hash;
433 spin_lock_bh(&head->lock); 432 spin_lock_bh(&head->lock);
434 if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { 433 if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) {
435 __inet_hash_nolisten(hinfo, sk); 434 hash(hinfo, sk);
436 spin_unlock_bh(&head->lock); 435 spin_unlock_bh(&head->lock);
437 return 0; 436 return 0;
438 } else { 437 } else {
439 spin_unlock(&head->lock); 438 spin_unlock(&head->lock);
440 /* No definite answer... Walk to established hash table */ 439 /* No definite answer... Walk to established hash table */
441 ret = __inet_check_established(death_row, sk, snum, NULL); 440 ret = check_established(death_row, sk, snum, NULL);
442out: 441out:
443 local_bh_enable(); 442 local_bh_enable();
444 return ret; 443 return ret;
445 } 444 }
446} 445}
446EXPORT_SYMBOL_GPL(__inet_hash_connect);
447
448/*
449 * Bind a port for a connect operation and hash it.
450 */
451int inet_hash_connect(struct inet_timewait_death_row *death_row,
452 struct sock *sk)
453{
454 return __inet_hash_connect(death_row, sk,
455 __inet_check_established, __inet_hash_nolisten);
456}
447 457
448EXPORT_SYMBOL_GPL(inet_hash_connect); 458EXPORT_SYMBOL_GPL(inet_hash_connect);