summaryrefslogtreecommitdiffstats
path: root/net/tipc/msg.c
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-02-05 08:36:39 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-05 19:00:02 -0500
commite3a77561e7d326e18881ef3cb84807892b353459 (patch)
treeb3d958bcfa747d87a979936e5814b7a5aeba97f3 /net/tipc/msg.c
parentd570d86497eeb11410b1c096d82ade11bcdd966c (diff)
tipc: split up function tipc_msg_eval()
The function tipc_msg_eval() is in reality doing two related, but different tasks. First it tries to find a new destination for named messages, in case there was no first lookup, or if the first lookup failed. Second, it does what its name suggests, evaluating the validity of the message and its destination, and returning an appropriate error code depending on the result. This is confusing, and in this commit we choose to break it up into two functions. A new function, tipc_msg_lookup_dest(), first attempts to find a new destination, if the message is of the right type. If this lookup fails, or if the message should not be subject to a second lookup, the already existing tipc_msg_reverse() is called. This function performs prepares the message for rejection, if applicable. 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/msg.c')
-rw-r--r--net/tipc/msg.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 940d74197b8c..697223a21240 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -411,43 +411,43 @@ bool tipc_msg_reverse(u32 own_addr, struct sk_buff *buf, u32 *dnode,
411 return true; 411 return true;
412exit: 412exit:
413 kfree_skb(buf); 413 kfree_skb(buf);
414 *dnode = 0;
414 return false; 415 return false;
415} 416}
416 417
417/** 418/**
418 * tipc_msg_eval: determine fate of message that found no destination 419 * tipc_msg_lookup_dest(): try to find new destination for named message
419 * @buf: the buffer containing the message. 420 * @skb: the buffer containing the message.
420 * @dnode: return value: next-hop node, if message to be forwarded 421 * @dnode: return value: next-hop node, if destination found
421 * @err: error code to use, if message to be rejected 422 * @err: return value: error code to use, if message to be rejected
422 *
423 * Does not consume buffer 423 * Does not consume buffer
424 * Returns 0 (TIPC_OK) if message ok and we can try again, -TIPC error 424 * Returns true if a destination is found, false otherwise
425 * code if message to be rejected
426 */ 425 */
427int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode) 426bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb,
427 u32 *dnode, int *err)
428{ 428{
429 struct tipc_msg *msg = buf_msg(buf); 429 struct tipc_msg *msg = buf_msg(skb);
430 u32 dport; 430 u32 dport;
431 431
432 if (msg_type(msg) != TIPC_NAMED_MSG) 432 if (!msg_isdata(msg))
433 return -TIPC_ERR_NO_PORT; 433 return false;
434 if (skb_linearize(buf)) 434 if (!msg_named(msg))
435 return -TIPC_ERR_NO_NAME; 435 return false;
436 if (msg_data_sz(msg) > MAX_FORWARD_SIZE) 436 *err = -TIPC_ERR_NO_NAME;
437 return -TIPC_ERR_NO_NAME; 437 if (skb_linearize(skb))
438 return false;
438 if (msg_reroute_cnt(msg) > 0) 439 if (msg_reroute_cnt(msg) > 0)
439 return -TIPC_ERR_NO_NAME; 440 return false;
440
441 *dnode = addr_domain(net, msg_lookup_scope(msg)); 441 *dnode = addr_domain(net, msg_lookup_scope(msg));
442 dport = tipc_nametbl_translate(net, msg_nametype(msg), 442 dport = tipc_nametbl_translate(net, msg_nametype(msg),
443 msg_nameinst(msg), 443 msg_nameinst(msg), dnode);
444 dnode);
445 if (!dport) 444 if (!dport)
446 return -TIPC_ERR_NO_NAME; 445 return false;
447 msg_incr_reroute_cnt(msg); 446 msg_incr_reroute_cnt(msg);
448 msg_set_destnode(msg, *dnode); 447 msg_set_destnode(msg, *dnode);
449 msg_set_destport(msg, dport); 448 msg_set_destport(msg, dport);
450 return TIPC_OK; 449 *err = TIPC_OK;
450 return true;
451} 451}
452 452
453/* tipc_msg_reassemble() - clone a buffer chain of fragments and 453/* tipc_msg_reassemble() - clone a buffer chain of fragments and