From: "Jan Beulich" Subject: [PATCH] linux: allow netback to be a module Date: Tue, 28 Feb 2006 17:45:21 +0100 Message-ID: <44048C31.76F0.0078.0@novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part67422A31.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part67422A31.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline This is only a first step. netback uses add_timer_on(), which isn't being exported, and which I don't think would be a good idea to export. Someone knowing the code better than me should check whether that function can be reasonably replaced by __mod_timer(). All other build issues preventing modular use should be resolved with this patch. Jan --=__Part67422A31.0__= Content-Type: text/plain; name="xenlinux-modular-netback.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="xenlinux-modular-netback.patch" Index: head-2006-02-23/drivers/xen/Kconfig =================================================================== --- head-2006-02-23.orig/drivers/xen/Kconfig 2006-02-28 15:22:29.000000000 +0100 +++ head-2006-02-23/drivers/xen/Kconfig 2006-02-28 15:23:42.000000000 +0100 @@ -89,7 +89,7 @@ config XEN_BLKDEV_TAP_BE modified to use grant tables. config XEN_NETDEV_BACKEND - bool "Network-device backend driver" + tristate "Network-device backend driver" default y help The network-device backend driver allows the kernel to export its @@ -161,6 +161,14 @@ config XEN_TPMDEV_FRONTEND help The TPM-device frontend driver. +config XEN_NETDEV_LOOPBACK + tristate "Network-device loopback driver" + depends on XEN_NETDEV_BACKEND && XEN_NETDEV_FRONTEND + default y + help + A two-interface loopback device to emulate a local netfront-netback + connection. + config XEN_SCRUB_PAGES bool "Scrub memory before freeing it to Xen" default y Index: head-2006-02-23/drivers/xen/core/skbuff.c =================================================================== --- head-2006-02-23.orig/drivers/xen/core/skbuff.c 2006-02-28 15:19:05.000000000 +0100 +++ head-2006-02-23/drivers/xen/core/skbuff.c 2006-02-28 14:44:15.000000000 +0100 @@ -16,6 +16,7 @@ /* Referenced in netback.c. */ /*static*/ kmem_cache_t *skbuff_cachep; +EXPORT_SYMBOL(skbuff_cachep); #define MAX_SKBUFF_ORDER 4 static kmem_cache_t *skbuff_order_cachep[MAX_SKBUFF_ORDER + 1]; Index: head-2006-02-23/drivers/xen/netback/Makefile =================================================================== --- head-2006-02-23.orig/drivers/xen/netback/Makefile 2006-02-28 15:19:05.000000000 +0100 +++ head-2006-02-23/drivers/xen/netback/Makefile 2006-02-28 14:59:45.000000000 +0100 @@ -1,2 +1,5 @@ +obj-$(CONFIG_XEN_NETDEV_BACKEND) := netbk.o +obj-$(CONFIG_XEN_NETDEV_LOOPBACK) += netloop.o -obj-y := netback.o xenbus.o interface.o loopback.o +netbk-y := netback.o xenbus.o interface.o +netloop-y := loopback.o Index: head-2006-02-23/drivers/xen/netback/loopback.c =================================================================== --- head-2006-02-23.orig/drivers/xen/netback/loopback.c 2006-02-28 15:19:05.000000000 +0100 +++ head-2006-02-23/drivers/xen/netback/loopback.c 2006-02-28 14:43:07.000000000 +0100 @@ -178,6 +178,23 @@ static int __init make_loopback(int i) return err; } +static void __init clean_loopback(int i) +{ + struct net_device *dev1, *dev2; + char dev_name[IFNAMSIZ]; + + sprintf(dev_name, "vif0.%d", i); + dev1 = dev_get_by_name(dev_name); + sprintf(dev_name, "veth%d", i); + dev2 = dev_get_by_name(dev_name); + if (dev1 && dev2) { + unregister_netdev(dev2); + unregister_netdev(dev1); + free_netdev(dev2); + free_netdev(dev1); + } +} + static int __init loopback_init(void) { int i, err = 0; @@ -191,6 +208,18 @@ static int __init loopback_init(void) module_init(loopback_init); +static void __exit loopback_exit(void) +{ + int i; + + for (i = nloopbacks; i-- > 0; ) + clean_loopback(i); +} + +module_exit(loopback_exit); + +MODULE_LICENSE("Dual BSD/GPL"); + /* * Local variables: * c-file-style: "linux" Index: head-2006-02-23/drivers/xen/netback/netback.c =================================================================== --- head-2006-02-23.orig/drivers/xen/netback/netback.c 2006-02-28 15:19:05.000000000 +0100 +++ head-2006-02-23/drivers/xen/netback/netback.c 2006-02-28 15:17:08.000000000 +0100 @@ -811,6 +811,8 @@ static int __init netback_init(void) &netif_be_dbg); #endif + __unsafe(THIS_MODULE); + return 0; } @@ -822,6 +824,8 @@ static void netback_cleanup(void) module_init(netback_init); module_exit(netback_cleanup); +MODULE_LICENSE("Dual BSD/GPL"); + /* * Local variables: * c-file-style: "linux" --=__Part67422A31.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part67422A31.0__=--