mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
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>
This commit is contained in:
parent
d570d86497
commit
e3a77561e7
3 changed files with 47 additions and 42 deletions
|
@ -1739,7 +1739,7 @@ static int filter_rcv(struct sock *sk, struct sk_buff **skb)
|
|||
* @sk: socket
|
||||
* @skb: message
|
||||
*
|
||||
* Caller must hold socket lock, but not port lock.
|
||||
* Caller must hold socket lock
|
||||
*
|
||||
* Returns 0
|
||||
*/
|
||||
|
@ -1805,27 +1805,31 @@ int tipc_sk_rcv(struct net *net, struct sk_buff *skb)
|
|||
struct tipc_net *tn;
|
||||
struct sock *sk;
|
||||
u32 dport = msg_destport(buf_msg(skb));
|
||||
int err;
|
||||
int err = -TIPC_ERR_NO_PORT;
|
||||
u32 dnode;
|
||||
|
||||
/* Validate destination and message */
|
||||
/* Find destination */
|
||||
tsk = tipc_sk_lookup(net, dport);
|
||||
if (unlikely(!tsk)) {
|
||||
err = tipc_msg_eval(net, skb, &dnode);
|
||||
goto exit;
|
||||
if (likely(tsk)) {
|
||||
sk = &tsk->sk;
|
||||
spin_lock_bh(&sk->sk_lock.slock);
|
||||
err = tipc_sk_enqueue_skb(sk, &skb);
|
||||
spin_unlock_bh(&sk->sk_lock.slock);
|
||||
sock_put(sk);
|
||||
}
|
||||
sk = &tsk->sk;
|
||||
|
||||
spin_lock_bh(&sk->sk_lock.slock);
|
||||
err = tipc_sk_enqueue_skb(sk, &skb);
|
||||
spin_unlock_bh(&sk->sk_lock.slock);
|
||||
sock_put(sk);
|
||||
exit:
|
||||
if (unlikely(skb)) {
|
||||
tn = net_generic(net, tipc_net_id);
|
||||
if (!err || tipc_msg_reverse(tn->own_addr, skb, &dnode, -err))
|
||||
tipc_link_xmit_skb(net, skb, dnode, 0);
|
||||
if (likely(!skb))
|
||||
return 0;
|
||||
if (tipc_msg_lookup_dest(net, skb, &dnode, &err))
|
||||
goto xmit;
|
||||
if (!err) {
|
||||
dnode = msg_destnode(buf_msg(skb));
|
||||
goto xmit;
|
||||
}
|
||||
tn = net_generic(net, tipc_net_id);
|
||||
if (!tipc_msg_reverse(tn->own_addr, skb, &dnode, -err))
|
||||
return -EHOSTUNREACH;
|
||||
xmit:
|
||||
tipc_link_xmit_skb(net, skb, dnode, dport);
|
||||
return err ? -EHOSTUNREACH : 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue