Skip to contentSkip to conversation

Vnet update

PATCH In review Mike Wray 2 participants 2 messages Aug 26, 2005

lore
Share & tools
lore

Mike Wray

author
#0 lore raw

PATCH 1/1 Vnet update

This patch fixes the tools/vnet makefiles so that vnets will compile and includes updates to the vnet implementation. Vnet ids are increased to 128 bits. The vnet module will insmod whether xen-br0 exists or not.

tools/vnet/00INSTALL +25 -9
diff -r 9fb0bad776dd tools/vnet/00INSTALL
@@ -1,14 +1,34 @@
 
-To compile and install run "make install"; if it fails or you need to reinstall 
-run "make clean" first or the build will fail, at least that is what I have 
-found under 2.6.10.
+make
+        - compile in local dirs. The module is in vnet-module/vnet_module.ko.
 
-Other important items:
+make dist
+        - compile and install into $(XEN_ROOT)/dist/install,
+        - where XEN_ROOT is the root of the xen tree.
+
+make install
+        - compile and install into system.
+
+The xen0 kernel must have been compiled before building the vnet module.
+The vnet module installs to
+ /lib/modules/<kernel version>-xen0/kernel/xen/vnet_module.ko
+
+The vnet module should be loaded before starting xend, or
+xend will fail to create any persistent vnets it has in its configuration.
+The script network-vnet is a modified version of the xen network script
+that loads the module if it's not already loaded.
+
+The module uses kernel crypto functions, and these need to be
+enabled in the xen0 kernel config. They should be on by default -
+if they're not you will get compile or insmod errors (see below).
+
+Kernel config options:
+
 1)	You will need to have your xen0 kernel compiled with HMAC_SUPPORT 
 	2.6.x = (MAIN MENU: Cryptographic Options -> HMAC Support)
 	BEFORE running "make install".
 
-2)	You will want at least some of the other alogorithms listed under
+2)	You will want at least some of the other algorithms listed under
 	"Cryptographic Options" for the kernel compiled as modules.
 
 3)	You will want the networking IPsec/VLAN options compiled in as modules
@@ -23,9 +43,5 @@
 	
 					802.1Q VLAN Support
 
-4)	The module (vnet_module) will not properly load from the command line
-	with a "modprobe vnet_module".  Use network-vnet to properly configure
-	your system and load the module for you.
-
 Please refer to the additional documentation found in tools/vnet/doc for
 proper syntax and config file parameters.
tools/vnet/Makefile +39 -33

93 lines not on this page · raw message

tools/vnet/doc/vnet-module.txt +21 -2
diff -r 9fb0bad776dd tools/vnet/doc/vnet-module.txt
@@ -1,20 +1,33 @@
 Vnet Module Command Interface
 Mike Wray <[email protected]>
-2004/09/17
+2005/08/25
 
 When insmod the vnet-module creates /proc/vnet/policy which
 can be used to control the module by writing commands into it.
 The return code from the command should be returned by close.
+Xend uses these commands to implement its vnet interface.
 
 The commands are:
 
-(vnet.add (id <id>) [(security { none | auth | conf } )] )
+(vnet.add (id <id>) [(vnetif <ifname>)] [(security { none | auth | conf } )] )
 
 Create the vnet with id <id> and the given security level (default none).
+Vnet ids are 128-bit and can be specified as 8 fields of 1 to 4 hex digits
+separated by colons. A vnet id with no colons is treated as one with the first
+7 fields zero. Examples:
+
+1500 - equivalent to 0:0:0:0:0:0:0:1500
+aaff:0:0:0:0:0:77:88
+
 Security levels:
 - none: no security
 - auth: message authentication (IPSEC hmac)
 - conf: message confidentiality (IPSEC hmac and encryption)
+
+The <ifname> is the name of the network device created for the vnet.
+If not given it defaults to vnif<N>, where <N> is the hex for the
+8-th field in the id. Note that network device names can have a
+maximum of 14 characters.
 
 (vnet.del (id <id>))
 
@@ -31,11 +44,17 @@
 Remove the vif with MAC address <macaddr> from the vnet with id <vnetid>.
 The vnet module will stop responding to VARP for the vif.
 
+(vif.print)
+
+Print the known vnets, vifs and varp cache on the console.
+
 Examples:
 
 To create vnet 10 with no security:
 
 echo '(vnet.add (id 10))' > /proc/vnet/policy
+
+This creates a device vnif0010.
 
 To create vnet 11 with message authentication:
 
tools/vnet/doc/vnet-xend.txt +22 -13
diff -r 9fb0bad776dd tools/vnet/doc/vnet-xend.txt
@@ -3,11 +3,13 @@
 
 Mike Wray <[email protected]>
 
