ia64/xen-unstable

changeset 9046:d741fa272309

While testing TCP & UDP tests (coming soon), I tracked down a bug in the
IP addressing scheme
used by xm-test: each machine running network tests is using the same IP
addresses, so two machines
in the same network can cross-pollinate/interfere with each other's tests.

This patch changes the IP addressing scheme to add some randomness. It's
gone through a couple of dozen
passes of xm-test, some on -bridge and some on -route, while xm-test was
running on another box on the same network.

Signed-off-by: Jim Dykman <dykman@us.ibm.com>
author emellor@leeni.uk.xensource.com
date Mon Feb 27 16:14:11 2006 +0100 (2006-02-27)
parents 136aea67b369
children cc9ed0eea55a 8e3865296e31
files tools/xm-test/lib/XmTestLib/Network.py
line diff
     1.1 --- a/tools/xm-test/lib/XmTestLib/Network.py	Mon Feb 27 16:13:05 2006 +0100
     1.2 +++ b/tools/xm-test/lib/XmTestLib/Network.py	Mon Feb 27 16:14:11 2006 +0100
     1.3 @@ -22,6 +22,7 @@
     1.4  import sys;
     1.5  import os;
     1.6  import atexit;
     1.7 +import random;
     1.8  
     1.9  from Test import *
    1.10  from Xm import *
    1.11 @@ -53,12 +54,22 @@ class XmNetwork:
    1.12          if rc == 0:
    1.13              SKIP("Zeroconf address found: " + out)
    1.14  
    1.15 +        # Randomize one octet of the IP addresses we choose, so that
    1.16 +        # multiple machines running network tests don't interfere 
    1.17 +        # with each other. 
    1.18 +        self.subnet = random.randint(1,254)
    1.19 +
    1.20      def calc_ip_address(self, dom, interface):
    1.21          # Generate an IP address from the dom# and eth#:
    1.22 -        #      169.254.(eth#+153).(dom#+10)
    1.23 +        #      169.254.(self.subnet).(eth#)*16 + (dom# + 1)
    1.24          ethnum = int(interface[len("eth"):])
    1.25 +        if (ethnum > 15):
    1.26 +            raise NetworkError("ethnum > 15 : " + interface)
    1.27          domnum = int(dom[len("dom"):])
    1.28 -        return "169.254."+ str(ethnum+153) + "." + str(domnum+10)
    1.29 +        if (domnum > 14):
    1.30 +            raise NetworkError("domnum > 14 : " + dom)
    1.31 +
    1.32 +        return "169.254."+ str(self.subnet) + "." + str(ethnum*16+domnum+1)
    1.33  
    1.34      def ip(self, dom, interface, todomname=None, toeth=None, bridge=None):
    1.35          newip = self.calc_ip_address(dom, interface)
    1.36 @@ -96,4 +107,4 @@ class XmNetwork:
    1.37          return newip
    1.38  
    1.39      def mask(self, dom, interface):
    1.40 -        return "255.255.255.0"
    1.41 +        return "255.255.255.240"