From: Patrick Mullaney <pmullaney@novell.com>
To: alacrityvm-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, kaber@trash.net, arnd@arndb.de,
bridge@lists.linux-foundation.org, evb@yahoogroups.com,
netdev@vger.kernel.org
Subject: [PATCH 2/4] macvlan: allow in-kernel modules to create and manage macvlan devices
Date: Tue, 10 Nov 2009 17:27:57 -0500 [thread overview]
Message-ID: <20091110222757.24100.16046.stgit@mimic.site> (raw)
In-Reply-To: <20091110222632.24100.14884.stgit@mimic.site>
The macvlan driver didn't allow for creation/deletion of devices
by other in-kernel modules. This patch provides common routines
for both in-kernel and netlink based management. This patch
also enables macvlan device support for gro for lower level
devices that support gro.
Signed-off-by: Patrick Mullaney <pmullaney@novell.com>
---
drivers/net/macvlan.c | 72 +++++++++++++++++++++++++++++++----------------
include/linux/macvlan.h | 6 ++++
2 files changed, 53 insertions(+), 25 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 0a389b8..6b98b26 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -208,7 +208,7 @@ static const struct header_ops macvlan_hard_header_ops = {
.cache_update = eth_header_cache_update,
};
-static int macvlan_open(struct net_device *dev)
+int macvlan_open(struct net_device *dev)
{
struct macvlan_dev *vlan = netdev_priv(dev);
struct net_device *lowerdev = vlan->lowerdev;
@@ -235,7 +235,7 @@ out:
return err;
}
-static int macvlan_stop(struct net_device *dev)
+int macvlan_stop(struct net_device *dev)
{
struct macvlan_dev *vlan = netdev_priv(dev);
struct net_device *lowerdev = vlan->lowerdev;
@@ -316,7 +316,7 @@ static struct lock_class_key macvlan_netdev_addr_lock_key;
#define MACVLAN_FEATURES \
(NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
NETIF_F_GSO | NETIF_F_TSO | NETIF_F_UFO | NETIF_F_GSO_ROBUST | \
- NETIF_F_TSO_ECN | NETIF_F_TSO6)
+ NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_GRO)
#define MACVLAN_STATE_MASK \
((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
@@ -440,7 +440,7 @@ static void macvlan_port_destroy(struct net_device *dev)
kfree(port);
}
-static void macvlan_transfer_operstate(struct net_device *dev)
+void macvlan_transfer_operstate(struct net_device *dev)
{
struct macvlan_dev *vlan = netdev_priv(dev);
const struct net_device *lowerdev = vlan->lowerdev;
@@ -458,6 +458,7 @@ static void macvlan_transfer_operstate(struct net_device *dev)
netif_carrier_off(dev);
}
}
+EXPORT_SYMBOL_GPL(macvlan_transfer_operstate);
int macvlan_validate(struct nlattr *tb[], struct nlattr *data[])
{
@@ -471,11 +472,47 @@ int macvlan_validate(struct nlattr *tb[], struct nlattr *data[])
}
EXPORT_SYMBOL_GPL(macvlan_validate);
-int macvlan_newlink(struct net_device *dev,
- struct nlattr *tb[], struct nlattr *data[])
+int macvlan_link_lowerdev(struct net_device *dev,
+ struct net_device *lowerdev)
{
struct macvlan_dev *vlan = netdev_priv(dev);
struct macvlan_port *port;
+ int err = 0;
+
+ if (lowerdev->macvlan_port == NULL) {
+ err = macvlan_port_create(lowerdev);
+ if (err < 0)
+ return err;
+ }
+ port = lowerdev->macvlan_port;
+
+ vlan->lowerdev = lowerdev;
+ vlan->dev = dev;
+ vlan->port = port;
+ vlan->receive = netif_rx;
+
+ macvlan_init(dev);
+
+ list_add_tail(&vlan->list, &port->vlans);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(macvlan_link_lowerdev);
+
+void macvlan_unlink_lowerdev(struct net_device *dev)
+{
+ struct macvlan_dev *vlan = netdev_priv(dev);
+ struct macvlan_port *port = vlan->port;
+
+ list_del(&vlan->list);
+
+ if (list_empty(&port->vlans))
+ macvlan_port_destroy(port->dev);
+}
+EXPORT_SYMBOL_GPL(macvlan_unlink_lowerdev);
+
+int macvlan_newlink(struct net_device *dev,
+ struct nlattr *tb[], struct nlattr *data[])
+{
struct net_device *lowerdev;
int err;
@@ -502,23 +539,14 @@ int macvlan_newlink(struct net_device *dev,
if (!tb[IFLA_ADDRESS])
random_ether_addr(dev->dev_addr);
- if (lowerdev->macvlan_port == NULL) {
- err = macvlan_port_create(lowerdev);
- if (err < 0)
- return err;
- }
- port = lowerdev->macvlan_port;
-
- vlan->lowerdev = lowerdev;
- vlan->dev = dev;
- vlan->port = port;
- vlan->receive = netif_rx;
+ err = macvlan_link_lowerdev(dev, lowerdev);
+ if (err < 0)
+ return err;
err = register_netdevice(dev);
if (err < 0)
return err;
- list_add_tail(&vlan->list, &port->vlans);
macvlan_transfer_operstate(dev);
return 0;
}
@@ -526,14 +554,8 @@ EXPORT_SYMBOL_GPL(macvlan_newlink);
void macvlan_dellink(struct net_device *dev)
{
- struct macvlan_dev *vlan = netdev_priv(dev);
- struct macvlan_port *port = vlan->port;
-
- list_del(&vlan->list);
+ macvlan_unlink_lowerdev(dev);
unregister_netdevice(dev);
-
- if (list_empty(&port->vlans))
- macvlan_port_destroy(port->dev);
}
EXPORT_SYMBOL_GPL(macvlan_dellink);
diff --git a/include/linux/macvlan.h b/include/linux/macvlan.h
index 3f3c6c3..cf8738a 100644
--- a/include/linux/macvlan.h
+++ b/include/linux/macvlan.h
@@ -24,6 +24,12 @@ struct macvlan_dev {
};
extern int macvlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
+extern int macvlan_link_lowerdev(struct net_device *dev,
+ struct net_device *lowerdev);
+
+extern void macvlan_unlink_lowerdev(struct net_device *dev);
+
+extern void macvlan_transfer_operstate(struct net_device *dev);
extern void macvlan_setup(struct net_device *dev);
next prev parent reply other threads:[~2009-11-10 22:27 UTC|newest]
Thread overview: 25+ 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 ` Patrick Mullaney [this message]
2009-11-11 15:29 ` [PATCH 2/4] macvlan: allow in-kernel modules to create and manage macvlan devices Patrick McHardy
2009-11-12 18:05 ` [PATCH] netdevice: provide common routine for macvlan and vlan operstate management Patrick Mullaney
2009-11-12 18:21 ` 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
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=20091110222757.24100.16046.stgit@mimic.site \
--to=pmullaney@novell.com \
--cc=alacrityvm-devel@lists.sourceforge.net \
--cc=arnd@arndb.de \
--cc=bridge@lists.linux-foundation.org \
--cc=evb@yahoogroups.com \
--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).