[dpdk-dev] [PATCH v2 7/7] app/testpmd: verify mtu with	rte_eth_dev_info_get()
    Ian Stokes 
    ian.stokes at intel.com
       
    Fri Mar 22 14:01:18 CET 2019
    
    
  
This commit uses the mtu fields populated in rte_eth_dev_info_get()
to validate the mtu value being passed in port_mtu_set().
Signed-off-by: Ian Stokes <ian.stokes at intel.com>
---
 app/test-pmd/config.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index b9e5dd923..6ca97d0e7 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1063,9 +1063,13 @@ void
 port_mtu_set(portid_t port_id, uint16_t mtu)
 {
 	int diag;
+	struct rte_eth_dev_info dev_info;
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN))
 		return;
+	rte_eth_dev_info_get(port_id, &dev_info);
+	if (mtu > dev_info.max_mtu || mtu < dev_info.min_mtu)
+		return;
 	diag = rte_eth_dev_set_mtu(port_id, mtu);
 	if (diag == 0)
 		return;
-- 
2.13.6
    
    
More information about the dev
mailing list