tipc: avoid unnecessary lookup for tipc bearer instance
authorYing Xue <ying.xue@windriver.com>
Fri, 18 Oct 2013 05:23:18 +0000 (07:23 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Oct 2013 17:20:43 +0000 (13:20 -0400)
tipc_block_bearer() currently takes a bearer name (const char*)
as argument. This requires the function to make a lookup to find
the pointer to the corresponding bearer struct. In the current
code base this is not necessary, since the only two callers
(tipc_continue(),recv_notification()) already have validated
copies of this pointer, and hence can pass it directly in the
function call.

We change tipc_block_bearer() to directly take struct tipc_bearer*
as argument instead.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/bearer.c
net/tipc/bearer.h
net/tipc/eth_media.c
net/tipc/ib_media.c

index 09faa5520079fecca0843938960734d400282670..3f9707a16d0650d6367ad716ab2a110318a03e96 100644 (file)
@@ -420,23 +420,15 @@ exit:
 }
 
 /**
- * tipc_block_bearer - Block the bearer with the given name, and reset all its links
+ * tipc_block_bearer - Block the bearer, and reset all its links
  */
-int tipc_block_bearer(const char *name)
+int tipc_block_bearer(struct tipc_bearer *b_ptr)
 {
-       struct tipc_bearer *b_ptr = NULL;
        struct tipc_link *l_ptr;
        struct tipc_link *temp_l_ptr;
 
        read_lock_bh(&tipc_net_lock);
-       b_ptr = tipc_bearer_find(name);
-       if (!b_ptr) {
-               pr_warn("Attempt to block unknown bearer <%s>\n", name);
-               read_unlock_bh(&tipc_net_lock);
-               return -EINVAL;
-       }
-
-       pr_info("Blocking bearer <%s>\n", name);
+       pr_info("Blocking bearer <%s>\n", b_ptr->name);
        spin_lock_bh(&b_ptr->lock);
        b_ptr->blocked = 1;
        list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
index f800e63980cf146231027d9caf94e411b8854e22..e5e04be6fffa3782c01f37db795c7f84c8b71793 100644 (file)
@@ -163,7 +163,7 @@ int tipc_register_media(struct tipc_media *m_ptr);
 
 void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
 
-int  tipc_block_bearer(const char *name);
+int  tipc_block_bearer(struct tipc_bearer *b_ptr);
 void tipc_continue(struct tipc_bearer *tb_ptr);
 
 int tipc_enable_bearer(const char *bearer_name, u32 disc_domain, u32 priority);
index e048d491cc0b2275acda9ce5ffb0678caaac6eb1..c36c938306a191f516c8d44a3c65ce58d7e7cad0 100644 (file)
@@ -265,17 +265,17 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
                if (netif_carrier_ok(dev))
                        tipc_continue(eb_ptr->bearer);
                else
-                       tipc_block_bearer(eb_ptr->bearer->name);
+                       tipc_block_bearer(eb_ptr->bearer);
                break;
        case NETDEV_UP:
                tipc_continue(eb_ptr->bearer);
                break;
        case NETDEV_DOWN:
-               tipc_block_bearer(eb_ptr->bearer->name);
+               tipc_block_bearer(eb_ptr->bearer);
                break;
        case NETDEV_CHANGEMTU:
        case NETDEV_CHANGEADDR:
-               tipc_block_bearer(eb_ptr->bearer->name);
+               tipc_block_bearer(eb_ptr->bearer);
                tipc_continue(eb_ptr->bearer);
                break;
        case NETDEV_UNREGISTER:
index 5545145ccffaba9ac85f1808d28725b4e6bc2831..20b1aa464321832f031efaad2cd8b3fe849537bc 100644 (file)
@@ -258,17 +258,17 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
                if (netif_carrier_ok(dev))
                        tipc_continue(ib_ptr->bearer);
                else
-                       tipc_block_bearer(ib_ptr->bearer->name);
+                       tipc_block_bearer(ib_ptr->bearer);
                break;
        case NETDEV_UP:
                tipc_continue(ib_ptr->bearer);
                break;
        case NETDEV_DOWN:
-               tipc_block_bearer(ib_ptr->bearer->name);
+               tipc_block_bearer(ib_ptr->bearer);
                break;
        case NETDEV_CHANGEMTU:
        case NETDEV_CHANGEADDR:
-               tipc_block_bearer(ib_ptr->bearer->name);
+               tipc_block_bearer(ib_ptr->bearer);
                tipc_continue(ib_ptr->bearer);
                break;
        case NETDEV_UNREGISTER: