Commit cda3696d authored by Jon Paul Maloy's avatar Jon Paul Maloy Committed by David S. Miller

tipc: clean up socket layer message reception

When a message is received in a socket, one of the call chains
tipc_sk_rcv()->tipc_sk_enqueue()->filter_rcv()(->tipc_sk_proto_rcv())
or
tipc_sk_backlog_rcv()->filter_rcv()(->tipc_sk_proto_rcv())
are followed. At each of these levels we may encounter situations
where the message may need to be rejected, or a new message
produced for transfer back to the sender. Despite recent
improvements, the current code for doing this is perceived
as awkward and hard to follow.

Leveraging the two previous commits in this series, we now
introduce a more uniform handling of such situations. We
let each of the functions in the chain itself produce/reverse
the message to be returned to the sender, but also perform the
actual forwarding. This simplifies the necessary logics within
each function.
Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bcd3ffd4
...@@ -520,17 +520,15 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err) ...@@ -520,17 +520,15 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
/** /**
* tipc_msg_lookup_dest(): try to find new destination for named message * tipc_msg_lookup_dest(): try to find new destination for named message
* @skb: the buffer containing the message. * @skb: the buffer containing the message.
* @dnode: return value: next-hop node, if destination found * @err: error code to be used by caller if lookup fails
* @err: return value: error code to use, if message to be rejected
* Does not consume buffer * Does not consume buffer
* Returns true if a destination is found, false otherwise * Returns true if a destination is found, false otherwise
*/ */
bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)
u32 *dnode, int *err)
{ {
struct tipc_msg *msg = buf_msg(skb); struct tipc_msg *msg = buf_msg(skb);
u32 dport; u32 dport, dnode;
u32 own_addr = tipc_own_addr(net); u32 onode = tipc_own_addr(net);
if (!msg_isdata(msg)) if (!msg_isdata(msg))
return false; return false;
...@@ -543,15 +541,15 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, ...@@ -543,15 +541,15 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb,
return false; return false;
if (msg_reroute_cnt(msg)) if (msg_reroute_cnt(msg))
return false; return false;
*dnode = addr_domain(net, msg_lookup_scope(msg)); dnode = addr_domain(net, msg_lookup_scope(msg));
dport = tipc_nametbl_translate(net, msg_nametype(msg), dport = tipc_nametbl_translate(net, msg_nametype(msg),
msg_nameinst(msg), dnode); msg_nameinst(msg), &dnode);
if (!dport) if (!dport)
return false; return false;
msg_incr_reroute_cnt(msg); msg_incr_reroute_cnt(msg);
if (*dnode != own_addr) if (dnode != onode)
msg_set_prevnode(msg, own_addr); msg_set_prevnode(msg, onode);
msg_set_destnode(msg, *dnode); msg_set_destnode(msg, dnode);
msg_set_destport(msg, dport); msg_set_destport(msg, dport);
*err = TIPC_OK; *err = TIPC_OK;
return true; return true;
......
...@@ -798,8 +798,7 @@ bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg, ...@@ -798,8 +798,7 @@ bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg,
bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos); bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos);
int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
int offset, int dsz, int mtu, struct sk_buff_head *list); int offset, int dsz, int mtu, struct sk_buff_head *list);
bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, u32 *dnode, bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err);
int *err);
struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list); struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list);
static inline u16 buf_seqno(struct sk_buff *skb) static inline u16 buf_seqno(struct sk_buff *skb)
......
This diff is collapsed.
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE)) SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE))
int tipc_socket_init(void); int tipc_socket_init(void);
void tipc_socket_stop(void); void tipc_socket_stop(void);
int tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq); void tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq);
void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq, void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,
struct sk_buff_head *inputq); struct sk_buff_head *inputq);
void tipc_sk_reinit(struct net *net); void tipc_sk_reinit(struct net *net);
......
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