aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bcast.c
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-02-05 08:36:36 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-05 19:00:01 -0500
commitc5898636c440da91d58f10beac00f073e68378df (patch)
tree67e7148b03414171b1d2012bd8f27ea63433c3ed /net/tipc/bcast.c
parent4134069f3ea6cd96903e426bd3dfb9bb44165357 (diff)
tipc: reduce usage of context info in socket and link
The most common usage of namespace information is when we fetch the own node addess from the net structure. This leads to a lot of passing around of a parameter of type 'struct net *' between functions just to make them able to obtain this address. However, in many cases this is unnecessary. The own node address is readily available as a member of both struct tipc_sock and tipc_link, and can be fetched from there instead. The fact that the vast majority of functions in socket.c and link.c anyway are maintaining a pointer to their respective base structures makes this option even more compelling. In this commit, we introduce the inline functions tsk_own_node() and link_own_node() to make it easy for functions to fetch the node address from those structs instead of having to pass along and dereference the namespace struct. In particular, we make calls to the msg_xx() functions in msg.{h,c} context independent by directly passing them the own node address as parameter when needed. Those functions should be regarded as leaves in the code dependency tree, and it is hence desirable to keep them namspace unaware. Apart from a potential positive effect on cache behavior, these changes make it easier to introduce the changes that will follow later in this series. 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/bcast.c')
-rw-r--r--net/tipc/bcast.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 53f8bf059fec..3b886eb35c87 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -283,10 +283,11 @@ exit:
283 * 283 *
284 * RCU and node lock set 284 * RCU and node lock set
285 */ 285 */
286void tipc_bclink_update_link_state(struct net *net, struct tipc_node *n_ptr, 286void tipc_bclink_update_link_state(struct tipc_node *n_ptr,
287 u32 last_sent) 287 u32 last_sent)
288{ 288{
289 struct sk_buff *buf; 289 struct sk_buff *buf;
290 struct net *net = n_ptr->net;
290 struct tipc_net *tn = net_generic(net, tipc_net_id); 291 struct tipc_net *tn = net_generic(net, tipc_net_id);
291 292
292 /* Ignore "stale" link state info */ 293 /* Ignore "stale" link state info */
@@ -317,7 +318,7 @@ void tipc_bclink_update_link_state(struct net *net, struct tipc_node *n_ptr,
317 struct sk_buff *skb = skb_peek(&n_ptr->bclink.deferred_queue); 318 struct sk_buff *skb = skb_peek(&n_ptr->bclink.deferred_queue);
318 u32 to = skb ? buf_seqno(skb) - 1 : n_ptr->bclink.last_sent; 319 u32 to = skb ? buf_seqno(skb) - 1 : n_ptr->bclink.last_sent;
319 320
320 tipc_msg_init(net, msg, BCAST_PROTOCOL, STATE_MSG, 321 tipc_msg_init(tn->own_addr, msg, BCAST_PROTOCOL, STATE_MSG,
321 INT_H_SIZE, n_ptr->addr); 322 INT_H_SIZE, n_ptr->addr);
322 msg_set_non_seq(msg, 1); 323 msg_set_non_seq(msg, 1);
323 msg_set_mc_netid(msg, tn->net_id); 324 msg_set_mc_netid(msg, tn->net_id);
@@ -954,6 +955,8 @@ int tipc_bclink_init(struct net *net)
954 bcl->bearer_id = MAX_BEARERS; 955 bcl->bearer_id = MAX_BEARERS;
955 rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer); 956 rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer);
956 bcl->state = WORKING_WORKING; 957 bcl->state = WORKING_WORKING;
958 bcl->pmsg = (struct tipc_msg *)&bcl->proto_msg;
959 msg_set_prevnode(bcl->pmsg, tn->own_addr);
957 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME); 960 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
958 tn->bcbearer = bcbearer; 961 tn->bcbearer = bcbearer;
959 tn->bclink = bclink; 962 tn->bclink = bclink;