Same here. Change SELECTABLE to AUTOSELECT.

Acked-by: Jon


> -----Original Message-----
> From: Hoang Le <[email protected]>
> Sent: 18-Feb-19 02:55
> To: [email protected]; Jon Maloy
> <[email protected]>; [email protected]; [email protected]
> Subject: [iproute2-next v2 2/2] tipc: add link broadcast get
> 
> The command prints the actually method that multicast is running in the
> system.
> Also 'ratio' value for SELECTABLE method.
> 
> A sample usage is shown below:
> $tipc link get broadcast
> BROADCAST
> 
> $tipc link get broadcast
> SELECTABLE ratio:30%
> 
> $tipc link get broadcast -j -p
> [ {
>         "method": "SELECTABLE"
>     },{
>         "ratio": 30
>     } ]
> 
> Signed-off-by: Hoang Le <[email protected]>
> ---
>  tipc/link.c | 83
> ++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 82 insertions(+), 1 deletion(-)
> 
> diff --git a/tipc/link.c b/tipc/link.c
> index c1db400f1b26..97c75122038e 100644
> --- a/tipc/link.c
> +++ b/tipc/link.c
> @@ -175,10 +175,90 @@ static void cmd_link_get_help(struct cmdl *cmdl)
>               "PROPERTIES\n"
>               " tolerance             - Get link tolerance\n"
>               " priority              - Get link priority\n"
> -             " window                - Get link window\n",
> +             " window                - Get link window\n"
> +             " broadcast             - Get link broadcast\n",
>               cmdl->argv[0]);
>  }
> 
> +static int cmd_link_get_bcast_cb(const struct nlmsghdr *nlh, void
> +*data) {
> +     int *prop = data;
> +     struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
> +     struct nlattr *info[TIPC_NLA_MAX + 1] = {};
> +     struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1] = {};
> +     struct nlattr *props[TIPC_NLA_PROP_MAX + 1] = {};
> +     int bc_mode;
> +
> +     mnl_attr_parse(nlh, sizeof(*genl), parse_attrs, info);
> +     if (!info[TIPC_NLA_LINK])
> +             return MNL_CB_ERROR;
> +
> +     mnl_attr_parse_nested(info[TIPC_NLA_LINK], parse_attrs, attrs);
> +     if (!attrs[TIPC_NLA_LINK_PROP])
> +             return MNL_CB_ERROR;
> +
> +     mnl_attr_parse_nested(attrs[TIPC_NLA_LINK_PROP], parse_attrs,
> props);
> +     if (!props[*prop])
> +             return MNL_CB_ERROR;
> +
> +     bc_mode = mnl_attr_get_u32(props[*prop]);
> +
> +     new_json_obj(json);
> +     open_json_object(NULL);
> +     switch (bc_mode) {
> +             case 0x1:
> +                     print_string(PRINT_ANY, "method", "%s\n",
> "BROADCAST");
> +             break;
> +             case 0x2:
> +                     print_string(PRINT_ANY, "method", "%s\n",
> "REPLICAST");
> +             break;
> +             case 0x4:
> +                     print_string(PRINT_ANY, "method", "%s",
> "SELECTABLE");
> +                     close_json_object();
> +                     open_json_object(NULL);
> +                     print_uint(PRINT_ANY, "ratio", " ratio:%u%\n",
> mnl_attr_get_u32(props[TIPC_NLA_PROP_BROADCAST_RATIO]));
> +             break;
> +             default:
> +                     print_string(PRINT_ANY, NULL, "UNKNOWN\n",
> NULL);
> +                     break;
> +     }
> +     close_json_object();
> +     delete_json_obj();
> +     return MNL_CB_OK;
> +}
> +
> +static void cmd_link_get_bcast_help(struct cmdl *cmdl) {
> +     fprintf(stderr, "Usage: %s link get PPROPERTY\n\n"
> +             "PROPERTIES\n"
> +             " broadcast             - Get link broadcast\n",
> +             cmdl->argv[0]);
> +}
> +
> +static int cmd_link_get_bcast(struct nlmsghdr *nlh, const struct cmd *cmd,
> +                          struct cmdl *cmdl, void *data)
> +{
> +     int prop = TIPC_NLA_PROP_BROADCAST;
> +     char buf[MNL_SOCKET_BUFFER_SIZE];
> +     struct nlattr *attrs;
> +
> +     if (help_flag) {
> +             (cmd->help)(cmdl);
> +             return -EINVAL;
> +     }
> +
> +     nlh = msg_init(buf, TIPC_NL_LINK_GET);
> +     if (!nlh) {
> +             fprintf(stderr, "error, message initialisation failed\n");
> +             return -1;
> +     }
> +     attrs = mnl_attr_nest_start(nlh, TIPC_NLA_LINK);
> +     /* Direct to broadcast-link setting */
> +     mnl_attr_put_strz(nlh, TIPC_NLA_LINK_NAME, tipc_bclink_name);
> +     mnl_attr_nest_end(nlh, attrs);
> +     return msg_doit(nlh, cmd_link_get_bcast_cb, &prop); }
> +
>  static int cmd_link_get(struct nlmsghdr *nlh, const struct cmd *cmd,
>                       struct cmdl *cmdl, void *data)
>  {
> @@ -186,6 +266,7 @@ static int cmd_link_get(struct nlmsghdr *nlh, const
> struct cmd *cmd,
>               { PRIORITY_STR, cmd_link_get_prop,
>       cmd_link_get_help },
>               { TOLERANCE_STR,        cmd_link_get_prop,
>       cmd_link_get_help },
>               { WINDOW_STR,   cmd_link_get_prop,
>       cmd_link_get_help },
> +             { BROADCAST_STR, cmd_link_get_bcast,
> cmd_link_get_bcast_help },
>               { NULL }
>       };
> 
> --
> 2.17.1



_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion

Reply via email to