Message ID | 1513755451-9800-2-git-send-email-serhe.popovych@gmail.com |
---|---|
State | Superseded, archived |
Delegated to: | stephen hemminger |
Headers | show |
Series | Forbid "type" for peer, update ifname and make it array in ll_cache | expand |
On Wed, 20 Dec 2017 09:37:29 +0200 Serhey Popovych <serhe.popovych@gmail.com> wrote: > It is already given for original device we configure this > peer for. > > Results from following command before/after change applied > are shown below: > > $ ip link add dev veth1a type veth peer name veth1b \ > type veth peer name veth1c > > Before: > ------- > > <no output, no netdevs created> > > After: > ------ > > Error: argument "type" is wrong: not supported for peer > > Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com> This makes a lot of sense. Maybe the better error message would be to use duparg() since that is the most likely cause of the user error.
Stephen Hemminger wrote: > On Wed, 20 Dec 2017 09:37:29 +0200 > Serhey Popovych <serhe.popovych@gmail.com> wrote: > >> It is already given for original device we configure this >> peer for. >> >> Results from following command before/after change applied >> are shown below: >> >> $ ip link add dev veth1a type veth peer name veth1b \ >> type veth peer name veth1c >> >> Before: >> ------- >> >> <no output, no netdevs created> >> >> After: >> ------ >> >> Error: argument "type" is wrong: not supported for peer >> >> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com> > > This makes a lot of sense. > Maybe the better error message would be to use duparg() since > that is the most likely cause of the user error. Not sure Stephen. With duparg() I get following error message for test case described in above. Error: duplicate "type": "veth" is the second value. It looks good for me, but we have two "type veth" in command and which one is wrong might not be very clear to user. Anyway I send v2 for this particular change to get and option to pick the best one. Thanks. >
diff --git a/ip/iplink_vxcan.c b/ip/iplink_vxcan.c index c13224c..13f2577 100644 --- a/ip/iplink_vxcan.c +++ b/ip/iplink_vxcan.c @@ -65,6 +65,9 @@ static int vxcan_parse_opt(struct link_util *lu, int argc, char **argv, if (err < 0) return err; + if (type) + invarg("not supported for peer", "type"); + if (name) { addattr_l(hdr, 1024, IFLA_IFNAME, name, strlen(name) + 1); diff --git a/ip/link_veth.c b/ip/link_veth.c index fcfd1ef..cc43198 100644 --- a/ip/link_veth.c +++ b/ip/link_veth.c @@ -63,6 +63,9 @@ static int veth_parse_opt(struct link_util *lu, int argc, char **argv, if (err < 0) return err; + if (type) + invarg("not supported for peer", "type"); + if (name) { addattr_l(hdr, 1024, IFLA_IFNAME, name, strlen(name) + 1);
It is already given for original device we configure this peer for. Results from following command before/after change applied are shown below: $ ip link add dev veth1a type veth peer name veth1b \ type veth peer name veth1c Before: ------- <no output, no netdevs created> After: ------ Error: argument "type" is wrong: not supported for peer Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com> --- ip/iplink_vxcan.c | 3 +++ ip/link_veth.c | 3 +++ 2 files changed, 6 insertions(+)