diff options
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r-- | net/tipc/bearer.c | 86 |
1 files changed, 10 insertions, 76 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 33dc3486d16c..48852c2dcc03 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -36,7 +36,6 @@ | |||
36 | 36 | ||
37 | #include <net/sock.h> | 37 | #include <net/sock.h> |
38 | #include "core.h" | 38 | #include "core.h" |
39 | #include "config.h" | ||
40 | #include "bearer.h" | 39 | #include "bearer.h" |
41 | #include "link.h" | 40 | #include "link.h" |
42 | #include "discover.h" | 41 | #include "discover.h" |
@@ -112,38 +111,18 @@ void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a) | |||
112 | m_ptr = media_find_id(a->media_id); | 111 | m_ptr = media_find_id(a->media_id); |
113 | 112 | ||
114 | if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) | 113 | if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) |
115 | ret = tipc_snprintf(buf, len, "%s(%s)", m_ptr->name, addr_str); | 114 | ret = scnprintf(buf, len, "%s(%s)", m_ptr->name, addr_str); |
116 | else { | 115 | else { |
117 | u32 i; | 116 | u32 i; |
118 | 117 | ||
119 | ret = tipc_snprintf(buf, len, "UNKNOWN(%u)", a->media_id); | 118 | ret = scnprintf(buf, len, "UNKNOWN(%u)", a->media_id); |
120 | for (i = 0; i < sizeof(a->value); i++) | 119 | for (i = 0; i < sizeof(a->value); i++) |
121 | ret += tipc_snprintf(buf - ret, len + ret, | 120 | ret += scnprintf(buf - ret, len + ret, |
122 | "-%02x", a->value[i]); | 121 | "-%02x", a->value[i]); |
123 | } | 122 | } |
124 | } | 123 | } |
125 | 124 | ||
126 | /** | 125 | /** |
127 | * tipc_media_get_names - record names of registered media in buffer | ||
128 | */ | ||
129 | struct sk_buff *tipc_media_get_names(void) | ||
130 | { | ||
131 | struct sk_buff *buf; | ||
132 | int i; | ||
133 | |||
134 | buf = tipc_cfg_reply_alloc(MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME)); | ||
135 | if (!buf) | ||
136 | return NULL; | ||
137 | |||
138 | for (i = 0; media_info_array[i] != NULL; i++) { | ||
139 | tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, | ||
140 | media_info_array[i]->name, | ||
141 | strlen(media_info_array[i]->name) + 1); | ||
142 | } | ||
143 | return buf; | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * bearer_name_validate - validate & (optionally) deconstruct bearer name | 126 | * bearer_name_validate - validate & (optionally) deconstruct bearer name |
148 | * @name: ptr to bearer name string | 127 | * @name: ptr to bearer name string |
149 | * @name_parts: ptr to area for bearer name components (or NULL if not needed) | 128 | * @name_parts: ptr to area for bearer name components (or NULL if not needed) |
@@ -205,35 +184,6 @@ struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name) | |||
205 | return NULL; | 184 | return NULL; |
206 | } | 185 | } |
207 | 186 | ||
208 | /** | ||
209 | * tipc_bearer_get_names - record names of bearers in buffer | ||
210 | */ | ||
211 | struct sk_buff *tipc_bearer_get_names(struct net *net) | ||
212 | { | ||
213 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
214 | struct sk_buff *buf; | ||
215 | struct tipc_bearer *b; | ||
216 | int i, j; | ||
217 | |||
218 | buf = tipc_cfg_reply_alloc(MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME)); | ||
219 | if (!buf) | ||
220 | return NULL; | ||
221 | |||
222 | for (i = 0; media_info_array[i] != NULL; i++) { | ||
223 | for (j = 0; j < MAX_BEARERS; j++) { | ||
224 | b = rtnl_dereference(tn->bearer_list[j]); | ||
225 | if (!b) | ||
226 | continue; | ||
227 | if (b->media == media_info_array[i]) { | ||
228 | tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME, | ||
229 | b->name, | ||
230 | strlen(b->name) + 1); | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | return buf; | ||
235 | } | ||
236 | |||
237 | void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest) | 187 | void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest) |
238 | { | 188 | { |
239 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 189 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
@@ -265,8 +215,8 @@ void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest) | |||
265 | /** | 215 | /** |
266 | * tipc_enable_bearer - enable bearer with the given name | 216 | * tipc_enable_bearer - enable bearer with the given name |
267 | */ | 217 | */ |
268 | int tipc_enable_bearer(struct net *net, const char *name, u32 disc_domain, | 218 | static int tipc_enable_bearer(struct net *net, const char *name, |
269 | u32 priority) | 219 | u32 disc_domain, u32 priority) |
270 | { | 220 | { |
271 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 221 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
272 | struct tipc_bearer *b_ptr; | 222 | struct tipc_bearer *b_ptr; |
@@ -422,22 +372,6 @@ static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr, | |||
422 | kfree_rcu(b_ptr, rcu); | 372 | kfree_rcu(b_ptr, rcu); |
423 | } | 373 | } |
424 | 374 | ||
425 | int tipc_disable_bearer(struct net *net, const char *name) | ||
426 | { | ||
427 | struct tipc_bearer *b_ptr; | ||
428 | int res; | ||
429 | |||
430 | b_ptr = tipc_bearer_find(net, name); | ||
431 | if (b_ptr == NULL) { | ||
432 | pr_warn("Attempt to disable unknown bearer <%s>\n", name); | ||
433 | res = -EINVAL; | ||
434 | } else { | ||
435 | bearer_disable(net, b_ptr, false); | ||
436 | res = 0; | ||
437 | } | ||
438 | return res; | ||
439 | } | ||
440 | |||
441 | int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b) | 375 | int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b) |
442 | { | 376 | { |
443 | struct net_device *dev; | 377 | struct net_device *dev; |
@@ -658,7 +592,7 @@ static int __tipc_nl_add_bearer(struct tipc_nl_msg *msg, | |||
658 | struct nlattr *attrs; | 592 | struct nlattr *attrs; |
659 | struct nlattr *prop; | 593 | struct nlattr *prop; |
660 | 594 | ||
661 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, | 595 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, |
662 | NLM_F_MULTI, TIPC_NL_BEARER_GET); | 596 | NLM_F_MULTI, TIPC_NL_BEARER_GET); |
663 | if (!hdr) | 597 | if (!hdr) |
664 | return -EMSGSIZE; | 598 | return -EMSGSIZE; |
@@ -785,7 +719,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info) | |||
785 | char *name; | 719 | char *name; |
786 | struct tipc_bearer *bearer; | 720 | struct tipc_bearer *bearer; |
787 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; | 721 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; |
788 | struct net *net = genl_info_net(info); | 722 | struct net *net = sock_net(skb->sk); |
789 | 723 | ||
790 | if (!info->attrs[TIPC_NLA_BEARER]) | 724 | if (!info->attrs[TIPC_NLA_BEARER]) |
791 | return -EINVAL; | 725 | return -EINVAL; |
@@ -816,11 +750,11 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info) | |||
816 | 750 | ||
817 | int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info) | 751 | int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info) |
818 | { | 752 | { |
819 | struct net *net = genl_info_net(info); | ||
820 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
821 | int err; | 753 | int err; |
822 | char *bearer; | 754 | char *bearer; |
823 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; | 755 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; |
756 | struct net *net = sock_net(skb->sk); | ||
757 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
824 | u32 domain; | 758 | u32 domain; |
825 | u32 prio; | 759 | u32 prio; |
826 | 760 | ||
@@ -924,7 +858,7 @@ static int __tipc_nl_add_media(struct tipc_nl_msg *msg, | |||
924 | struct nlattr *attrs; | 858 | struct nlattr *attrs; |
925 | struct nlattr *prop; | 859 | struct nlattr *prop; |
926 | 860 | ||
927 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, | 861 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, |
928 | NLM_F_MULTI, TIPC_NL_MEDIA_GET); | 862 | NLM_F_MULTI, TIPC_NL_MEDIA_GET); |
929 | if (!hdr) | 863 | if (!hdr) |
930 | return -EMSGSIZE; | 864 | return -EMSGSIZE; |