examples/l3fwd-power: fix stop and close on signal
[dpdk.git] / examples / l3fwd-power / main.c
index e741434..15b47c7 100644 (file)
@@ -379,6 +379,7 @@ static void
 signal_exit_now(int sigtype)
 {
        unsigned lcore_id;
+       unsigned int portid, nb_ports;
        int ret;
 
        if (sigtype == SIGINT) {
@@ -393,6 +394,15 @@ signal_exit_now(int sigtype)
                                        "library de-initialization failed on "
                                                        "core%u\n", lcore_id);
                }
+
+               nb_ports = rte_eth_dev_count();
+               for (portid = 0; portid < nb_ports; portid++) {
+                       if ((enabled_port_mask & (1 << portid)) == 0)
+                               continue;
+
+                       rte_eth_dev_stop(portid);
+                       rte_eth_dev_close(portid);
+               }
        }
 
        rte_exit(EXIT_SUCCESS, "User forced exit\n");