Adding hping TCP and UDP tests. They hping a number of packets to

local interface, dom0, and from domU to domU. HVM support included.

Signed-off-by: Jim Dykman <dykman@us.ibm.com>
Signed-off-by: Daniel Stekloff <dsteklof@us.ibm.com>
This commit is contained in:
stekloff@localhost.localdomain committed 2006-03-10 00:49:54 +01:00
1 parent 872f58b6fd
commit 0552b3845c
7 files changed
+524 -2

No files matched your search

@@ -0,0 +1,95 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
# Author: <dykman@us.ibm.com>
# TCP tests on local interfaces.
# - creates a single guest domain
# - sets up a single NIC
# - conducts hping tcp tests to the local loopback and IP address
# hping2 127.0.0.1 -c 1 -d $size
# hping2 $local_IP -c 1 -d $size
# where $size = 1, 48, 64, 512, 1440, 1448, 1500, 1505,
# 4096, 4192, 32767, 65507, 65508
trysizes = [ 1, 48, 64, 512, 1440, 1448, 1500, 1505, 4096, 4192,
32767, 65495 ]
from XmTestLib import *
rc = 0
Net = XmNetwork()
try:
# read an IP address from the config
ip = Net.ip("dom1", "eth0")
mask = Net.mask("dom1", "eth0")
except NetworkError, e:
FAIL(str(e))
# Fire up a guest domain w/1 nic
if ENABLE_HVM_SUPPORT:
brg = "xenbr0"
config = {"vif" : ['type=ioemu, bridge=%s' % brg]}
else:
brg = None
config = {"vif" : ['ip=%s' % ip]}
domain = XmTestDomain(extraConfig=config)
try:
domain.start()
except DomainError, e:
if verbose:
print "Failed to create test domain because:"
print e.extra
FAIL(str(e))
# Attach a console
try:
console = XmConsole(domain.getName(), historySaveCmds=True)
except ConsoleError, e:
FAIL(str(e))
try:
# Activate the console
console.sendInput("bhs")
# Bring up the "lo" interface.
console.runCmd("ifconfig lo 127.0.0.1")
console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up")
# First do loopback
lofails=""
for size in trysizes:
out = console.runCmd("hping2 127.0.0.1 -E /dev/urandom -q -c 20 "
+ "--fast -d " + str(size))
if out["return"]:
lofails += " " + str(size)
# Next comes eth0
eth0fails=""
for size in trysizes:
out = console.runCmd("hping2 " + ip + " -E /dev/urandom -q -c 20 "
+ "--fast -d "+ str(size))
if out["return"]:
eth0fails += " " + str(size)
except ConsoleError, e:
FAIL(str(e))
except NetworkError, e:
FAIL(str(e))
# Tally up failures
failures=""
if len(lofails):
failures += "TCP hping2 over loopback failed for size" + lofails + ". "
if len(eth0fails):
failures += "TCP hping2 over eth0 failed for size" + eth0fails + "."
if len(failures):
FAIL(failures)
@@ -0,0 +1,96 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
# Author: <dykman@us.ibm.com>
# UDP tests on local interfaces.
# - creates a single guest domain
# - sets up a single NIC
# - conducts hping udp tests to the local loopback and IP address
# hping2 127.0.0.1 -2 -c 1 -d $size
# hping2 $local_IP -2 -c 1 -d $size
# where $size = 1, 48, 64, 512, 1440, 1448, 1500, 1505,
# 4096, 4192, 32767, 65507, 65508
trysizes = [ 1, 48, 64, 512, 1440, 1448, 1500, 1505, 4096, 4192,
32767, 65495 ]
from XmTestLib import *
rc = 0
Net = XmNetwork()
try:
# read an IP address from the config
ip = Net.ip("dom1", "eth0")
mask = Net.mask("dom1", "eth0")
except NetworkError, e:
FAIL(str(e))
# Fire up a guest domain w/1 nic
if ENABLE_HVM_SUPPORT:
brg = "xenbr0"
config = {"vif" : ['type=ioemu, bridge=%s' % brg]}
else:
brg = None
config = {"vif" : ['ip=%s' % ip]}
domain = XmTestDomain(extraConfig=config)
try:
domain.start()
except DomainError, e:
if verbose:
print "Failed to create test domain because:"
print e.extra
FAIL(str(e))
# Attach a console
try:
console = XmConsole(domain.getName(), historySaveCmds=True)
except ConsoleError, e:
FAIL(str(e))
try:
# Activate the console
console.sendInput("bhs")
# Bring up the "lo" interface.
console.runCmd("ifconfig lo 127.0.0.1")
console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up")
# First do loopback
lofails=""
for size in trysizes:
out = console.runCmd("hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 "
+ "--fast -d " + str(size))
if out["return"]:
lofails += " " + str(size)
print out["output"]
# Next comes eth0
eth0fails=""
for size in trysizes:
out = console.runCmd("hping2 " + ip + " -E /dev/urandom -2 -q -c 20 "
+ "--fast -d " + str(size))
if out["return"]:
eth0fails += " " + str(size)
print out["output"]
except ConsoleError, e:
FAIL(str(e))
except NetworkError, e:
FAIL(str(e))
# Tally up failures
failures=""
if len(lofails):
failures += "UDP hping2 over loopback failed for size" + lofails + ". "
if len(eth0fails):
failures += "UDP hping2 over eth0 failed for size" + eth0fails + "."
if len(failures):
FAIL(failures)
@@ -0,0 +1,81 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
# Author: <dykman@us.ibm.com>
# TCP tests to dom0.
# - determines dom0 network
# - creates a single guest domain
# - sets up a single NIC on same subnet as dom0
# - conducts hping2 tcp tests to the dom0 IP address
# hping2 $dom0_IP -c 1 -d $size
# where $size = 1, 48, 64, 512, 1440, 1448, 1500, 1505,
# 4096, 4192, 32767, 65507, 65508
trysizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192,
32767, 65495 ]
from XmTestLib import *
rc = 0
Net = XmNetwork()
try:
# read an IP address from the config
ip = Net.ip("dom1", "eth0")
mask = Net.mask("dom1", "eth0")
except NetworkError, e:
FAIL(str(e))
# Fire up a guest domain w/1 nic
if ENABLE_HVM_SUPPORT:
brg = "xenbr0"
config = {"vif" : ['type=ioemu, bridge=%s' % brg]}
else:
brg = None
config = {"vif" : ["ip=%s" % ip]}
domain = XmTestDomain(extraConfig=config)
try:
domain.start()
except DomainError, e:
if verbose:
print "Failed to create test domain because:"
print e.extra
FAIL(str(e))
# Attach a console
try:
console = XmConsole(domain.getName(), historySaveCmds=True)
# Activate the console
console.sendInput("bhs")
except ConsoleError, e:
FAIL(str(e))
try:
# Add a suitable dom0 IP address
dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0", bridge=brg)
except NetworkError, e:
FAIL(str(e))
try:
console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up")
# Ping dom0
fails=""
for size in trysizes:
out = console.runCmd("hping2 " + dom0ip + " -E /dev/urandom -q -c 20 "
+ "--fast -d " + str(size))
if out["return"]:
fails += " " + str(size)
print out["output"]
except ConsoleError, e:
FAIL(str(e))
if len(fails):
FAIL("TCP hping2 to dom0 failed for size" + fails + ".")
@@ -0,0 +1,81 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
# Author: <dykman@us.ibm.com>
# UDP tests to dom0.
# - determines dom0 network
# - creates a single guest domain
# - sets up a single NIC on same subnet as dom0
# - conducts hping2 udp tests to the dom0 IP address
# hping2 $dom0_IP -2 -c 1 -d $size
# where $size = 1, 48, 64, 512, 1440, 1448, 1500, 1505,
# 4096, 4192, 32767, 65507, 65508
trysizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192,
32767, 65495 ]
from XmTestLib import *
rc = 0
Net = XmNetwork()
try:
# read an IP address from the config
ip = Net.ip("dom1", "eth0")
mask = Net.mask("dom1", "eth0")
except NetworkError, e:
FAIL(str(e))
# Fire up a guest domain w/1 nic
if ENABLE_HVM_SUPPORT:
brg = "xenbr0"
config = {"vif" : ['type=ioemu, bridge=%s' % brg]}
else:
brg = None
config = {"vif" : ["ip=%s" % ip]}
domain = XmTestDomain(extraConfig=config)
try:
domain.start()
except DomainError, e:
if verbose:
print "Failed to create test domain because:"
print e.extra
FAIL(str(e))
# Attach a console
try:
console = XmConsole(domain.getName(), historySaveCmds=True)
# Activate the console
console.sendInput("bhs")
except ConsoleError, e:
FAIL(str(e))
try:
# Add a suitable dom0 IP address
dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0", bridge=brg)
except NetworkError, e:
FAIL(str(e))
try:
console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up")
# Ping dom0
fails=""
for size in trysizes:
out = console.runCmd("hping2 " + dom0ip + " -E /dev/urandom -2 -q -c 20"
+ " --fast -d " + str(size))
if out["return"]:
fails += " " + str(size)
print out["output"]
except ConsoleError, e:
FAIL(str(e))
if len(fails):
FAIL("UDP hping2 to dom0 failed for size" + fails + ".")
@@ -0,0 +1,82 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
# Author: <dykman@us.ibm.com>
# TCP tests to domU interface
# - creates two guest domains
# - sets up a single NIC on each on same subnet
# - conducts tcp tests to the domU IP address.
# hping2 $domU_IP -c 1 -d $size
# where $size = 1, 48, 64, 512, 1440, 1500, 1505,
# 4096, 4192, 32767, 65507, 65508
pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 16384, 24567,
32767, 65495 ]
from XmTestLib import *
def netDomain(ip):
if ENABLE_HVM_SUPPORT:
config = {"vif" : ['type=ioemu']}
else:
config = {"vif" : ["ip=%s" % ip]}
dom = XmTestDomain(extraConfig=config)
try:
dom.start()
except DomainError, e:
if verbose:
print "Failed to create test domain because:"
print e.extra
FAIL(str(e))
try:
# Attach a console
console = XmConsole(dom.getName(), historySaveCmds=True)
# Activate the console
console.sendInput("bhs")
except ConsoleError, e:
FAIL(str(e))
return console
rc = 0
Net = XmNetwork()
try:
# pick an IP address
ip1 = Net.ip("dom1", "eth2")
mask1 = Net.mask("dom1", "eth2")
except NetworkError, e:
FAIL(str(e))
try:
# pick another IP address
ip2 = Net.ip("dom2", "eth2")
mask2 = Net.mask("dom2", "eth2")
except NetworkError, e:
FAIL(str(e))
# Fire up a pair of guest domains w/1 nic each
src_console = netDomain(ip1)
dst_console = netDomain(ip2)
try:
src_console.runCmd("ifconfig eth0 inet "+ip1+" netmask "+mask1+" up")
dst_console.runCmd("ifconfig eth0 inet "+ip2+" netmask "+mask2+" up")
# Ping the victim over eth0
fails=""
for size in pingsizes:
out = src_console.runCmd("hping2 " + ip2 + " -E /dev/urandom -q -c 20 "
+ "--fast -d " + str(size))
if out["return"]:
fails += " " + str(size)
print out["output"]
except ConsoleError, e:
FAIL(str(e))
if len(fails):
FAIL("TCP hping2 failed for size" + fails + ".")
@@ -0,0 +1,82 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
# Author: <dykman@us.ibm.com>
# UDP tests to domU interface
# - creates two guest domains
# - sets up a single NIC on each on same subnet
# - conducts udp tests to the domU IP address.
# hping2 $domU_IP -2 -c 1 -d $size
# where $size = 1, 48, 64, 512, 1440, 1500, 1505,
# 4096, 4192, 32767, 65507, 65508
pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192,
32767, 65495 ]
from XmTestLib import *
def netDomain(ip):
if ENABLE_HVM_SUPPORT:
config = {"vif" : ['type=ioemu']}
else:
config = {"vif" : ["ip=%s" % ip]}
dom = XmTestDomain(extraConfig=config)
try:
dom.start()
except DomainError, e:
if verbose:
print "Failed to create test domain because:"
print e.extra
FAIL(str(e))
try:
# Attach a console
console = XmConsole(dom.getName(), historySaveCmds=True)
# Activate the console
console.sendInput("bhs")
except ConsoleError, e:
FAIL(str(e))
return console
rc = 0
Net = XmNetwork()
try:
# pick an IP address
ip1 = Net.ip("dom1", "eth2")
mask1 = Net.mask("dom1", "eth2")
except NetworkError, e:
FAIL(str(e))
try:
# pick another IP address
ip2 = Net.ip("dom2", "eth2")
mask2 = Net.mask("dom2", "eth2")
except NetworkError, e:
FAIL(str(e))
# Fire up a pair of guest domains w/1 nic each
src_console = netDomain(ip1)
dst_console = netDomain(ip2)
try:
src_console.runCmd("ifconfig eth0 inet "+ip1+" netmask "+mask1+" up")
dst_console.runCmd("ifconfig eth0 inet "+ip2+" netmask "+mask2+" up")
# Ping the victim over eth0
fails=""
for size in pingsizes:
out = src_console.runCmd("hping2 " + ip2 + " -E /dev/urandom -2 -q "
+ "-c 20 --fast -d " + str(size))
if out["return"]:
fails += " " + str(size)
print out["output"]
except ConsoleError, e:
FAIL(str(e))
if len(fails):
FAIL("UDP hping2 failed for size" + fails + ".")
+7 -2
View File
@@ -1,10 +1,15 @@
SUBDIRS =
TESTS = \
02_network_local_ping_pos.test \
03_network_local_tcp_pos.test \
04_network_local_udp_pos.test \
05_network_dom0_ping_pos.test \
11_network_domU_ping_pos.test
06_network_dom0_tcp_pos.test \
07_network_dom0_udp_pos.test \
11_network_domU_ping_pos.test \
12_network_domU_tcp_pos.test \
13_network_domU_udp_pos.test
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.