Skip to content

Commit 03b6fef

Browse files
Tuong Liendavem330
authored andcommitted
tipc: add support for broadcast rcv stats dumping
This commit enables dumping the statistics of a broadcast-receiver link like the traditional 'broadcast-link' one (which is for broadcast- sender). The link dumping can be triggered via netlink (e.g. the iproute2/tipc tool) by the link flag - 'TIPC_NLA_LINK_BROADCAST' as the indicator. The name of a broadcast-receiver link of a specific peer will be in the format: 'broadcast-link:<peer-id>'. For example: Link <broadcast-link:1001002> Window:50 packets RX packets:7841 fragments:2408/440 bundles:0/0 TX packets:0 fragments:0/0 bundles:0/0 RX naks:0 defs:124 dups:0 TX naks:21 acks:0 retrans:0 Congestion link:0 Send queue max:0 avg:0 In addition, the broadcast-receiver link statistics can be reset in the usual way via netlink by specifying that link name in command. Note: the 'tipc_link_name_ext()' is removed because the link name can now be retrieved simply via the 'l->name'. Acked-by: Ying Xue <ying.xue@windriver.com> Acked-by: Jon Maloy <jmaloy@redhat.com> Signed-off-by: Tuong Lien <tuong.t.lien@dektech.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a91d55d commit 03b6fef

9 files changed

Lines changed: 101 additions & 56 deletions

File tree

‎net/tipc/bcast.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,8 @@ void tipc_bcast_remove_peer(struct net *net, struct tipc_link *rcv_l)
563563
tipc_sk_rcv(net, inputq);
564564
}
565565

566-
int tipc_bclink_reset_stats(struct net *net)
566+
int tipc_bclink_reset_stats(struct net *net, struct tipc_link *l)
567567
{
568-
struct tipc_link *l = tipc_bc_sndlink(net);
569-
570568
if (!l)
571569
return -ENOPROTOOPT;
572570

@@ -694,7 +692,7 @@ int tipc_bcast_init(struct net *net)
694692
tn->bcbase = bb;
695693
spin_lock_init(&tipc_net(net)->bclock);
696694

697-
if (!tipc_link_bc_create(net, 0, 0,
695+
if (!tipc_link_bc_create(net, 0, 0, NULL,
698696
FB_MTU,
699697
BCLINK_WIN_DEFAULT,
700698
BCLINK_WIN_DEFAULT,

‎net/tipc/bcast.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
9696
int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,
9797
struct tipc_msg *hdr,
9898
struct sk_buff_head *retrq);
99-
int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg);
99+
int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg,
100+
struct tipc_link *bcl);
100101
int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]);
101-
int tipc_bclink_reset_stats(struct net *net);
102+
int tipc_bclink_reset_stats(struct net *net, struct tipc_link *l);
102103

103104
u32 tipc_bcast_get_broadcast_mode(struct net *net);
104105
u32 tipc_bcast_get_broadcast_ratio(struct net *net);

‎net/tipc/link.c‎

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
539539
*
540540
* Returns true if link was created, otherwise false
541541
*/
542-
bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
542+
bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, u8 *peer_id,
543543
int mtu, u32 min_win, u32 max_win, u16 peer_caps,
544544
struct sk_buff_head *inputq,
545545
struct sk_buff_head *namedq,
@@ -554,7 +554,18 @@ bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
554554
return false;
555555

