Skip to content

Commit

Permalink
tipc: Standardize error checking on incoming messages via native API
Browse files Browse the repository at this point in the history
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: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Allan Stephens authored and David S. Miller committed Jun 5, 2008
1 parent 84b07c1 commit 5307e46
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions net/tipc/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,14 @@ static void port_dispatcher_sigh(void *dummy)
u32 peer_node = port_peernode(p_ptr);

tipc_port_unlock(p_ptr);
if (unlikely(!cb))
goto reject;
if (unlikely(!connected)) {
if (tipc_connect2port(dref, &orig))
goto reject;
} else if ((msg_origport(msg) != peer_port) ||
(msg_orignode(msg) != peer_node))
goto reject;
if (unlikely(!cb))
goto reject;
if (unlikely(++p_ptr->publ.conn_unacked >=
TIPC_FLOW_CONTROL_WIN))
tipc_acknowledge(dref,
Expand All @@ -862,9 +862,7 @@ static void port_dispatcher_sigh(void *dummy)
tipc_msg_event cb = up_ptr->msg_cb;

tipc_port_unlock(p_ptr);
if (unlikely(connected))
goto reject;
if (unlikely(!cb))
if (unlikely(!cb || connected))
goto reject;
skb_pull(buf, msg_hdr_sz(msg));
cb(usr_handle, dref, &buf, msg_data(msg),
Expand All @@ -877,11 +875,7 @@ static void port_dispatcher_sigh(void *dummy)
tipc_named_msg_event cb = up_ptr->named_msg_cb;

tipc_port_unlock(p_ptr);
if (unlikely(connected))
goto reject;
if (unlikely(!cb))
goto reject;
if (unlikely(!published))
if (unlikely(!cb || connected || !published))
goto reject;
dseq.type = msg_nametype(msg);
dseq.lower = msg_nameinst(msg);
Expand All @@ -908,11 +902,10 @@ static void port_dispatcher_sigh(void *dummy)
u32 peer_node = port_peernode(p_ptr);

tipc_port_unlock(p_ptr);
if (!connected || !cb)
break;
if (msg_origport(msg) != peer_port)
if (!cb || !connected)
break;
if (msg_orignode(msg) != peer_node)
if ((msg_origport(msg) != peer_port) ||
(msg_orignode(msg) != peer_node))
break;
tipc_disconnect(dref);
skb_pull(buf, msg_hdr_sz(msg));
Expand All @@ -924,7 +917,7 @@ static void port_dispatcher_sigh(void *dummy)
tipc_msg_err_event cb = up_ptr->err_cb;

tipc_port_unlock(p_ptr);
if (connected || !cb)
if (!cb || connected)
break;
skb_pull(buf, msg_hdr_sz(msg));
cb(usr_handle, dref, &buf, msg_data(msg),
Expand All @@ -937,7 +930,7 @@ static void port_dispatcher_sigh(void *dummy)
up_ptr->named_err_cb;

tipc_port_unlock(p_ptr);
if (connected || !cb)
if (!cb || connected)
break;
dseq.type = msg_nametype(msg);
dseq.lower = msg_nameinst(msg);
Expand Down

0 comments on commit 5307e46

Please sign in to comment.