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 >