aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/port.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/port.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/port.c')
-rw-r--r--net/tipc/port.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 9f2ff12cf436..c68dc956a423 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -74,7 +74,8 @@ static u32 port_peerport(struct tipc_port *p_ptr)
74 */ 74 */
75 75
76int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, 76int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
77 u32 num_sect, struct iovec const *msg_sect) 77 u32 num_sect, struct iovec const *msg_sect,
78 unsigned int total_len)
78{ 79{
79 struct tipc_msg *hdr; 80 struct tipc_msg *hdr;
80 struct sk_buff *buf; 81 struct sk_buff *buf;
@@ -98,7 +99,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
98 msg_set_namelower(hdr, seq->lower); 99 msg_set_namelower(hdr, seq->lower);
99 msg_set_nameupper(hdr, seq->upper); 100 msg_set_nameupper(hdr, seq->upper);
100 msg_set_hdr_sz(hdr, MCAST_H_SIZE); 101 msg_set_hdr_sz(hdr, MCAST_H_SIZE);
101 res = tipc_msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, 102 res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, MAX_MSG_SIZE,
102 !oport->user_port, &buf); 103 !oport->user_port, &buf);
103 if (unlikely(!buf)) 104 if (unlikely(!buf))
104 return res; 105 return res;
@@ -418,12 +419,12 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
418 419
419int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, 420int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr,
420 struct iovec const *msg_sect, u32 num_sect, 421 struct iovec const *msg_sect, u32 num_sect,
421 int err) 422 unsigned int total_len, int err)
422{ 423{
423 struct sk_buff *buf; 424 struct sk_buff *buf;
424 int res; 425 int res;
425 426
426 res = tipc_msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, 427 res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, MAX_MSG_SIZE,
427 !p_ptr->user_port, &buf); 428 !p_ptr->user_port, &buf);
428 if (!buf) 429 if (!buf)
429 return res; 430 return res;
@@ -1163,12 +1164,13 @@ int tipc_shutdown(u32 ref)
1163 */ 1164 */
1164 1165
1165static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect, 1166static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect,
1166 struct iovec const *msg_sect) 1167 struct iovec const *msg_sect,
1168 unsigned int total_len)
1167{ 1169{
1168 struct sk_buff *buf; 1170 struct sk_buff *buf;
1169 int res; 1171 int res;
1170 1172
1171 res = tipc_msg_build(&sender->phdr, msg_sect, num_sect, 1173 res = tipc_msg_build(&sender->phdr, msg_sect, num_sect, total_len,
1172 MAX_MSG_SIZE, !sender->user_port, &buf); 1174 MAX_MSG_SIZE, !sender->user_port, &buf);
1173 if (likely(buf)) 1175 if (likely(buf))
1174 tipc_port_recv_msg(buf); 1176 tipc_port_recv_msg(buf);
@@ -1179,7 +1181,8 @@ static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_se
1179 * tipc_send - send message sections on connection 1181 * tipc_send - send message sections on connection
1180 */ 1182 */
1181 1183
1182int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect) 1184int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect,
1185 unsigned int total_len)
1183{ 1186{
1184 struct tipc_port *p_ptr; 1187 struct tipc_port *p_ptr;
1185 u32 destnode; 1188 u32 destnode;
@@ -1194,9 +1197,10 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1194 destnode = port_peernode(p_ptr); 1197 destnode = port_peernode(p_ptr);
1195 if (likely(destnode != tipc_own_addr)) 1198 if (likely(destnode != tipc_own_addr))
1196 res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, 1199 res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect,
1197 destnode); 1200 total_len, destnode);
1198 else 1201 else
1199 res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect); 1202 res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect,
1203 total_len);
1200 1204
1201 if (likely(res != -ELINKCONG)) { 1205 if (likely(res != -ELINKCONG)) {
1202 p_ptr->congested = 0; 1206 p_ptr->congested = 0;
@@ -1207,8 +1211,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1207 } 1211 }
1208 if (port_unreliable(p_ptr)) { 1212 if (port_unreliable(p_ptr)) {
1209 p_ptr->congested = 0; 1213 p_ptr->congested = 0;
1210 /* Just calculate msg length and return */ 1214 return total_len;
1211 return tipc_msg_calc_data_size(msg_sect, num_sect);
1212 } 1215 }
1213 return -ELINKCONG; 1216 return -ELINKCONG;
1214} 1217}
@@ -1218,7 +1221,8 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1218 */ 1221 */
1219 1222
1220int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, 1223int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1221 unsigned int num_sect, struct iovec const *msg_sect) 1224 unsigned int num_sect, struct iovec const *msg_sect,
1225 unsigned int total_len)
1222{ 1226{
1223 struct tipc_port *p_ptr; 1227 struct tipc_port *p_ptr;
1224 struct tipc_msg *msg; 1228 struct tipc_msg *msg;
@@ -1245,23 +1249,23 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1245 if (likely(destport)) { 1249 if (likely(destport)) {
1246 if (likely(destnode == tipc_own_addr)) 1250 if (likely(destnode == tipc_own_addr))
1247 res = tipc_port_recv_sections(p_ptr, num_sect, 1251 res = tipc_port_recv_sections(p_ptr, num_sect,
1248 msg_sect); 1252 msg_sect, total_len);
1249 else 1253 else
1250 res = tipc_link_send_sections_fast(p_ptr, msg_sect, 1254 res = tipc_link_send_sections_fast(p_ptr, msg_sect,
1251 num_sect, destnode); 1255 num_sect, total_len,
1256 destnode);
1252 if (likely(res != -ELINKCONG)) { 1257 if (likely(res != -ELINKCONG)) {
1253 if (res > 0) 1258 if (res > 0)
1254 p_ptr->sent++; 1259 p_ptr->sent++;
1255 return res; 1260 return res;
1256 } 1261 }
1257 if (port_unreliable(p_ptr)) { 1262 if (port_unreliable(p_ptr)) {
1258 /* Just calculate msg length and return */ 1263 return total_len;
1259 return tipc_msg_calc_data_size(msg_sect, num_sect);
1260 } 1264 }
1261 return -ELINKCONG; 1265 return -ELINKCONG;
1262 } 1266 }
1263 return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, 1267 return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect,
1264 TIPC_ERR_NO_NAME); 1268 total_len, TIPC_ERR_NO_NAME);
1265} 1269}
1266 1270
1267/** 1271/**
@@ -1269,7 +1273,8 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1269 */ 1273 */
1270 1274
1271int tipc_send2port(u32 ref, struct tipc_portid const *dest, 1275int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1272 unsigned int num_sect, struct iovec const *msg_sect) 1276 unsigned int num_sect, struct iovec const *msg_sect,
1277 unsigned int total_len)
1273{ 1278{
1274 struct tipc_port *p_ptr; 1279 struct tipc_port *p_ptr;
1275 struct tipc_msg *msg; 1280 struct tipc_msg *msg;
@@ -1289,18 +1294,18 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1289 msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); 1294 msg_set_hdr_sz(msg, DIR_MSG_H_SIZE);
1290 1295
1291 if (dest->node == tipc_own_addr) 1296 if (dest->node == tipc_own_addr)
1292 res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect); 1297 res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect,
1298 total_len);
1293 else 1299 else
1294 res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, 1300 res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect,
1295 dest->node); 1301 total_len, dest->node);
1296 if (likely(res != -ELINKCONG)) { 1302 if (likely(res != -ELINKCONG)) {
1297 if (res > 0) 1303 if (res > 0)
1298 p_ptr->sent++; 1304 p_ptr->sent++;
1299 return res; 1305 return res;
1300 } 1306 }
1301 if (port_unreliable(p_ptr)) { 1307 if (port_unreliable(p_ptr)) {
1302 /* Just calculate msg length and return */ 1308 return total_len;
1303 return tipc_msg_calc_data_size(msg_sect, num_sect);
1304 } 1309 }
1305 return -ELINKCONG; 1310 return -ELINKCONG;
1306} 1311}