Skip to content

Commit ff0d3e7

Browse files
Parthasarathy Bhuvaragandavem330
authored andcommitted
tipc: add a function to get the bearer name
Introduce a new function to get the bearer name from its id. This is used in subsequent commit. Reviewed-by: Jon Maloy <[email protected]> Signed-off-by: Parthasarathy Bhuvaragan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bf1035b commit ff0d3e7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

net/tipc/bearer.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,27 @@ struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name)
171171
return NULL;
172172
}
173173

174+
/* tipc_bearer_get_name - get the bearer name from its id.
175+
* @net: network namespace
176+
* @name: a pointer to the buffer where the name will be stored.
177+
* @bearer_id: the id to get the name from.
178+
*/
179+
int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
180+
{
181+
struct tipc_net *tn = tipc_net(net);
182+
struct tipc_bearer *b;
183+
184+
if (bearer_id >= MAX_BEARERS)
185+
return -EINVAL;
186+
187+
b = rtnl_dereference(tn->bearer_list[bearer_id]);
188+
if (!b)
189+
return -EINVAL;
190+
191+
strcpy(name, b->name);
192+
return 0;
193+
}
194+
174195
void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest)
175196
{
176197
struct tipc_net *tn = net_generic(net, tipc_net_id);

net/tipc/bearer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ int tipc_l2_send_msg(struct net *net, struct sk_buff *buf,
197197
void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest);
198198
void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest);
199199
struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name);
200+
int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id);
200201
struct tipc_media *tipc_media_find(const char *name);
201202
void tipc_bearer_reset_all(struct net *net);
202203
int tipc_bearer_setup(void);

0 commit comments

Comments
 (0)