aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/sctp/sctp.h4
-rw-r--r--include/net/sctp/structs.h2
-rw-r--r--net/sctp/endpointola.c4
-rw-r--r--net/sctp/input.c19
4 files changed, 18 insertions, 11 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 7c0504034583..87b119f74c4a 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -638,9 +638,9 @@ static inline int sctp_phashfn(struct net *net, __u16 lport)
638} 638}
639 639
640/* This is the hash function for the endpoint hash table. */ 640/* This is the hash function for the endpoint hash table. */
641static inline int sctp_ep_hashfn(__u16 lport) 641static inline int sctp_ep_hashfn(struct net *net, __u16 lport)
642{ 642{
643 return lport & (sctp_ep_hashsize - 1); 643 return (net_hash_mix(net) + lport) & (sctp_ep_hashsize - 1);
644} 644}
645 645
646/* This is the hash function for the association hash table. */ 646/* This is the hash function for the association hash table. */
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index c089bb12af77..9f9de558541f 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1426,7 +1426,7 @@ struct sctp_association *sctp_endpoint_lookup_assoc(
1426int sctp_endpoint_is_peeled_off(struct sctp_endpoint *, 1426int sctp_endpoint_is_peeled_off(struct sctp_endpoint *,
1427 const union sctp_addr *); 1427 const union sctp_addr *);
1428struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *, 1428struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *,
1429 const union sctp_addr *); 1429 struct net *, const union sctp_addr *);
1430int sctp_has_association(const union sctp_addr *laddr, 1430int sctp_has_association(const union sctp_addr *laddr,
1431 const union sctp_addr *paddr); 1431 const union sctp_addr *paddr);
1432 1432
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 68a385d7c3bd..50c87b4ad765 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -302,11 +302,13 @@ void sctp_endpoint_put(struct sctp_endpoint *ep)
302 302
303/* Is this the endpoint we are looking for? */ 303/* Is this the endpoint we are looking for? */
304struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep, 304struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep,
305 struct net *net,
305 const union sctp_addr *laddr) 306 const union sctp_addr *laddr)
306{ 307{
307 struct sctp_endpoint *retval = NULL; 308 struct sctp_endpoint *retval = NULL;
308 309
309 if (htons(ep->base.bind_addr.port) == laddr->v4.sin_port) { 310 if ((htons(ep->base.bind_addr.port) == laddr->v4.sin_port) &&
311 net_eq(sock_net(ep->base.sk), net)) {
310 if (sctp_bind_addr_match(&ep->base.bind_addr, laddr, 312 if (sctp_bind_addr_match(&ep->base.bind_addr, laddr,
311 sctp_sk(ep->base.sk))) 313 sctp_sk(ep->base.sk)))
312 retval = ep; 314 retval = ep;
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);
73static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr); 73static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net,
74 const union sctp_addr *laddr);
74static struct sctp_association *__sctp_lookup_association( 75static 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. */
724static void __sctp_hash_endpoint(struct sctp_endpoint *ep) 726static 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. */
748static void __sctp_unhash_endpoint(struct sctp_endpoint *ep) 751static 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. */
773static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr) 777static 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