summaryrefslogtreecommitdiffstats
path: root/net/tipc/port.c
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2011-11-09 19:29:18 +0100
committerPaul Gortmaker <paul.gortmaker@windriver.com>2012-02-29 17:44:32 +0100
commit9b641251aee1a804169a17fe4236a50188894994 (patch)
tree38748e8e60bb1df91e3ea5a70444823e05398c26 /net/tipc/port.c
parenttipc: Eliminate support for tipc_mode global variable (diff)
downloadlinux-9b641251aee1a804169a17fe4236a50188894994.tar.xz
linux-9b641251aee1a804169a17fe4236a50188894994.zip
tipc: Un-inline port routine for processing incoming messages
Converts a non-trivial routine from inline to non-inline form to avoid bloating the TIPC code base with 6 copies of its body. This change is essentially cosmetic, and doesn't change existing TIPC behavior. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r--net/tipc/port.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index b103d7630c82..6adcdf99123b 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -1133,6 +1133,49 @@ int tipc_shutdown(u32 ref)
return tipc_disconnect(ref);
}
+/**
+ * tipc_port_recv_msg - receive message from lower layer and deliver to port user
+ */
+
+int tipc_port_recv_msg(struct sk_buff *buf)
+{
+ struct tipc_port *p_ptr;
+ struct tipc_msg *msg = buf_msg(buf);
+ u32 destport = msg_destport(msg);
+ u32 dsz = msg_data_sz(msg);
+ u32 err;
+
+ /* forward unresolved named message */
+ if (unlikely(!destport)) {
+ tipc_net_route_msg(buf);
+ return dsz;
+ }
+
+ /* validate destination & pass to port, otherwise reject message */
+ p_ptr = tipc_port_lock(destport);
+ if (likely(p_ptr)) {
+ if (likely(p_ptr->connected)) {
+ if ((unlikely(msg_origport(msg) !=
+ tipc_peer_port(p_ptr))) ||
+ (unlikely(msg_orignode(msg) !=
+ tipc_peer_node(p_ptr))) ||
+ (unlikely(!msg_connected(msg)))) {
+ err = TIPC_ERR_NO_PORT;
+ tipc_port_unlock(p_ptr);
+ goto reject;
+ }
+ }
+ err = p_ptr->dispatcher(p_ptr, buf);
+ tipc_port_unlock(p_ptr);
+ if (likely(!err))
+ return dsz;
+ } else {
+ err = TIPC_ERR_NO_PORT;
+ }
+reject:
+ return tipc_reject_msg(buf, err);
+}
+
/*
* tipc_port_recv_sections(): Concatenate and deliver sectioned
* message for this node.