aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/node.c
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-11-19 14:30:42 -0500
committerDavid S. Miller <davem@davemloft.net>2015-11-20 14:06:10 -0500
commit1d7e1c2595bd20c5274a8e49d89cf0cf483759de (patch)
tree291677f9816bfbcc47405245e5d06af4fcb23d2b /net/tipc/node.c
parent5c10e9794013143eec80d494603d46dcb219970a (diff)
tipc: reduce code dependency between binding table and node layer
The file name_distr.c currently contains three functions, named_cluster_distribute(), tipc_publ_subcscribe() and tipc_publ_unsubscribe() that all directly access fields in struct tipc_node. We want to eliminate such dependencies, so we move those functions to the file node.c and rename them to tipc_node_broadcast(), tipc_node_subscribe() and tipc_node_unsubscribe() respectively. Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/node.c')
-rw-r--r--net/tipc/node.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 7756804034e2..932195258551 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -234,6 +234,42 @@ void tipc_node_stop(struct net *net)
234 spin_unlock_bh(&tn->node_list_lock); 234 spin_unlock_bh(&tn->node_list_lock);
235} 235}
236 236
237void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr)
238{
239 struct tipc_node *n;
240
241 if (in_own_node(net, addr))
242 return;
243
244 n = tipc_node_find(net, addr);
245 if (!n) {
246 pr_warn("Node subscribe rejected, unknown node 0x%x\n", addr);
247 return;
248 }
249 tipc_node_lock(n);
250 list_add_tail(subscr, &n->publ_list);
251 tipc_node_unlock(n);
252 tipc_node_put(n);
253}
254
255void tipc_node_unsubscribe(struct net *net, struct list_head *subscr, u32 addr)
256{
257 struct tipc_node *n;
258
259 if (in_own_node(net, addr))
260 return;
261
262 n = tipc_node_find(net, addr);
263 if (!n) {
264 pr_warn("Node unsubscribe rejected, unknown node 0x%x\n", addr);
265 return;
266 }
267 tipc_node_lock(n);
268 list_del_init(subscr);
269 tipc_node_unlock(n);
270 tipc_node_put(n);
271}
272
237int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port) 273int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port)
238{ 274{
239 struct tipc_node *node; 275 struct tipc_node *node;
@@ -1075,6 +1111,30 @@ int tipc_node_xmit_skb(struct net *net, struct sk_buff *skb, u32 dnode,
1075 return 0; 1111 return 0;
1076} 1112}
1077 1113
1114void tipc_node_broadcast(struct net *net, struct sk_buff *skb)
1115{
1116 struct sk_buff *txskb;
1117 struct tipc_node *n;
1118 u32 dst;
1119
1120 rcu_read_lock();
1121 list_for_each_entry_rcu(n, tipc_nodes(net), list) {
1122 dst = n->addr;
1123 if (in_own_node(net, dst))
1124 continue;
1125 if (!tipc_node_is_up(n))
1126 continue;
1127 txskb = pskb_copy(skb, GFP_ATOMIC);
1128 if (!txskb)
1129 break;
1130 msg_set_destnode(buf_msg(txskb), dst);
1131 tipc_node_xmit_skb(net, txskb, dst, 0);
1132 }
1133 rcu_read_unlock();
1134
1135 kfree_skb(skb);
1136}
1137
1078/** 1138/**
1079 * tipc_node_bc_rcv - process TIPC broadcast packet arriving from off-node 1139 * tipc_node_bc_rcv - process TIPC broadcast packet arriving from off-node
1080 * @net: the applicable net namespace 1140 * @net: the applicable net namespace