From: Ivan Ilchenko Date: Sat, 14 Sep 2019 11:37:31 +0000 (+0100) Subject: kni: check code of promiscuous mode switch X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b57e35d6e9eb6ed0a0b7b51b3641f7c6b887a66f;p=dpdk.git kni: check code of promiscuous mode switch rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return value was changed from void to int, so modify usage of these functions across lib/librte_kni according to new return type. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko --- diff --git a/app/test/test_kni.c b/app/test/test_kni.c index 2c333748db..e47ab36e02 100644 --- a/app/test/test_kni.c +++ b/app/test/test_kni.c @@ -601,7 +601,12 @@ test_kni(void) printf("fail to start port %d\n", port_id); return -1; } - rte_eth_promiscuous_enable(port_id); + ret = rte_eth_promiscuous_enable(port_id); + if (ret != 0) { + printf("fail to enable promiscuous mode for port %d: %s\n", + port_id, rte_strerror(-ret)); + return -1; + } /* basic test of kni processing */ fd = fopen(KNI_MODULE_PARAM_LO, "r"); diff --git a/examples/kni/main.c b/examples/kni/main.c index e43f174479..1069fd08bb 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -636,8 +636,13 @@ init_port(uint16_t port) rte_exit(EXIT_FAILURE, "Could not start port%u (%d)\n", (unsigned)port, ret); - if (promiscuous_on) - rte_eth_promiscuous_enable(port); + if (promiscuous_on) { + ret = rte_eth_promiscuous_enable(port); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Could not enable promiscuous mode for port%u: %s\n", + port, rte_strerror(-ret)); + } } /* Check the link status of all ports in up to 9s, and print them finally */ diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 4b51fb4fed..04806ebb40 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -472,6 +472,8 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[]) static int kni_config_promiscusity(uint16_t port_id, uint8_t to_on) { + int ret; + if (!rte_eth_dev_is_valid_port(port_id)) { RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); return -EINVAL; @@ -481,11 +483,17 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) port_id, to_on); if (to_on) - rte_eth_promiscuous_enable(port_id); + ret = rte_eth_promiscuous_enable(port_id); else - rte_eth_promiscuous_disable(port_id); + ret = rte_eth_promiscuous_disable(port_id); - return 0; + if (ret != 0) + RTE_LOG(ERR, KNI, + "Failed to %s promiscuous mode for port %u: %s\n", + to_on ? "enable" : "disable", port_id, + rte_strerror(-ret)); + + return ret; } int