Acked if you make the small changes I am suggesting below.

///jon


> -----Original Message-----
> From: Hoang Le <[email protected]>
> Sent: 18-Feb-19 02:54
> To: [email protected]; Jon Maloy
> <[email protected]>; [email protected]; [email protected]
> Subject: [iproute2-next v2 1/2] tipc: add link broadcast set method and ratio
> 
> This command is to support broacast/replicast configurable for broadcast-
> link.
[jon] The command added here makes it possible to forcibly configure the 
broadcast link to use
          either broadcast or replicast, in addition to the already existing 
auto selection algorithm.
> 
> A sample usage is shown below:
> $tipc link set broadcast BROADCAST
> $tipc link set broadcast SELECTABLE ratio 25
> 
> $tipc link set broadcast -h
> Usage: tipc link set broadcast PROPERTY
> 
> PROPERTIES
>  BROADCAST         - Forces all multicast traffic to be
>                      transmitted via broadcast only,
>                      irrespective of cluster size and number
>                      of destinations
> 
>  REPLICAST         - Forces all multicast traffic to be
>                      transmitted via replicast only,
>                      irrespective of cluster size and number
>                      of destinations
> 
>  SELECTABLE        - Auto switching to broadcast or replicast
>                      depending on cluster size and destination
[jon] node
>                      number

[jon] I  would like to rename SELECTABLE to AUTOSELECT.  The same number of 
letter, but easier to understand.


> 
>  ratio SIZE        - Set the selection ratio for SELECTABLE PROPERTY

[jon]  - Set the AUTOSELECT criteria, percentage of destination nodes vs 
cluster size

