On 2016-05-23 15:27, Parthasarathy Bhuvaragan wrote:
> Signed-off-by: Parthasarathy Bhuvaragan
> <[email protected]>
> ---
> include/linux/tipc_netlink.h | 33 ++++++++++++++++++++
> tipc/link.c | 74
> +++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 106 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/tipc_netlink.h b/include/linux/tipc_netlink.h
> index d4c8f142ba63..c22f2796265f 100644
> --- a/include/linux/tipc_netlink.h
> +++ b/include/linux/tipc_netlink.h
> @@ -56,6 +56,9 @@ enum {
> TIPC_NL_NET_GET,
> TIPC_NL_NET_SET,
> TIPC_NL_NAME_TABLE_GET,
> + TIPC_NL_MON_SET,
> + TIPC_NL_MON_GET,
> + TIPC_NL_MON_PEER_GET,
>
> __TIPC_NL_CMD_MAX,
> TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
> @@ -72,6 +75,8 @@ enum {
> TIPC_NLA_NODE, /* nest */
> TIPC_NLA_NET, /* nest */
> TIPC_NLA_NAME_TABLE, /* nest */
> + TIPC_NLA_MON, /* nest */
> + TIPC_NLA_MON_PEER, /* nest */
>
> __TIPC_NLA_MAX,
> TIPC_NLA_MAX = __TIPC_NLA_MAX - 1
> @@ -166,6 +171,18 @@ enum {
> TIPC_NLA_NAME_TABLE_MAX = __TIPC_NLA_NAME_TABLE_MAX - 1
> };
>
> +/* Monitor info */
> +enum {
> + TIPC_NLA_MON_UNSPEC,
> + TIPC_NLA_MON_REF, /* u32 */
> + TIPC_NLA_MON_PEERCNT, /* u32 */
> + TIPC_NLA_MON_LISTGEN, /* u32 */
> + TIPC_NLA_MON_ACTIVATION_THRESHOLD, /* u32 */
This is the only defined used in this patch? I guess the others
should be added later?
> +
> + __TIPC_NLA_MON_MAX,
> + TIPC_NLA_MON_MAX = __TIPC_NLA_MON_MAX - 1
> +};
> +
> /* Publication info */
> enum {
> TIPC_NLA_PUBL_UNSPEC,
> @@ -182,6 +199,22 @@ enum {
> TIPC_NLA_PUBL_MAX = __TIPC_NLA_PUBL_MAX - 1
> };
>
> +/* Monitor peer info */
> +enum {
> + TIPC_NLA_MON_PEER_UNSPEC,
> +
> + TIPC_NLA_MON_PEER_DOMGEN, /* u32 */
> + TIPC_NLA_MON_PEER_MEMBERS_APPLIED, /* u32 */
> + TIPC_NLA_MON_PEER_UPMAP, /* u64 */
> + TIPC_NLA_MON_PEER_HEADMAP, /* u64 */
> + TIPC_NLA_MON_PEER_MEMBERS, /* tlv */
> + TIPC_NLA_MON_PEER_HEAD, /* flag */
> + TIPC_NLA_MON_PEER_LOCAL, /* flag */
> +
> + __TIPC_NLA_MON_PEER_MAX,
> + TIPC_NLA_MON_PEER_MAX = __TIPC_NLA_MON_PEER_MAX - 1
> +};
Again, this is dead code?
> +
> /* Nest, connection info */
> enum {
> TIPC_NLA_CON_UNSPEC,
> diff --git a/tipc/link.c b/tipc/link.c
> index a36c7abb5d52..2e67be1d0470 100644
> --- a/tipc/link.c
> +++ b/tipc/link.c
> @@ -490,6 +490,76 @@ 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 (help_flag) {
> + (cmd->help)(cmdl);
> + return -EINVAL;
> + }
> +
> + if (cmdl->optind >= cmdl->argc) {
> + 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"
Trailing space before newline.
> + "PROPERTIES\n"
> + " threshold SIZE - Set activation threshold for
> monitor\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 },
You could add tabs between these entries to keep the style aligned. As you
have done below.
> + { 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,
> @@ -499,7 +569,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]);
> }
>
> @@ -511,6 +582,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 }
> };
>
>
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion