X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fip_pipeline%2Ftap.c;h=adae640c1e6b4a3d11d2cbdd962cf54384bb1c2f;hb=a9fe152363e283d4c590ab8e8d51396f2ffab9ff;hp=5b340321897f97973e00884e92aea02abbcaff82;hpb=2f74ae28e23f441c6f51241b4f3ea1c9b8b15812;p=dpdk.git diff --git a/examples/ip_pipeline/tap.c b/examples/ip_pipeline/tap.c index 5b34032189..adae640c1e 100644 --- a/examples/ip_pipeline/tap.c +++ b/examples/ip_pipeline/tap.c @@ -3,7 +3,7 @@ */ #include -#ifdef RTE_EXEC_ENV_LINUXAPP +#ifdef RTE_EXEC_ENV_LINUX #include #include #endif @@ -15,6 +15,8 @@ #include #include +#include + #include "tap.h" #define TAP_DEV "/dev/net/tun" @@ -44,7 +46,7 @@ tap_find(const char *name) return NULL; } -#ifndef RTE_EXEC_ENV_LINUXAPP +#ifndef RTE_EXEC_ENV_LINUX struct tap * tap_create(const char *name __rte_unused) @@ -73,19 +75,22 @@ tap_create(const char *name) memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; /* No packet information */ - snprintf(ifr.ifr_name, IFNAMSIZ, "%s", name); + strlcpy(ifr.ifr_name, name, IFNAMSIZ); status = ioctl(fd, TUNSETIFF, (void *) &ifr); - if (status < 0) + if (status < 0) { + close(fd); return NULL; + } /* Node allocation */ tap = calloc(1, sizeof(struct tap)); - if (tap == NULL) + if (tap == NULL) { + close(fd); return NULL; - + } /* Node fill in */ - strncpy(tap->name, name, sizeof(tap->name)); + strlcpy(tap->name, name, sizeof(tap->name)); tap->fd = fd; /* Node add to list */