+2005/08/25
+
 0) Introduction
 ---------------
 
 Vnets provide virtual private LANs for virtual machines.
-This is done using bridging and tunneling. A virtual interface
+This is done using bridging and multipoint tunneling. A virtual interface
 on a vnet can only see other interfaces on the same vnet - it cannot
 see the real network, and the real network cannot see it either.
 
@@ -32,13 +34,16 @@
 
 Restart xend.
 
+Alternatively insert the vnet module using vnet-insert,
+preferably before xend starts.
+
 2) Creating vnets
 -----------------
 
 Xend already implements commands to add/remove vnets and
 bridge to them. To add a vnet use
 
-xm call vnet_add <vnet config file>
+xm vnet-create <vnet config file>
 
 For example, if vnet97.sxp contains:
 
@@ -46,7 +51,7 @@
 
 do
 
-xm call vnet_add vnet97.sxp
+xm vnet-create vnet97.sxp
 
 This will define a vnet with id 97 and no security. The bridge for the
 vnet is called vnet97 and the virtual interface for it is vnetif97.
@@ -64,31 +69,35 @@
 Once configured, vnets are persistent in the xend database.
 To remove a vnet use
 
-xm call vnet_delete <vnet id>
+xm vnet-delete <vnet id>
 
 To list vnets use
 
-xm call vnets
+xm vnet-list
 
 To get information on a vnet id use
 
-xm call vnet <vnet id>
+xm vnet-list <vnet id>
 
 3) Troubleshooting
 ------------------
 
 The vnet module should appear in 'lsmod'.
-If a vnet has been configured it should appear in the output of 'xm call vnets'.
+If a vnet has been configured it should appear in the output of 'xm vnet-list'.
 Its bridge and interface should appear in 'ifconfig'.
 It should also show in 'brctl show', with its attached interfaces.
 
-You can 'see into' a vnet from dom0 if you put an IP address on the bridge.
+You can 'see into' a vnet from dom0 if you put an IP address on the bridge
+and configure its MAC address as a vif.
 For example, if you have vnet97 with a vm with ip addr 10.0.0.12 on it,
-then
+and <mac> is the MAC address of vnet97 (use ifconfig), then
 
+echo '(vif.add (vnet 97) (vmac <mac>))' >/proc/vnet/policy
 ifconfig vnet97 10.0.0.20 up
 
 should let you ping 10.0.0.12 via the vnet97 bridge.
+This works even if the vm with vif 10.0.0.12 is on another
+machine (it only works locally if you don't use vif.add).
 
 4) Examples
 -----------
@@ -104,11 +113,11 @@
   (linux
    (kernel /boot/vmlinuz-2.6-xenU)
    (ip 10.0.0.12:1.2.3.4::::eth0:off)
-   (root /dev/hda1)
+   (root /dev/sda1)
    (args 'rw fastboot 4')
   )
  )
- (device (vbd (uname phy:hda2) (dev hda1) (mode w)))
+ (device (vbd (uname phy:hda2) (dev sda1) (mode w)))
  (device (vif (mac aa:00:00:11:00:12) (bridge vnet97)))
 )
 
@@ -123,11 +132,11 @@
   (linux
    (kernel /boot/vmlinuz-2.6-xenU)
    (ip 10.0.0.11:1.2.3.4::::eth0:off)
-   (root /dev/hda1)
+   (root /dev/sda1)
    (args 'rw fastboot 4')
   )
  )
- (device (vbd (uname phy:hda3) (dev hda1) (mode w)))
+ (device (vbd (uname phy:hda3) (dev sda1) (mode w)))
  (device (vif (mac aa:00:00:11:00:11) (bridge vnet97)))
 )
 
tools/vnet/examples/Makefile +3 -0
diff -r 9fb0bad776dd tools/vnet/examples/Makefile
@@ -2,11 +2,14 @@
 #============================================================================
 
 XEN_SCRIPT_DIR:=/etc/xen/scripts
+
+.PHONY: all install clean
 
 all:
 
 install:
 	install -m 0755 -d $(DESTDIR)$(XEN_SCRIPT_DIR)
 	install -m 0554 network-vnet $(DESTDIR)$(XEN_SCRIPT_DIR)
+	install -m 0554 vnet-insert $(DESTDIR)$(XEN_SCRIPT_DIR)
 
 clean:
\ No newline at end of file
tools/vnet/examples/network-vnet +7 -215

225 lines not on this page · raw message

tools/vnet/examples/vnet97.sxp +0 -1
diff -r 9fb0bad776dd tools/vnet/examples/vnet97.sxp
@@ -1,3 +1,2 @@
 # Vnet configuration for a vnet with id 97 and no security.
