tipc: Minor optimizations to name table translation code
authorAllan Stephens <allan.stephens@windriver.com>
Fri, 3 Sep 2010 08:33:39 +0000 (08:33 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Sep 2010 01:12:56 +0000 (18:12 -0700)
Optimizes TIPC's name table translation code to avoid unnecessary
manipulation of the node address field of the resulting port id when
name translation fails.  This change is possible because a valid port
id cannot have a reference field of zero, so examining the reference
only is sufficient to determine if the translation was successful.

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/name_table.c
net/tipc/port.c

index d504e490fd02726140549606074afa2ebcce6c29..c13c2c7c4b575205d7ce8a397121acf30f09d724 100644 (file)
@@ -613,8 +613,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
 }
 
 /*
- * tipc_nametbl_translate(): Translate tipc_name -> tipc_portid.
- *                      Very time-critical.
+ * tipc_nametbl_translate - translate name to port id
  *
  * Note: on entry 'destnode' is the search domain used during translation;
  *       on exit it passes back the node address of the matching port (if any)
@@ -685,7 +684,6 @@ found:
        }
        spin_unlock_bh(&seq->lock);
 not_found:
-       *destnode = 0;
        read_unlock_bh(&tipc_nametbl_lock);
        return 0;
 }
index ebcbc21d8f9827c525e85b4ea8636a2101091e3b..d760336f2ca815cb8ef8dcf35ef0bc8ec56898bd 100644 (file)
@@ -1464,7 +1464,7 @@ int tipc_forward2name(u32 ref,
        msg_set_destnode(msg, destnode);
        msg_set_destport(msg, destport);
 
-       if (likely(destport || destnode)) {
+       if (likely(destport)) {
                p_ptr->sent++;
                if (likely(destnode == tipc_own_addr))
                        return tipc_port_recv_sections(p_ptr, num_sect, msg_sect);
@@ -1542,7 +1542,7 @@ int tipc_forward_buf2name(u32 ref,
        skb_push(buf, LONG_H_SIZE);
        skb_copy_to_linear_data(buf, msg, LONG_H_SIZE);
        msg_dbg(buf_msg(buf),"PREP:");
-       if (likely(destport || destnode)) {
+       if (likely(destport)) {
                p_ptr->sent++;
                if (destnode == tipc_own_addr)
                        return tipc_port_recv_msg(buf);