> 
> Signed-off-by: Hoang Le <[email protected]>
> ---
>  include/uapi/linux/tipc_netlink.h |  2 +
>  tipc/link.c                       | 95 ++++++++++++++++++++++++++++++-
>  2 files changed, 96 insertions(+), 1 deletion(-)
> 
> diff --git a/include/uapi/linux/tipc_netlink.h
> b/include/uapi/linux/tipc_netlink.h
> index 0ebe02ef1a86..efb958fd167d 100644
> --- a/include/uapi/linux/tipc_netlink.h
> +++ b/include/uapi/linux/tipc_netlink.h
> @@ -281,6 +281,8 @@ enum {
>       TIPC_NLA_PROP_TOL,              /* u32 */
>       TIPC_NLA_PROP_WIN,              /* u32 */
>       TIPC_NLA_PROP_MTU,              /* u32 */
> +     TIPC_NLA_PROP_BROADCAST,        /* u32 */
> +     TIPC_NLA_PROP_BROADCAST_RATIO,  /* u32 */
> 
>       __TIPC_NLA_PROP_MAX,
>       TIPC_NLA_PROP_MAX = __TIPC_NLA_PROP_MAX - 1 diff --git
> a/tipc/link.c b/tipc/link.c index 43e26da3fa6b..c1db400f1b26 100644
> --- a/tipc/link.c
> +++ b/tipc/link.c
> @@ -28,6 +28,9 @@
>  #define PRIORITY_STR "priority"
>  #define TOLERANCE_STR "tolerance"
>  #define WINDOW_STR "window"
> +#define BROADCAST_STR "broadcast"
> +
> +static const char tipc_bclink_name[] = "broadcast-link";
> 
>  static int link_list_cb(const struct nlmsghdr *nlh, void *data)  { @@ -521,7
> +524,8 @@ static void cmd_link_set_help(struct cmdl *cmdl)
>               "PROPERTIES\n"
>               " tolerance TOLERANCE   - Set link tolerance\n"
>               " priority PRIORITY     - Set link priority\n"
> -             " window WINDOW         - Set link window\n",
> +             " window WINDOW         - Set link window\n"
> +             " broadcast BROADCAST   - Set link broadcast\n",
>               cmdl->argv[0]);
>  }
> 
> @@ -585,6 +589,94 @@ static int cmd_link_set_prop(struct nlmsghdr *nlh,
> const struct cmd *cmd,
>       return msg_doit(nlh, link_get_cb, &prop);  }
> 
> +static void cmd_link_set_bcast_help(struct cmdl *cmdl) {
> +     fprintf(stderr, "Usage: %s link set broadcast PROPERTY\n\n"
> +             "PROPERTIES\n"
> +             " BROADCAST         - Forces all multicast traffic to be\n"
> +             "                     transmitted via broadcast only,\n"
> +             "                     irrespective of cluster size and number\n"
> +             "                     of destinations\n\n"
> +             " REPLICAST         - Forces all multicast traffic to be\n"
> +             "                     transmitted via replicast only,\n"
> +             "                     irrespective of cluster size and number\n"
> +             "                     of destinations\n\n"
> +             " SELECTABLE        - Auto switching to broadcast or 
> replicast\n"
> +             "                     depending on cluster size and 
> destination\n"
> +             "                     number\n\n"
> +             " ratio SIZE        - Set the selection ratio for 
> SELECTABLE\n\n",
> +             cmdl->argv[0]);
> +}
> +
> +static int cmd_link_set_bcast(struct nlmsghdr *nlh, const struct cmd *cmd,
> +                          struct cmdl *cmdl, void *data)
> +{
> +     char buf[MNL_SOCKET_BUFFER_SIZE];
> +     struct nlattr *props;
> +     struct nlattr *attrs;
> +     struct opt *opt;
> +     struct opt opts[] = {
> +             { "BROADCAST",  OPT_KEY, NULL },
> +             { "REPLICAST",  OPT_KEY, NULL },
> +             { "SELECTABLE", OPT_KEY, NULL },
> +             { "ratio",      OPT_KEYVAL,     NULL },
> +             { NULL }
> +     };
> +     int method = 0;
> +
> +     if (help_flag) {
> +             (cmd->help)(cmdl);
> +             return -EINVAL;
> +     }
> +
> +     if (parse_opts(opts, cmdl) < 0)
> +             return -EINVAL;
> +
> +     for (opt = opts; opt->key; opt++)
> +             if (opt->val)
> +                     break;
> +
> +     if (!opt || !opt->key) {
> +             (cmd->help)(cmdl);
> +             return -EINVAL;
> +     }
> +
> +     nlh = msg_init(buf, TIPC_NL_LINK_SET);
> +     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);
> +     props = mnl_attr_nest_start(nlh, TIPC_NLA_LINK_PROP);
> +
> +     if (get_opt(opts, "BROADCAST"))
> +             method = 0x1;
> +     else if (get_opt(opts, "REPLICAST"))
> +             method = 0x2;
> +     else if (get_opt(opts, "SELECTABLE"))
> +             method = 0x4;
> +
> +     opt = get_opt(opts, "ratio");
> +     if (!method && !opt) {
> +             (cmd->help)(cmdl);
> +             return -EINVAL;
> +     }
> +
> +     if (method)
> +             mnl_attr_put_u32(nlh, TIPC_NLA_PROP_BROADCAST,
> method);
> +
> +     if (opt)
> +             mnl_attr_put_u32(nlh,
> TIPC_NLA_PROP_BROADCAST_RATIO,
> +                              atoi(opt->val));
> +
> +     mnl_attr_nest_end(nlh, props);
> +     mnl_attr_nest_end(nlh, attrs);
> +     return msg_doit(nlh, NULL, NULL);
> +}
> +
>  static int cmd_link_set(struct nlmsghdr *nlh, const struct cmd *cmd,
>                       struct cmdl *cmdl, void *data)
>  {
> @@ -592,6 +684,7 @@ static int cmd_link_set(struct nlmsghdr *nlh, const
> struct cmd *cmd,
>               { PRIORITY_STR, cmd_link_set_prop,
>       cmd_link_set_help },
>               { TOLERANCE_STR,        cmd_link_set_prop,
>       cmd_link_set_help },
>               { WINDOW_STR,   cmd_link_set_prop,
>       cmd_link_set_help },
> +             { BROADCAST_STR, cmd_link_set_bcast,
> cmd_link_set_bcast_help },
>               { NULL }
>       };
> 
> --
> 2.17.1



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

Reply via email to