netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alexey Andriyanov" <alan@al-an.info>
To: Roman Gushchin <klamm@yandex-team.ru>, netdev@vger.kernel.org
Cc: Alexey Andriyanov <alan@al-an.info>,
	David Miller <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>
Subject: [net-next 2/2] ip6_tunnel: allow to change mode for the ip6tnl0
Date: Tue, 21 Oct 2014 12:19:56 +0400	[thread overview]
Message-ID: <1413879596-13726-2-git-send-email-alan@al-an.info> (raw)
In-Reply-To: <1413879596-13726-1-git-send-email-alan@al-an.info>

The fallback device is in ipv6 mode by default.
The mode can not be changed in runtime, so there
is no way to decapsulate ip4in6 packets coming from
various sources without creating the specific tunnel
ifaces for each peer.

This allows to update the fallback tunnel device, but only
the mode could be changed.

Cc: David Miller <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Alexey Andriyanov <alan@al-an.info>
---
 net/ipv6/ip6_tunnel.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index a48f212..0e45ec9 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1285,6 +1285,14 @@ static int ip6_tnl_update(struct ip6_tnl *t, struct __ip6_tnl_parm *p)
 	return err;
 }
 
+static int ip6_tnl0_update(struct ip6_tnl *t, struct __ip6_tnl_parm *p)
+{
+	/* for default tnl0 device allow to change only the proto */
+	t->parms.proto = p->proto;
+	netdev_state_change(t->dev);
+	return 0;
+}
+
 static void
 ip6_tnl_parm_from_user(struct __ip6_tnl_parm *p, const struct ip6_tnl_parm *u)
 {
@@ -1384,7 +1392,7 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 			break;
 		ip6_tnl_parm_from_user(&p1, &p);
 		t = ip6_tnl_locate(net, &p1, cmd == SIOCADDTUNNEL);
-		if (dev != ip6n->fb_tnl_dev && cmd == SIOCCHGTUNNEL) {
+		if (cmd == SIOCCHGTUNNEL) {
 			if (t != NULL) {
 				if (t->dev != dev) {
 					err = -EEXIST;
@@ -1392,8 +1400,10 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 				}
 			} else
 				t = netdev_priv(dev);
-
-			err = ip6_tnl_update(t, &p1);
+			if (dev == ip6n->fb_tnl_dev)
+				err = ip6_tnl0_update(t, &p1);
+			else
+				err = ip6_tnl_update(t, &p1);
 		}
 		if (t) {
 			err = 0;
-- 
1.9.1

  reply	other threads:[~2014-10-21  8:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21  8:19 [net-next 1/2] ip6_tunnel: put ip6tnl0 FB device into 'any' mode Alexey Andriyanov
2014-10-21  8:19 ` Alexey Andriyanov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-10-21  8:11 Alexey Andriyanov
2014-10-21  8:11 ` [net-next 2/2] ip6_tunnel: allow to change mode for the ip6tnl0 Alexey Andriyanov
2014-10-21 15:13   ` Nicolas Dichtel
2014-10-21 15:46     ` Alexey Andrianov

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=1413879596-13726-2-git-send-email-alan@al-an.info \
    --to=alan@al-an.info \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=klamm@yandex-team.ru \
    --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).