556556
l = *link;
557-
strcpy(l->name, tipc_bclink_name);
557+
if (peer_id) {
558+
char peer_str[NODE_ID_STR_LEN] = {0,};
559+
560+
tipc_nodeid2string(peer_str, peer_id);
561+
if (strlen(peer_str) > 16)
562+
sprintf(peer_str, "%x", peer);
563+
/* Broadcast receiver link name: "broadcast-link:<peer>" */
564+
snprintf(l->name, sizeof(l->name), "%s:%s", tipc_bclink_name,
565+
peer_str);
566+
} else {
567+
strcpy(l->name, tipc_bclink_name);
568+
}
558569
trace_tipc_link_reset(l, TIPC_DUMP_ALL, "bclink created!");
559570
tipc_link_reset(l);
560571
l->state = LINK_RESET;
@@ -1412,11 +1423,8 @@ static u8 __tipc_build_gap_ack_blks(struct tipc_gap_ack_blks *ga,
14121423
gacks[n].ack = htons(expect - 1);
14131424
gacks[n].gap = htons(seqno - expect);
14141425
if (++n >= MAX_GAP_ACK_BLKS / 2) {
1415-
char buf[TIPC_MAX_LINK_NAME];
1416-
14171426
pr_info_ratelimited("Gacks on %s: %d, ql: %d!\n",
1418-
tipc_link_name_ext(l, buf),
1419-
n,
1427+
l->name, n,
14201428
skb_queue_len(&l->deferdq));
14211429
return n;
14221430
}
@@ -1587,6 +1595,8 @@ static int tipc_link_advance_transmq(struct tipc_link *l, struct tipc_link *r,
15871595
_skb->priority = TC_PRIO_CONTROL;
15881596
__skb_queue_tail(xmitq, _skb);
15891597
l->stats.retransmitted++;
1598+
if (!is_uc)
1599+
r->stats.retransmitted++;
15901600
*retransmitted = true;
15911601
/* Increase actual retrans counter & mark first time */
15921602
if (!TIPC_SKB_CB(skb)->retr_cnt++)
@@ -1753,7 +1763,8 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,
17531763

17541764
/* Defer delivery if sequence gap */
17551765
if (unlikely(seqno != rcv_nxt)) {
1756-
__tipc_skb_queue_sorted(defq, seqno, skb);
1766+
if (!__tipc_skb_queue_sorted(defq, seqno, skb))
1767+
l->stats.duplicates++;
17571768
rc |= tipc_link_build_nack_msg(l, xmitq);
17581769
break;
17591770
}
@@ -1787,15 +1798,15 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
17871798
int tolerance, int priority,
17881799
struct sk_buff_head *xmitq)
17891800
{
1801+
struct tipc_mon_state *mstate = &l->mon_state;
1802+
struct sk_buff_head *dfq = &l->deferdq;
17901803
struct tipc_link *bcl = l->bc_rcvlink;
1791-
struct sk_buff *skb;
17921804
struct tipc_msg *hdr;
1793-
struct sk_buff_head *dfq = &l->deferdq;
1805+
struct sk_buff *skb;
17941806
bool node_up = link_is_up(bcl);
1795-
struct tipc_mon_state *mstate = &l->mon_state;
1807+
u16 glen = 0, bc_rcvgap = 0;
17961808
int dlen = 0;
17971809
void *data;
1798-
u16 glen = 0;
17991810

18001811
/* Don't send protocol message during reset or link failover */
18011812
if (tipc_link_is_blocked(l))
@@ -1833,7 +1844,8 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
18331844
if (l->peer_caps & TIPC_LINK_PROTO_SEQNO)
18341845
msg_set_seqno(hdr, l->snd_nxt_state++);
18351846
msg_set_seq_gap(hdr, rcvgap);
1836-
msg_set_bc_gap(hdr, link_bc_rcv_gap(bcl));
1847+
bc_rcvgap = link_bc_rcv_gap(bcl);
1848+
msg_set_bc_gap(hdr, bc_rcvgap);
18371849
msg_set_probe(hdr, probe);
18381850
msg_set_is_keepalive(hdr, probe || probe_reply);
18391851
if (l->peer_caps & TIPC_GAP_ACK_BLOCK)
@@ -1858,6 +1870,8 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
18581870
l->stats.sent_probes++;
18591871
if (rcvgap)
18601872
l->stats.sent_nacks++;
1873+
if (bc_rcvgap)
1874+
bcl->stats.sent_nacks++;
18611875
skb->priority = TC_PRIO_CONTROL;
18621876
__skb_queue_tail(xmitq, skb);
18631877
trace_tipc_proto_build(skb, false, l->name);
@@ -2358,8 +2372,6 @@ int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,
23582372
if (!l->bc_peer_is_up)
23592373
return rc;
23602374

2361-
l->stats.recv_nacks++;
2362-
23632375
/* Ignore if peers_snd_nxt goes beyond receive window */
23642376
if (more(peers_snd_nxt, l->rcv_nxt + l->window))
23652377
return rc;
@@ -2410,6 +2422,11 @@ int tipc_link_bc_ack_rcv(struct tipc_link *r, u16 acked, u16 gap,
24102422
if (!link_is_up(r) || !r->bc_peer_is_up)
24112423
return 0;
24122424

2425+
if (gap) {
2426+
l->stats.recv_nacks++;
2427+
r->stats.recv_nacks++;
2428+
}
2429+
24132430
if (less(acked, r->acked) || (acked == r->acked && !gap && !ga))
24142431
return 0;
24152432

@@ -2721,16 +2738,15 @@ static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb,
27212738
return -EMSGSIZE;
27222739
}
27232740

2724-
int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg)
2741+
int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg,
2742+
struct tipc_link *bcl)
27252743
{
27262744
int err;
27272745
void *hdr;
27282746
struct nlattr *attrs;
27292747
struct nlattr *prop;
2730-
struct tipc_net *tn = net_generic(net, tipc_net_id);
27312748
u32 bc_mode = tipc_bcast_get_broadcast_mode(net);
27322749
u32 bc_ratio = tipc_bcast_get_broadcast_ratio(net);
2733-
struct tipc_link *bcl = tn->bcl;
27342750

27352751
if (!bcl)
27362752
return 0;
@@ -2817,21 +2833,6 @@ void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit)
28172833
l->abort_limit = limit;
28182834
}
28192835

