summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-03-14 13:48:40 +0200
committerHanoh Haim <hhaim@cisco.com>2016-03-14 13:48:40 +0200
commit22f33006471cfed556e6987f88d3d9f7e532687a (patch)
treed82c114419afa32076cb2edb687a1137aa3967f7
parentd82201e2da3beb0e81e0c8ba30600d87f1b8276f (diff)
parent22e06f3c3532890ad336341c279012afc0710a9d (diff)
merge cleanup
-rwxr-xr-xscripts/automation/regression/hltapi_playground.py34
-rw-r--r--scripts/automation/regression/stateless_tests/stl_general_test.py56
-rwxr-xr-xscripts/automation/regression/trex_unit_test.py5
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py14
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py70
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py8
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py11
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py31
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py2
-rwxr-xr-xscripts/dpdk_nic_bind.py62
-rwxr-xr-xscripts/dpdk_setup_ports.py2
-rw-r--r--scripts/external_libs/prebuild/zmq/README.txt41
-rw-r--r--scripts/external_libs/prebuild/zmq/pyzmq-14.5.0.tar.gzbin0 -> 997150 bytes
-rw-r--r--scripts/external_libs/prebuild/zmq/zeromq-4.0.2.tar.gzbin0 -> 2168988 bytes
-rw-r--r--src/flow_stat.cpp14
-rw-r--r--src/rpc-server/trex_rpc_cmd.cpp2
16 files changed, 248 insertions, 104 deletions
diff --git a/scripts/automation/regression/hltapi_playground.py b/scripts/automation/regression/hltapi_playground.py
index 793b0282..b790fe25 100755
--- a/scripts/automation/regression/hltapi_playground.py
+++ b/scripts/automation/regression/hltapi_playground.py
@@ -55,12 +55,34 @@ if __name__ == "__main__":
port_handle = res['port_handle']
print('Connected, got port handles %s' % port_handle)
ports_streams_dict = CStreamsPerPort()
-
- res = check_res(hlt_client.traffic_config(mode = 'create', l2_encap = 'ethernet_ii_vlan', rate_pps = 1,
- l3_protocol = 'ipv4',
- length_mode = 'imix', l3_length = 200,
- ipv6_dst_mode = 'decrement', ipv6_dst_count = 300, ipv6_dst_addr = 'fe80:0:0:0:0:0:0:000f',
- port_handle = port_handle, port_handle2 = port_handle[1], save_to_yaml = '/tmp/d1.yaml'))
+ print hlt_client.traffic_control(action = 'poll')
+
+ print hlt_client.traffic_config(mode = 'create', l2_encap = 'ethernet_ii_vlan', rate_pps = 1,
+ l3_protocol = 'ipv4',
+ #length_mode = 'imix', l3_length = 200,
+ ipv6_dst_mode = 'decrement', ipv6_dst_count = 300, ipv6_dst_addr = 'fe80:0:0:0:0:0:0:000f',
+ port_handle = port_handle, port_handle2 = port_handle[1],
+ #save_to_yaml = '/tmp/d1.yaml',
+ #stream_id = 1,
+ )
+ print hlt_client.traffic_control(action = 'poll')
+ print hlt_client.traffic_control(action = 'run')
+ print hlt_client.traffic_control(action = 'poll')
+ wait_with_progress(2)
+ print hlt_client.traffic_control(action = 'poll')
+ print hlt_client.traffic_control(action = 'stop')
+ print hlt_client.traffic_control(action = 'poll')
+ print hlt_client.traffic_stats(mode = 'aggregate')
+ print hlt_client.traffic_control(action = 'clear_stats')
+ wait_with_progress(1)
+ print hlt_client.traffic_stats(mode = 'aggregate')
+
+ wait_with_progress(1)
+ print hlt_client.traffic_stats(mode = 'aggregate')
+ wait_with_progress(1)
+ print hlt_client.traffic_stats(mode = 'aggregate')
+ wait_with_progress(1)
+ print hlt_client.traffic_stats(mode = 'aggregate')
#print res
#print hlt_client._streams_history
#print hlt_client.trex_client._STLClient__get_all_streams(port_id = port_handle[0])
diff --git a/scripts/automation/regression/stateless_tests/stl_general_test.py b/scripts/automation/regression/stateless_tests/stl_general_test.py
index 435c7eea..64e93510 100644
--- a/scripts/automation/regression/stateless_tests/stl_general_test.py
+++ b/scripts/automation/regression/stateless_tests/stl_general_test.py
@@ -21,18 +21,41 @@ class CStlGeneral_Test(CTRexGeneral_Test):
if CTRexScenario.stl_init_error:
self.skip(CTRexScenario.stl_init_error)
- @staticmethod
- def connect(timeout = 20):
+ def connect(self, timeout = 20):
sys.stdout.write('Connecting')
for i in range(timeout):
try:
sys.stdout.write('.')
sys.stdout.flush()
- CTRexScenario.stl_trex.connect()
- return
+ self.stl_trex.connect()
+ print ''
+ return True
except:
time.sleep(1)
- CTRexScenario.stl_trex.connect()
+ print ''
+ return False
+
+ def map_ports(self, timeout = 5):
+ sys.stdout.write('Mapping ports')
+ for i in range(timeout):
+ sys.stdout.write('.')
+ sys.stdout.flush()
+ CTRexScenario.stl_ports_map = stl_map_ports(self.stl_trex)
+ if self.verify_bidirectional(CTRexScenario.stl_ports_map):
+ print ''
+ return True
+ time.sleep(1)
+ print ''
+ return False
+
+ # verify all the ports are bidirectional
+ @staticmethod
+ def verify_bidirectional(mapping_dict):
+ if len(mapping_dict['unknown']):
+ return False
+ if len(mapping_dict['bi']) * 2 == len(mapping_dict['map']):
+ return True
+ return False
@staticmethod
def get_port_count():
@@ -51,18 +74,13 @@ class STLBasic_Test(CStlGeneral_Test):
CTRexScenario.router.configure_basic_interfaces()
CTRexScenario.router.config_pbr(mode = "config")
- CTRexScenario.stl_init_error = 'Client could not connect'
- self.connect()
- print ''
- try:
- stl_map_ports(CTRexScenario.stl_trex)
- except:
- pass
- time.sleep(5)
- CTRexScenario.stl_init_error = 'Client could not map ports'
- CTRexScenario.stl_ports_map = stl_map_ports(CTRexScenario.stl_trex)
- CTRexScenario.stl_init_error = 'Could not determine bidirectional ports'
- print 'Ports mapping: %s' % CTRexScenario.stl_ports_map
- if not len(CTRexScenario.stl_ports_map['bi']):
- raise STLError('No bidirectional ports')
+ err = 'Client could not connect'
+ CTRexScenario.stl_init_error = err
+ if not self.connect():
+ self.fail(err)
+ err = 'Client could not map ports'
+ CTRexScenario.stl_init_error = err
+ if not self.map_ports():
+ self.fail(err)
+ print 'Got ports mapping: %s' % CTRexScenario.stl_ports_map
CTRexScenario.stl_init_error = None
diff --git a/scripts/automation/regression/trex_unit_test.py b/scripts/automation/regression/trex_unit_test.py
index 67b74fea..c8565c19 100755
--- a/scripts/automation/regression/trex_unit_test.py
+++ b/scripts/automation/regression/trex_unit_test.py
@@ -326,13 +326,14 @@ if __name__ == "__main__":
additional_args = ['--stf'] + CTRexScenario.test_types['stateful_tests']
if xml_arg:
additional_args += ['--with-xunit', xml_arg.replace('.xml', '_stateful.xml')]
- result = result and nose.run(argv = nose_argv + additional_args, addplugins = [red_nose, config_plugin])
+ result = nose.run(argv = nose_argv + additional_args, addplugins = [red_nose, config_plugin]) and result
if len(CTRexScenario.test_types['stateless_tests']):
additional_args = ['--stl', 'stateless_tests/stl_general_test.py:STLBasic_Test.test_connectivity'] + CTRexScenario.test_types['stateless_tests']
if xml_arg:
additional_args += ['--with-xunit', xml_arg.replace('.xml', '_stateless.xml')]
- result = result and nose.run(argv = nose_argv + additional_args, addplugins = [red_nose, config_plugin])
+ result = nose.run(argv = nose_argv + additional_args, addplugins = [red_nose, config_plugin]) and result
except Exception as e:
+ result = False
print e
finally:
save_setup_info()
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index 1d109988..c76abeea 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -1406,7 +1406,8 @@ class STLClient(object):
if not rc:
raise STLError(rc)
- return [stream.get_id() for stream in streams]
+ # return the stream IDs
+ return rc.data()
@__api_check(True)
@@ -1769,9 +1770,6 @@ class STLClient(object):
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
-
- expr = time.time() + timeout
-
return set(self.get_active_ports()).intersection(ports)
@@ -1958,8 +1956,8 @@ class STLClient(object):
try:
profile = STLProfile.load(opts.file[0])
except STLError as e:
- print format_text("\nError while loading profile '{0}'\n".format(opts.file[0]), 'bold')
- print e.brief() + "\n"
+ self.logger.log(format_text("\nError while loading profile '{0}'\n".format(opts.file[0]), 'bold'))
+ self.logger.log(e.brief() + "\n")
return
@@ -2221,7 +2219,7 @@ class STLClient(object):
self.start(ports = opts.ports, duration = opts.duration, force = opts.force)
except STLError as e:
- print e.brief()
+ stl.logger.log(e.brief())
return
return True
@@ -2245,7 +2243,7 @@ class STLClient(object):
try:
self.set_port_attr(opts.ports, opts.prom)
except STLError as e:
- print e.brief()
+ stl.logger.log(brief())
return
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py
index 81676df8..98336ef2 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_hltapi.py
@@ -303,6 +303,7 @@ class CStreamsPerPort(defaultdict):
# save HLT args to modify streams later
def save_stream_args(self, ports_list, stream_id, stream_hlt_args):
+ if stream_id is None: return # no stream_id, can't save TODO: remove this check ASAP
if stream_hlt_args.get('load_profile'): return # can't modify profiles, don't save
if not self.hlt_history: raise STLError('CStreamsPerPort: this object works only with HLT history, try init with hlt_history = True')
if type(stream_id) not in (int, long): raise STLError('CStreamsPerPort: stream_id should be number')
@@ -401,9 +402,17 @@ class CTRexHltApi(object):
except Exception as e:
return HLT_ERR('Unable to determine which ports to release: %s' % e if isinstance(e, STLError) else traceback.format_exc())
try:
+ self.trex_client.stop(port_list)
+ except Exception as e:
+ return HLT_ERR('Unable to stop traffic %s: %s' % (port_list, e if isinstance(e, STLError) else traceback.format_exc()))
+ try:
+ self.trex_client.remove_all_streams(port_list)
+ except Exception as e:
+ return HLT_ERR('Unable to remove all streams %s: %s' % (port_list, e if isinstance(e, STLError) else traceback.format_exc()))
+ try:
self.trex_client.release(port_list)
except Exception as e:
- return HLT_ERR('Unable to release ports %s: %s' % (port_list, e))
+ return HLT_ERR('Unable to release ports %s: %s' % (port_list, e if isinstance(e, STLError) else traceback.format_exc()))
try:
self.trex_client.disconnect(stop_traffic = False, release_ports = False)
except Exception as e:
@@ -585,30 +594,53 @@ class CTRexHltApi(object):
kwargs = merge_kwargs(traffic_control_kwargs, user_kwargs)
action = kwargs['action']
port_handle = kwargs['port_handle']
- ALLOWED_ACTIONS = ['clear_stats', 'run', 'stop', 'sync_run']
+ ALLOWED_ACTIONS = ['clear_stats', 'run', 'stop', 'sync_run', 'poll', 'reset']
if action not in ALLOWED_ACTIONS:
return HLT_ERR('Action must be one of the following values: {actions}'.format(actions=ALLOWED_ACTIONS))
- if type(port_handle) is not list:
- port_handle = [port_handle]
if action == 'run':
try:
self.trex_client.start(ports = port_handle)
except Exception as e:
return HLT_ERR('Could not start traffic: %s' % e if isinstance(e, STLError) else traceback.format_exc())
- return HLT_OK(stopped = 0)
+
+ elif action == 'sync_run': # (clear_stats + run)
+ try:
+ self.trex_client.clear_stats(ports = port_handle)
+ self.trex_client.start(ports = port_handle)
+ except Exception as e:
+ return HLT_ERR('Unable to do sync_run: %s' % e if isinstance(e, STLError) else traceback.format_exc())
elif action == 'stop':
try:
self.trex_client.stop(ports = port_handle)
except Exception as e:
- return HLT_ERR('Could not start traffic: %s' % e if isinstance(e, STLError) else traceback.format_exc())
- return HLT_OK(stopped = 1)
- else:
- return HLT_ERR("Action '{0}' is not supported yet on TRex".format(action))
+ return HLT_ERR('Could not stop traffic: %s' % e if isinstance(e, STLError) else traceback.format_exc())
+
+ elif action == 'reset':
+ try:
+ self.trex_client.reset(ports = port_handle)
+ for port in port_handle:
+ if port in self._streams_history:
+ del self._streams_history[port]
+ except Exception as e:
+ return HLT_ERR('Could not reset traffic: %s' % e if isinstance(e, STLError) else traceback.format_exc())
+
+ elif action == 'clear_stats':
+ try:
+ self.trex_client.clear_stats(ports = port_handle)
+ except Exception as e:
+ return HLT_ERR('Could not clear stats: %s' % e if isinstance(e, STLError) else traceback.format_exc())
+
+ elif action != 'poll': # at poll just return 'stopped' status
+ return HLT_ERR("Action '%s' is not supported yet on TRex" % action)
- # if we arrived here, this means that operation FAILED!
- return HLT_ERR("Probably action '%s' is not implemented" % action)
+ try:
+ is_traffic_active = self.trex_client.is_traffic_active(ports = port_handle)
+ except Exception as e:
+ return HLT_ERR('Unable to determine ports status: %s' % e if isinstance(e, STLError) else traceback.format_exc())
+
+ return HLT_OK(stopped = not is_traffic_active)
def traffic_stats(self, **user_kwargs):
if not self.trex_client:
@@ -653,6 +685,16 @@ class CTRexHltApi(object):
}
return HLT_OK(hlt_stats_dict)
+ # timeout = maximal time to wait
+ def wait_on_traffic(self, port_handle = None, timeout = 60):
+ try:
+ self.trex_client.wait_on_traffic(port_handle, timeout)
+ except Exception as e:
+ return HLT_ERR('Unable to run wait_on_traffic: %s' % e if isinstance(e, STLError) else traceback.format_exc())
+
+###########################
+# Private functions #
+###########################
# remove streams from given port(s).
# stream_id can be:
@@ -689,11 +731,6 @@ class CTRexHltApi(object):
return
raise STLError('_remove_stream: wrong param %s' % stream_id)
-
-###########################
-# Private functions #
-###########################
-
@staticmethod
def _parse_port_list(port_list):
if type(port_list) is str:
@@ -1481,6 +1518,7 @@ def correct_direction(user_kwargs, kwargs):
dst_arg = 'ipv6_dst_' + arg[9:]
user_kwargs[arg], user_kwargs[dst_arg] = kwargs[dst_arg], kwargs[arg]
+# we produce packets without fcs, so need to reduce produced sizes
def correct_sizes(kwargs):
for arg in kwargs.keys():
if type(arg) in (int, long):
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index 2a8bedb8..0558360d 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -227,8 +227,9 @@ class Port(object):
rc = self.transmit_batch(batch)
+ ret = RC()
for i, single_rc in enumerate(rc):
- if single_rc:
+ if single_rc.rc:
stream_id = batch[i].params['stream_id']
next_id = batch[i].params['stream']['next_stream_id']
self.streams[stream_id] = {'next_id' : next_id,
@@ -236,10 +237,13 @@ class Port(object):
'mode' : streams_list[i].get_mode(),
'rate' : streams_list[i].get_rate()}
+ ret.add(RC_OK(data = stream_id))
+ else:
+ ret.add(RC(*single_rc))
self.state = self.STATE_STREAMS if (len(self.streams) > 0) else self.STATE_IDLE
- return self.ok() if rc else self.err(str(rc))
+ return ret if ret else self.err(str(ret))
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index bb877586..12bf881a 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -828,8 +828,8 @@ class CRxStats(CTRexStats):
# copy timestamp field
output['ts'] = current['ts']
- # aggregate all the PG ids (previous and current)
- pg_ids = filter(is_intable, set(prev.keys() + current.keys()))
+ # we care only about the current active keys
+ pg_ids = filter(is_intable, current.keys())
for pg_id in pg_ids:
@@ -854,6 +854,13 @@ class CRxStats(CTRexStats):
self.calculate_bw_for_pg(output[pg_id], prev_pg, diff_sec)
+ # cleanp old reference values - they are dead
+ ref_pg_ids = filter(is_intable, self.reference_stats.keys())
+
+ deleted_pg_ids = set(ref_pg_ids).difference(pg_ids)
+ for d_pg_id in deleted_pg_ids:
+ del self.reference_stats[d_pg_id]
+
return output
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py
index 8596bbfe..20600791 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py
@@ -5,26 +5,15 @@ from trex_stl_packet_builder_scapy import *
# will destroy all streams/data on the ports
def stl_map_ports (client, ports = None):
# by default use all ports
- if ports == None:
+ if ports is None:
ports = client.get_all_ports()
- # reset the ports
- client.reset(ports)
-
- # generate streams
- base_pkt = STLPktBuilder(pkt = Ether()/IP())
-
- # send something initial to calm down switches with arps etc.
- stream = STLStream(packet = base_pkt,
- mode = STLTXSingleBurst(pps = 100000, total_pkts = 1))
- client.add_streams(stream, ports)
-
- client.start(ports, mult = "50%")
- client.wait_on_traffic(ports)
- client.reset(ports)
+ stl_send_3_pkts(client, ports)
tx_pkts = {}
pkts = 1
+ base_pkt = STLPktBuilder(pkt = Ether()/IP())
+
for port in ports:
tx_pkts[pkts] = port
stream = STLStream(packet = base_pkt,
@@ -75,3 +64,15 @@ def stl_map_ports (client, ports = None):
return table
+# reset ports and send 3 packets from each acquired port
+def stl_send_3_pkts(client, ports = None):
+
+ base_pkt = STLPktBuilder(pkt = Ether()/IP())
+ stream = STLStream(packet = base_pkt,
+ mode = STLTXSingleBurst(pps = 100000, total_pkts = 3))
+
+ client.reset(ports)
+ client.add_streams(stream, ports)
+ client.start(ports, mult = "50%")
+ client.wait_on_traffic(ports)
+ client.reset(ports)
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
index 496bea13..bd48f939 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
@@ -5,7 +5,7 @@ from trex_stl_exceptions import *
import types
RpcCmdData = namedtuple('RpcCmdData', ['method', 'params'])
-TupleRC = namedtuple('RC', ['rc', 'data', 'is_warn'])
+TupleRC = namedtuple('RCT', ['rc', 'data', 'is_warn'])
class RpcResponseStatus(namedtuple('RpcResponseStatus', ['success', 'id', 'msg'])):
__slots__ = ()
diff --git a/scripts/dpdk_nic_bind.py b/scripts/dpdk_nic_bind.py
index f02454e5..1ec91c2f 100755
--- a/scripts/dpdk_nic_bind.py
+++ b/scripts/dpdk_nic_bind.py
@@ -34,7 +34,7 @@
import sys, os, getopt, subprocess
from os.path import exists, abspath, dirname, basename
-
+from distutils.util import strtobool
# The PCI device class for ETHERNET devices
ETHERNET_CLASS = "0200"
@@ -89,7 +89,7 @@ Options:
--force:
By default, devices which are used by Linux - as indicated by having
- routes in the routing table - cannot be modified. Using the --force
+ established connections - cannot be modified. Using the --force
flag overrides this behavior, allowing active links to be forcibly
unbound.
WARNING: This can lead to loss of network connection and should be used
@@ -207,8 +207,7 @@ def get_pci_device_details(dev_id):
device["Interface"] = ",".join(os.listdir(sys_path))
else:
device["Interface"] = ""
- # check if a port is used for ssh connection
- device["Ssh_if"] = False
+ # check if a port is used for connections (ssh etc)
device["Active"] = ""
return device
@@ -237,17 +236,19 @@ def get_nic_details():
name, value = dev_line.split("\t", 1)
dev[name.rstrip(":")] = value
- # check what is the interface if any for an ssh connection if
- # any to this host, so we can mark it later.
- ssh_if = []
- route = check_output(["ip", "-o", "route"])
- # filter out all lines for 169.254 routes
- route = "\n".join(filter(lambda ln: not ln.startswith("169.254"),
- route.splitlines()))
- rt_info = route.split()
- for i in xrange(len(rt_info) - 1):
- if rt_info[i] == "dev":
- ssh_if.append(rt_info[i+1])
+ # check active interfaces with established connections
+ established_ip = set()
+ for line in check_output(['netstat', '-tn']).splitlines(): # tcp 0 0 10.56.216.133:22 10.56.46.20:45079 ESTABLISHED
+ line_arr = line.split()
+ if len(line_arr) == 6 and line_arr[0] == 'tcp' and line_arr[5] == 'ESTABLISHED':
+ established_ip.add(line_arr[3].rsplit(':', 1)[0])
+
+ active_if = []
+ for line in check_output(["ip", "-o", "addr"]).splitlines(): # 6: eth4 inet 10.56.216.133/24 brd 10.56.216.255 scope global eth4\ valid_lft forever preferred_lft forever
+ line_arr = line.split()
+ if len(line_arr) > 6 and line_arr[2] == 'inet':
+ if line_arr[3].rsplit('/', 1)[0] in established_ip:
+ active_if.append(line_arr[1])
# based on the basic info, get extended text details
for d in devices.keys():
@@ -255,9 +256,8 @@ def get_nic_details():
devices[d] = dict(devices[d].items() +
get_pci_device_details(d).items())
- for _if in ssh_if:
+ for _if in active_if:
if _if in devices[d]["Interface"].split(","):
- devices[d]["Ssh_if"] = True
devices[d]["Active"] = "*Active*"
break;
@@ -306,10 +306,15 @@ def unbind_one(dev_id, force):
return
# prevent us disconnecting ourselves
- if dev["Ssh_if"] and not force:
- print "Routing table indicates that interface %s is active" \
- ". Skipping unbind" % (dev_id)
- return
+ if dev["Active"] and not force:
+ print "netstat indicates that interface %s is active." % dev_id
+ result = None
+ try:
+ result = strtobool(raw_input("Confirm unbind (y/N)"))
+ finally:
+ if not result:
+ print 'Not unbinding.'
+ return
# write to /sys to unbind
filename = "/sys/bus/pci/drivers/%s/unbind" % dev["Driver_str"]
@@ -317,7 +322,7 @@ def unbind_one(dev_id, force):
f = open(filename, "a")
except:
print "Error: unbind failed for %s - Cannot open %s" % (dev_id, filename)
- sys/exit(1)
+ sys.exit(1)
f.write(dev_id)
f.close()
@@ -328,10 +333,15 @@ def bind_one(dev_id, driver, force):
saved_driver = None # used to rollback any unbind in case of failure
# prevent disconnection of our ssh session
- if dev["Ssh_if"] and not force:
- print "Routing table indicates that interface %s is active" \
- ". Not modifying" % (dev_id)
- return
+ if dev["Active"] and not force:
+ print "netstat indicates that interface %s is active" % dev_id
+ result = None
+ try:
+ result = strtobool(raw_input("Confirm bind (y/N)"))
+ finally:
+ if not result:
+ print 'Not binding.'
+ return
# unbind any existing drivers we don't want
if has_driver(dev_id):
diff --git a/scripts/dpdk_setup_ports.py b/scripts/dpdk_setup_ports.py
index 9472c0b3..62eac038 100755
--- a/scripts/dpdk_setup_ports.py
+++ b/scripts/dpdk_setup_ports.py
@@ -97,7 +97,7 @@ Other network devices
def do_bind_one (self,key):
- cmd='./dpdk_nic_bind.py --force --bind=igb_uio %s ' % ( key)
+ cmd='./dpdk_nic_bind.py --bind=igb_uio %s ' % ( key)
print cmd
res=os.system(cmd);
if res!=0:
diff --git a/scripts/external_libs/prebuild/zmq/README.txt b/scripts/external_libs/prebuild/zmq/README.txt
new file mode 100644
index 00000000..0e4f284c
--- /dev/null
+++ b/scripts/external_libs/prebuild/zmq/README.txt
@@ -0,0 +1,41 @@
+How to build PyZMQ for your system
+==================================
+
+I'll desrcibe a harder task - how to build cross platform PyZMQ.
+Building for current system will be much easier.
+
+for the example I will build 32 bit Python 3 PyZMQ on a 64 bit machine.
+
+1. build ZMQ library
+ a. Unzip zeromq-4.0.2.tar.gz
+ b. create a dir called zermoq-4.0.2-bin
+ c set CC, CXX, CXXLD, CFLAGS, CXXFLAGS and LDSHARED correctly if you need another toolchain
+ d. configure: ./configure --prefix=zeromq-4.0.2-bin
+ e. make -j64
+ f. make install
+
+now we have ZMQ binaries built to zeromq-4.0.2-bin
+
+
+2. build PyZMQ
+
+ a. unzip pyzmq-14.5.0
+ b. create a dir called pyzmq-14.5.0-bin
+ c. setenv LD_LIBRARY_PATH zeromq-4.0.2-bin/lib
+ c. *FOR CROSS COMPILE* we need a setup.cfg file skip to D
+ for non cross compile - you can simply run:
+ python setup.py configure --zmq=zeromq-4.0.2-bin
+ python setup.py build --prefix=pyzmq-14.5.0-bin
+
+
+ d. *CROSS COMPILE*
+ create a setup.cfg accroding to setup.cfg.template
+ with include_libs, and directory_libs
+ make sure they include the Python include/lib directories
+ as well as ZMQ
+ for example, for Python 3 i had to download the Python 3 development package
+
+
+The final output:
+prebuild/zmq/pyzmq-14.5.0-bin/lib/python3.4/site-packages/zmq
+
diff --git a/scripts/external_libs/prebuild/zmq/pyzmq-14.5.0.tar.gz b/scripts/external_libs/prebuild/zmq/pyzmq-14.5.0.tar.gz
new file mode 100644
index 00000000..6b3a8c22
--- /dev/null
+++ b/scripts/external_libs/prebuild/zmq/pyzmq-14.5.0.tar.gz
Binary files differ
diff --git a/scripts/external_libs/prebuild/zmq/zeromq-4.0.2.tar.gz b/scripts/external_libs/prebuild/zmq/zeromq-4.0.2.tar.gz
new file mode 100644
index 00000000..6ecb0255
--- /dev/null
+++ b/scripts/external_libs/prebuild/zmq/zeromq-4.0.2.tar.gz
Binary files differ
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index de081ffe..dc039661 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -640,11 +640,8 @@ bool CFlowStatRuleMgr::dump_json(std::string & json, bool baseline) {
data_section["ts"]["freq"] = Json::Value::UInt64(os_get_hr_freq());
if (m_user_id_map.is_empty()) {
- if (baseline) {
- json = writer.write(root);
- return true;
- } else
- return false;
+ json = writer.write(root);
+ return true;
}
// read hw counters, and update
@@ -682,6 +679,7 @@ bool CFlowStatRuleMgr::dump_json(std::string & json, bool baseline) {
// build json report
flow_stat_user_id_map_it_t it;
for (it = m_user_id_map.begin(); it != m_user_id_map.end(); it++) {
+ bool send_empty = true;
CFlowStatUserIdInfo *user_id_info = it->second;
uint32_t user_id = it->first;
std::string str_user_id = static_cast<std::ostringstream*>( &(std::ostringstream()
@@ -689,19 +687,25 @@ bool CFlowStatRuleMgr::dump_json(std::string & json, bool baseline) {
if (! user_id_info->was_sent()) {
data_section[str_user_id]["first_time"] = true;
user_id_info->set_was_sent(true);
+ send_empty = false;
}
for (uint8_t port = 0; port < m_num_ports; port++) {
std::string str_port = static_cast<std::ostringstream*>( &(std::ostringstream() << int(port) ) )->str();
if (user_id_info->need_to_send_rx(port) || baseline) {
user_id_info->set_no_need_to_send_rx(port);
data_section[str_user_id]["rx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port));
+ send_empty = false;
}
if (user_id_info->need_to_send_tx(port) || baseline) {
user_id_info->set_no_need_to_send_tx(port);
data_section[str_user_id]["tx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_pkts());
data_section[str_user_id]["tx_bytes"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_bytes());
+ send_empty = false;
}
}
+ if (send_empty) {
+ data_section[str_user_id] = Json::objectValue;
+ }
}
json = writer.write(root);
diff --git a/src/rpc-server/trex_rpc_cmd.cpp b/src/rpc-server/trex_rpc_cmd.cpp
index 77869d0d..caf161e3 100644
--- a/src/rpc-server/trex_rpc_cmd.cpp
+++ b/src/rpc-server/trex_rpc_cmd.cpp
@@ -51,7 +51,7 @@ TrexRpcCommand::check_param_count(const Json::Value &params, int expected, Json:
if (params.size() != expected) {
std::stringstream ss;
- ss << "method expects '" << expected << "' paramteres, '" << params.size() << "' provided";
+ ss << "method expects '" << expected << "' parameter(s), '" << params.size() << "' provided";
generate_parse_err(result, ss.str());
}
}