All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 3/4] sit: follow state of lower device
Date: Thu, 12 Apr 2012 09:31:18 -0700	[thread overview]
Message-ID: <20120412163142.659412516@vyatta.com> (raw)
In-Reply-To: 20120412163115.076119065@vyatta.com

[-- Attachment #1: sit-lowerup.patch --]
[-- Type: text/plain, Size: 2515 bytes --]

SIT tunnels like other layered devices should propogate
carrier and RFC2863 state from lower device to tunnel.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/net/ipv6/sit.c	2012-04-12 08:31:05.249059443 -0700
+++ b/net/ipv6/sit.c	2012-04-12 08:34:44.093009537 -0700
@@ -284,6 +284,7 @@ static struct ip_tunnel *ipip6_tunnel_lo
 	dev_hold(dev);
 
 	ipip6_tunnel_link(sitn, nt);
+	linkwatch_fire_event(dev);
 	return nt;
 
 failed_free:
@@ -901,6 +902,7 @@ static void ipip6_tunnel_bind_dev(struct
 		dev->mtu = tdev->mtu - sizeof(struct iphdr);
 		if (dev->mtu < IPV6_MIN_MTU)
 			dev->mtu = IPV6_MIN_MTU;
+		netif_stacked_transfer_operstate(tdev, dev);
 	}
 	dev->iflink = tunnel->parms.link;
 }
@@ -1231,6 +1233,36 @@ static void __net_exit sit_destroy_tunne
 	}
 }
 
+/* If lower device changes state, reflect that to the tunnel. */
+static int sit_notify(struct notifier_block *unused,
+			unsigned long event, void *ptr)
+{
+	struct net_device *dev = ptr;
+	struct net *net = dev_net(dev);
+	struct sit_net *sitn = net_generic(net, sit_net_id);
+	unsigned int prio, h;
+	struct ip_tunnel *t;
+
+	if (event == NETDEV_CHANGE)
+		return NOTIFY_DONE;
+
+	for (prio = 0; prio < 4; prio++)
+		for (h = 0; h < HASH_SIZE; h++) {
+			for (t = rtnl_dereference(sitn->tunnels[prio][h]);
+			     t; t = rtnl_dereference(t->next)) {
+				if (dev->ifindex != t->dev->iflink)
+					continue;
+				netif_stacked_transfer_operstate(dev, t->dev);
+			}
+		}
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block sit_notifier = {
+	.notifier_call = sit_notify,
+};
+
 static int __net_init sit_init_net(struct net *net)
 {
 	struct sit_net *sitn = net_generic(net, sit_net_id);
@@ -1293,6 +1325,7 @@ static struct pernet_operations sit_net_
 
 static void __exit sit_cleanup(void)
 {
+	unregister_netdevice_notifier(&sit_notifier);
 	xfrm4_tunnel_deregister(&sit_handler, AF_INET6);
 
 	unregister_pernet_device(&sit_net_ops);
@@ -1309,11 +1342,21 @@ static int __init sit_init(void)
 	if (err < 0)
 		return err;
 	err = xfrm4_tunnel_register(&sit_handler, AF_INET6);
-	if (err < 0) {
-		unregister_pernet_device(&sit_net_ops);
-		printk(KERN_INFO "sit init: Can't add protocol\n");
-	}
+	if (err < 0)
+		goto xfrm4_failed;
+
+	err = register_netdevice_notifier(&sit_notifier);
+	if (err < 0)
+		goto notify_failed;
+
+out:
 	return err;
+
+notify_failed:
+	xfrm4_tunnel_deregister(&sit_handler, AF_INET6);
+xfrm4_failed:
+	unregister_pernet_device(&sit_net_ops);
+	goto out;
 }
 
 module_init(sit_init);

  parent reply	other threads:[~2012-04-12 16:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-12 16:31 [PATCH 0/4] Tunneling related patches Stephen Hemminger
2012-04-12 16:31 ` [PATCH 1/4] tunnel: implement 64 bits statistics Stephen Hemminger
2012-04-14 18:51   ` David Miller
2012-04-12 16:31 ` [PATCH 2/4] ipgre: follow state of lower device Stephen Hemminger
2012-04-12 17:32   ` Ben Hutchings
2012-04-12 17:38     ` Stephen Hemminger
2012-04-14 18:53   ` David Miller
2012-04-15  2:56     ` Stephen Hemminger
2012-05-03 22:40     ` Stephen Hemminger
2012-05-04 23:34       ` Christian Benvenuti (benve)
2012-04-12 16:31 ` Stephen Hemminger [this message]
2012-04-12 16:31 ` [PATCH 4/4] ipip: " 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=20120412163142.659412516@vyatta.com \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.