aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2015-12-30 10:50:46 -0500
committerDavid S. Miller <davem@davemloft.net>2016-01-05 12:24:00 -0500
commitd6c0256a60e685214cc8cc2b886809f11efc0084 (patch)
tree03e8c0a111ac179ee0c5351969921994408eec14 /include/net
parent6a5ef90c58daada158ba16ba330558efc3471491 (diff)
sctp: add the rhashtable apis for sctp global transport hashtable
tranport hashtbale will replace the association hashtable to do the lookup for transport, and then get association by t->assoc, rhashtable apis will be used because of it's resizable, scalable and using rcu. lport + rport + paddr will be the base hashkey to locate the chain, with net to protect one netns from another, then plus the laddr to compare to get the target. this patch will provider the lookup functions: - sctp_epaddr_lookup_transport - sctp_addrs_lookup_transport hash/unhash functions: - sctp_hash_transport - sctp_unhash_transport init/destroy functions: - sctp_transport_hashtable_init - sctp_transport_hashtable_destroy Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/sctp/sctp.h11
-rw-r--r--include/net/sctp/structs.h5
2 files changed, 16 insertions, 0 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index ce13cf20f625..7bbdfbab2efa 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -143,6 +143,17 @@ void sctp_icmp_proto_unreachable(struct sock *sk,
143 struct sctp_transport *t); 143 struct sctp_transport *t);
144void sctp_backlog_migrate(struct sctp_association *assoc, 144void sctp_backlog_migrate(struct sctp_association *assoc,
145 struct sock *oldsk, struct sock *newsk); 145 struct sock *oldsk, struct sock *newsk);
146int sctp_transport_hashtable_init(void);
147void sctp_transport_hashtable_destroy(void);
148void sctp_hash_transport(struct sctp_transport *t);
149void sctp_unhash_transport(struct sctp_transport *t);
150struct sctp_transport *sctp_addrs_lookup_transport(
151 struct net *net,
152 const union sctp_addr *laddr,
153 const union sctp_addr *paddr);
154struct sctp_transport *sctp_epaddr_lookup_transport(
155 const struct sctp_endpoint *ep,
156 const union sctp_addr *paddr);
146 157
147/* 158/*
148 * sctp/proc.c 159 * sctp/proc.c
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index eea9bdeecba2..4ab87d08e766 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -48,6 +48,7 @@
48#define __sctp_structs_h__ 48#define __sctp_structs_h__
49 49
50#include <linux/ktime.h> 50#include <linux/ktime.h>
51#include <linux/rhashtable.h>
51#include <linux/socket.h> /* linux/in.h needs this!! */ 52#include <linux/socket.h> /* linux/in.h needs this!! */
52#include <linux/in.h> /* We get struct sockaddr_in. */ 53#include <linux/in.h> /* We get struct sockaddr_in. */
53#include <linux/in6.h> /* We get struct in6_addr */ 54#include <linux/in6.h> /* We get struct in6_addr */
@@ -123,6 +124,8 @@ extern struct sctp_globals {
123 struct sctp_hashbucket *assoc_hashtable; 124 struct sctp_hashbucket *assoc_hashtable;
124 /* This is the sctp port control hash. */ 125 /* This is the sctp port control hash. */
125 struct sctp_bind_hashbucket *port_hashtable; 126 struct sctp_bind_hashbucket *port_hashtable;
127 /* This is the hash of all transports. */
128 struct rhashtable transport_hashtable;
126 129
127 /* Sizes of above hashtables. */ 130 /* Sizes of above hashtables. */
128 int ep_hashsize; 131 int ep_hashsize;
@@ -147,6 +150,7 @@ extern struct sctp_globals {
147#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) 150#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
148#define sctp_port_hashsize (sctp_globals.port_hashsize) 151#define sctp_port_hashsize (sctp_globals.port_hashsize)
149#define sctp_port_hashtable (sctp_globals.port_hashtable) 152#define sctp_port_hashtable (sctp_globals.port_hashtable)
153#define sctp_transport_hashtable (sctp_globals.transport_hashtable)
150#define sctp_checksum_disable (sctp_globals.checksum_disable) 154#define sctp_checksum_disable (sctp_globals.checksum_disable)
151 155
152/* SCTP Socket type: UDP or TCP style. */ 156/* SCTP Socket type: UDP or TCP style. */
@@ -753,6 +757,7 @@ static inline int sctp_packet_empty(struct sctp_packet *packet)
753struct sctp_transport { 757struct sctp_transport {
754 /* A list of transports. */ 758 /* A list of transports. */
755 struct list_head transports; 759 struct list_head transports;
760 struct rhash_head node;
756 761
757 /* Reference counting. */ 762 /* Reference counting. */
758 atomic_t refcnt; 763 atomic_t refcnt;