aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2008-06-04 20:37:34 -0400
committerDavid S. Miller <davem@davemloft.net>2008-06-04 20:37:34 -0400
commit757152175666681d54d370500e41a756cfedd4fc (patch)
tree39452e5ea148ec0743300a14a336c861a344fe0a /net/tipc
parent9c396a7bfb4fe74e444be09069651280da520944 (diff)
tipc: Optimize message initialization routine
This patch eliminates the rarely-used "error code" argument when initializing a TIPC message header, since the default value of zero is the desired result in most cases; the few exceptional cases now set the error code explicitly. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/bcast.c2
-rw-r--r--net/tipc/cluster.c2
-rw-r--r--net/tipc/discover.c3
-rw-r--r--net/tipc/link.c12
-rw-r--r--net/tipc/msg.h3
-rw-r--r--net/tipc/name_distr.c3
-rw-r--r--net/tipc/port.c9
7 files changed, 16 insertions, 18 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index e7880172ef19..0052c0747d05 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -276,7 +276,7 @@ static void bclink_send_nack(struct node *n_ptr)
276 if (buf) { 276 if (buf) {
277 msg = buf_msg(buf); 277 msg = buf_msg(buf);
278 msg_init(msg, BCAST_PROTOCOL, STATE_MSG, 278 msg_init(msg, BCAST_PROTOCOL, STATE_MSG,
279 TIPC_OK, INT_H_SIZE, n_ptr->addr); 279 INT_H_SIZE, n_ptr->addr);
280 msg_set_mc_netid(msg, tipc_net_id); 280 msg_set_mc_netid(msg, tipc_net_id);
281 msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); 281 msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in));
282 msg_set_bcgap_after(msg, n_ptr->bclink.gap_after); 282 msg_set_bcgap_after(msg, n_ptr->bclink.gap_after);
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c
index 4bb3404f610b..bc1db474fe01 100644
--- a/net/tipc/cluster.c
+++ b/net/tipc/cluster.c
@@ -238,7 +238,7 @@ static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest)
238 if (buf) { 238 if (buf) {
239 msg = buf_msg(buf); 239 msg = buf_msg(buf);
240 memset((char *)msg, 0, size); 240 memset((char *)msg, 0, size);
241 msg_init(msg, ROUTE_DISTRIBUTOR, 0, TIPC_OK, INT_H_SIZE, dest); 241 msg_init(msg, ROUTE_DISTRIBUTOR, 0, INT_H_SIZE, dest);
242 } 242 }
243 return buf; 243 return buf;
244} 244}
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index ada213aac4d4..64c20284e0f7 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -120,8 +120,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
120 120
121 if (buf) { 121 if (buf) {
122 msg = buf_msg(buf); 122 msg = buf_msg(buf);
123 msg_init(msg, LINK_CONFIG, type, TIPC_OK, DSC_H_SIZE, 123 msg_init(msg, LINK_CONFIG, type, DSC_H_SIZE, dest_domain);
124 dest_domain);
125 msg_set_non_seq(msg); 124 msg_set_non_seq(msg);
126 msg_set_req_links(msg, req_links); 125 msg_set_req_links(msg, req_links);
127 msg_set_dest_domain(msg, dest_domain); 126 msg_set_dest_domain(msg, dest_domain);
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 022cb2f107ac..9784a8e963b4 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -468,7 +468,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
468 468
469 l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; 469 l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg;
470 msg = l_ptr->pmsg; 470 msg = l_ptr->pmsg;
471 msg_init(msg, LINK_PROTOCOL, RESET_MSG, TIPC_OK, INT_H_SIZE, l_ptr->addr); 471 msg_init(msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, l_ptr->addr);
472 msg_set_size(msg, sizeof(l_ptr->proto_msg)); 472 msg_set_size(msg, sizeof(l_ptr->proto_msg));
473 msg_set_session(msg, (tipc_random & 0xffff)); 473 msg_set_session(msg, (tipc_random & 0xffff));
474 msg_set_bearer_id(msg, b_ptr->identity); 474 msg_set_bearer_id(msg, b_ptr->identity);
@@ -1128,7 +1128,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1128 1128
1129 if (bundler) { 1129 if (bundler) {
1130 msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG, 1130 msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG,
1131 TIPC_OK, INT_H_SIZE, l_ptr->addr); 1131 INT_H_SIZE, l_ptr->addr);
1132 skb_copy_to_linear_data(bundler, &bundler_hdr, 1132 skb_copy_to_linear_data(bundler, &bundler_hdr,
1133 INT_H_SIZE); 1133 INT_H_SIZE);
1134 skb_trim(bundler, INT_H_SIZE); 1134 skb_trim(bundler, INT_H_SIZE);
@@ -1392,7 +1392,7 @@ again:
1392 1392
1393 msg_dbg(hdr, ">FRAGMENTING>"); 1393 msg_dbg(hdr, ">FRAGMENTING>");
1394 msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, 1394 msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT,
1395 TIPC_OK, INT_H_SIZE, msg_destnode(hdr)); 1395 INT_H_SIZE, msg_destnode(hdr));
1396 msg_set_link_selector(&fragm_hdr, sender->publ.ref); 1396 msg_set_link_selector(&fragm_hdr, sender->publ.ref);
1397 msg_set_size(&fragm_hdr, max_pkt); 1397 msg_set_size(&fragm_hdr, max_pkt);
1398 msg_set_fragm_no(&fragm_hdr, 1); 1398 msg_set_fragm_no(&fragm_hdr, 1);
@@ -2426,7 +2426,7 @@ void tipc_link_changeover(struct link *l_ptr)
2426 } 2426 }
2427 2427
2428 msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, 2428 msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL,
2429 ORIGINAL_MSG, TIPC_OK, INT_H_SIZE, l_ptr->addr); 2429 ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr);
2430 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); 2430 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id);
2431 msg_set_msgcnt(&tunnel_hdr, msgcount); 2431 msg_set_msgcnt(&tunnel_hdr, msgcount);
2432 dbg("Link changeover requires %u tunnel messages\n", msgcount); 2432 dbg("Link changeover requires %u tunnel messages\n", msgcount);
@@ -2481,7 +2481,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
2481 struct tipc_msg tunnel_hdr; 2481 struct tipc_msg tunnel_hdr;
2482 2482
2483 msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, 2483 msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL,
2484 DUPLICATE_MSG, TIPC_OK, INT_H_SIZE, l_ptr->addr); 2484 DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr);
2485 msg_set_msgcnt(&tunnel_hdr, l_ptr->out_queue_size); 2485 msg_set_msgcnt(&tunnel_hdr, l_ptr->out_queue_size);
2486 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); 2486 msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id);
2487 iter = l_ptr->first_out; 2487 iter = l_ptr->first_out;
@@ -2687,7 +2687,7 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
2687 /* Prepare reusable fragment header: */ 2687 /* Prepare reusable fragment header: */
2688 2688
2689 msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, 2689 msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT,
2690 TIPC_OK, INT_H_SIZE, destaddr); 2690 INT_H_SIZE, destaddr);
2691 msg_set_link_selector(&fragm_hdr, msg_link_selector(inmsg)); 2691 msg_set_link_selector(&fragm_hdr, msg_link_selector(inmsg));
2692 msg_set_long_msgno(&fragm_hdr, mod(l_ptr->long_msg_seq_no++)); 2692 msg_set_long_msgno(&fragm_hdr, mod(l_ptr->long_msg_seq_no++));
2693 msg_set_fragm_no(&fragm_hdr, fragm_no); 2693 msg_set_fragm_no(&fragm_hdr, fragm_no);
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index ad487e8abcc2..3418ffa72c94 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -696,7 +696,7 @@ static inline u32 msg_tot_importance(struct tipc_msg *m)
696 696
697 697
698static inline void msg_init(struct tipc_msg *m, u32 user, u32 type, 698static inline void msg_init(struct tipc_msg *m, u32 user, u32 type,
699 u32 err, u32 hsize, u32 destnode) 699 u32 hsize, u32 destnode)
700{ 700{
701 memset(m, 0, hsize); 701 memset(m, 0, hsize);
702 msg_set_version(m); 702 msg_set_version(m);
@@ -705,7 +705,6 @@ static inline void msg_init(struct tipc_msg *m, u32 user, u32 type,
705 msg_set_size(m, hsize); 705 msg_set_size(m, hsize);
706 msg_set_prevnode(m, tipc_own_addr); 706 msg_set_prevnode(m, tipc_own_addr);
707 msg_set_type(m, type); 707 msg_set_type(m, type);
708 msg_set_errcode(m, err);
709 if (!msg_short(m)) { 708 if (!msg_short(m)) {
710 msg_set_orignode(m, tipc_own_addr); 709 msg_set_orignode(m, tipc_own_addr);
711 msg_set_destnode(m, destnode); 710 msg_set_destnode(m, destnode);
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index aecba5cd87d6..10a69894e2fd 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -103,8 +103,7 @@ static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
103 103
104 if (buf != NULL) { 104 if (buf != NULL) {
105 msg = buf_msg(buf); 105 msg = buf_msg(buf);
106 msg_init(msg, NAME_DISTRIBUTOR, type, TIPC_OK, 106 msg_init(msg, NAME_DISTRIBUTOR, type, LONG_H_SIZE, dest);
107 LONG_H_SIZE, dest);
108 msg_set_size(msg, LONG_H_SIZE + size); 107 msg_set_size(msg, LONG_H_SIZE + size);
109 } 108 }
110 return buf; 109 return buf;
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 4dfef9e798e3..e3e9c121afbe 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -244,8 +244,7 @@ u32 tipc_createport_raw(void *usr_handle,
244 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; 244 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT;
245 p_ptr->publ.ref = ref; 245 p_ptr->publ.ref = ref;
246 msg = &p_ptr->publ.phdr; 246 msg = &p_ptr->publ.phdr;
247 msg_init(msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG, TIPC_OK, LONG_H_SIZE, 247 msg_init(msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG, LONG_H_SIZE, 0);
248 0);
249 msg_set_orignode(msg, tipc_own_addr); 248 msg_set_orignode(msg, tipc_own_addr);
250 msg_set_prevnode(msg, tipc_own_addr); 249 msg_set_prevnode(msg, tipc_own_addr);
251 msg_set_origport(msg, ref); 250 msg_set_origport(msg, ref);
@@ -404,7 +403,8 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
404 buf = buf_acquire(LONG_H_SIZE); 403 buf = buf_acquire(LONG_H_SIZE);
405 if (buf) { 404 if (buf) {
406 msg = buf_msg(buf); 405 msg = buf_msg(buf);
407 msg_init(msg, usr, type, err, LONG_H_SIZE, destnode); 406 msg_init(msg, usr, type, LONG_H_SIZE, destnode);
407 msg_set_errcode(msg, err);
408 msg_set_destport(msg, destport); 408 msg_set_destport(msg, destport);
409 msg_set_origport(msg, origport); 409 msg_set_origport(msg, origport);
410 msg_set_destnode(msg, destnode); 410 msg_set_destnode(msg, destnode);
@@ -448,7 +448,8 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
448 return data_sz; 448 return data_sz;
449 } 449 }
450 rmsg = buf_msg(rbuf); 450 rmsg = buf_msg(rbuf);
451 msg_init(rmsg, imp, msg_type(msg), err, hdr_sz, msg_orignode(msg)); 451 msg_init(rmsg, imp, msg_type(msg), hdr_sz, msg_orignode(msg));
452 msg_set_errcode(rmsg, err);
452 msg_set_destport(rmsg, msg_origport(msg)); 453 msg_set_destport(rmsg, msg_origport(msg));
453 msg_set_prevnode(rmsg, tipc_own_addr); 454 msg_set_prevnode(rmsg, tipc_own_addr);
454 msg_set_origport(rmsg, msg_destport(msg)); 455 msg_set_origport(rmsg, msg_destport(msg));