diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-06 04:40:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-15 01:44:12 -0400 |
commit | 4cdadcbcb64bdf3ae8bdf3ef5bb2b91c85444cfa (patch) | |
tree | fc6fd317dd6e128f176101c5843f58ed8ab86c9c /net/sctp/input.c | |
parent | f1f4376307ca45558eb22487022aefceed7385e8 (diff) |
sctp: Make the endpoint hashtable handle multiple network namespaces
- Use struct net in the hash calculation
- Use sock_net(endpoint.base.sk) in the endpoint lookups.
- On receive calculate the network namespace from skb->dev.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/input.c')
-rw-r--r-- | net/sctp/input.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/net/sctp/input.c b/net/sctp/input.c index e64d5210ed13..c0ca893ab1d1 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
@@ -70,7 +70,8 @@ static struct sctp_association *__sctp_rcv_lookup(struct sk_buff *skb, | |||
70 | const union sctp_addr *laddr, | 70 | const union sctp_addr *laddr, |
71 | const union sctp_addr *paddr, | 71 | const union sctp_addr *paddr, |
72 | struct sctp_transport **transportp); | 72 | struct sctp_transport **transportp); |
73 | static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr); | 73 | static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net, |
74 | const union sctp_addr *laddr); | ||
74 | static struct sctp_association *__sctp_lookup_association( | 75 | static struct sctp_association *__sctp_lookup_association( |
75 | const union sctp_addr *local, | 76 | const union sctp_addr *local, |
76 | const union sctp_addr *peer, | 77 | const union sctp_addr *peer, |
@@ -129,6 +130,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
129 | union sctp_addr dest; | 130 | union sctp_addr dest; |
130 | int family; | 131 | int family; |
131 | struct sctp_af *af; | 132 | struct sctp_af *af; |
133 | struct net *net = dev_net(skb->dev); | ||
132 | 134 | ||
133 | if (skb->pkt_type!=PACKET_HOST) | 135 | if (skb->pkt_type!=PACKET_HOST) |
134 | goto discard_it; | 136 | goto discard_it; |
@@ -181,7 +183,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
181 | asoc = __sctp_rcv_lookup(skb, &src, &dest, &transport); | 183 | asoc = __sctp_rcv_lookup(skb, &src, &dest, &transport); |
182 | 184 | ||
183 | if (!asoc) | 185 | if (!asoc) |
184 | ep = __sctp_rcv_lookup_endpoint(&dest); | 186 | ep = __sctp_rcv_lookup_endpoint(net, &dest); |
185 | 187 | ||
186 | /* Retrieve the common input handling substructure. */ | 188 | /* Retrieve the common input handling substructure. */ |
187 | rcvr = asoc ? &asoc->base : &ep->base; | 189 | rcvr = asoc ? &asoc->base : &ep->base; |
@@ -723,12 +725,13 @@ discard: | |||
723 | /* Insert endpoint into the hash table. */ | 725 | /* Insert endpoint into the hash table. */ |
724 | static void __sctp_hash_endpoint(struct sctp_endpoint *ep) | 726 | static void __sctp_hash_endpoint(struct sctp_endpoint *ep) |
725 | { | 727 | { |
728 | struct net *net = sock_net(ep->base.sk); | ||
726 | struct sctp_ep_common *epb; | 729 | struct sctp_ep_common *epb; |
727 | struct sctp_hashbucket *head; | 730 | struct sctp_hashbucket *head; |
728 | 731 | ||
729 | epb = &ep->base; | 732 | epb = &ep->base; |
730 | 733 | ||
731 | epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); | 734 | epb->hashent = sctp_ep_hashfn(net, epb->bind_addr.port); |
732 | head = &sctp_ep_hashtable[epb->hashent]; | 735 | head = &sctp_ep_hashtable[epb->hashent]; |
733 | 736 | ||
734 | sctp_write_lock(&head->lock); | 737 | sctp_write_lock(&head->lock); |
@@ -747,12 +750,13 @@ void sctp_hash_endpoint(struct sctp_endpoint *ep) | |||
747 | /* Remove endpoint from the hash table. */ | 750 | /* Remove endpoint from the hash table. */ |
748 | static void __sctp_unhash_endpoint(struct sctp_endpoint *ep) | 751 | static void __sctp_unhash_endpoint(struct sctp_endpoint *ep) |
749 | { | 752 | { |
753 | struct net *net = sock_net(ep->base.sk); | ||
750 | struct sctp_hashbucket *head; | 754 | struct sctp_hashbucket *head; |
751 | struct sctp_ep_common *epb; | 755 | struct sctp_ep_common *epb; |
752 | 756 | ||
753 | epb = &ep->base; | 757 | epb = &ep->base; |
754 | 758 | ||
755 | epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); | 759 | epb->hashent = sctp_ep_hashfn(net, epb->bind_addr.port); |
756 | 760 | ||
757 | head = &sctp_ep_hashtable[epb->hashent]; | 761 | head = &sctp_ep_hashtable[epb->hashent]; |
758 | 762 | ||
@@ -770,7 +774,8 @@ void sctp_unhash_endpoint(struct sctp_endpoint *ep) | |||
770 | } | 774 | } |
771 | 775 | ||
772 | /* Look up an endpoint. */ | 776 | /* Look up an endpoint. */ |
773 | static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr) | 777 | static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net, |
778 | const union sctp_addr *laddr) | ||
774 | { | 779 | { |
775 | struct sctp_hashbucket *head; | 780 | struct sctp_hashbucket *head; |
776 | struct sctp_ep_common *epb; | 781 | struct sctp_ep_common *epb; |
@@ -778,12 +783,12 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l | |||
778 | struct hlist_node *node; | 783 | struct hlist_node *node; |
779 | int hash; | 784 | int hash; |
780 | 785 | ||
781 | hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port)); | 786 | hash = sctp_ep_hashfn(net, ntohs(laddr->v4.sin_port)); |
782 | head = &sctp_ep_hashtable[hash]; | 787 | head = &sctp_ep_hashtable[hash]; |
783 | read_lock(&head->lock); | 788 | read_lock(&head->lock); |
784 | sctp_for_each_hentry(epb, node, &head->chain) { | 789 | sctp_for_each_hentry(epb, node, &head->chain) { |
785 | ep = sctp_ep(epb); | 790 | ep = sctp_ep(epb); |
786 | if (sctp_endpoint_is_match(ep, laddr)) | 791 | if (sctp_endpoint_is_match(ep, net, laddr)) |
787 | goto hit; | 792 | goto hit; |
788 | } | 793 | } |
789 | 794 | ||