]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
tipc: add a function to get the bearer name
authorParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Tue, 26 Jul 2016 06:47:21 +0000 (08:47 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Jul 2016 21:26:42 +0000 (14:26 -0700)
Introduce a new function to get the bearer name from
its id. This is used in subsequent commit.

Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/bearer.c
net/tipc/bearer.h

index 65b0998a9bab1df02b07429e97e2f3719c537bf4..65b1bbf133bde535088f10b134b372aaa6f252c2 100644 (file)
@@ -171,6 +171,27 @@ struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name)
        return NULL;
 }
 
+/*     tipc_bearer_get_name - get the bearer name from its id.
+ *     @net: network namespace
+ *     @name: a pointer to the buffer where the name will be stored.
+ *     @bearer_id: the id to get the name from.
+ */
+int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
+{
+       struct tipc_net *tn = tipc_net(net);
+       struct tipc_bearer *b;
+
+       if (bearer_id >= MAX_BEARERS)
+               return -EINVAL;
+
+       b = rtnl_dereference(tn->bearer_list[bearer_id]);
+       if (!b)
+               return -EINVAL;
+
+       strcpy(name, b->name);
+       return 0;
+}
+
 void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
 {
        struct tipc_net *tn = net_generic(net, tipc_net_id);
index f1e6db5e63450eb698ffacc329cc0888d03f457c..43757f1f9cb3d45597fecab8787fdbc0d3005c5a 100644 (file)
@@ -197,6 +197,7 @@ int tipc_l2_send_msg(struct net *net, struct sk_buff *buf,
 void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest);
 void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest);
 struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name);
+int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id);
 struct tipc_media *tipc_media_find(const char *name);
 void tipc_bearer_reset_all(struct net *net);
 int tipc_bearer_setup(void);