diff options
Diffstat (limited to 'net/tipc/bcast.c')
-rw-r--r-- | net/tipc/bcast.c | 126 |
1 files changed, 4 insertions, 122 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 9dc239dfe192..e401108360a2 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -332,131 +332,15 @@ void tipc_bcast_remove_peer(struct net *net, struct tipc_link *rcv_l) | |||
332 | tipc_sk_rcv(net, inputq); | 332 | tipc_sk_rcv(net, inputq); |
333 | } | 333 | } |
334 | 334 | ||
335 | static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb, | ||
336 | struct tipc_stats *stats) | ||
337 | { | ||
338 | int i; | ||
339 | struct nlattr *nest; | ||
340 | |||
341 | struct nla_map { | ||
342 | __u32 key; | ||
343 | __u32 val; | ||
344 | }; | ||
345 | |||
346 | struct nla_map map[] = { | ||
347 | {TIPC_NLA_STATS_RX_INFO, stats->recv_info}, | ||
348 | {TIPC_NLA_STATS_RX_FRAGMENTS, stats->recv_fragments}, | ||
349 | {TIPC_NLA_STATS_RX_FRAGMENTED, stats->recv_fragmented}, | ||
350 | {TIPC_NLA_STATS_RX_BUNDLES, stats->recv_bundles}, | ||
351 | {TIPC_NLA_STATS_RX_BUNDLED, stats->recv_bundled}, | ||
352 | {TIPC_NLA_STATS_TX_INFO, stats->sent_info}, | ||
353 | {TIPC_NLA_STATS_TX_FRAGMENTS, stats->sent_fragments}, | ||
354 | {TIPC_NLA_STATS_TX_FRAGMENTED, stats->sent_fragmented}, | ||
355 | {TIPC_NLA_STATS_TX_BUNDLES, stats->sent_bundles}, | ||
356 | {TIPC_NLA_STATS_TX_BUNDLED, stats->sent_bundled}, | ||
357 | {TIPC_NLA_STATS_RX_NACKS, stats->recv_nacks}, | ||
358 | {TIPC_NLA_STATS_RX_DEFERRED, stats->deferred_recv}, | ||
359 | {TIPC_NLA_STATS_TX_NACKS, stats->sent_nacks}, | ||
360 | {TIPC_NLA_STATS_TX_ACKS, stats->sent_acks}, | ||
361 | {TIPC_NLA_STATS_RETRANSMITTED, stats->retransmitted}, | ||
362 | {TIPC_NLA_STATS_DUPLICATES, stats->duplicates}, | ||
363 | {TIPC_NLA_STATS_LINK_CONGS, stats->link_congs}, | ||
364 | {TIPC_NLA_STATS_MAX_QUEUE, stats->max_queue_sz}, | ||
365 | {TIPC_NLA_STATS_AVG_QUEUE, stats->queue_sz_counts ? | ||
366 | (stats->accu_queue_sz / stats->queue_sz_counts) : 0} | ||
367 | }; | ||
368 | |||
369 | nest = nla_nest_start(skb, TIPC_NLA_LINK_STATS); | ||
370 | if (!nest) | ||
371 | return -EMSGSIZE; | ||
372 | |||
373 | for (i = 0; i < ARRAY_SIZE(map); i++) | ||
374 | if (nla_put_u32(skb, map[i].key, map[i].val)) | ||
375 | goto msg_full; | ||
376 | |||
377 | nla_nest_end(skb, nest); | ||
378 | |||
379 | return 0; | ||
380 | msg_full: | ||
381 | nla_nest_cancel(skb, nest); | ||
382 | |||
383 | return -EMSGSIZE; | ||
384 | } | ||
385 | |||
386 | int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg) | ||
387 | { | ||
388 | int err; | ||
389 | void *hdr; | ||
390 | struct nlattr *attrs; | ||
391 | struct nlattr *prop; | ||
392 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
393 | struct tipc_link *bcl = tn->bcl; | ||
394 | |||
395 | if (!bcl) | ||
396 | return 0; | ||
397 | |||
398 | tipc_bcast_lock(net); | ||
399 | |||
400 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, | ||
401 | NLM_F_MULTI, TIPC_NL_LINK_GET); | ||
402 | if (!hdr) | ||
403 | return -EMSGSIZE; | ||
404 | |||
405 | attrs = nla_nest_start(msg->skb, TIPC_NLA_LINK); | ||
406 | if (!attrs) | ||
407 | goto msg_full; | ||
408 | |||
409 | /* The broadcast link is always up */ | ||
410 | if (nla_put_flag(msg->skb, TIPC_NLA_LINK_UP)) | ||
411 | goto attr_msg_full; | ||
412 | |||
413 | if (nla_put_flag(msg->skb, TIPC_NLA_LINK_BROADCAST)) | ||
414 | goto attr_msg_full; | ||
415 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, bcl->name)) | ||
416 | goto attr_msg_full; | ||
417 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, bcl->rcv_nxt)) | ||
418 | goto attr_msg_full; | ||
419 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, bcl->snd_nxt)) | ||
420 | goto attr_msg_full; | ||
421 | |||
422 | prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP); | ||
423 | if (!prop) | ||
424 | goto attr_msg_full; | ||
425 | if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, bcl->window)) | ||
426 | goto prop_msg_full; | ||
427 | nla_nest_end(msg->skb, prop); | ||
428 | |||
429 | err = __tipc_nl_add_bc_link_stat(msg->skb, &bcl->stats); | ||
430 | if (err) | ||
431 | goto attr_msg_full; | ||
432 | |||
433 | tipc_bcast_unlock(net); | ||
434 | nla_nest_end(msg->skb, attrs); | ||
435 | genlmsg_end(msg->skb, hdr); | ||
436 | |||
437 | return 0; | ||
438 | |||
439 | prop_msg_full: | ||
440 | nla_nest_cancel(msg->skb, prop); | ||
441 | attr_msg_full: | ||
442 | nla_nest_cancel(msg->skb, attrs); | ||
443 | msg_full: | ||
444 | tipc_bcast_unlock(net); | ||
445 | genlmsg_cancel(msg->skb, hdr); | ||
446 | |||
447 | return -EMSGSIZE; | ||
448 | } | ||
449 | |||
450 | int tipc_bclink_reset_stats(struct net *net) | 335 | int tipc_bclink_reset_stats(struct net *net) |
451 | { | 336 | { |
452 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 337 | struct tipc_link *l = tipc_bc_sndlink(net); |
453 | struct tipc_link *bcl = tn->bcl; | ||
454 | 338 | ||
455 | if (!bcl) | 339 | if (!l) |
456 | return -ENOPROTOOPT; | 340 | return -ENOPROTOOPT; |
457 | 341 | ||
458 | tipc_bcast_lock(net); | 342 | tipc_bcast_lock(net); |
459 | memset(&bcl->stats, 0, sizeof(bcl->stats)); | 343 | tipc_link_reset_stats(l); |
460 | tipc_bcast_unlock(net); | 344 | tipc_bcast_unlock(net); |
461 | return 0; | 345 | return 0; |
462 | } | 346 | } |
@@ -530,9 +414,7 @@ enomem: | |||
530 | 414 | ||
531 | void tipc_bcast_reinit(struct net *net) | 415 | void tipc_bcast_reinit(struct net *net) |
532 | { | 416 | { |
533 | struct tipc_bc_base *b = tipc_bc_base(net); | 417 | tipc_link_reinit(tipc_bc_sndlink(net), tipc_own_addr(net)); |
534 | |||
535 | msg_set_prevnode(b->link->pmsg, tipc_own_addr(net)); | ||
536 | } | 418 | } |
537 | 419 | ||
538 | void tipc_bcast_stop(struct net *net) | 420 | void tipc_bcast_stop(struct net *net) |