#include <rte_ethdev.h>
#include <rte_bus_pci.h>
+#include <rte_string_fns.h>
#include "kni.h"
#include "mempool.h"
{
int ret = 0;
- if (port_id >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port_id))
return -EINVAL;
ret = (if_up) ?
{
int ret;
- if (port_id >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port_id))
return -EINVAL;
- if (new_mtu > ETHER_MAX_LEN)
+ if (new_mtu > RTE_ETHER_MAX_LEN)
return -EINVAL;
/* Set new MTU */
struct rte_kni *k;
const struct rte_pci_device *pci_dev;
const struct rte_bus *bus = NULL;
+ int ret;
/* Check input params */
if ((name == NULL) ||
return NULL;
/* Resource create */
- rte_eth_dev_info_get(link->port_id, &dev_info);
+ ret = rte_eth_dev_info_get(link->port_id, &dev_info);
+ if (ret != 0)
+ return NULL;
memset(&kni_conf, 0, sizeof(kni_conf));
- snprintf(kni_conf.name, RTE_KNI_NAMESIZE, "%s", name);
+ strlcpy(kni_conf.name, name, RTE_KNI_NAMESIZE);
kni_conf.force_bind = params->force_bind;
kni_conf.core_id = params->thread_id;
kni_conf.group_id = link->port_id;
return NULL;
/* Node fill in */
- strncpy(kni->name, name, sizeof(kni->name));
+ strlcpy(kni->name, name, sizeof(kni->name));
kni->k = k;
/* Node add to list */