From: Patrick Mullaney <pmullaney@novell.com>
To: kaber@trash.net
Cc: linux-kernel@vger.kernel.org, arnd@arnd.de,
netdev@vger.kernel.org, bridge@lists.linux-foundation.rog
Subject: [PATCH] netdevice: provide common routine for macvlan and vlan operstate management
Date: Thu, 12 Nov 2009 13:05:11 -0500 [thread overview]
Message-ID: <20091112180137.10186.9386.stgit@mimic.site> (raw)
In-Reply-To: <4AFAD86A.9070506@trash.net>
Patrick,
This patch is intended to address your comment on moving the operstate
transition function. I decided to move it to netdevice.h, perhaps that
is a bad idea? It didn't seem to logically fall into dev.c or link_watch.c.
I am not against moving them to either one though. Your other comments
are addressed and I will send out a second series once this gets
reviewed and agreed on.
Thanks for your review/comments.
----------
Provide common routine for the transition of operational state for a leaf
device during a root device transition.
Signed-off-by: Patrick Mullaney <pmullaney@novell.com>
---
include/linux/netdevice.h | 19 +++++++++++++++++++
net/8021q/vlan.c | 29 ++++-------------------------
2 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d4a4d98..a15920a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1999,6 +1999,25 @@ static inline u32 dev_ethtool_get_flags(struct net_device *dev)
return 0;
return dev->ethtool_ops->get_flags(dev);
}
+
+static inline
+void netif_stacked_transfer_operstate(const struct net_device *rootdev,
+ struct net_device *dev)
+{
+ if (rootdev->operstate == IF_OPER_DORMANT)
+ netif_dormant_on(dev);
+ else
+ netif_dormant_off(dev);
+
+ if (netif_carrier_ok(rootdev)) {
+ if (!netif_carrier_ok(dev))
+ netif_carrier_on(dev);
+ } else {
+ if (netif_carrier_ok(dev))
+ netif_carrier_off(dev);
+ }
+}
+
#endif /* __KERNEL__ */
#endif /* _LINUX_NETDEVICE_H */
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index fe64908..5d11c12 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -183,27 +183,6 @@ void unregister_vlan_dev(struct net_device *dev)
dev_put(real_dev);
}
-static void vlan_transfer_operstate(const struct net_device *dev,
- struct net_device *vlandev)
-{
- /* Have to respect userspace enforced dormant state
- * of real device, also must allow supplicant running
- * on VLAN device
- */
- if (dev->operstate == IF_OPER_DORMANT)
- netif_dormant_on(vlandev);
- else
- netif_dormant_off(vlandev);
-
- if (netif_carrier_ok(dev)) {
- if (!netif_carrier_ok(vlandev))
- netif_carrier_on(vlandev);
- } else {
- if (netif_carrier_ok(vlandev))
- netif_carrier_off(vlandev);
- }
-}
-
int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id)
{
const char *name = real_dev->name;
@@ -267,7 +246,7 @@ int register_vlan_dev(struct net_device *dev)
/* Account for reference in struct vlan_dev_info */
dev_hold(real_dev);
- vlan_transfer_operstate(real_dev, dev);
+ netif_stacked_transfer_operstate(real_dev, dev);
linkwatch_fire_event(dev); /* _MUST_ call rfc2863_policy() */
/* So, got the sucker initialized, now lets place
@@ -449,7 +428,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
if (!vlandev)
continue;
- vlan_transfer_operstate(dev, vlandev);
+ netif_stacked_transfer_operstate(dev, vlandev);
}
break;
@@ -492,7 +471,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
continue;
dev_change_flags(vlandev, flgs & ~IFF_UP);
- vlan_transfer_operstate(dev, vlandev);
+ netif_stacked_transfer_operstate(dev, vlandev);
}
break;
@@ -508,7 +487,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
continue;
dev_change_flags(vlandev, flgs | IFF_UP);
- vlan_transfer_operstate(dev, vlandev);
+ netif_stacked_transfer_operstate(dev, vlandev);
}
break;
next prev parent reply other threads:[~2009-11-12 18:05 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-10 22:27 [PATCH 0/4] vbus: venet macvlan support Patrick Mullaney
2009-11-10 22:27 ` [PATCH 1/4] macvlan: derived from Arnd Bergmann's patch for macvtap Patrick Mullaney
2009-11-10 22:27 ` [PATCH 2/4] macvlan: allow in-kernel modules to create and manage macvlan devices Patrick Mullaney
2009-11-11 15:29 ` Patrick McHardy
2009-11-12 18:05 ` Patrick Mullaney [this message]
2009-11-12 18:21 ` [PATCH] netdevice: provide common routine for macvlan and vlan operstate management Patrick McHardy
2009-11-13 19:55 ` [PATCH 0/3] macvlan: support for guest vm direct rx/tx Patrick Mullaney
2009-11-13 19:55 ` [PATCH 1/3] netdevice: provide common routine for macvlan and vlan operstate management Patrick Mullaney
2009-11-27 13:09 ` Arnd Bergmann
2009-11-13 19:55 ` [PATCH 2/3] macvlan: derived from Arnd Bergmann's patch for macvtap Patrick Mullaney
2009-11-13 19:55 ` [PATCH 3/3] macvlan: allow in-kernel modules to create and manage macvlan devices Patrick Mullaney
2009-11-27 22:14 ` Arnd Bergmann
2009-11-27 22:19 ` Arnd Bergmann
2009-11-13 21:27 ` [PATCH 0/3] macvlan: support for guest vm direct rx/tx Stephen Hemminger
2009-11-27 23:43 ` Arnd Bergmann
2009-11-28 0:19 ` David Miller
2009-11-28 5:38 ` Stephen Hemminger
2009-11-28 6:58 ` David Miller
2009-11-10 22:28 ` [PATCH 3/4] venetdev: support common venet netdev routines Patrick Mullaney
2009-11-10 22:28 ` [PATCH 4/4] venet-macvlan: add new driver to connect a venet to a macvlan netdevice Patrick Mullaney
2009-11-11 15:36 ` Patrick McHardy
2009-11-12 15:44 ` [PATCH 0/4] vbus: venet macvlan support Gregory Haskins
2009-11-12 15:53 ` Patrick McHardy
2009-11-12 15:54 ` Gregory Haskins
2009-11-12 15:59 ` Patrick McHardy
-- strict thread matches above, loose matches on Subject: below --
2009-11-27 22:30 [PATCH v2] netdevice: provide common routine for macvlan and vlan operstate management Patrick McHardy
2009-12-03 20:21 ` [PATCH] " Patrick Mullaney
2009-12-03 21:34 ` Arnd Bergmann
2009-12-03 23:59 ` David Miller
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=20091112180137.10186.9386.stgit@mimic.site \
--to=pmullaney@novell.com \
--cc=arnd@arnd.de \
--cc=bridge@lists.linux-foundation.rog \
--cc=kaber@trash.net \
--cc=linux-kernel@vger.kernel.org \
--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).