diff options
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r-- | net/tipc/socket.c | 90 |
1 files changed, 2 insertions, 88 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 4a98d15a1323..f73e975af80b 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include "name_table.h" | 40 | #include "name_table.h" |
41 | #include "node.h" | 41 | #include "node.h" |
42 | #include "link.h" | 42 | #include "link.h" |
43 | #include "config.h" | ||
44 | #include "name_distr.h" | 43 | #include "name_distr.h" |
45 | #include "socket.h" | 44 | #include "socket.h" |
46 | 45 | ||
@@ -2281,91 +2280,6 @@ static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, | |||
2281 | return rc; | 2280 | return rc; |
2282 | } | 2281 | } |
2283 | 2282 | ||
2284 | static int tipc_sk_show(struct tipc_sock *tsk, char *buf, | ||
2285 | int len, int full_id) | ||
2286 | { | ||
2287 | struct net *net = sock_net(&tsk->sk); | ||
2288 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2289 | struct publication *publ; | ||
2290 | int ret; | ||
2291 | |||
2292 | if (full_id) | ||
2293 | ret = tipc_snprintf(buf, len, "<%u.%u.%u:%u>:", | ||
2294 | tipc_zone(tn->own_addr), | ||
2295 | tipc_cluster(tn->own_addr), | ||
2296 | tipc_node(tn->own_addr), tsk->portid); | ||
2297 | else | ||
2298 | ret = tipc_snprintf(buf, len, "%-10u:", tsk->portid); | ||
2299 | |||
2300 | if (tsk->connected) { | ||
2301 | u32 dport = tsk_peer_port(tsk); | ||
2302 | u32 destnode = tsk_peer_node(tsk); | ||
2303 | |||
2304 | ret += tipc_snprintf(buf + ret, len - ret, | ||
2305 | " connected to <%u.%u.%u:%u>", | ||
2306 | tipc_zone(destnode), | ||
2307 | tipc_cluster(destnode), | ||
2308 | tipc_node(destnode), dport); | ||
2309 | if (tsk->conn_type != 0) | ||
2310 | ret += tipc_snprintf(buf + ret, len - ret, | ||
2311 | " via {%u,%u}", tsk->conn_type, | ||
2312 | tsk->conn_instance); | ||
2313 | } else if (tsk->published) { | ||
2314 | ret += tipc_snprintf(buf + ret, len - ret, " bound to"); | ||
2315 | list_for_each_entry(publ, &tsk->publications, pport_list) { | ||
2316 | if (publ->lower == publ->upper) | ||
2317 | ret += tipc_snprintf(buf + ret, len - ret, | ||
2318 | " {%u,%u}", publ->type, | ||
2319 | publ->lower); | ||
2320 | else | ||
2321 | ret += tipc_snprintf(buf + ret, len - ret, | ||
2322 | " {%u,%u,%u}", publ->type, | ||
2323 | publ->lower, publ->upper); | ||
2324 | } | ||
2325 | } | ||
2326 | ret += tipc_snprintf(buf + ret, len - ret, "\n"); | ||
2327 | return ret; | ||
2328 | } | ||
2329 | |||
2330 | struct sk_buff *tipc_sk_socks_show(struct net *net) | ||
2331 | { | ||
2332 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2333 | const struct bucket_table *tbl; | ||
2334 | struct rhash_head *pos; | ||
2335 | struct sk_buff *buf; | ||
2336 | struct tlv_desc *rep_tlv; | ||
2337 | char *pb; | ||
2338 | int pb_len; | ||
2339 | struct tipc_sock *tsk; | ||
2340 | int str_len = 0; | ||
2341 | int i; | ||
2342 | |||
2343 | buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN)); | ||
2344 | if (!buf) | ||
2345 | return NULL; | ||
2346 | rep_tlv = (struct tlv_desc *)buf->data; | ||
2347 | pb = TLV_DATA(rep_tlv); | ||
2348 | pb_len = ULTRA_STRING_MAX_LEN; | ||
2349 | |||
2350 | rcu_read_lock(); | ||
2351 | tbl = rht_dereference_rcu((&tn->sk_rht)->tbl, &tn->sk_rht); | ||
2352 | for (i = 0; i < tbl->size; i++) { | ||
2353 | rht_for_each_entry_rcu(tsk, pos, tbl, i, node) { | ||
2354 | spin_lock_bh(&tsk->sk.sk_lock.slock); | ||
2355 | str_len += tipc_sk_show(tsk, pb + str_len, | ||
2356 | pb_len - str_len, 0); | ||
2357 | spin_unlock_bh(&tsk->sk.sk_lock.slock); | ||
2358 | } | ||
2359 | } | ||
2360 | rcu_read_unlock(); | ||
2361 | |||
2362 | str_len += 1; /* for "\0" */ | ||
2363 | skb_put(buf, TLV_SPACE(str_len)); | ||
2364 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); | ||
2365 | |||
2366 | return buf; | ||
2367 | } | ||
2368 | |||
2369 | /* tipc_sk_reinit: set non-zero address in all existing sockets | 2283 | /* tipc_sk_reinit: set non-zero address in all existing sockets |
2370 | * when we go from standalone to network mode. | 2284 | * when we go from standalone to network mode. |
2371 | */ | 2285 | */ |
@@ -2783,7 +2697,7 @@ static int __tipc_nl_add_sk(struct sk_buff *skb, struct netlink_callback *cb, | |||
2783 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 2697 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
2784 | 2698 | ||
2785 | hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, | 2699 | hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, |
2786 | &tipc_genl_v2_family, NLM_F_MULTI, TIPC_NL_SOCK_GET); | 2700 | &tipc_genl_family, NLM_F_MULTI, TIPC_NL_SOCK_GET); |
2787 | if (!hdr) | 2701 | if (!hdr) |
2788 | goto msg_cancel; | 2702 | goto msg_cancel; |
2789 | 2703 | ||
@@ -2864,7 +2778,7 @@ static int __tipc_nl_add_sk_publ(struct sk_buff *skb, | |||
2864 | struct nlattr *attrs; | 2778 | struct nlattr *attrs; |
2865 | 2779 | ||
2866 | hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, | 2780 | hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, |
2867 | &tipc_genl_v2_family, NLM_F_MULTI, TIPC_NL_PUBL_GET); | 2781 | &tipc_genl_family, NLM_F_MULTI, TIPC_NL_PUBL_GET); |
2868 | if (!hdr) | 2782 | if (!hdr) |
2869 | goto msg_cancel; | 2783 | goto msg_cancel; |
2870 | 2784 | ||