netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Allan Stephens <allan.stephens@windriver.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, allan.stephens@windriver.com
Subject: [PATCH 02/13 net-next-2.6] [TIPC]: Standardize error checking on incoming messages via native API
Date: Fri, 30 May 2008 14:20:37 -0400	[thread overview]
Message-ID: <1212171648-27122-3-git-send-email-allan.stephens@windriver.com> (raw)
In-Reply-To: <1212171648-27122-1-git-send-email-allan.stephens@windriver.com>

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>
---
 net/tipc/port.c |   25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/net/tipc/port.c b/net/tipc/port.c
index 0bd3e61..4dfef9e 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -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,
@@ -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),
@@ -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);
@@ -908,11 +902,10 @@ err:
 				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));
@@ -924,7 +917,7 @@ err:
 				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),
@@ -937,7 +930,7 @@ err:
 					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);
-- 
1.5.3.2


  parent reply	other threads:[~2008-05-30 18:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-30 18:20 [PATCH 00/13 net-next-2.6] [TIPC]: More minor fixes and enhancements Allan Stephens
2008-05-30 18:20 ` [PATCH 01/13 net-next-2.6] [TIPC]: Fix bug in connection setup via native API Allan Stephens
2008-05-30 18:20 ` Allan Stephens [this message]
2008-05-30 18:20 ` [PATCH 03/13 net-next-2.6] [TIPC]: Fix bugs in message error code display when debugging Allan Stephens
2008-05-30 18:20 ` [PATCH 04/13 net-next-2.6] [TIPC]: Fix minor bugs in link session number handling Allan Stephens
2008-05-30 18:20 ` [PATCH 05/13 net-next-2.6] [TIPC]: Minor optimizations to received message processing Allan Stephens
2008-05-30 18:20 ` [PATCH 06/13 net-next-2.6] [TIPC]: Prevent access of non-existent field in short message header Allan Stephens
2008-05-30 18:20 ` [PATCH 07/13 net-next-2.6] [TIPC]: Optimize message initialization routine Allan Stephens
2008-05-30 18:20 ` [PATCH 08/13 net-next-2.6] [TIPC]: Prevent display of name table types with no publications Allan Stephens
2008-05-30 18:20 ` [PATCH 09/13 net-next-2.6] [TIPC]: Add missing spinlock in name table display code Allan Stephens
2008-05-30 18:20 ` [PATCH 10/13 net-next-2.6] [TIPC]: Expand link sequence gap field to 13 bits Allan Stephens
2008-05-30 18:20 ` [PATCH 11/13 net-next-2.6] [TIPC]: Message header creation optimizations Allan Stephens
2008-05-30 18:20 ` [PATCH 12/13 net-next-2.6] [TIPC]: Fix bugs in rejection of message with short header Allan Stephens
2008-05-30 18:20 ` [PATCH 13/13 net-next-2.6] [TIPC]: Message rejection rework preparatory changes Allan Stephens
2008-06-05  1:21 ` [PATCH 00/13 net-next-2.6] [TIPC]: More minor fixes and enhancements David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1212171648-27122-3-git-send-email-allan.stephens@windriver.com \
    --to=allan.stephens@windriver.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).