aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/node.h
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2015-01-09 02:27:05 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-12 16:24:32 -0500
commitf2f9800d4955a96d92896841d8ba9b04201deaa1 (patch)
tree3b817800cfd8fcb2de6d5a3d7eb4fff972fba681 /net/tipc/node.h
parentc93d3baa24095887005647984cff5de8c63d3611 (diff)
tipc: make tipc node table aware of net namespace
Global variables associated with node table are below: - node table list (node_htable) - node hash table list (tipc_node_list) - node table lock (node_list_lock) - node number counter (tipc_num_nodes) - node link number counter (tipc_num_links) To make node table support namespace, above global variables must be moved to tipc_net structure in order to keep secret for different namespaces. As a consequence, these variables are allocated and initialized when namespace is created, and deallocated when namespace is destroyed. After the change, functions associated with these variables have to utilize a namespace pointer to access them. So adding namespace pointer as a parameter of these functions is the major change made in the commit. Signed-off-by: Ying Xue <ying.xue@windriver.com> Tested-by: Tero Aho <Tero.Aho@coriant.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/node.h')
-rw-r--r--net/tipc/node.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/net/tipc/node.h b/net/tipc/node.h
index cbe0e950f1cc..43ef88ef3035 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -42,10 +42,10 @@
42#include "bearer.h" 42#include "bearer.h"
43#include "msg.h" 43#include "msg.h"
44 44
45/* 45/* Out-of-range value for node signature */
46 * Out-of-range value for node signature 46#define INVALID_NODE_SIG 0x10000
47 */ 47
48#define INVALID_NODE_SIG 0x10000 48#define NODE_HTABLE_SIZE 512
49 49
50/* Flags used to take different actions according to flag type 50/* Flags used to take different actions according to flag type
51 * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down 51 * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down
@@ -90,6 +90,7 @@ struct tipc_node_bclink {
90 * struct tipc_node - TIPC node structure 90 * struct tipc_node - TIPC node structure
91 * @addr: network address of node 91 * @addr: network address of node
92 * @lock: spinlock governing access to structure 92 * @lock: spinlock governing access to structure
93 * @net: the applicable net namespace
93 * @hash: links to adjacent nodes in unsorted hash chain 94 * @hash: links to adjacent nodes in unsorted hash chain
94 * @active_links: pointers to active links to node 95 * @active_links: pointers to active links to node
95 * @links: pointers to all links to node 96 * @links: pointers to all links to node
@@ -106,6 +107,7 @@ struct tipc_node_bclink {
106struct tipc_node { 107struct tipc_node {
107 u32 addr; 108 u32 addr;
108 spinlock_t lock; 109 spinlock_t lock;
110 struct net *net;
109 struct hlist_node hash; 111 struct hlist_node hash;
110 struct tipc_link *active_links[2]; 112 struct tipc_link *active_links[2];
111 u32 act_mtus[2]; 113 u32 act_mtus[2];
@@ -123,23 +125,24 @@ struct tipc_node {
123 struct rcu_head rcu; 125 struct rcu_head rcu;
124}; 126};
125 127
126extern struct list_head tipc_node_list; 128struct tipc_node *tipc_node_find(struct net *net, u32 addr);
127 129struct tipc_node *tipc_node_create(struct net *net, u32 addr);
128struct tipc_node *tipc_node_find(u32 addr); 130void tipc_node_stop(struct net *net);
129struct tipc_node *tipc_node_create(u32 addr);
130void tipc_node_stop(void);
131void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); 131void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
132void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); 132void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
133void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr); 133void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
134void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr); 134void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr);
135int tipc_node_active_links(struct tipc_node *n_ptr); 135int tipc_node_active_links(struct tipc_node *n_ptr);
136int tipc_node_is_up(struct tipc_node *n_ptr); 136int tipc_node_is_up(struct tipc_node *n_ptr);
137struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); 137struct sk_buff *tipc_node_get_links(struct net *net, const void *req_tlv_area,
138struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); 138 int req_tlv_space);
139int tipc_node_get_linkname(u32 bearer_id, u32 node, char *linkname, size_t len); 139struct sk_buff *tipc_node_get_nodes(struct net *net, const void *req_tlv_area,
140 int req_tlv_space);
141int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node,
142 char *linkname, size_t len);
140void tipc_node_unlock(struct tipc_node *node); 143void tipc_node_unlock(struct tipc_node *node);
141int tipc_node_add_conn(u32 dnode, u32 port, u32 peer_port); 144int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port);
142void tipc_node_remove_conn(u32 dnode, u32 port); 145void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port);
143 146
144int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb); 147int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb);
145 148
@@ -154,12 +157,12 @@ static inline bool tipc_node_blocked(struct tipc_node *node)
154 TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN)); 157 TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN));
155} 158}
156 159
157static inline uint tipc_node_get_mtu(u32 addr, u32 selector) 160static inline uint tipc_node_get_mtu(struct net *net, u32 addr, u32 selector)
158{ 161{
159 struct tipc_node *node; 162 struct tipc_node *node;
160 u32 mtu; 163 u32 mtu;
161 164
162 node = tipc_node_find(addr); 165 node = tipc_node_find(net, addr);
163 166
164 if (likely(node)) 167 if (likely(node))
165 mtu = node->act_mtus[selector & 1]; 168 mtu = node->act_mtus[selector & 1];