aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sctp
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-08-06 04:39:38 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-15 01:44:12 -0400
commitf1f4376307ca45558eb22487022aefceed7385e8 (patch)
treeeb4a61a314b8a5176ff5f17ab803c5fd0c9579f5 /include/net/sctp
parenteea68e2f1a0061e09265992b91fdc0014930ae92 (diff)
sctp: Make the port hash table use struct net in it's key.
- Add struct net into the port hash table hash calculation - Add struct net inot the struct sctp_bind_bucket so there is a memory of which network namespace a port is allocated in. No need for a ref count because sctp_bind_bucket only exists when there are sockets in the hash table and sockets can not change their network namspace, and sockets already ref count their network namespace. - Add struct net into the key comparison when we are testing to see if we have found the port hash table entry we are looking for. With these changes lookups in the port hash table becomes safe to use in multiple network namespaces. 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 'include/net/sctp')
-rw-r--r--include/net/sctp/sctp.h4
-rw-r--r--include/net/sctp/structs.h1
2 files changed, 3 insertions, 2 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index ff499640528b..7c0504034583 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -632,9 +632,9 @@ static inline int sctp_sanity_check(void)
632 632
633/* Warning: The following hash functions assume a power of two 'size'. */ 633/* Warning: The following hash functions assume a power of two 'size'. */
634/* This is the hash function for the SCTP port hash table. */ 634/* This is the hash function for the SCTP port hash table. */
635static inline int sctp_phashfn(__u16 lport) 635static inline int sctp_phashfn(struct net *net, __u16 lport)
636{ 636{
637 return lport & (sctp_port_hashsize - 1); 637 return (net_hash_mix(net) + lport) & (sctp_port_hashsize - 1);
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. */
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index fc5e60016e37..c089bb12af77 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -102,6 +102,7 @@ struct sctp_bind_bucket {
102 unsigned short fastreuse; 102 unsigned short fastreuse;
103 struct hlist_node node; 103 struct hlist_node node;
104 struct hlist_head owner; 104 struct hlist_head owner;
105 struct net *net;
105}; 106};
106 107
107struct sctp_bind_hashbucket { 108struct sctp_bind_hashbucket {