-# Configure using 'xm call vnet_add vnet97.sxp'.
 (vnet (id 97) (bridge vnet97) (vnetif vnetif97) (security none))
tools/vnet/examples/vnet98.sxp +0 -1
diff -r 9fb0bad776dd tools/vnet/examples/vnet98.sxp
@@ -1,3 +1,2 @@
 # Vnet configuration for a vnet with id 98 and message authentication.
-# Configure using 'xm call vnet_add vnet98.sxp'.
 (vnet (id 98) (bridge vnet98) (vnetif vnetif98) (security auth))
tools/vnet/examples/vnet99.sxp +0 -1
diff -r 9fb0bad776dd tools/vnet/examples/vnet99.sxp
@@ -1,3 +1,2 @@
 # Vnet configuration for a vnet with id 99 and message confidentiality.
-# Configure using 'xm call vnet_add vnet99.sxp'.
 (vnet (id 99) (bridge vnet99) (vnetif vnetif99) (security conf))
tools/vnet/libxutil/Makefile +10 -4
diff -r 9fb0bad776dd tools/vnet/libxutil/Makefile
@@ -1,5 +1,8 @@
+ifndef VNET_ROOT
+export VNET_ROOT = $(shell cd .. && pwd)
+include $(VNET_ROOT)/Make.env
+endif
 
-XEN_ROOT = ../../..
 INSTALL		= install
 INSTALL_DATA	= $(INSTALL) -m0644
 INSTALL_PROG	= $(INSTALL) -m0755
@@ -15,6 +18,7 @@
 LIB_SRCS += hash_table.c
 LIB_SRCS += iostream.c
 LIB_SRCS += lexis.c
+LIB_SRCS += mem_stream.c
 LIB_SRCS += string_stream.c
 LIB_SRCS += sxpr.c
 LIB_SRCS += sxpr_parser.c
@@ -26,6 +30,7 @@
 PIC_OBJS := $(LIB_SRCS:.c=.opic)
 
 CFLAGS   += -Wall -Werror -O3 -fno-strict-aliasing
+CFLAGS   += -g
 
 # Get gcc to generate the dependencies for us.
 CFLAGS   += -Wp,-MD,.$(@F).d
@@ -39,6 +44,7 @@
 LIB      += libxutil.a
 
 all: build
+
 build: check-for-zlib
 	$(MAKE) $(LIB)
 
@@ -70,8 +76,8 @@
 	ln -sf libxutil.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxutil.so
 
 clean:
-	$(RM) *.a *.so* *.o *.opic *.rpm 
-	$(RM) *~
-	$(RM) $(DEPS)
+	-@$(RM) *.a *.so* *.o *.opic *.rpm 
+	-@$(RM) *~
+	-@$(RM) $(DEPS)
 
 -include $(DEPS)
tools/vnet/libxutil/debug.h +3 -3
diff -r 9fb0bad776dd tools/vnet/libxutil/debug.h
@@ -49,9 +49,9 @@
 #ifdef DEBUG
 
 #define dprintf(fmt, args...) fprintf(stdout, "%d [DBG] " MODULE_NAME ">%s" fmt, getpid(), __FUNCTION__, ##args)
-#define wprintf(fmt, args...) fprintf(stderr, "%d [WRN] " MODULE_NAME ">%s" fmt, getpid(),__FUNCTION__, ##args)
-#define iprintf(fmt, args...) fprintf(stderr, "%d [INF] " MODULE_NAME ">%s" fmt, getpid(),__FUNCTION__, ##args)
-#define eprintf(fmt, args...) fprintf(stderr, "%d [ERR] " MODULE_NAME ">%s" fmt, getpid(),__FUNCTION__, ##args)
+#define wprintf(fmt, args...) fprintf(stderr, "%d [WRN] " MODULE_NAME ">%s" fmt, getpid(), __FUNCTION__, ##args)
+#define iprintf(fmt, args...) fprintf(stderr, "%d [INF] " MODULE_NAME ">%s" fmt, getpid(), __FUNCTION__, ##args)
+#define eprintf(fmt, args...) fprintf(stderr, "%d [ERR] " MODULE_NAME ">%s" fmt, getpid(), __FUNCTION__, ##args)
 
 #else
 
