aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/port.c
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2011-05-31 16:10:08 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-06-24 16:18:18 -0400
commite244a915ff7676b1567ba68102c9b53011f5b766 (patch)
treec5c2eaede7ac38927a075d7b019e36cc54f65daf /net/tipc/port.c
parent741d9eb7b8f352071f56aacb77f5245b4e2a4fbe (diff)
tipc: Optimize creation of FIN messages
Speeds up the creation of the FIN message that terminates a TIPC connection. The typical peer termination message is now created by duplicating the terminating port's standard payload message header and adjusting the message size, importance, and error code fields, rather than building all fields of the message from scratch. A FIN message that is directed to the port itself is created the same way. but also requires swapping the origin and destination address fields. In addition to reducing the work required to create FIN messages, these changes eliminate several instances of duplicated code, Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r--net/tipc/port.c61
1 files changed, 24 insertions, 37 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 70e9de577113..8be68e0bf300 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -489,39 +489,38 @@ static void port_handle_node_down(unsigned long ref)
489 489
490static struct sk_buff *port_build_self_abort_msg(struct tipc_port *p_ptr, u32 err) 490static struct sk_buff *port_build_self_abort_msg(struct tipc_port *p_ptr, u32 err)
491{ 491{
492 u32 imp = msg_importance(&p_ptr->phdr); 492 struct sk_buff *buf = port_build_peer_abort_msg(p_ptr, err);
493 493
494 if (!p_ptr->connected) 494 if (buf) {
495 return NULL; 495 struct tipc_msg *msg = buf_msg(buf);
496 if (imp < TIPC_CRITICAL_IMPORTANCE) 496 msg_swap_words(msg, 4, 5);
497 imp++; 497 msg_swap_words(msg, 6, 7);
498 return port_build_proto_msg(p_ptr->ref, 498 }
499 tipc_own_addr, 499 return buf;
500 port_peerport(p_ptr),
501 port_peernode(p_ptr),
502 imp,
503 TIPC_CONN_MSG,
504 err,
505 0);
506} 500}
507 501
508 502
509static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 err) 503static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 err)
510{ 504{
511 u32 imp = msg_importance(&p_ptr->phdr); 505 struct sk_buff *buf;
506 struct tipc_msg *msg;
507 u32 imp;
512 508
513 if (!p_ptr->connected) 509 if (!p_ptr->connected)
514 return NULL; 510 return NULL;
515 if (imp < TIPC_CRITICAL_IMPORTANCE) 511
516 imp++; 512 buf = tipc_buf_acquire(BASIC_H_SIZE);
517 return port_build_proto_msg(port_peerport(p_ptr), 513 if (buf) {
518 port_peernode(p_ptr), 514 msg = buf_msg(buf);
519 p_ptr->ref, 515 memcpy(msg, &p_ptr->phdr, BASIC_H_SIZE);
520 tipc_own_addr, 516 msg_set_hdr_sz(msg, BASIC_H_SIZE);
521 imp, 517 msg_set_size(msg, BASIC_H_SIZE);
522 TIPC_CONN_MSG, 518 imp = msg_importance(msg);
523 err, 519 if (imp < TIPC_CRITICAL_IMPORTANCE)
524 0); 520 msg_set_importance(msg, ++imp);
521 msg_set_errcode(msg, err);
522 }
523 return buf;
525} 524}
526 525
527void tipc_port_recv_proto_msg(struct sk_buff *buf) 526void tipc_port_recv_proto_msg(struct sk_buff *buf)
@@ -1149,19 +1148,7 @@ int tipc_shutdown(u32 ref)
1149 if (!p_ptr) 1148 if (!p_ptr)
1150 return -EINVAL; 1149 return -EINVAL;
1151 1150
1152 if (p_ptr->connected) { 1151 buf = port_build_peer_abort_msg(p_ptr, TIPC_CONN_SHUTDOWN);
1153 u32 imp = msg_importance(&p_ptr->phdr);
1154 if (imp < TIPC_CRITICAL_IMPORTANCE)
1155 imp++;
1156 buf = port_build_proto_msg(port_peerport(p_ptr),
1157 port_peernode(p_ptr),
1158 ref,
1159 tipc_own_addr,
1160 imp,
1161 TIPC_CONN_MSG,
1162 TIPC_CONN_SHUTDOWN,
1163 0);
1164 }
1165 tipc_port_unlock(p_ptr); 1152 tipc_port_unlock(p_ptr);
1166 tipc_net_route_msg(buf); 1153 tipc_net_route_msg(buf);
1167 return tipc_disconnect(ref); 1154 return tipc_disconnect(ref);