diff options
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r-- | net/tipc/port.c | 43 |
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) | |||
1133 | return tipc_disconnect(ref); | 1133 | return tipc_disconnect(ref); |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | /** | ||
1137 | * tipc_port_recv_msg - receive message from lower layer and deliver to port user | ||
1138 | */ | ||
1139 | |||
1140 | int tipc_port_recv_msg(struct sk_buff *buf) | ||
1141 | { | ||
1142 | struct tipc_port *p_ptr; | ||
1143 | struct tipc_msg *msg = buf_msg(buf); | ||
1144 | u32 destport = msg_destport(msg); | ||
1145 | u32 dsz = msg_data_sz(msg); | ||
1146 | u32 err; | ||
1147 | |||
1148 | /* forward unresolved named message */ | ||
1149 | if (unlikely(!destport)) { | ||
1150 | tipc_net_route_msg(buf); | ||
1151 | return dsz; | ||
1152 | } | ||
1153 | |||
1154 | /* validate destination & pass to port, otherwise reject message */ | ||
1155 | p_ptr = tipc_port_lock(destport); | ||
1156 | if (likely(p_ptr)) { | ||
1157 | if (likely(p_ptr->connected)) { | ||
1158 | if ((unlikely(msg_origport(msg) != | ||
1159 | tipc_peer_port(p_ptr))) || | ||
1160 | (unlikely(msg_orignode(msg) != | ||
1161 | tipc_peer_node(p_ptr))) || | ||
1162 | (unlikely(!msg_connected(msg)))) { | ||
1163 | err = TIPC_ERR_NO_PORT; | ||
1164 | tipc_port_unlock(p_ptr); | ||
1165 | goto reject; | ||
1166 | } | ||
1167 | } | ||
1168 | err = p_ptr->dispatcher(p_ptr, buf); | ||
1169 | tipc_port_unlock(p_ptr); | ||
1170 | if (likely(!err)) | ||
1171 | return dsz; | ||
1172 | } else { | ||
1173 | err = TIPC_ERR_NO_PORT; | ||
1174 | } | ||
1175 | reject: | ||
1176 | return tipc_reject_msg(buf, err); | ||
1177 | } | ||
1178 | |||
1136 | /* | 1179 | /* |
1137 | * tipc_port_recv_sections(): Concatenate and deliver sectioned | 1180 | * tipc_port_recv_sections(): Concatenate and deliver sectioned |
1138 | * message for this node. | 1181 | * message for this node. |