From: Alexandre Cassen <acassen@freebox.fr>
To: netdev@vger.kernel.org
Subject: [PATCH][iproute2] Detect 6rd kernel missing support / 6rd tunnel scope
Date: Sun, 4 Apr 2010 22:40:14 +0200 [thread overview]
Message-ID: <20100404204014.GA24602@lnxos.staff.proxad.net> (raw)
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 | 2 +-
ip/tunnel.c | 11 ++++++-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/ip/iptunnel.c b/ip/iptunnel.c
index 1cd9fbd..3525fbb 100644
--- a/ip/iptunnel.c
+++ b/ip/iptunnel.c
@@ -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);
diff --git a/ip/tunnel.c b/ip/tunnel.c
index d389e86..6efbd2d 100644
--- a/ip/tunnel.c
+++ b/ip/tunnel.c
@@ -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);
}
--
1.6.3.3
next reply other threads:[~2010-04-04 20:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-04 20:40 Alexandre Cassen [this message]
2010-04-12 18:46 ` [PATCH][iproute2] Detect 6rd kernel missing support / 6rd tunnel scope Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100404204014.GA24602@lnxos.staff.proxad.net \
--to=acassen@freebox.fr \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).