#include <inttypes.h>
#include <sys/queue.h>
#include <errno.h>
-#include <netinet/ip.h>
+#include <signal.h>
#include <rte_common.h>
#include <rte_memory.h>
{
static const char err_address[] = "00:00:00:00:00:00";
static char addresses[RTE_MAX_ETHPORTS][sizeof(err_address)];
+ int ret;
if (unlikely(port >= RTE_MAX_ETHPORTS))
return err_address;
if (unlikely(addresses[port][0]=='\0')){
- struct ether_addr mac;
- rte_eth_macaddr_get(port, &mac);
+ struct rte_ether_addr mac;
+ ret = rte_eth_macaddr_get(port, &mac);
+ if (ret != 0) {
+ printf("Failed to get MAC address (port %u): %s\n",
+ port, rte_strerror(-ret));
+ return err_address;
+ }
snprintf(addresses[port], sizeof(addresses[port]),
"%02x:%02x:%02x:%02x:%02x:%02x\n",
mac.addr_bytes[0], mac.addr_bytes[1], mac.addr_bytes[2],
}
}
+static void
+signal_handler(int signal)
+{
+ uint16_t port_id;
+
+ if (signal == SIGINT)
+ RTE_ETH_FOREACH_DEV(port_id) {
+ rte_eth_dev_stop(port_id);
+ rte_eth_dev_close(port_id);
+ }
+ exit(0);
+}
+
int
main(int argc, char *argv[])
{
+ signal(SIGINT, signal_handler);
/* initialise the system */
if (init(argc, argv) < 0 )
return -1;