tools/vnet/libxutil/sxpr.c +2 -2
diff -r 9fb0bad776dd tools/vnet/libxutil/sxpr.c
@@ -405,7 +405,6 @@
 #endif /* USE_GC */
 
 /** Create a new atom with the given name.
- * Makes an integer sxpr if the name can be parsed as an int.
  *
  * @param name the name
  * @return new atom
@@ -414,7 +413,8 @@
     Sxpr n, obj = ONOMEM;
     long v;
 
-    if(convert_atol(name, &v) == 0){
+    // Don't always want to do this.
+    if(0 && convert_atol(name, &v) == 0){
         obj = OINT(v);
     } else {
         n = string_new(name);
tools/vnet/libxutil/sxpr.h +6 -2
diff -r 9fb0bad776dd tools/vnet/libxutil/sxpr.h
@@ -228,7 +228,9 @@
  *
  * @param val pointer
  */
-#define PTR(val) OBJP(T_UINT, (void*)(val))
+static inline Sxpr PTR(void *val){
+    return OBJP(T_UINT, (void*)(val));
+}
 
 /** Allocate some memory and return an sxpr containing it.
  * Returns ONOMEM if allocation failed.
@@ -237,7 +239,9 @@
  * @param ty typecode
  * @return sxpr
  */
-#define halloc(_n, _ty) OBJP(_ty, allocate(_n))
+static inline Sxpr halloc(int n, int ty){
+    return OBJP(ty, allocate(n));
+}
 
 /** Allocate an sxpr containing a pointer to the given type.
  *
tools/vnet/libxutil/sxpr_parser.c +8 -1
diff -r 9fb0bad776dd tools/vnet/libxutil/sxpr_parser.c
@@ -472,7 +472,14 @@
 }
 
 int Parser_atom(Parser *p){
-    Sxpr obj = atom_new(peek_token(p));
+    Sxpr obj;
+    long v;
+    if(Parser_flags(p, PARSE_INT) &&
+       convert_atol(peek_token(p), &v) == 0){
+        obj = OINT(v);
+    } else {
+        obj = atom_new(peek_token(p));
+    }
     return Parser_set_value(p, obj);
 }
 
tools/vnet/libxutil/sxpr_parser.h +11 -5
diff -r 9fb0bad776dd tools/vnet/libxutil/sxpr_parser.h
@@ -89,15 +89,17 @@
 
 
 /** Parser flags. */
-//enum {
-//};
+enum {
+    /** Convert integer atoms to ints. */
+    PARSE_INT=1,
+};
 
 /** Raise some parser flags.
  *
  * @param in parser
  * @param flags flags mask
  */