2820-
char *tipc_link_name_ext(struct tipc_link *l, char *buf)
2821-
{
2822-
if (!l)
2823-
scnprintf(buf, TIPC_MAX_LINK_NAME, "null");
2824-
else if (link_is_bc_sndlink(l))
2825-
scnprintf(buf, TIPC_MAX_LINK_NAME, "broadcast-sender");
2826-
else if (link_is_bc_rcvlink(l))
2827-
scnprintf(buf, TIPC_MAX_LINK_NAME,
2828-
"broadcast-receiver, peer %x", l->addr);
2829-
else
2830-
memcpy(buf, l->name, TIPC_MAX_LINK_NAME);
2831-
2832-
return buf;
2833-
}
2834-
28352836
/**
28362837
* tipc_link_dump - dump TIPC link data
28372838
* @l: tipc link to be dumped

‎net/tipc/link.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
8080
struct sk_buff_head *inputq,
8181
struct sk_buff_head *namedq,
8282
struct tipc_link **link);
83-
bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
83+
bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, u8 *peer_id,
8484
int mtu, u32 min_win, u32 max_win, u16 peer_caps,
8585
struct sk_buff_head *inputq,
8686
struct sk_buff_head *namedq,
@@ -111,7 +111,6 @@ u16 tipc_link_rcv_nxt(struct tipc_link *l);
111111
u16 tipc_link_acked(struct tipc_link *l);
112112
u32 tipc_link_id(struct tipc_link *l);
113113
char *tipc_link_name(struct tipc_link *l);
114-
char *tipc_link_name_ext(struct tipc_link *l, char *buf);
115114
u32 tipc_link_state(struct tipc_link *l);
116115
char tipc_link_plane(struct tipc_link *l);
117116
int tipc_link_prio(struct tipc_link *l);

‎net/tipc/msg.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,19 +825,19 @@ bool tipc_msg_pskb_copy(u32 dst, struct sk_buff_head *msg,
825825
* @seqno: sequence number of buffer to add
826826
* @skb: buffer to add
827827
*/
828-
void __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno,
828+
bool __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno,
829829
struct sk_buff *skb)
830830
{
831831
struct sk_buff *_skb, *tmp;
832832

833833
if (skb_queue_empty(list) || less(seqno, buf_seqno(skb_peek(list)))) {
834834
__skb_queue_head(list, skb);
835-
return;
835+
return true;
836836
}
837837

838838
if (more(seqno, buf_seqno(skb_peek_tail(list)))) {
839839
__skb_queue_tail(list, skb);
840-
return;
840+
return true;
841841
}
842842

843843
skb_queue_walk_safe(list, _skb, tmp) {
@@ -846,9 +846,10 @@ void __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno,
846846
if (seqno == buf_seqno(_skb))
847847
break;
848848
__skb_queue_before(list, _skb, skb);
849-
return;
849+
return true;
850850
}
851851
kfree_skb(skb);
852+
return false;
852853
}
853854

854855
void tipc_skb_reject(struct net *net, int err, struct sk_buff *skb,

‎net/tipc/msg.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ bool tipc_msg_assemble(struct sk_buff_head *list);
11451145
bool tipc_msg_reassemble(struct sk_buff_head *list, struct sk_buff_head *rcvq);
11461146
bool tipc_msg_pskb_copy(u32 dst, struct sk_buff_head *msg,
11471147
struct sk_buff_head *cpy);
1148-
void __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno,
1148+
bool __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno,
11491149
struct sk_buff *skb);
11501150
bool tipc_msg_skb_clone(struct sk_buff_head *msg, struct sk_buff_head *cpy);
11511151

‎net/tipc/netlink.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
188188
},
189189
{
190190
.cmd = TIPC_NL_LINK_GET,
191-
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
191+
.validate = GENL_DONT_VALIDATE_STRICT,
192192
.doit = tipc_nl_node_get_link,
193193
.dumpit = tipc_nl_node_dump_link,
194194
},

0 commit comments

Comments
 (0)