aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
authorAllan Stephens <Allan.Stephens@windriver.com>2011-04-21 11:42:07 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-05-10 16:03:57 -0400
commit2689690469c9fd76f9db0afcdf2523f48cce4006 (patch)
tree73d23b37b9e4ad965f893857aa618b0ed110bdf7 /net/tipc/link.c
parentc29c3f70c9eb6f18090da5af9dbe9dcb4adece8c (diff)
tipc: Avoid recomputation of outgoing message length
Rework TIPC's message sending routines to take advantage of the total amount of data value passed to it by the kernel socket infrastructure. This change eliminates the need for TIPC to compute the size of outgoing messages itself, as well as the check for an oversize message in tipc_msg_build(). In addition, this change warrants an explanation: - res = send_packet(NULL, sock, &my_msg, 0); + res = send_packet(NULL, sock, &my_msg, bytes_to_send); Previously, the final argument to send_packet() was ignored (since the amount of data being sent was recalculated by a lower-level routine) and we could just pass in a dummy value (0). Now that the recalculation is being eliminated, the argument value being passed to send_packet() is significant and we have to supply the actual amount of data we want to send. Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r--net/tipc/link.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 2a9f44a203eb..4bab139d5e74 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -92,7 +92,8 @@ static int link_recv_changeover_msg(struct link **l_ptr, struct sk_buff **buf);
92static void link_set_supervision_props(struct link *l_ptr, u32 tolerance); 92static void link_set_supervision_props(struct link *l_ptr, u32 tolerance);
93static int link_send_sections_long(struct tipc_port *sender, 93static int link_send_sections_long(struct tipc_port *sender,
94 struct iovec const *msg_sect, 94 struct iovec const *msg_sect,
95 u32 num_sect, u32 destnode); 95 u32 num_sect, unsigned int total_len,
96 u32 destnode);
96static void link_check_defragm_bufs(struct link *l_ptr); 97static void link_check_defragm_bufs(struct link *l_ptr);
97static void link_state_event(struct link *l_ptr, u32 event); 98static void link_state_event(struct link *l_ptr, u32 event);
98static void link_reset_statistics(struct link *l_ptr); 99static void link_reset_statistics(struct link *l_ptr);
@@ -1043,6 +1044,7 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
1043int tipc_link_send_sections_fast(struct tipc_port *sender, 1044int tipc_link_send_sections_fast(struct tipc_port *sender,
1044 struct iovec const *msg_sect, 1045 struct iovec const *msg_sect,
1045 const u32 num_sect, 1046 const u32 num_sect,
1047 unsigned int total_len,
1046 u32 destaddr) 1048 u32 destaddr)
1047{ 1049{
1048 struct tipc_msg *hdr = &sender->phdr; 1050 struct tipc_msg *hdr = &sender->phdr;
@@ -1058,8 +1060,8 @@ again:
1058 * (Must not hold any locks while building message.) 1060 * (Must not hold any locks while building message.)
1059 */ 1061 */
1060 1062
1061 res = tipc_msg_build(hdr, msg_sect, num_sect, sender->max_pkt, 1063 res = tipc_msg_build(hdr, msg_sect, num_sect, total_len,
1062 !sender->user_port, &buf); 1064 sender->max_pkt, !sender->user_port, &buf);
1063 1065
1064 read_lock_bh(&tipc_net_lock); 1066 read_lock_bh(&tipc_net_lock);
1065 node = tipc_node_find(destaddr); 1067 node = tipc_node_find(destaddr);
@@ -1104,7 +1106,8 @@ exit:
1104 goto again; 1106 goto again;
1105 1107
1106 return link_send_sections_long(sender, msg_sect, 1108 return link_send_sections_long(sender, msg_sect,
1107 num_sect, destaddr); 1109 num_sect, total_len,
1110 destaddr);
1108 } 1111 }
1109 tipc_node_unlock(node); 1112 tipc_node_unlock(node);
1110 } 1113 }
@@ -1116,7 +1119,7 @@ exit:
1116 return tipc_reject_msg(buf, TIPC_ERR_NO_NODE); 1119 return tipc_reject_msg(buf, TIPC_ERR_NO_NODE);
1117 if (res >= 0) 1120 if (res >= 0)
1118 return tipc_port_reject_sections(sender, hdr, msg_sect, num_sect, 1121 return tipc_port_reject_sections(sender, hdr, msg_sect, num_sect,
1119 TIPC_ERR_NO_NODE); 1122 total_len, TIPC_ERR_NO_NODE);
1120 return res; 1123 return res;
1121} 1124}
1122 1125
@@ -1137,12 +1140,13 @@ exit:
1137static int link_send_sections_long(struct tipc_port *sender, 1140static int link_send_sections_long(struct tipc_port *sender,
1138 struct iovec const *msg_sect, 1141 struct iovec const *msg_sect,
1139 u32 num_sect, 1142 u32 num_sect,
1143 unsigned int total_len,
1140 u32 destaddr) 1144 u32 destaddr)
1141{ 1145{
1142 struct link *l_ptr; 1146 struct link *l_ptr;
1143 struct tipc_node *node; 1147 struct tipc_node *node;
1144 struct tipc_msg *hdr = &sender->phdr; 1148 struct tipc_msg *hdr = &sender->phdr;
1145 u32 dsz = msg_data_sz(hdr); 1149 u32 dsz = total_len;
1146 u32 max_pkt, fragm_sz, rest; 1150 u32 max_pkt, fragm_sz, rest;
1147 struct tipc_msg fragm_hdr; 1151 struct tipc_msg fragm_hdr;
1148 struct sk_buff *buf, *buf_chain, *prev; 1152 struct sk_buff *buf, *buf_chain, *prev;
@@ -1269,7 +1273,7 @@ reject:
1269 buf_discard(buf_chain); 1273 buf_discard(buf_chain);
1270 } 1274 }
1271 return tipc_port_reject_sections(sender, hdr, msg_sect, num_sect, 1275 return tipc_port_reject_sections(sender, hdr, msg_sect, num_sect,
1272 TIPC_ERR_NO_NODE); 1276 total_len, TIPC_ERR_NO_NODE);
1273 } 1277 }
1274 1278
1275 /* Append whole chain to send queue: */ 1279 /* Append whole chain to send queue: */