Skip to content

Commit

Permalink
tipc: Standardize exit logic for message rejection handling
Browse files Browse the repository at this point in the history
Modifies the routine that handles the rejection of payload messages
so that it has a single exit point that frees up the rejected message,
thereby eliminating some duplicated code.

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
  • Loading branch information
Allan Stephens authored and Paul Gortmaker committed Jun 24, 2011
1 parent 7ae4738 commit acc631b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions net/tipc/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,21 +367,18 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
imp++;

/* discard rejected message if it shouldn't be returned to sender */
if (msg_errcode(msg) || msg_dest_droppable(msg)) {
buf_discard(buf);
return data_sz;
}
if (msg_errcode(msg) || msg_dest_droppable(msg))
goto exit;

/* construct rejected message */
if (msg_mcast(msg))
hdr_sz = MCAST_H_SIZE;
else
hdr_sz = LONG_H_SIZE;
rbuf = tipc_buf_acquire(data_sz + hdr_sz);
if (rbuf == NULL) {
buf_discard(buf);
return data_sz;
}
if (rbuf == NULL)
goto exit;

rmsg = buf_msg(rbuf);
tipc_msg_init(rmsg, imp, msg_type(msg), hdr_sz, msg_orignode(msg));
msg_set_errcode(rmsg, err);
Expand Down Expand Up @@ -411,9 +408,11 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
tipc_net_route_msg(abuf);
}

/* send rejected message */
buf_discard(buf);
/* send returned message & dispose of rejected message */

tipc_net_route_msg(rbuf);
exit:
buf_discard(buf);
return data_sz;
}

Expand Down

0 comments on commit acc631b

Please sign in to comment.