[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48c341d6-d611-3f4e-a64d-85719af7ed45@gmail.com>
Date: Mon, 7 Oct 2019 15:37:21 -0600
From: David Ahern <dsahern@...il.com>
To: Jiri Pirko <jiri@...nulli.us>, netdev@...r.kernel.org
Cc: davem@...emloft.net, jakub.kicinski@...ronome.com,
roopa@...ulusnetworks.com, dcbw@...hat.com,
nikolay@...ulusnetworks.com, mkubecek@...e.cz, andrew@...n.ch,
parav@...lanox.com, saeedm@...lanox.com, f.fainelli@...il.com,
stephen@...workplumber.org, sd@...asysnail.net, sbrivio@...hat.com,
pabeni@...hat.com, mlxsw@...lanox.com
Subject: Re: [patch iproute2-next v2 1/2] ip: add support for alternative name
addition/deletion/list
On 10/2/19 4:56 AM, Jiri Pirko wrote:
> diff --git a/ip/iplink.c b/ip/iplink.c
> index 212a088535da..e3f8a28fe94c 100644
> --- a/ip/iplink.c
> +++ b/ip/iplink.c
> @@ -111,7 +111,9 @@ void iplink_usage(void)
> "\n"
> " ip link xstats type TYPE [ ARGS ]\n"
> "\n"
> - " ip link afstats [ dev DEVICE ]\n");
> + " ip link afstats [ dev DEVICE ]\n"
> + " ip link prop add dev DEVICE [ altname NAME .. ]\n"
> + " ip link prop del dev DEVICE [ altname NAME .. ]\n");
spell out 'property' here. The matches below on "prop" is fine, but the
help can show the full name.
> +
> + if (matches(*argv, "add") == 0) {
> + req.n.nlmsg_flags |= NLM_F_EXCL | NLM_F_CREATE | NLM_F_APPEND;
> + req.n.nlmsg_type = RTM_NEWLINKPROP;
> + } else if (matches(*argv, "del") == 0) {
> + req.n.nlmsg_flags |= RTM_DELLINK;
RTM_DELLINK is a command not a netlink flag.
> + req.n.nlmsg_type = RTM_DELLINKPROP;
> + } else if (matches(*argv, "help") == 0) {
> + usage();
> + } else {
> + fprintf(stderr, "Operator required\n");
> + exit(-1);
> + }
> + return iplink_prop_mod(argc - 1, argv + 1, &req);
> +}
> +
> static void do_help(int argc, char **argv)
> {
> struct link_util *lu = NULL;
>
> diff --git a/lib/utils.c b/lib/utils.c
> index 95d46ff210aa..bbb3bdcfa80b 100644
> --- a/lib/utils.c
> +++ b/lib/utils.c
> @@ -824,14 +824,10 @@ int nodev(const char *dev)
> return -1;
> }
>
> -int check_ifname(const char *name)
> +static int __check_ifname(const char *name)
> {
> - /* These checks mimic kernel checks in dev_valid_name */
> if (*name == '\0')
> return -1;
> - if (strlen(name) >= IFNAMSIZ)
> - return -1;
> -
> while (*name) {
> if (*name == '/' || isspace(*name))
> return -1;
> @@ -840,6 +836,19 @@ int check_ifname(const char *name)
> return 0;
> }
>
> +int check_ifname(const char *name)
> +{
> + /* These checks mimic kernel checks in dev_valid_name */
> + if (strlen(name) >= IFNAMSIZ)
> + return -1;
> + return __check_ifname(name);
> +}
> +
> +int check_altifname(const char *name)
> +{
> + return __check_ifname(name);
> +}
> +
> /* buf is assumed to be IFNAMSIZ */
> int get_ifname(char *buf, const char *name)
> {
> diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
> index a8ae72d2b097..7cb4d56726d8 100644
> --- a/man/man8/ip-link.8.in
> +++ b/man/man8/ip-link.8.in
> @@ -244,6 +244,17 @@ ip-link \- network device configuration
> .IR VLAN-QOS " ] ["
> .B proto
> .IR VLAN-PROTO " ] ]"
> +.in -8
> +
> +.ti -8
> +.BI "ip link prop add"
> +.RB "[ " altname
> +.IR NAME " .. ]"
> +
> +.ti -8
> +.BI "ip link prop del"
> +.RB "[ " altname
> +.IR NAME " .. ]"
>
> .SH "DESCRIPTION"
> .SS ip link add - add virtual link
>
Powered by blists - more mailing lists