Commit 5307e469 authored by Allan Stephens's avatar Allan Stephens Committed by David S. Miller

tipc: Standardize error checking on incoming messages via native API

This patch re-orders & re-groups the error checks performed on
messages being delivered to native API ports, in order to clarify the
similarities and differences required for the various message types.
Signed-off-by: default avatarAllan Stephens <allan.stephens@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 84b07c16
...@@ -841,14 +841,14 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -841,14 +841,14 @@ static void port_dispatcher_sigh(void *dummy)
u32 peer_node = port_peernode(p_ptr); u32 peer_node = port_peernode(p_ptr);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
if (unlikely(!cb))
goto reject;
if (unlikely(!connected)) { if (unlikely(!connected)) {
if (tipc_connect2port(dref, &orig)) if (tipc_connect2port(dref, &orig))
goto reject; goto reject;
} else if ((msg_origport(msg) != peer_port) || } else if ((msg_origport(msg) != peer_port) ||
(msg_orignode(msg) != peer_node)) (msg_orignode(msg) != peer_node))
goto reject; goto reject;
if (unlikely(!cb))
goto reject;
if (unlikely(++p_ptr->publ.conn_unacked >= if (unlikely(++p_ptr->publ.conn_unacked >=
TIPC_FLOW_CONTROL_WIN)) TIPC_FLOW_CONTROL_WIN))
tipc_acknowledge(dref, tipc_acknowledge(dref,
...@@ -862,9 +862,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -862,9 +862,7 @@ static void port_dispatcher_sigh(void *dummy)
tipc_msg_event cb = up_ptr->msg_cb; tipc_msg_event cb = up_ptr->msg_cb;
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
if (unlikely(connected)) if (unlikely(!cb || connected))
goto reject;
if (unlikely(!cb))
goto reject; goto reject;
skb_pull(buf, msg_hdr_sz(msg)); skb_pull(buf, msg_hdr_sz(msg));
cb(usr_handle, dref, &buf, msg_data(msg), cb(usr_handle, dref, &buf, msg_data(msg),
...@@ -877,11 +875,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -877,11 +875,7 @@ static void port_dispatcher_sigh(void *dummy)
tipc_named_msg_event cb = up_ptr->named_msg_cb; tipc_named_msg_event cb = up_ptr->named_msg_cb;
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
if (unlikely(connected)) if (unlikely(!cb || connected || !published))
goto reject;
if (unlikely(!cb))
goto reject;
if (unlikely(!published))
goto reject; goto reject;
dseq.type = msg_nametype(msg); dseq.type = msg_nametype(msg);
dseq.lower = msg_nameinst(msg); dseq.lower = msg_nameinst(msg);
...@@ -908,11 +902,10 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -908,11 +902,10 @@ static void port_dispatcher_sigh(void *dummy)
u32 peer_node = port_peernode(p_ptr); u32 peer_node = port_peernode(p_ptr);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
if (!connected || !cb) if (!cb || !connected)
break;
if (msg_origport(msg) != peer_port)
break; break;
if (msg_orignode(msg) != peer_node) if ((msg_origport(msg) != peer_port) ||
(msg_orignode(msg) != peer_node))
break; break;
tipc_disconnect(dref); tipc_disconnect(dref);
skb_pull(buf, msg_hdr_sz(msg)); skb_pull(buf, msg_hdr_sz(msg));
...@@ -924,7 +917,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -924,7 +917,7 @@ static void port_dispatcher_sigh(void *dummy)
tipc_msg_err_event cb = up_ptr->err_cb; tipc_msg_err_event cb = up_ptr->err_cb;
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
if (connected || !cb) if (!cb || connected)
break; break;
skb_pull(buf, msg_hdr_sz(msg)); skb_pull(buf, msg_hdr_sz(msg));
cb(usr_handle, dref, &buf, msg_data(msg), cb(usr_handle, dref, &buf, msg_data(msg),
...@@ -937,7 +930,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -937,7 +930,7 @@ static void port_dispatcher_sigh(void *dummy)
up_ptr->named_err_cb; up_ptr->named_err_cb;
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
if (connected || !cb) if (!cb || connected)
break; break;
dseq.type = msg_nametype(msg); dseq.type = msg_nametype(msg);
dseq.lower = msg_nameinst(msg); dseq.lower = msg_nameinst(msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment