diff options
author | Richard Alpe <richard.alpe@ericsson.com> | 2015-02-09 03:50:11 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-09 16:20:48 -0500 |
commit | 487d2a3a1326d339ce273ffbcd03247f2b7b052e (patch) | |
tree | 6ffa649e50216a6a894cf4fe0143b587ee2e190d /net/tipc/socket.c | |
parent | 44a8ae94fd5525aa06a8c71cb52efbc418fb8b7c (diff) |
tipc: convert legacy nl socket dump to nl compat
Convert socket (port) listing to compat dumpit call. If a socket
(port) has publications a second dumpit call is issued to collect them
and format then into the legacy buffer before continuing to process
the sockets (ports).
Command converted in this patch:
TIPC_CMD_SHOW_PORTS
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r-- | net/tipc/socket.c | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index d76c171f7b7e..e77d738bb771 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -2281,91 +2281,6 @@ static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, | |||
2281 | return rc; | 2281 | return rc; |
2282 | } | 2282 | } |
2283 | 2283 | ||
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 | 2284 | /* tipc_sk_reinit: set non-zero address in all existing sockets |
2370 | * when we go from standalone to network mode. | 2285 | * when we go from standalone to network mode. |
2371 | */ | 2286 | */ |