From patchwork Mon Sep 12 15:17:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parthasarathy Bhuvaragan X-Patchwork-Id: 668856 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sXrzC1Jjcz9sxb for ; Tue, 13 Sep 2016 01:17:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933420AbcILPRj (ORCPT ); Mon, 12 Sep 2016 11:17:39 -0400 Received: from sesbmg23.ericsson.net ([193.180.251.37]:60468 "EHLO sesbmg23.ericsson.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933143AbcILPRh (ORCPT ); Mon, 12 Sep 2016 11:17:37 -0400 X-AuditID: c1b4fb25-ca31e98000001071-1e-57d6c70e5ca7 Received: from ESESSHC011.ericsson.se (Unknown_Domain [153.88.183.51]) by (Symantec Mail Security) with SMTP id 8E.3D.04209.E07C6D75; Mon, 12 Sep 2016 17:17:34 +0200 (CEST) Received: from tipsy.lab.linux.ericsson.se (10.35.28.120) by ESESSHC011.ericsson.se (153.88.183.51) with Microsoft SMTP Server (TLS) id 14.3.301.0; Mon, 12 Sep 2016 17:17:25 +0200 From: Parthasarathy Bhuvaragan To: CC: , , Subject: [PATCH iproute2 net-next v1 2/7] tipc: add link monitor set threshold Date: Mon, 12 Sep 2016 17:17:16 +0200 Message-ID: <1473693441-14254-3-git-send-email-parthasarathy.bhuvaragan@ericsson.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473693441-14254-1-git-send-email-parthasarathy.bhuvaragan@ericsson.com> References: <1473693441-14254-1-git-send-email-parthasarathy.bhuvaragan@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [10.35.28.120] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPLMWRmVeSWpSXmKPExsUyM2K7sS7f8WvhBq+nCVksWnSYyeLYAjGL LeezHJg93vdcYfLYveAzk8fnTXIBzFFcNimpOZllqUX6dglcGQcXtDMWrJCqOPmxg6mB8ahI FyMnh4SAiUTHhu2MXYxcHEIC6xklzr66wAThbGeU6Fm5kbWLkYODTcBNYl5zAkiDiICMxNH+ BWwgNrNAjMS3rs9MILawgJ/Ek2UHWUFsFgFVibuzdrGD2LwCoRILrq5gg1gmJ3H++E9mEJtT IExiwal/YPVCQDU3NlxigagXlDg58wkLxHwJiYMvXjBD1BhJTLh4nAlijoLEt5ndTBMYBWYh aZmFpGUBI9MqRtHi1OKk3HQjY73Uoszk4uL8PL281JJNjMBgPLjlt+oOxstvHA8xCnAwKvHw PthyLVyINbGsuDL3EKMEB7OSCG/tMaAQb0piZVVqUX58UWlOavEhRmkOFiVxXv+XiuFCAumJ JanZqakFqUUwWSYOTqkGxtj0p0s4p3pdromYaPhA917N9cviid9jbv9ZLnLio9e2tC2zuP66 Ca5+sNVz+vnL5TuniN6pvnbjt+35Ltb527bFZbofqzi5sCm499ysc2k7g2Y8W8O5p8CN+7Te XCm5CP13q25v6REoFYyzfZWprvTtGTujwy3tlfuvdpWUvj8rLnTVeEH0eWklluKMREMt5qLi RAAiKkVhQgIAAA== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: Jon Maloy Tested-by: Jon Maloy Signed-off-by: Parthasarathy Bhuvaragan --- tipc/link.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/tipc/link.c b/tipc/link.c index 8bdc98224d39..3469cd302469 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 } };