summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py5
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py8
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp18
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp8
4 files changed, 27 insertions, 12 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 945aacd0..743ff27c 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
@@ -2973,11 +2973,6 @@ class STLClient(object):
ports = ports if ports is not None else self.get_resolvable_ports()
ports = self._validate_port_list(ports)
- active_ports = list_intersect(ports, self.get_active_ports())
- if active_ports:
- raise STLError('Port(s) {0} are active, please stop them before resolving'.format(active_ports))
-
-
self.logger.pre_cmd('Resolving destination on port(s) {0}:'.format(ports))
with self.logger.supress():
rc = self.__resolve(ports, retries)
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 487f3055..66d8be2b 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
@@ -114,7 +114,7 @@ class Port(object):
return port.err("{0} - port is not owned".format(func.__name__))
if not port.is_writeable():
- return port.err("{0} - port is not in a writeable state".format(func.__name__))
+ return port.err("{0} - port is active, please stop the port before executing command".format(func.__name__))
return func(*args, **kwargs)
@@ -123,7 +123,7 @@ class Port(object):
def err(self, msg):
- return RC_ERR("port {0} : {1}\n".format(self.port_id, msg))
+ return RC_ERR("port {0} : *** {1}".format(self.port_id, msg))
def ok(self, data = ""):
return RC_OK(data)
@@ -519,7 +519,7 @@ class Port(object):
return self.ok()
- @owned
+ @writeable
def set_l2_mode (self, dst_mac):
if not self.is_service_mode_on():
return self.err('port service mode must be enabled for configuring L2 mode. Please enable service mode')
@@ -535,7 +535,7 @@ class Port(object):
return self.sync()
- @owned
+ @writeable
def set_l3_mode (self, src_addr, dest_addr, resolved_mac = None):
if not self.is_service_mode_on():
return self.err('port service mode must be enabled for configuring L3 mode. Please enable service mode')
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index c8b4841a..f936f946 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -799,7 +799,11 @@ TrexRpcCmdSetL2::_run(const Json::Value &params, Json::Value &result) {
generate_parse_err(result, ss.str());
}
- port->set_l2_mode(dst_mac);
+ try {
+ port->set_l2_mode(dst_mac);
+ } catch (const TrexException &ex) {
+ generate_execute_err(result, ex.what());
+ }
return (TREX_RPC_CMD_OK);
}
@@ -844,11 +848,19 @@ TrexRpcCmdSetL3::_run(const Json::Value &params, Json::Value &result) {
generate_parse_err(result, ss.str());
}
- port->set_l3_mode(src_ipv4, dst_ipv4, mac);
+ try {
+ port->set_l3_mode(src_ipv4, dst_ipv4, mac);
+ } catch (const TrexException &ex) {
+ generate_execute_err(result, ex.what());
+ }
} else {
+ try {
+ port->set_l3_mode(src_ipv4, dst_ipv4);
+ } catch (const TrexException &ex) {
+ generate_execute_err(result, ex.what());
+ }
- port->set_l3_mode(src_ipv4, dst_ipv4);
}
return (TREX_RPC_CMD_OK);
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index e41cc88c..3a4db196 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -1004,6 +1004,9 @@ TrexStatelessPort::get_rx_queue_pkts() {
void
TrexStatelessPort::set_l2_mode(const uint8_t *dest_mac) {
+ /* not valid under traffic */
+ verify_state(PORT_STATE_IDLE | PORT_STATE_STREAMS, "set_l2_mode");
+
/* no IPv4 src */
getPortAttrObj()->set_src_ipv4(0);
@@ -1020,6 +1023,9 @@ TrexStatelessPort::set_l2_mode(const uint8_t *dest_mac) {
void
TrexStatelessPort::set_l3_mode(uint32_t src_ipv4, uint32_t dest_ipv4) {
+ /* not valid under traffic */
+ verify_state(PORT_STATE_IDLE | PORT_STATE_STREAMS, "set_l3_mode");
+
/* set src IPv4 */
getPortAttrObj()->set_src_ipv4(src_ipv4);
@@ -1041,6 +1047,8 @@ TrexStatelessPort::set_l3_mode(uint32_t src_ipv4, uint32_t dest_ipv4) {
void
TrexStatelessPort::set_l3_mode(uint32_t src_ipv4, uint32_t dest_ipv4, const uint8_t *resolved_mac) {
+ verify_state(PORT_STATE_IDLE | PORT_STATE_STREAMS, "set_l3_mode");
+
/* set src IPv4 */
getPortAttrObj()->set_src_ipv4(src_ipv4);