tipc: Minor optimizations to received message processing
[safe/jmp/linux-2.6] / net / tipc / link.c
index bd206eb..c62ebfe 100644 (file)
 
 
 /*
+ * Out-of-range value for link session numbers
+ */
+
+#define INVALID_SESSION 0x10000
+
+/*
  * Limit for deferred reception queue:
  */
 
@@ -464,7 +470,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
        msg = l_ptr->pmsg;
        msg_init(msg, LINK_PROTOCOL, RESET_MSG, TIPC_OK, INT_H_SIZE, l_ptr->addr);
        msg_set_size(msg, sizeof(l_ptr->proto_msg));
-       msg_set_session(msg, tipc_random);
+       msg_set_session(msg, (tipc_random & 0xffff));
        msg_set_bearer_id(msg, b_ptr->identity);
        strcpy((char *)msg_data(msg), if_name);
 
@@ -705,10 +711,10 @@ void tipc_link_reset(struct link *l_ptr)
        u32 checkpoint = l_ptr->next_in_no;
        int was_active_link = tipc_link_is_active(l_ptr);
 
-       msg_set_session(l_ptr->pmsg, msg_session(l_ptr->pmsg) + 1);
+       msg_set_session(l_ptr->pmsg, ((msg_session(l_ptr->pmsg) + 1) & 0xffff));
 
-       /* Link is down, accept any session: */
-       l_ptr->peer_session = 0;
+       /* Link is down, accept any session */
+       l_ptr->peer_session = INVALID_SESSION;
 
        /* Prepare for max packet size negotiation */
        link_init_max_pkt(l_ptr);
@@ -1760,21 +1766,6 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
        l_ptr->retransm_queue_head = l_ptr->retransm_queue_size = 0;
 }
 
-/*
- * link_recv_non_seq: Receive packets which are outside
- *                    the link sequence flow
- */
-
-static void link_recv_non_seq(struct sk_buff *buf)
-{
-       struct tipc_msg *msg = buf_msg(buf);
-
-       if (msg_user(msg) ==  LINK_CONFIG)
-               tipc_disc_recv_msg(buf);
-       else
-               tipc_bclink_recv_pkt(buf);
-}
-
 /**
  * link_insert_deferred_queue - insert deferred messages back into receive chain
  */
@@ -1851,7 +1842,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
 {
        read_lock_bh(&tipc_net_lock);
        while (head) {
-               struct bearer *b_ptr;
+               struct bearer *b_ptr = (struct bearer *)tb_ptr;
                struct node *n_ptr;
                struct link *l_ptr;
                struct sk_buff *crs;
@@ -1862,9 +1853,6 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
                u32 released = 0;
                int type;
 
-               b_ptr = (struct bearer *)tb_ptr;
-               TIPC_SKB_CB(buf)->handle = b_ptr;
-
                head = head->next;
 
                /* Ensure message is well-formed */
@@ -1883,7 +1871,10 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
                msg = buf_msg(buf);
 
                if (unlikely(msg_non_seq(msg))) {
-                       link_recv_non_seq(buf);
+                       if (msg_user(msg) ==  LINK_CONFIG)
+                               tipc_disc_recv_msg(buf, b_ptr);
+                       else
+                               tipc_bclink_recv_pkt(buf);
                        continue;
                }
 
@@ -1990,8 +1981,6 @@ deliver:
                                                if (link_recv_changeover_msg(&l_ptr, &buf)) {
                                                        msg = buf_msg(buf);
                                                        seq_no = msg_seqno(msg);
-                                                       TIPC_SKB_CB(buf)->handle
-                                                               = b_ptr;
                                                        if (type == ORIGINAL_MSG)
                                                                goto deliver;
                                                        goto protocol_check;
@@ -2275,7 +2264,8 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
        switch (msg_type(msg)) {
 
        case RESET_MSG:
-               if (!link_working_unknown(l_ptr) && l_ptr->peer_session) {
+               if (!link_working_unknown(l_ptr) &&
+                   (l_ptr->peer_session != INVALID_SESSION)) {
                        if (msg_session(msg) == l_ptr->peer_session) {
                                dbg("Duplicate RESET: %u<->%u\n",
                                    msg_session(msg), l_ptr->peer_session);