diff options
author | imarom <imarom@cisco.com> | 2016-12-21 12:03:25 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-12-21 14:26:13 +0200 |
commit | bf7c614dc174697b416eb3dfad515cedb104028b (patch) | |
tree | 96baa43bc014f325e8c150e68c83c182f0decd41 /scripts/automation/trex_control_plane/stl | |
parent | eae78d4356b8834b78a91c52d869a7949f8f3e90 (diff) |
minor error checks refinements
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'scripts/automation/trex_control_plane/stl')
4 files changed, 25 insertions, 30 deletions
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 4662768a..946c79dc 100755 --- 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 @@ -27,7 +27,6 @@ import json import traceback import os.path - ############################ logger ############################# ############################ ############################# ############################ ############################# @@ -909,7 +908,7 @@ class STLClient(object): if not rc: return rc - + # API sync rc = self._transmit("api_sync", params = {'api_vers': self.api_vers}, api_class = None) if not rc: @@ -1708,7 +1707,6 @@ class STLClient(object): self.logger.set_verbose(modes[level]) - @__api_check(False) def connect (self): """ @@ -1722,7 +1720,6 @@ class STLClient(object): + :exc:`STLError` """ - rc = self.__connect() if not rc: raise STLError(rc) @@ -3809,17 +3806,8 @@ class STLClient(object): if not opts: return opts - ports = list_intersect(opts.ports, self.get_resolvable_ports()) - if not ports: - if not opts.ports: - msg = 'resolve - no ports with IPv4 destination' - else: - msg = 'pause - none of ports {0} are configured with IPv4 destination'.format(opts.ports) - - self.logger.log(msg) - return RC_ERR(msg) - - self.resolve(ports = ports, retries = opts.retries) + + self.resolve(ports = opts.ports, retries = opts.retries) return RC_OK() 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 9eefc177..37472cdb 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 @@ -762,6 +762,11 @@ class Port(object): # invalidates the current ARP def invalidate_arp (self): dest = self.__attr['dest'] + + if not self.is_l3_mode(): + return self.err('port is not configured with L3') + + self.set_l3_mode(self.get_src_addr()['ipv4'], self.get_dst_addr()['ipv4']) if dest['type'] != 'mac': return self.set_attr(dest = dest['ipv4']) @@ -867,6 +872,8 @@ class Port(object): # RX filter mode info['rx_filter_mode'] = 'hardware match' if attr['rx_filter_mode'] == 'hw' else 'fetch all' + info['layer_mode'] = 'IPv4' if self.is_l3_mode() else 'Ethernet' + # src MAC and IPv4 info['src_mac'] = attr['src_mac'] info['src_ipv4'] = attr['src_ipv4'] @@ -939,6 +946,8 @@ class Port(object): else: assert(0) + def is_l3_mode (self): + return self.get_dst_addr()['ipv4'] is not None # port is considered resolved if it's dest is either MAC or resolved IPv4 def is_resolved (self): @@ -976,7 +985,7 @@ class Port(object): "src MAC": info['src_mac'], "src IPv4": info['src_ipv4'], "Destination": info['dest'], - "ARP Resolution": format_text("{0}".format(info['arp']), 'bold', 'red') if info['arp'] == 'unresolved' else info['arp'], + "ARP Resolution": format_text("{0}".format(info['arp']), 'bold', 'red' if info['arp'] == 'unresolved' else None), "PCI Address": info['pci_addr'], "NUMA Node": info['numa'], "--": "", @@ -989,6 +998,7 @@ class Port(object): "promiscuous" : info['prom'], "flow ctrl" : info['fc'], + "layer mode": format_text(info['layer_mode'], 'green' if info['layer_mode'] == 'IPv4' else 'magenta'), "RX Filter Mode": info['rx_filter_mode'], "RX Queueing": info['rx_queue'], "RX sniffer": info['rx_sniffer'], diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_rx_features.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_rx_features.py index ec83de5d..727451e6 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_rx_features.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_rx_features.py @@ -129,16 +129,13 @@ class ARPResolver(Resolver): # before resolve def pre_send (self): + + if not self.port.is_l3_mode(): + return self.port.err("arp - port is not configured as L3 layer") + self.dst = self.port.get_dst_addr() self.src = self.port.get_src_addr() - - if self.dst['ipv4'] is None: - return self.port.err("Port has a non-IPv4 destination: '{0}'".format(self.dst['mac'])) - if self.src['ipv4'] is None: - return self.port.err('Port must have an IPv4 source address configured') - - # invalidate the current ARP resolution (if exists) return self.port.invalidate_arp() @@ -158,7 +155,7 @@ class ARPResolver(Resolver): return None arp = scapy_pkt['ARP'] - + # check this is the right ARP (ARP reply with the address) if (arp.op != 2) or (arp.psrc != self.dst['ipv4']): return None @@ -187,15 +184,15 @@ class PingResolver(Resolver): self.pkt_size = pkt_size def pre_send (self): + if not self.port.is_l3_mode(): + return self.port.err('ping - port is not configured as L3 layer') + + if not self.port.is_resolved(): + return self.port.err('ping - port has an unresolved destination, cannot determine next hop MAC address') self.src = self.port.get_src_addr() self.dst = self.port.get_dst_addr() - if self.src['ipv4'] is None: - return self.port.err('Ping - port does not have an IPv4 address configured') - - if self.dst['mac'] is None: - return self.port.err('Ping - port has an unresolved destination, cannot determine next hop MAC address') return self.port.ok() @@ -208,7 +205,6 @@ class PingResolver(Resolver): base_pkt = base_pkt / (pad * 'x') - #base_pkt.show2() s1 = STLStream( packet = STLPktBuilder(pkt = base_pkt), mode = STLTXSingleBurst(total_pkts = 1) ) self.base_pkt = base_pkt 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 c08a0af8..38726062 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 @@ -670,6 +670,7 @@ class CTRexInfoGenerator(object): ("promiscuous", []), ("flow ctrl", []), ("--", []), + ("layer mode", []), ("src IPv4", []), ("src MAC", []), ("---", []), |