diff options
| author | Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com> | 2016-07-26 02:47:21 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-07-26 17:26:42 -0400 |
| commit | ff0d3e78a67a8edd09688f073361de9ed8abf9dc (patch) | |
| tree | c227005af52da82c24c476a35a97c6cc82d01bfc | |
| parent | bf1035b2ff5296c7c49e262152253ce29d87e82d (diff) | |
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 <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/tipc/bearer.c | 21 | ||||
| -rw-r--r-- | net/tipc/bearer.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 65b0998a9bab..65b1bbf133bd 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
| @@ -171,6 +171,27 @@ struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name) | |||
| 171 | return NULL; | 171 | return NULL; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 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 | |||
| 174 | void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest) | 195 | void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest) |
| 175 | { | 196 | { |
| 176 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 197 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index f1e6db5e6345..43757f1f9cb3 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
| @@ -197,6 +197,7 @@ int tipc_l2_send_msg(struct net *net, struct sk_buff *buf, | |||
| 197 | void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest); | 197 | void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest); |
| 198 | void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest); | 198 | void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest); |
| 199 | struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name); | 199 | 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); | ||
| 200 | struct tipc_media *tipc_media_find(const char *name); | 201 | struct tipc_media *tipc_media_find(const char *name); |
| 201 | void tipc_bearer_reset_all(struct net *net); | 202 | void tipc_bearer_reset_all(struct net *net); |
| 202 | int tipc_bearer_setup(void); | 203 | int tipc_bearer_setup(void); |
