Skip to content

Commit

Permalink
tipc: extend sock diag for group communication
Browse files Browse the repository at this point in the history
This commit extends the existing TIPC socket diagnostics framework
for information related to TIPC group communication.

Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: GhantaKrishnamurthy MohanKrishna <mohan.krishna.ghanta.krishnamurthy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
GhantaKrishnamurthy MohanKrishna authored and davem330 committed Jun 30, 2018
1 parent 6a939f3 commit a1be5a2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/uapi/linux/tipc_netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ enum {
TIPC_NLA_SOCK_TIPC_STATE, /* u32 */
TIPC_NLA_SOCK_COOKIE, /* u64 */
TIPC_NLA_SOCK_PAD, /* flag */
TIPC_NLA_SOCK_GROUP, /* nest */

__TIPC_NLA_SOCK_MAX,
TIPC_NLA_SOCK_MAX = __TIPC_NLA_SOCK_MAX - 1
Expand Down Expand Up @@ -233,6 +234,19 @@ enum {
TIPC_NLA_MON_PEER_MAX = __TIPC_NLA_MON_PEER_MAX - 1
};

/* Nest, socket group info */
enum {
TIPC_NLA_SOCK_GROUP_ID, /* u32 */
TIPC_NLA_SOCK_GROUP_OPEN, /* flag */
TIPC_NLA_SOCK_GROUP_NODE_SCOPE, /* flag */
TIPC_NLA_SOCK_GROUP_CLUSTER_SCOPE, /* flag */
TIPC_NLA_SOCK_GROUP_INSTANCE, /* u32 */
TIPC_NLA_SOCK_GROUP_BC_SEND_NEXT, /* u32 */

__TIPC_NLA_SOCK_GROUP_MAX,
TIPC_NLA_SOCK_GROUP_MAX = __TIPC_NLA_SOCK_GROUP_MAX - 1
};

/* Nest, connection info */
enum {
TIPC_NLA_CON_UNSPEC,
Expand Down
32 changes: 32 additions & 0 deletions net/tipc/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,3 +918,35 @@ void tipc_group_member_evt(struct tipc_group *grp,
}
*sk_rcvbuf = tipc_group_rcvbuf_limit(grp);
}

int tipc_group_fill_sock_diag(struct tipc_group *grp, struct sk_buff *skb)
{
struct nlattr *group = nla_nest_start(skb, TIPC_NLA_SOCK_GROUP);

if (nla_put_u32(skb, TIPC_NLA_SOCK_GROUP_ID,
grp->type) ||
nla_put_u32(skb, TIPC_NLA_SOCK_GROUP_INSTANCE,
grp->instance) ||
nla_put_u32(skb, TIPC_NLA_SOCK_GROUP_BC_SEND_NEXT,
grp->bc_snd_nxt))
goto group_msg_cancel;

if (grp->scope == TIPC_NODE_SCOPE)
if (nla_put_flag(skb, TIPC_NLA_SOCK_GROUP_NODE_SCOPE))
goto group_msg_cancel;

if (grp->scope == TIPC_CLUSTER_SCOPE)
if (nla_put_flag(skb, TIPC_NLA_SOCK_GROUP_CLUSTER_SCOPE))
goto group_msg_cancel;

if (*grp->open)
if (nla_put_flag(skb, TIPC_NLA_SOCK_GROUP_OPEN))
goto group_msg_cancel;

nla_nest_end(skb, group);
return 0;

group_msg_cancel:
nla_nest_cancel(skb, group);
return -1;
}
1 change: 1 addition & 0 deletions net/tipc/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ void tipc_group_update_rcv_win(struct tipc_group *grp, int blks, u32 node,
u32 port, struct sk_buff_head *xmitq);
u16 tipc_group_bc_snd_nxt(struct tipc_group *grp);
void tipc_group_update_member(struct tipc_member *m, int len);
int tipc_group_fill_sock_diag(struct tipc_group *grp, struct sk_buff *skb);
#endif
5 changes: 5 additions & 0 deletions net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -3316,6 +3316,11 @@ int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb,
goto stat_msg_cancel;

nla_nest_end(skb, stat);

if (tsk->group)
if (tipc_group_fill_sock_diag(tsk->group, skb))
goto stat_msg_cancel;

nla_nest_end(skb, attrs);

return 0;
Expand Down

0 comments on commit a1be5a2

Please sign in to comment.