ia64/xen-unstable

changeset 9071:271cb04a4f2b

Allow netback to be built as a module.

From: Jan Beulich

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Feb 28 18:59:24 2006 +0100 (2006-02-28)
parents ead0b7fcad3a
children a66763eb86fe
files buildconfigs/linux-defconfig_xen0_x86_32 buildconfigs/linux-defconfig_xen0_x86_64 buildconfigs/linux-defconfig_xen_x86_32 buildconfigs/linux-defconfig_xen_x86_64 linux-2.6-xen-sparse/drivers/xen/Kconfig linux-2.6-xen-sparse/drivers/xen/core/skbuff.c linux-2.6-xen-sparse/drivers/xen/netback/Makefile linux-2.6-xen-sparse/drivers/xen/netback/loopback.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c
line diff
     1.1 --- a/buildconfigs/linux-defconfig_xen0_x86_32	Tue Feb 28 18:56:00 2006 +0100
     1.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_32	Tue Feb 28 18:59:24 2006 +0100
     1.3 @@ -1320,6 +1320,7 @@ CONFIG_XEN_BLKDEV_BACKEND=y
     1.4  # CONFIG_XEN_BLKDEV_TAP_BE is not set
     1.5  CONFIG_XEN_NETDEV_BACKEND=y
     1.6  # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
     1.7 +CONFIG_XEN_NETDEV_LOOPBACK=y
     1.8  # CONFIG_XEN_TPMDEV_BACKEND is not set
     1.9  CONFIG_XEN_BLKDEV_FRONTEND=y
    1.10  CONFIG_XEN_NETDEV_FRONTEND=y
     2.1 --- a/buildconfigs/linux-defconfig_xen0_x86_64	Tue Feb 28 18:56:00 2006 +0100
     2.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_64	Tue Feb 28 18:59:24 2006 +0100
     2.3 @@ -1244,6 +1244,7 @@ CONFIG_XEN_BLKDEV_BACKEND=y
     2.4  # CONFIG_XEN_BLKDEV_TAP_BE is not set
     2.5  CONFIG_XEN_NETDEV_BACKEND=y
     2.6  # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
     2.7 +CONFIG_XEN_NETDEV_LOOPBACK=y
     2.8  # CONFIG_XEN_TPMDEV_BACKEND is not set
     2.9  CONFIG_XEN_BLKDEV_FRONTEND=y
    2.10  CONFIG_XEN_NETDEV_FRONTEND=y
     3.1 --- a/buildconfigs/linux-defconfig_xen_x86_32	Tue Feb 28 18:56:00 2006 +0100
     3.2 +++ b/buildconfigs/linux-defconfig_xen_x86_32	Tue Feb 28 18:59:24 2006 +0100
     3.3 @@ -2986,6 +2986,7 @@ CONFIG_XEN_BLKDEV_BACKEND=y
     3.4  # CONFIG_XEN_BLKDEV_TAP_BE is not set
     3.5  CONFIG_XEN_NETDEV_BACKEND=y
     3.6  # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
     3.7 +CONFIG_XEN_NETDEV_LOOPBACK=y
     3.8  # CONFIG_XEN_TPMDEV_BACKEND is not set
     3.9  CONFIG_XEN_BLKDEV_FRONTEND=y
    3.10  CONFIG_XEN_NETDEV_FRONTEND=y
     4.1 --- a/buildconfigs/linux-defconfig_xen_x86_64	Tue Feb 28 18:56:00 2006 +0100
     4.2 +++ b/buildconfigs/linux-defconfig_xen_x86_64	Tue Feb 28 18:59:24 2006 +0100
     4.3 @@ -2656,6 +2656,7 @@ CONFIG_XEN_BLKDEV_BACKEND=y
     4.4  # CONFIG_XEN_BLKDEV_TAP_BE is not set
     4.5  CONFIG_XEN_NETDEV_BACKEND=y
     4.6  # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
     4.7 +CONFIG_XEN_NETDEV_LOOPBACK=y
     4.8  # CONFIG_XEN_TPMDEV_BACKEND is not set
     4.9  CONFIG_XEN_BLKDEV_FRONTEND=y
    4.10  CONFIG_XEN_NETDEV_FRONTEND=y
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Tue Feb 28 18:56:00 2006 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Tue Feb 28 18:59:24 2006 +0100
     5.3 @@ -89,7 +89,7 @@ config XEN_BLKDEV_TAP_BE
     5.4            modified to use grant tables.
     5.5  
     5.6  config XEN_NETDEV_BACKEND
     5.7 -	bool "Network-device backend driver"
     5.8 +	tristate "Network-device backend driver"
     5.9  	default y
    5.10  	help
    5.11  	  The network-device backend driver allows the kernel to export its
    5.12 @@ -109,6 +109,14 @@ config XEN_NETDEV_PIPELINED_TRANSMITTER
    5.13  	  are unsure; or if you experience network hangs when this option is
    5.14  	  enabled; then you must say N here.
    5.15  
    5.16 +config XEN_NETDEV_LOOPBACK
    5.17 +	tristate "Network-device loopback driver"
    5.18 +	depends on XEN_NETDEV_BACKEND
    5.19 +	default y
    5.20 +	help
    5.21 +	  A two-interface loopback device to emulate a local netfront-netback
    5.22 +	  connection.
    5.23 +
    5.24  config XEN_TPMDEV_BACKEND
    5.25  	bool "TPM-device backend driver"
    5.26  	default n
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/skbuff.c	Tue Feb 28 18:56:00 2006 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/skbuff.c	Tue Feb 28 18:59:24 2006 +0100
     6.3 @@ -16,6 +16,7 @@
     6.4  
     6.5  /* Referenced in netback.c. */
     6.6  /*static*/ kmem_cache_t *skbuff_cachep;
     6.7 +EXPORT_SYMBOL(skbuff_cachep);
     6.8  
     6.9  #define MAX_SKBUFF_ORDER 4
    6.10  static kmem_cache_t *skbuff_order_cachep[MAX_SKBUFF_ORDER + 1];
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/Makefile	Tue Feb 28 18:56:00 2006 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/Makefile	Tue Feb 28 18:59:24 2006 +0100
     7.3 @@ -1,2 +1,5 @@
     7.4 +obj-$(CONFIG_XEN_NETDEV_BACKEND) := netbk.o
     7.5 +obj-$(CONFIG_XEN_NETDEV_LOOPBACK) += netloop.o
     7.6  
     7.7 -obj-y	:= netback.o xenbus.o interface.o loopback.o
     7.8 +netbk-y   := netback.o xenbus.o interface.o
     7.9 +netloop-y := loopback.o
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Tue Feb 28 18:56:00 2006 +0100
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Tue Feb 28 18:59:24 2006 +0100
     8.3 @@ -178,6 +178,23 @@ static int __init make_loopback(int i)
     8.4  	return err;
     8.5  }
     8.6  
     8.7 +static void __init clean_loopback(int i)
     8.8 +{
     8.9 +	struct net_device *dev1, *dev2;
    8.10 +	char dev_name[IFNAMSIZ];
    8.11 +
    8.12 +	sprintf(dev_name, "vif0.%d", i);
    8.13 +	dev1 = dev_get_by_name(dev_name);
    8.14 +	sprintf(dev_name, "veth%d", i);
    8.15 +	dev2 = dev_get_by_name(dev_name);
    8.16 +	if (dev1 && dev2) {
    8.17 +		unregister_netdev(dev2);
    8.18 +		unregister_netdev(dev1);
    8.19 +		free_netdev(dev2);
    8.20 +		free_netdev(dev1);
    8.21 +	}
    8.22 +}
    8.23 +
    8.24  static int __init loopback_init(void)
    8.25  {
    8.26  	int i, err = 0;
    8.27 @@ -191,6 +208,18 @@ static int __init loopback_init(void)
    8.28  
    8.29  module_init(loopback_init);
    8.30  
    8.31 +static void __exit loopback_exit(void)
    8.32 +{
    8.33 +	int i;
    8.34 +
    8.35 +	for (i = nloopbacks; i-- > 0; )
    8.36 +		clean_loopback(i);
    8.37 +}
    8.38 +
    8.39 +module_exit(loopback_exit);
    8.40 +
    8.41 +MODULE_LICENSE("Dual BSD/GPL");
    8.42 +
    8.43  /*
    8.44   * Local variables:
    8.45   *  c-file-style: "linux"
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Feb 28 18:56:00 2006 +0100
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Feb 28 18:59:24 2006 +0100
     9.3 @@ -809,6 +809,8 @@ static int __init netback_init(void)
     9.4  		&netif_be_dbg);
     9.5  #endif
     9.6  
     9.7 +	__unsafe(THIS_MODULE);
     9.8 +
     9.9  	return 0;
    9.10  }
    9.11  
    9.12 @@ -820,6 +822,8 @@ static void netback_cleanup(void)
    9.13  module_init(netback_init);
    9.14  module_exit(netback_cleanup);
    9.15  
    9.16 +MODULE_LICENSE("Dual BSD/GPL");
    9.17 +
    9.18  /*
    9.19   * Local variables:
    9.20   *  c-file-style: "linux"