* [PATCH] iproute2: ip6_tunnel mode bugfixes: any,vti6
@ 2014-10-29 6:19 Alexey Andriyanov
2014-11-02 19:49 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Andriyanov @ 2014-10-29 6:19 UTC (permalink / raw)
To: netdev; +Cc: Alexey Andriyanov, Stephen Hemminger
- any ipv6 tunnel mode (proto == 0) could not be set
due to incomplete set of cases in do_add, do_del.
- vti6 logic was inverted: it was using "ip6_vti0" basedev
UNLESS mode is set to vti6.
We don't need a switch by p.proto in do_add()/do_del(): it
already exists in parse_args(). So if parse_args() call
was successful, no need to check tunnel mode again.
CC: Stephen Hemminger <shemming@brocade.com>
Signed-off-by: Alexey Andriyanov <alan@al-an.info>
---
ip/ip6tunnel.c | 40 ++++++++++++++--------------------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/ip/ip6tunnel.c b/ip/ip6tunnel.c
index b83534e..62a8240 100644
--- a/ip/ip6tunnel.c
+++ b/ip/ip6tunnel.c
@@ -453,49 +453,37 @@ static int do_show(int argc, char **argv)
static int do_add(int cmd, int argc, char **argv)
{
struct ip6_tnl_parm2 p;
+ const char *basedev = "ip6tnl0";
ip6_tnl_parm_init(&p, 1);
if (parse_args(argc, argv, cmd, &p) < 0)
return -1;
- switch (p.proto) {
- case IPPROTO_IPIP:
- case IPPROTO_IPV6:
- if (p.i_flags != VTI_ISVTI)
- return tnl_add_ioctl(cmd, "ip6_vti0", p.name, &p);
- else
- return tnl_add_ioctl(cmd, "ip6tnl0", p.name, &p);
- case IPPROTO_GRE:
- return tnl_add_ioctl(cmd, "ip6gre0", p.name, &p);
- default:
- fprintf(stderr, "cannot determine tunnel mode (ip6ip6, ipip6, vti6 or gre)\n");
- }
- return -1;
+ if (p.proto == IPPROTO_GRE)
+ basedev = "ip6gre0";
+ else if (p.i_flags & VTI_ISVTI)
+ basedev = "ip6_vti0";
+
+ return tnl_add_ioctl(cmd, basedev, p.name, &p);
}
static int do_del(int argc, char **argv)
{
struct ip6_tnl_parm2 p;
+ const char *basedev = "ip6tnl0";
ip6_tnl_parm_init(&p, 1);
if (parse_args(argc, argv, SIOCDELTUNNEL, &p) < 0)
return -1;
- switch (p.proto) {
- case IPPROTO_IPIP:
- case IPPROTO_IPV6:
- if (p.i_flags != VTI_ISVTI)
- return tnl_del_ioctl("ip6_vti0", p.name, &p);
- else
- return tnl_del_ioctl("ip6tnl0", p.name, &p);
- case IPPROTO_GRE:
- return tnl_del_ioctl("ip6gre0", p.name, &p);
- default:
- return tnl_del_ioctl(p.name, p.name, &p);
- }
- return -1;
+ if (p.proto == IPPROTO_GRE)
+ basedev = "ip6gre0";
+ else if (p.i_flags & VTI_ISVTI)
+ basedev = "ip6_vti0";
+
+ return tnl_del_ioctl(basedev, p.name, &p);
}
int do_ip6tunnel(int argc, char **argv)
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] iproute2: ip6_tunnel mode bugfixes: any,vti6
2014-10-29 6:19 [PATCH] iproute2: ip6_tunnel mode bugfixes: any,vti6 Alexey Andriyanov
@ 2014-11-02 19:49 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2014-11-02 19:49 UTC (permalink / raw)
To: Alexey Andriyanov; +Cc: netdev
On Wed, 29 Oct 2014 09:19:30 +0300
"Alexey Andriyanov" <alan@al-an.info> wrote:
> - any ipv6 tunnel mode (proto == 0) could not be set
> due to incomplete set of cases in do_add, do_del.
> - vti6 logic was inverted: it was using "ip6_vti0" basedev
> UNLESS mode is set to vti6.
>
> We don't need a switch by p.proto in do_add()/do_del(): it
> already exists in parse_args(). So if parse_args() call
> was successful, no need to check tunnel mode again.
>
> CC: Stephen Hemminger <shemming@brocade.com>
> Signed-off-by: Alexey Andriyanov <alan@al-an.info>
Accepted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-02 20:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-29 6:19 [PATCH] iproute2: ip6_tunnel mode bugfixes: any,vti6 Alexey Andriyanov
2014-11-02 19:49 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox