Skip to content

Commit cda3696

Browse files
Jon Paul Maloydavem330
authored andcommitted
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: Ying Xue <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bcd3ffd commit cda3696

File tree

4 files changed

+134
-146
lines changed

4 files changed

+134
-146
lines changed

net/tipc/msg.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,15 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
520520
/**
521521
* tipc_msg_lookup_dest(): try to find new destination for named message
522522
* @skb: the buffer containing the message.
523-
* @dnode: return value: next-hop node, if destination found
524-
* @err: return value: error code to use, if message to be rejected
523+
* @err: error code to be used by caller if lookup fails
525524
* Does not consume buffer
526525
* Returns true if a destination is found, false otherwise
527526
*/
528-
bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb,
529-
u32 *dnode, int *err)
527+
bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)
530528
{
531529
struct tipc_msg *msg = buf_msg(skb);
532-
u32 dport;
533-
u32 own_addr = tipc_own_addr(net);
530+
u32 dport, dnode;
531+
u32 onode = tipc_own_addr(net);
534532

535533
if (!msg_isdata(msg))
536534
return false;
@@ -543,15 +541,15 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb,
543541
return false;
544542
if (msg_reroute_cnt(msg))
545543
return false;
546-
*dnode = addr_domain(net, msg_lookup_scope(msg));
544+
dnode = addr_domain(net, msg_lookup_scope(msg));
547545
dport = tipc_nametbl_translate(net, msg_nametype(msg),
548-
msg_nameinst(msg), dnode);
546+
msg_nameinst(msg), &dnode);
549547
if (!dport)
550548
return false;
551549
msg_incr_reroute_cnt(msg);
552-
if (*dnode != own_addr)
553-
msg_set_prevnode(msg, own_addr);
554-
msg_set_destnode(msg, *dnode);
550+
if (dnode != onode)
551+
msg_set_prevnode(msg, onode);
552+
msg_set_destnode(msg, dnode);
555553
msg_set_destport(msg, dport);
556554
*err = TIPC_OK;
557555
return true;

net/tipc/msg.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,7 @@ bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg,
798798
bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos);
799799
int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
800800
int offset, int dsz, int mtu, struct sk_buff_head *list);
801-
bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, u32 *dnode,
802-
int *err);
801+
bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err);
803802
struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list);
804803

805804
static inline u16 buf_seqno(struct sk_buff *skb)

0 commit comments

Comments
 (0)