X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fip_pipeline%2Fkni.c;h=e9262e0790b1c889ea6ebf12871d46defc448596;hb=f6feb39c20cec3b520eaaef2dde436379e48330a;hp=712775338274778b18b0b879bdfdc14655575d91;hpb=cd8c7c7ce241d2ea7c059a9df07caa9411ef19ed;p=dpdk.git diff --git a/examples/ip_pipeline/kni.c b/examples/ip_pipeline/kni.c index 7127753382..e9262e0790 100644 --- a/examples/ip_pipeline/kni.c +++ b/examples/ip_pipeline/kni.c @@ -7,6 +7,7 @@ #include #include +#include #include "kni.h" #include "mempool.h" @@ -67,7 +68,7 @@ kni_config_network_interface(uint16_t port_id, uint8_t if_up) { int ret = 0; - if (port_id >= rte_eth_dev_count()) + if (!rte_eth_dev_is_valid_port(port_id)) return -EINVAL; ret = (if_up) ? @@ -82,10 +83,10 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu) { 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 */ @@ -125,7 +126,7 @@ kni_create(const char *name, struct kni_params *params) rte_eth_dev_info_get(link->port_id, &dev_info); 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; @@ -153,7 +154,7 @@ kni_create(const char *name, struct kni_params *params) 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 */