]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/commitdiff
Detect 6rd kernel missing support / 6rd tunnel scope
authorAlexandre Cassen <acassen@freebox.fr>
Sun, 4 Apr 2010 20:40:14 +0000 (22:40 +0200)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 12 Apr 2010 18:45:51 +0000 (11:45 -0700)
This patch fix two issues:

* If kernel is not supporting 6rd then ioctl() call
  will return EINVAL, if so just skip perror call.

* 6rd scope is ipv6/ip tunnels. Dont try to fetch
  6rd tunnel parms if tunnel protocol != IPPROTO_IPV6.

Signed-off-by: Alexandre Cassen <acassen@freebox.fr>
ip/iptunnel.c
ip/tunnel.c

index 1cd9fbd68e6b694baad802d45a1681e6a902d083..3525fbb2f9e19e3e1b9021851a50a35919e5654b 100644 (file)
@@ -365,7 +365,7 @@ static void print_tunnel(struct ip_tunnel_parm *p)
        if (!(p->iph.frag_off&htons(IP_DF)))
                printf(" nopmtudisc");
 
-       if (!tnl_ioctl_get_6rd(p->name, &ip6rd) && ip6rd.prefixlen) {
+       if (p->iph.protocol == IPPROTO_IPV6 && !tnl_ioctl_get_6rd(p->name, &ip6rd) && ip6rd.prefixlen) {
                printf(" 6rd-prefix %s/%u ",
                       inet_ntop(AF_INET6, &ip6rd.prefix, s1, sizeof(s1)),
                       ip6rd.prefixlen);
index d389e8660b862bfb3e10682f64fdd3f50a836195..6efbd2dfcebfdd868c116f94a94c2fd8247c8498 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
@@ -168,7 +169,7 @@ int tnl_del_ioctl(const char *basedev, const char *name, void *p)
        return err;
 }
 
-static int tnl_gen_ioctl(int cmd, const char *name, void *p)
+static int tnl_gen_ioctl(int cmd, const char *name, void *p, int skiperr)
 {
        struct ifreq ifr;
        int fd;
@@ -178,7 +179,7 @@ static int tnl_gen_ioctl(int cmd, const char *name, void *p)
        ifr.ifr_ifru.ifru_data = p;
        fd = socket(preferred_family, SOCK_DGRAM, 0);
        err = ioctl(fd, cmd, &ifr);
-       if (err)
+       if (err && errno != skiperr)
                perror("ioctl");
        close(fd);
        return err;
@@ -186,15 +187,15 @@ static int tnl_gen_ioctl(int cmd, const char *name, void *p)
 
 int tnl_prl_ioctl(int cmd, const char *name, void *p)
 {
-       return tnl_gen_ioctl(cmd, name, p);
+       return tnl_gen_ioctl(cmd, name, p, -1);
 }
 
 int tnl_6rd_ioctl(int cmd, const char *name, void *p)
 {
-       return tnl_gen_ioctl(cmd, name, p);
+       return tnl_gen_ioctl(cmd, name, p, -1);
 }
 
 int tnl_ioctl_get_6rd(const char *name, void *p)
 {
-       return tnl_gen_ioctl(SIOCGET6RD, name, p);
+       return tnl_gen_ioctl(SIOCGET6RD, name, p, EINVAL);
 }