Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5377831 authored by Jon Paul Maloy's avatar Jon Paul Maloy Committed by David S. Miller
Browse files

tipc: changes to general packet reception algorithm



We change the order of checking for destination users when processing
incoming packets. By placing the checks for users that may potentially
replace the processed buffer, i.e., CHANGEOVER_PROTOCOL and
MSG_FRAGMENTER, in a separate step before we check for the true end
users, we get rid of a label and a 'goto', at the same time making the
code more comprehensible and easy to follow.

This commit does not change any functionality, it is just a cosmetic
code reshuffle.

Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 02842f71
Loading
Loading
Loading
Loading
+40 −36
Original line number Original line Diff line number Diff line
@@ -1503,7 +1503,6 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
		while ((crs != l_ptr->next_out) &&
		while ((crs != l_ptr->next_out) &&
		       less_eq(buf_seqno(crs), ackd)) {
		       less_eq(buf_seqno(crs), ackd)) {
			struct sk_buff *next = crs->next;
			struct sk_buff *next = crs->next;

			kfree_skb(crs);
			kfree_skb(crs);
			crs = next;
			crs = next;
			released++;
			released++;
@@ -1516,14 +1515,17 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
		/* Try sending any messages link endpoint has pending */
		/* Try sending any messages link endpoint has pending */
		if (unlikely(l_ptr->next_out))
		if (unlikely(l_ptr->next_out))
			tipc_link_push_queue(l_ptr);
			tipc_link_push_queue(l_ptr);

		if (unlikely(!list_empty(&l_ptr->waiting_ports)))
		if (unlikely(!list_empty(&l_ptr->waiting_ports)))
			tipc_link_wakeup_ports(l_ptr, 0);
			tipc_link_wakeup_ports(l_ptr, 0);

		if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) {
		if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) {
			l_ptr->stats.sent_acks++;
			l_ptr->stats.sent_acks++;
			tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
			tipc_link_send_proto_msg(l_ptr, STATE_MSG,
						 0, 0, 0, 0, 0);
		}
		}


		/* Now (finally!) process the incoming message */
		/* Process the incoming packet */
		if (unlikely(!link_working_working(l_ptr))) {
		if (unlikely(!link_working_working(l_ptr))) {
			if (msg_user(msg) == LINK_PROTOCOL) {
			if (msg_user(msg) == LINK_PROTOCOL) {
				link_recv_proto_msg(l_ptr, buf);
				link_recv_proto_msg(l_ptr, buf);
@@ -1555,14 +1557,40 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
		l_ptr->next_in_no++;
		l_ptr->next_in_no++;
		if (unlikely(l_ptr->oldest_deferred_in))
		if (unlikely(l_ptr->oldest_deferred_in))
			head = link_insert_deferred_queue(l_ptr, head);
			head = link_insert_deferred_queue(l_ptr, head);
deliver:

		if (likely(msg_isdata(msg))) {
		/* Deliver packet/message to correct user: */
		if (unlikely(msg_user(msg) ==  CHANGEOVER_PROTOCOL)) {
			if (!tipc_link_tunnel_rcv(n_ptr, &buf)) {
				tipc_node_unlock(n_ptr);
				tipc_node_unlock(n_ptr);
			tipc_port_recv_msg(buf);
				continue;
				continue;
			}
			}
			msg = buf_msg(buf);
		} else if (msg_user(msg) == MSG_FRAGMENTER) {
			int rc;

			l_ptr->stats.recv_fragments++;
			rc = tipc_link_frag_rcv(&l_ptr->reasm_head,
						&l_ptr->reasm_tail,
						&buf);
			if (rc == LINK_REASM_COMPLETE) {
				l_ptr->stats.recv_fragmented++;
				msg = buf_msg(buf);
			} else {
				if (rc == LINK_REASM_ERROR)
					tipc_link_reset(l_ptr);
				tipc_node_unlock(n_ptr);
				continue;
			}
		}

		switch (msg_user(msg)) {
		switch (msg_user(msg)) {
			int ret;
		case TIPC_LOW_IMPORTANCE:
		case TIPC_MEDIUM_IMPORTANCE:
		case TIPC_HIGH_IMPORTANCE:
		case TIPC_CRITICAL_IMPORTANCE:
			tipc_node_unlock(n_ptr);
			tipc_port_recv_msg(buf);
			continue;
		case MSG_BUNDLER:
		case MSG_BUNDLER:
			l_ptr->stats.recv_bundles++;
			l_ptr->stats.recv_bundles++;
			l_ptr->stats.recv_bundled += msg_msgcnt(msg);
			l_ptr->stats.recv_bundled += msg_msgcnt(msg);
@@ -1574,44 +1602,20 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr)
			tipc_node_unlock(n_ptr);
			tipc_node_unlock(n_ptr);
			tipc_named_recv(buf);
			tipc_named_recv(buf);
			continue;
			continue;
		case BCAST_PROTOCOL:
			tipc_link_recv_sync(n_ptr, buf);
			tipc_node_unlock(n_ptr);
			continue;
		case CONN_MANAGER:
		case CONN_MANAGER:
			tipc_node_unlock(n_ptr);
			tipc_node_unlock(n_ptr);
			tipc_port_recv_proto_msg(buf);
			tipc_port_recv_proto_msg(buf);
			continue;
			continue;
		case MSG_FRAGMENTER:
		case BCAST_PROTOCOL:
			l_ptr->stats.recv_fragments++;
			tipc_link_recv_sync(n_ptr, buf);
			ret = tipc_link_frag_rcv(&l_ptr->reasm_head,
						 &l_ptr->reasm_tail,
						 &buf);
			if (ret == LINK_REASM_COMPLETE) {
				l_ptr->stats.recv_fragmented++;
				msg = buf_msg(buf);
				goto deliver;
			}
			if (ret == LINK_REASM_ERROR)
				tipc_link_reset(l_ptr);
			tipc_node_unlock(n_ptr);
			continue;
		case CHANGEOVER_PROTOCOL:
			if (!tipc_link_tunnel_rcv(n_ptr, &buf))
			break;
			break;
			msg = buf_msg(buf);
			seq_no = msg_seqno(msg);
			goto deliver;
		default:
		default:
			kfree_skb(buf);
			kfree_skb(buf);
			buf = NULL;
			break;
			break;
		}
		}
		tipc_node_unlock(n_ptr);
		tipc_node_unlock(n_ptr);
		tipc_net_route_msg(buf);
		continue;
		continue;
unlock_discard:
unlock_discard:

		tipc_node_unlock(n_ptr);
		tipc_node_unlock(n_ptr);
discard:
discard:
		kfree_skb(buf);
		kfree_skb(buf);