-inline static void Parser_flags_raise(Parser *in, int flags){
+static inline void Parser_flags_raise(Parser *in, int flags){
     in->flags |= flags;
 }
 
@@ -106,7 +108,7 @@
  * @param in parser
  * @param flags flags mask
  */
-inline static void Parser_flags_lower(Parser *in, int flags){
+static inline void Parser_flags_lower(Parser *in, int flags){
     in->flags &= ~flags;
 }
 
@@ -114,8 +116,12 @@
  *
  * @param in parser
  */
-inline static void Parser_flags_clear(Parser *in){
+static inline void Parser_flags_clear(Parser *in){
     in->flags = 0;
+}
+
+static inline int Parser_flags(Parser *in, int flags){
+    return in->flags & flags;
 }
 
 extern void Parser_free(Parser *z);
tools/vnet/libxutil/sys_string.c +25 -0
diff -r 9fb0bad776dd tools/vnet/libxutil/sys_string.c
@@ -27,6 +27,31 @@
 
 #include "allocate.h"
 #include "sys_string.h"
+
+#ifdef __KERNEL__
+
+#define deferr(_err) case _err: return #_err
+
+extern char *strerror(int err)
+{
+    switch(err){
+        deferr(EPERM);
+        deferr(ENOENT);
+        deferr(ESRCH);
+        deferr(EINTR);
+        deferr(EIO);
+        deferr(EINVAL);
+        deferr(ENOMEM);
+        deferr(EACCES);
+        deferr(EFAULT);
+        deferr(EBUSY);
+        
+    default:
+        return "ERROR";
+    }
+}
+
+#endif
 
 /** Set the base to use for converting a string to a number.  Base is
  * hex if starts with 0x, otherwise decimal.
tools/vnet/libxutil/sys_string.h +2 -0
diff -r 9fb0bad776dd tools/vnet/libxutil/sys_string.h
@@ -31,6 +31,8 @@
 #include <linux/types.h>
 #include <stdarg.h>
 #include "allocate.h"
+
+extern char *strerror(int err);
 
 #if 0
 static inline int tolower(int c){
tools/vnet/vnet-module/00README +4 -4
diff -r 9fb0bad776dd tools/vnet/vnet-module/00README
@@ -6,11 +6,11 @@
 The makefiles  use the following variables, which
 can be set in your env or on the make command line:
 
-LINUX_SERIES: linux release to compile for, 2.4 (default), or 2.6.
-XEN_ROOT: root of the xen tree containing kernel source.
+LINUX_SERIES:   linux release to compile for: 2.4, or 2.6 (default).
+XEN_ROOT:       root of the xen tree containing kernel source.
 KERNEL_VERSION: kernel version, default got from XEN_ROOT.
-KERNEL_MINOR: kernel minor version, default -xen0.
-KERNEL_SRC: path to kernel source, default linux-<VERSION> under XEN_ROOT.
+KERNEL_MINOR:   kernel minor version, default -xen0.
+KERNEL_SRC:     path to kernel source, default linux-<VERSION> under XEN_ROOT.
 
 *) For 2.4 kernel
 
tools/vnet/vnet-module/Makefile +9 -5
diff -r 9fb0bad776dd tools/vnet/vnet-module/Makefile
@@ -18,9 +18,13 @@
 # 59 Temple Place, suite 330, Boston, MA 02111-1307 USA
 #============================================================================
 
+ifndef VNET_ROOT
+export VNET_ROOT = $(shell cd .. && pwd)
+include $(VNET_ROOT)/Make.env
+endif
+
 #============================================================================
 ifeq ($(src),)
-LINUX_SERIES ?=2.6
 
 include Makefile-$(LINUX_SERIES)
 
@@ -45,7 +49,7 @@
 # Setup explicit rules for them using the kbuild C compile rule.
 
 # File names in the lib dir.
-remote_srcs = $(foreach file,$(VNET_LIB_SRC),$(LIB_DIR)/$(file))
+remote_srcs = $(foreach file,$(VNET_LIB_SRC),$(LIBXUTIL_DIR)/$(file))
 
 # Equivalent file names here.
 local_srcs = $(foreach file,$(VNET_LIB_SRC),$(src)/$(file))
@@ -54,12 +58,12 @@
 local_objs = $(local_srcs:.c=.o)
 
 # Make the local objects depend on compiling the remote sources.
-$(local_objs): $(src)/%.o: $(LIB_DIR)/%.c
+$(local_objs): $(src)/%.o: $(LIBXUTIL_DIR)/%.c
 	$(call if_changed_rule,cc_o_c)
 #----------------------------------------------------------------------------
 
-vpath %.h $(LIB_DIR)
-EXTRA_CFLAGS += -I $(LIB_DIR)
+vpath %.h $(LIBXUTIL_DIR)
+EXTRA_CFLAGS += -I $(LIBXUTIL_DIR)
 EXTRA_CFLAGS += -I $(src)
 
 endif
tools/vnet/vnet-module/Makefile-2.4 +8 -7
diff -r 9fb0bad776dd tools/vnet/vnet-module/Makefile-2.4
@@ -21,7 +21,7 @@
 #============================================================================
 # Vnet module makefile for 2.4 series kernels.
 
-LINUX_SERIES ?=2.4
+LINUX_SERIES =2.4
 include Makefile.ver
 
 KERNEL_MODULE := vnet_module.o
@@ -37,9 +37,9 @@
 vpath %.h $(KERNEL_SRC)/include
 INCLUDES+= -I $(KERNEL_SRC)/include
 
-vpath %.h $(LIB_DIR)
-vpath %.c $(LIB_DIR)
-INCLUDES += -I $(LIB_DIR)
+vpath %.h $(LIBXUTIL_DIR)
+vpath %.c $(LIBXUTIL_DIR)
+INCLUDES += -I $(LIBXUTIL_DIR)
 
 INCLUDES+= -I .
 
@@ -61,6 +61,7 @@
 CFLAGS += -Wno-unused-function
 CFLAGS += -Wno-unused-parameter 
 
+CFLAGS += -g
 CFLAGS += -O2
 CFLAGS += -fno-strict-aliasing 
 CFLAGS += -fno-common 
@@ -90,8 +91,8 @@
 
 .PHONY: clean
 clean:
-	@rm -f *.a *.o *.ko *~
-	@rm -f $(VNET_DEP) .*.cmd *.mod.?
-	@rm -rf .tmp_versions
+	-@$(RM) *.a *.o *.ko *~
+	-@$(RM) $(VNET_DEP) .*.cmd *.mod.?
+	-@$(RM) -r .tmp_versions
 
 -include $(VNET_DEP)
tools/vnet/vnet-module/Makefile-2.6 +6 -5
diff -r 9fb0bad776dd tools/vnet/vnet-module/Makefile-2.6
@@ -21,7 +21,7 @@
 #============================================================================
 # Vnet module makefile for 2.6 series kernels.
 
-LINUX_SERIES ?=2.6
+LINUX_SERIES =2.6
 include Makefile.ver
 
 KERNEL_MODULE = vnet_module.ko
@@ -38,13 +38,14 @@
 
 .PHONY: install install-module modules_install
 install install-module modules_install: module
-	install -m 0755 -d $(DESTDIR)$(KERNEL_MODULE_DIR)/xen
-	install -m 0554 $(KERNEL_MODULE) $(DESTDIR)$(KERNEL_MODULE_DIR)/xen
+	install -m 0755 -d $(DESTDIR)$(KERNEL_MODULE_DIR)
+	install -m 0554 $(KERNEL_MODULE) $(DESTDIR)$(KERNEL_MODULE_DIR)
 
 .PHONY: clean
 clean:
-	@$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
-	@rm -f *.a *.o *.ko *~ .*.d .*.cmd *.mod.?
+	-@$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
+	-@$(RM) *.a *.o *.ko *~ .*.d .*.cmd *.mod.?
+	-@$(RM) -r .tmp_versions
 
 TAGS:
 	etags *.c *.h
tools/vnet/vnet-module/Makefile.ver +2 -13
diff -r 9fb0bad776dd tools/vnet/vnet-module/Makefile.ver
@@ -18,22 +18,11 @@
 # 59 Temple Place, suite 330, Boston, MA 02111-1307 USA
 #============================================================================
 
-#----------------------------------------------------------------------------
-# Xeno/xen.
-
-# Root of xen tree.
-XEN_ROOT ?=../../..
-
-# Path to relativize the install. Set to /
-# to install relative to filesystem root.
-prefix ?=$(XEN_ROOT)/install/
-#----------------------------------------------------------------------------
-
 LINUX_SERIES ?=2.6
 KERNEL_MINOR ?=-xen0
 
-LINUX_VERSION ?= $(shell ( /bin/ls -ld $(XEN_ROOT)/linux-$(LINUX_SERIES).*-xen-sparse ) 2>/dev/null | \
-                      sed -e 's!^.*linux-\(.\+\)-xen-sparse!\1!' )
+LINUX_VERSION ?= $(shell ( /bin/ls -ld $(XEN_ROOT)/linux-$(LINUX_SERIES).*-xen0 ) 2>/dev/null | \
+                      sed -e 's!^.*linux-\(.\+\)-xen0!\1!' )
 
 ifeq ($(LINUX_VERSION),)
 $(error Kernel source for linux $(LINUX_SERIES) not found)
tools/vnet/vnet-module/Makefile.vnet +0 -2
diff -r 9fb0bad776dd tools/vnet/vnet-module/Makefile.vnet
@@ -23,8 +23,6 @@
 else
 SRC_DIR=$(src)/
 endif
-
-LIB_DIR := $(SRC_DIR)../libxutil
 
 VNET_SRC :=
 VNET_SRC += esp.c
tools/vnet/vnet-module/etherip.c +71 -47

219 lines not on this page · raw message

tools/vnet/vnet-module/if_etherip.h +20 -6
diff -r 9fb0bad776dd tools/vnet/vnet-module/if_etherip.h
@@ -18,15 +18,30 @@
  */
 #ifndef _VNET_IF_ETHERIP_H_
 #define _VNET_IF_ETHERIP_H_
-/*----------------------------------------------------------------------------*/
+
+#define CONFIG_ETHERIP_EXT
+
 #ifdef CONFIG_ETHERIP_EXT
+
+#define ETHERIP_VERSION 4
+
 struct etheriphdr {
-    __u8 version;
-    __u32 vnet;
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+    __u16    reserved:12,
+             version:4;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+    __u16    version:4,
+            reserved:12;
+#else
+#error  "Please fix <asm/byteorder.h>"
+#endif
+    __u8 vnet[16];
 } __attribute__ ((packed));
 
-/*----------------------------------------------------------------------------*/
 #else
+
+#define ETHERIP_VERSION 3
+
 struct etheriphdr
 {
 #if defined(__LITTLE_ENDIAN_BITFIELD)
@@ -42,10 +57,9 @@
 };
 #endif
 
+
 #ifndef IPPROTO_ETHERIP
 #define IPPROTO_ETHERIP 97
 #endif
 
-/*----------------------------------------------------------------------------*/
-
 #endif /* ! _VNET_IF_ETHERIP_H_ */
tools/vnet/vnet-module/if_varp.h +31 -7
diff -r 9fb0bad776dd tools/vnet/vnet-module/if_varp.h
@@ -20,6 +20,14 @@
 #ifndef _VNET_IF_VARP_H
 #define _VNET_IF_VARP_H
 
+/* Need struct in_addr, struct in6_addr. */
+#ifdef __KERNEL__
+#include <linux/in.h>
+#include <linux/in6.h>
+#else
+#include <netinet/in.h>
+#endif
+
 typedef struct Vmac {
     unsigned char mac[ETH_ALEN];
 } Vmac;
@@ -30,17 +38,35 @@
     VARP_OP_ANNOUNCE = 2,
 };
 
+typedef struct VnetId {
+    union {
+        uint8_t vnet8[16];
+        uint16_t vnet16[8];
+        uint32_t vnet32[4];
+    } u;
+} __attribute__((packed)) VnetId;
+
+typedef struct VarpAddr {
+    uint8_t family; // AF_INET or AF_INET6.
+    union {
+        uint8_t raw[16];
+        struct in_addr ip4;
+        struct in6_addr ip6;
+    } u;
+} __attribute__((packed)) VarpAddr;
+
 typedef struct VnetMsgHdr {
     uint16_t id;
     uint16_t opcode;
 } __attribute__((packed)) VnetMsgHdr;
 
 typedef struct VarpHdr {
-    VnetMsgHdr vnetmsghdr;
-    uint32_t vnet;
-    Vmac vmac;
-    uint32_t addr;
+  VnetMsgHdr hdr;
+  VnetId vnet;
+  Vmac vmac;
+  VarpAddr addr;
 } __attribute__((packed)) VarpHdr;
+
 
 /** Default address for varp/vnet broadcasts: 224.10.0.1 */
 #define VARP_MCAST_ADDR     0xe00a0001
@@ -48,6 +74,4 @@
 /** UDP port to use for varp protocol. */
 #define VARP_PORT           1798
 
-
-
-#endif  /* ! _VNET_IF_VARP_H */
+#endif /* ! _VNET_IF_VARP_H */
tools/vnet/vnet-module/skb_util.h +52 -1

63 lines not on this page · raw message

tools/vnet/vnet-module/tunnel.c +19 -23

103 lines not on this page · raw message

tools/vnet/vnet-module/tunnel.h +8 -5
diff -r 9fb0bad776dd tools/vnet/vnet-module/tunnel.h
@@ -22,6 +22,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <asm/atomic.h>
+#include <if_varp.h>
 
 struct sk_buff;
 struct Tunnel;
@@ -41,8 +42,8 @@
 } TunnelStats;
 
 typedef struct TunnelKey {
-    u32 vnet;
-    u32 addr;
+    VnetId vnet;
+    VarpAddr addr;
 } TunnelKey;
 
 typedef struct Tunnel {
@@ -87,13 +88,15 @@
 }
 
 extern int Tunnel_init(void);
-extern Tunnel * Tunnel_lookup(u32 vnet, u32 addr);
+extern Tunnel * Tunnel_lookup(struct VnetId *vnet, struct VarpAddr *addr);
 extern int Tunnel_add(Tunnel *tunnel);
 extern int Tunnel_del(Tunnel *tunnel);
 extern int Tunnel_send(Tunnel *tunnel, struct sk_buff *skb);
 
-extern int Tunnel_create(TunnelType *type, u32 vnet, u32 addr, Tunnel *base, Tunnel **tunnelp);
-extern int Tunnel_open(TunnelType *type, u32 vnet, u32 addr, Tunnel *base, Tunnel **tunnelp);
+extern int Tunnel_create(TunnelType *type, struct VnetId *vnet, struct VarpAddr *addr,
+                         Tunnel *base, Tunnel **tunnelp);
+extern int Tunnel_open(TunnelType *type, struct VnetId *vnet, struct VarpAddr *addr,
+                       Tunnel *base, Tunnel **tunnelp);
 
 extern int tunnel_module_init(void);
 extern void tunnel_module_exit(void);
tools/vnet/vnet-module/varp.c +237 -152

788 lines not on this page · raw message

tools/vnet/vnet-module/varp.h +8 -7
diff -r 9fb0bad776dd tools/vnet/vnet-module/varp.h
@@ -19,6 +19,10 @@
 
 #ifndef _VNET_VARP_H
 #define _VNET_VARP_H
+#include "hash_table.h"
+#include "if_varp.h"
+#include "varp_util.h"
+
 
 #define CONFIG_VARP_GRATUITOUS 1
 
@@ -26,29 +30,26 @@
 struct sk_buff;
 struct Vif;
 
-#define DEVICE "xen-br0"
-
 extern int vnet_get_device(const char *name, struct net_device **dev);
 extern int vnet_get_device_address(struct net_device *dev, u32 *addr);
 
 extern int varp_handle_message(struct sk_buff *skb);
-extern int varp_output(struct sk_buff *skb, u32 vnet);
-extern int varp_update(int vnet, unsigned char *vmac, u32 addr);
+extern int varp_output(struct sk_buff *skb, struct VnetId *vnet);
+extern int varp_update(struct VnetId *vnet, unsigned char *vmac, struct VarpAddr *addr);
 
 extern int varp_init(void);
 extern void varp_exit(void);
 
-extern int varp_open(u32 mcaddr, u32 addr, u16 port);
+extern int varp_open(u32 mcaddr, u16 port);
 extern void varp_close(void);
 extern int varp_set_mcast_addr(u32 addr);
 
 extern void varp_print(void);
+extern void varp_flush(void);
 
 extern int varp_announce_vif(struct net_device *dev, struct Vif *vif);
-//extern int varp_announce_vifs(struct net_device *dev, struct task_struct *domain);
 
 extern u32 varp_mcast_addr;
-
 
 /* MAC broadcast addr is ff-ff-ff-ff-ff-ff (all 1's).
  * MAC multicast addr has low bit 1, i.e. 01-00-00-00-00-00.
tools/vnet/vnet-module/varp_socket.c +8 -47

126 lines not on this page · raw message

tools/vnet/vnet-module/vif.c +55 -62

216 lines not on this page · raw message

tools/vnet/vnet-module/vif.h +9 -7
diff -r 9fb0bad776dd tools/vnet/vnet-module/vif.h
@@ -24,12 +24,12 @@
 
 /** Key for entries in the vif table. */
 typedef struct VifKey {
-    int vnet;
+    VnetId vnet;
     Vmac vmac;
 } VifKey;
 
 typedef struct Vif {
-    int vnet;
+    VnetId vnet;
     Vmac vmac;
     struct net_device *dev;
     atomic_t refcount;
@@ -38,15 +38,17 @@
 struct HashTable;
 extern struct HashTable *vif_table;
 
+extern void vif_print(void);
+
 extern void vif_decref(Vif *vif);
 extern void vif_incref(Vif *vif);
 
-extern int vif_create(int vnet, Vmac *vmac, Vif **vif);
+extern int vif_create(struct VnetId *vnet, Vmac *vmac, Vif **vif);
 
-extern int vif_add(int vnet, Vmac *vmac, Vif **vif);
-extern int vif_lookup(int vnet, Vmac *vmac, Vif **vif);
-extern int vif_remove(int vnet, Vmac *vmac);
-extern int vif_find(int vnet, Vmac *vmac, int create, Vif **vif);
+extern int vif_create(VnetId *vnet, Vmac *vmac, Vif **vif);
+extern int vif_add(struct VnetId *vnet, Vmac *vmac, Vif **vif);
+extern int vif_lookup(struct VnetId *vnet, Vmac *vmac, Vif **vif);
+extern int vif_remove(struct VnetId *vnet, Vmac *vmac);
 extern void vif_purge(void);
 
 extern int vif_init(void);
tools/vnet/vnet-module/vnet.c +94 -230

386 lines not on this page · raw message

tools/vnet/vnet-module/vnet.h +17 -21
diff -r 9fb0bad776dd tools/vnet/vnet-module/vnet.h

Lines of this file are not shown. View the raw message.

tools/vnet/vnet-module/vnet_dev.c +57 -242

299 lines not on this page · raw message

tools/vnet/vnet-module/vnet_dev.h +0 -3
diff -r 9fb0bad776dd tools/vnet/vnet-module/vnet_dev.h

Lines of this file are not shown. View the raw message.

tools/vnet/vnet-module/vnet_ioctl.c +90 -104

194 lines not on this page · raw message

tools/vnet/vnetd/Makefile +12 -15
diff -r 9fb0bad776dd tools/vnet/vnetd/Makefile

Lines of this file are not shown. View the raw message.

tools/vnet/vnetd/vcache.c +64 -51

115 lines not on this page · raw message

tools/vnet/vnetd/vcache.h +3 -3
diff -r 9fb0bad776dd tools/vnet/vnetd/vcache.h

Lines of this file are not shown. View the raw message.

tools/vnet/vnetd/vnetd.c +2 -9
diff -r 9fb0bad776dd tools/vnet/vnetd/vnetd.c

Lines of this file are not shown. View the raw message.

tools/vnet/vnetd/vnetd.h +1 -0
diff -r 9fb0bad776dd tools/vnet/vnetd/vnetd.h

Lines of this file are not shown. View the raw message.

tools/vnet/INSTALL deleted +0 -31
diff -r 9fb0bad776dd tools/vnet/INSTALL

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Part of the diff is not shown here. View the raw message.

#1 lore raw

Thanks!

Quoted 6 lines · Mike Wray

This patch fixes the tools/vnet makefiles so that vnets will compile and includes updates to the vnet implementation. Vnet ids are increased to 128 bits. The vnet module will insmod whether xen-br0 exists or not.