The command sets the activation threshold for the new cluster ring supervision. A sample usage is shown below: $ tipc link monitor set threshold 4
$ tipc link monitor set -h Usage: tipc monitor set PPROPERTY PROPERTIES threshold SIZE - Set activation threshold for monitor Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvara...@ericsson.com> --- include/linux/tipc_netlink.h | 11 +++++++ tipc/link.c | 69 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/include/linux/tipc_netlink.h b/include/linux/tipc_netlink.h index d4c8f142ba63..d387b65a0d97 100644 --- a/include/linux/tipc_netlink.h +++ b/include/linux/tipc_netlink.h @@ -56,6 +56,7 @@ enum { TIPC_NL_NET_GET, TIPC_NL_NET_SET, TIPC_NL_NAME_TABLE_GET, + TIPC_NL_MON_SET, __TIPC_NL_CMD_MAX, TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1 @@ -72,6 +73,7 @@ enum { TIPC_NLA_NODE, /* nest */ TIPC_NLA_NET, /* nest */ TIPC_NLA_NAME_TABLE, /* nest */ + TIPC_NLA_MON, /* nest */ __TIPC_NLA_MAX, TIPC_NLA_MAX = __TIPC_NLA_MAX - 1 @@ -166,6 +168,15 @@ enum { TIPC_NLA_NAME_TABLE_MAX = __TIPC_NLA_NAME_TABLE_MAX - 1 }; +/* Monitor info */ +enum { + TIPC_NLA_MON_UNSPEC, + TIPC_NLA_MON_ACTIVATION_THRESHOLD, /* u32 */ + + __TIPC_NLA_MON_MAX, + TIPC_NLA_MON_MAX = __TIPC_NLA_MON_MAX - 1 +}; + /* Publication info */ enum { TIPC_NLA_PUBL_UNSPEC, diff --git a/tipc/link.c b/tipc/link.c index a9d256e1b9a8..6ee14c3c8a4c 100644 --- a/tipc/link.c +++ b/tipc/link.c @@ -489,6 +489,71 @@ static int cmd_link_set(struct nlmsghdr *nlh, const struct cmd *cmd, return run_cmd(nlh, cmd, cmds, cmdl, NULL); } +static int cmd_link_mon_set_prop(struct nlmsghdr *nlh, const struct cmd *cmd, + struct cmdl *cmdl, void *data) +{ + int size; + char buf[MNL_SOCKET_BUFFER_SIZE]; + struct nlattr *attrs; + + if (cmdl->argc != cmdl->optind + 1) { + fprintf(stderr, "error, missing value\n"); + return -EINVAL; + } + size = atoi(shift_cmdl(cmdl)); + + if (!(nlh = msg_init(buf, TIPC_NL_MON_SET))) { + fprintf(stderr, "error, message initialisation failed\n"); + return -1; + } + attrs = mnl_attr_nest_start(nlh, TIPC_NLA_MON); + + mnl_attr_put_u32(nlh, TIPC_NLA_MON_ACTIVATION_THRESHOLD, size); + + mnl_attr_nest_end(nlh, attrs); + + return msg_doit(nlh, NULL, NULL); +} + +static void cmd_link_mon_set_help(struct cmdl *cmdl) +{ + fprintf(stderr, "Usage: %s monitor set PPROPERTY\n\n" + "PROPERTIES\n" + " threshold SIZE - Set monitor activation threshold\n", + cmdl->argv[0]); +} + +static int cmd_link_mon_set(struct nlmsghdr *nlh, const struct cmd *cmd, + struct cmdl *cmdl, void *data) +{ + const struct cmd cmds[] = { + { "threshold", cmd_link_mon_set_prop, NULL }, + { NULL } + }; + + return run_cmd(nlh, cmd, cmds, cmdl, NULL); +} + +static void cmd_link_mon_help(struct cmdl *cmdl) +{ + fprintf(stderr, + "Usage: %s montior COMMAND [ARGS] ...\n\n" + "COMMANDS\n" + " set - Set monitor properties\n", + cmdl->argv[0]); +} + +static int cmd_link_mon(struct nlmsghdr *nlh, const struct cmd *cmd, struct cmdl *cmdl, + void *data) +{ + const struct cmd cmds[] = { + { "set", cmd_link_mon_set, cmd_link_mon_set_help }, + { NULL } + }; + + return run_cmd(nlh, cmd, cmds, cmdl, NULL); +} + void cmd_link_help(struct cmdl *cmdl) { fprintf(stderr, @@ -498,7 +563,8 @@ void cmd_link_help(struct cmdl *cmdl) " list - List links\n" " get - Get various link properties\n" " set - Set various link properties\n" - " statistics - Show or reset statistics\n", + " statistics - Show or reset statistics\n" + " monitor - Show or set link supervision\n", cmdl->argv[0]); } @@ -510,6 +576,7 @@ int cmd_link(struct nlmsghdr *nlh, const struct cmd *cmd, struct cmdl *cmdl, { "list", cmd_link_list, NULL }, { "set", cmd_link_set, cmd_link_set_help }, { "statistics", cmd_link_stat, cmd_link_stat_help }, + { "monitor", cmd_link_mon, cmd_link_mon_help }, { NULL } }; -- 2.1.4 ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e _______________________________________________ tipc-discussion mailing list tipc-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tipc-discussion