diff options
| author | Vlad Yasevich <vladislav.yasevich@hp.com> | 2007-11-09 11:43:40 -0500 |
|---|---|---|
| committer | Vlad Yasevich <vladislav.yasevich@hp.com> | 2007-11-09 11:43:40 -0500 |
| commit | d970dbf8455eb1b8cebd3cde6e18f73dd1b3ce38 (patch) | |
| tree | e7866d392c3654a379492ca78249231be47401a4 | |
| parent | 123ed979eaa8de0dd2422862d247469eda0bd645 (diff) | |
SCTP: Convert custom hash lists to use hlist.
Convert the custom hash list traversals to use hlist functions.
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
| -rw-r--r-- | include/net/sctp/sctp.h | 3 | ||||
| -rw-r--r-- | include/net/sctp/structs.h | 10 | ||||
| -rw-r--r-- | net/sctp/endpointola.c | 3 | ||||
| -rw-r--r-- | net/sctp/input.c | 43 | ||||
| -rw-r--r-- | net/sctp/proc.c | 6 | ||||
| -rw-r--r-- | net/sctp/protocol.c | 6 | ||||
| -rw-r--r-- | net/sctp/socket.c | 14 |
7 files changed, 32 insertions, 53 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index 70827305f5..67c997cecf 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
| @@ -665,6 +665,9 @@ static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag) | |||
| 665 | return (h & (sctp_assoc_hashsize-1)); | 665 | return (h & (sctp_assoc_hashsize-1)); |
| 666 | } | 666 | } |
| 667 | 667 | ||
| 668 | #define sctp_for_each_hentry(epb, node, head) \ | ||
| 669 | hlist_for_each_entry(epb, node, head, node) | ||
| 670 | |||
| 668 | /* Is a socket of this style? */ | 671 | /* Is a socket of this style? */ |
| 669 | #define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style)) | 672 | #define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style)) |
| 670 | static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style) | 673 | static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style) |
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 44f2672859..eb3113c38a 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
| @@ -100,20 +100,19 @@ struct crypto_hash; | |||
| 100 | struct sctp_bind_bucket { | 100 | struct sctp_bind_bucket { |
| 101 | unsigned short port; | 101 | unsigned short port; |
| 102 | unsigned short fastreuse; | 102 | unsigned short fastreuse; |
| 103 | struct sctp_bind_bucket *next; | 103 | struct hlist_node node; |
| 104 | struct sctp_bind_bucket **pprev; | ||
| 105 | struct hlist_head owner; | 104 | struct hlist_head owner; |
| 106 | }; | 105 | }; |
| 107 | 106 | ||
| 108 | struct sctp_bind_hashbucket { | 107 | struct sctp_bind_hashbucket { |
| 109 | spinlock_t lock; | 108 | spinlock_t lock; |
| 110 | struct sctp_bind_bucket *chain; | 109 | struct hlist_head chain; |
| 111 | }; | 110 | }; |
| 112 | 111 | ||
| 113 | /* Used for hashing all associations. */ | 112 | /* Used for hashing all associations. */ |
| 114 | struct sctp_hashbucket { | 113 | struct sctp_hashbucket { |
| 115 | rwlock_t lock; | 114 | rwlock_t lock; |
| 116 | struct sctp_ep_common *chain; | 115 | struct hlist_head chain; |
| 117 | } __attribute__((__aligned__(8))); | 116 | } __attribute__((__aligned__(8))); |
| 118 | 117 | ||
| 119 | 118 | ||
| @@ -1230,8 +1229,7 @@ typedef enum { | |||
| 1230 | 1229 | ||
| 1231 | struct sctp_ep_common { | 1230 | struct sctp_ep_common { |
| 1232 | /* Fields to help us manage our entries in the hash tables. */ | 1231 | /* Fields to help us manage our entries in the hash tables. */ |
| 1233 | struct sctp_ep_common *next; | 1232 | struct hlist_node node; |
| 1234 | struct sctp_ep_common **pprev; | ||
| 1235 | int hashent; | 1233 | int hashent; |
| 1236 | 1234 | ||
| 1237 | /* Runtime type information. What kind of endpoint is this? */ | 1235 | /* Runtime type information. What kind of endpoint is this? */ |
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 68f0556efc..de6f505d6f 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c | |||
| @@ -332,6 +332,7 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( | |||
| 332 | struct sctp_transport *t = NULL; | 332 | struct sctp_transport *t = NULL; |
| 333 | struct sctp_hashbucket *head; | 333 | struct sctp_hashbucket *head; |
| 334 | struct sctp_ep_common *epb; | 334 | struct sctp_ep_common *epb; |
| 335 | struct hlist_node *node; | ||
| 335 | int hash; | 336 | int hash; |
| 336 | int rport; | 337 | int rport; |
| 337 | 338 | ||
| @@ -341,7 +342,7 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( | |||
| 341 | hash = sctp_assoc_hashfn(ep->base.bind_addr.port, rport); | 342 | hash = sctp_assoc_hashfn(ep->base.bind_addr.port, rport); |
| 342 | head = &sctp_assoc_hashtable[hash]; | 343 | head = &sctp_assoc_hashtable[hash]; |
| 343 | read_lock(&head->lock); | 344 | read_lock(&head->lock); |
| 344 | for (epb = head->chain; epb; epb = epb->next) { | 345 | sctp_for_each_hentry(epb, node, &head->chain) { |
| 345 | asoc = sctp_assoc(epb); | 346 | asoc = sctp_assoc(epb); |
| 346 | if (asoc->ep != ep || rport != asoc->peer.port) | 347 | if (asoc->ep != ep || rport != asoc->peer.port) |
| 347 | goto next; | 348 | goto next; |
diff --git a/net/sctp/input.c b/net/sctp/input.c index 86503e7fa2..91ae463b07 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
| @@ -656,7 +656,6 @@ discard: | |||
| 656 | /* Insert endpoint into the hash table. */ | 656 | /* Insert endpoint into the hash table. */ |
| 657 | static void __sctp_hash_endpoint(struct sctp_endpoint *ep) | 657 | static void __sctp_hash_endpoint(struct sctp_endpoint *ep) |
| 658 | { | 658 | { |
| 659 | struct sctp_ep_common **epp; | ||
| 660 | struct sctp_ep_common *epb; | 659 | struct sctp_ep_common *epb; |
| 661 | struct sctp_hashbucket *head; | 660 | struct sctp_hashbucket *head; |
| 662 | 661 | ||
| @@ -666,12 +665,7 @@ static void __sctp_hash_endpoint(struct sctp_endpoint *ep) | |||
| 666 | head = &sctp_ep_hashtable[epb->hashent]; | 665 | head = &sctp_ep_hashtable[epb->hashent]; |
| 667 | 666 | ||
| 668 | sctp_write_lock(&head->lock); | 667 | sctp_write_lock(&head->lock); |
| 669 | epp = &head->chain; | 668 | hlist_add_head(&epb->node, &head->chain); |
| 670 | epb->next = *epp; | ||
| 671 | if (epb->next) | ||
| 672 | (*epp)->pprev = &epb->next; | ||
| 673 | *epp = epb; | ||
| 674 | epb->pprev = epp; | ||
| 675 | sctp_write_unlock(&head->lock); | 669 | sctp_write_unlock(&head->lock); |
| 676 | } | 670 | } |
| 677 | 671 | ||
| @@ -691,19 +685,15 @@ static void __sctp_unhash_endpoint(struct sctp_endpoint *ep) | |||
| 691 | 685 | ||
| 692 | epb = &ep->base; | 686 | epb = &ep->base; |
| 693 | 687 | ||
| 688 | if (hlist_unhashed(&epb->node)) | ||
| 689 | return; | ||
| 690 | |||
| 694 | epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); | 691 | epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); |
| 695 | 692 | ||
| 696 | head = &sctp_ep_hashtable[epb->hashent]; | 693 | head = &sctp_ep_hashtable[epb->hashent]; |
| 697 | 694 | ||
| 698 | sctp_write_lock(&head->lock); | 695 | sctp_write_lock(&head->lock); |
| 699 | 696 | __hlist_del(&epb->node); | |
| 700 | if (epb->pprev) { | ||
| 701 | if (epb->next) | ||
| 702 | epb->next->pprev = epb->pprev; | ||
| 703 | *epb->pprev = epb->next; | ||
| 704 | epb->pprev = NULL; | ||
| 705 | } | ||
| 706 | |||
| 707 | sctp_write_unlock(&head->lock); | 697 | sctp_write_unlock(&head->lock); |
| 708 | } | 698 | } |
| 709 | 699 | ||
| @@ -721,12 +711,13 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l | |||
| 721 | struct sctp_hashbucket *head; | 711 | struct sctp_hashbucket *head; |
| 722 | struct sctp_ep_common *epb; | 712 | struct sctp_ep_common *epb; |
| 723 | struct sctp_endpoint *ep; | 713 | struct sctp_endpoint *ep; |
| 714 | struct hlist_node *node; | ||
| 724 | int hash; | 715 | int hash; |
| 725 | 716 | ||
| 726 | hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port)); | 717 | hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port)); |
| 727 | head = &sctp_ep_hashtable[hash]; | 718 | head = &sctp_ep_hashtable[hash]; |
| 728 | read_lock(&head->lock); | 719 | read_lock(&head->lock); |
| 729 | for (epb = head->chain; epb; epb = epb->next) { | 720 | sctp_for_each_hentry(epb, node, &head->chain) { |
| 730 | ep = sctp_ep(epb); | 721 | ep = sctp_ep(epb); |
| 731 | if (sctp_endpoint_is_match(ep, laddr)) | 722 | if (sctp_endpoint_is_match(ep, laddr)) |
| 732 | goto hit; | 723 | goto hit; |
| @@ -744,7 +735,6 @@ hit: | |||
| 744 | /* Insert association into the hash table. */ | 735 | /* Insert association into the hash table. */ |
| 745 | static void __sctp_hash_established(struct sctp_association *asoc) | 736 | static void __sctp_hash_established(struct sctp_association *asoc) |
| 746 | { | 737 | { |
| 747 | struct sctp_ep_common **epp; | ||
| 748 | struct sctp_ep_common *epb; | 738 | struct sctp_ep_common *epb; |
| 749 | struct sctp_hashbucket *head; | 739 | struct sctp_hashbucket *head; |
| 750 | 740 | ||
| @@ -756,12 +746,7 @@ static void __sctp_hash_established(struct sctp_association *asoc) | |||
| 756 | head = &sctp_assoc_hashtable[epb->hashent]; | 746 | head = &sctp_assoc_hashtable[epb->hashent]; |
| 757 | 747 | ||
| 758 | sctp_write_lock(&head->lock); | 748 | sctp_write_lock(&head->lock); |
| 759 | epp = &head->chain; | 749 | hlist_add_head(&epb->node, &head->chain); |
| 760 | epb->next = *epp; | ||
| 761 | if (epb->next) | ||
| 762 | (*epp)->pprev = &epb->next; | ||
| 763 | *epp = epb; | ||
| 764 | epb->pprev = epp; | ||
| 765 | sctp_write_unlock(&head->lock); | 750 | sctp_write_unlock(&head->lock); |
| 766 | } | 751 | } |
| 767 | 752 | ||
| @@ -790,14 +775,7 @@ static void __sctp_unhash_established(struct sctp_association *asoc) | |||
| 790 | head = &sctp_assoc_hashtable[epb->hashent]; | 775 | head = &sctp_assoc_hashtable[epb->hashent]; |
| 791 | 776 | ||
| 792 | sctp_write_lock(&head->lock); | 777 | sctp_write_lock(&head->lock); |
| 793 | 778 | __hlist_del(&epb->node); | |
| 794 | if (epb->pprev) { | ||
| 795 | if (epb->next) | ||
| 796 | epb->next->pprev = epb->pprev; | ||
| 797 | *epb->pprev = epb->next; | ||
| 798 | epb->pprev = NULL; | ||
| 799 | } | ||
| 800 | |||
| 801 | sctp_write_unlock(&head->lock); | 779 | sctp_write_unlock(&head->lock); |
| 802 | } | 780 | } |
| 803 | 781 | ||
| @@ -822,6 +800,7 @@ static struct sctp_association *__sctp_lookup_association( | |||
| 822 | struct sctp_ep_common *epb; | 800 | struct sctp_ep_common *epb; |
| 823 | struct sctp_association *asoc; | 801 | struct sctp_association *asoc; |
| 824 | struct sctp_transport *transport; | 802 | struct sctp_transport *transport; |
