git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
examples/vdpa: remove useless device count
[dpdk.git]
/
examples
/
ip_pipeline
/
tap.c
diff --git
a/examples/ip_pipeline/tap.c
b/examples/ip_pipeline/tap.c
index
5b34032
..
adae640
100644
(file)
--- a/
examples/ip_pipeline/tap.c
+++ b/
examples/ip_pipeline/tap.c
@@
-3,7
+3,7
@@
*/
#include <netinet/in.h>
*/
#include <netinet/in.h>
-#ifdef RTE_EXEC_ENV_LINUX
APP
+#ifdef RTE_EXEC_ENV_LINUX
#include <linux/if.h>
#include <linux/if_tun.h>
#endif
#include <linux/if.h>
#include <linux/if_tun.h>
#endif
@@
-15,6
+15,8
@@
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
+#include <rte_string_fns.h>
+
#include "tap.h"
#define TAP_DEV "/dev/net/tun"
#include "tap.h"
#define TAP_DEV "/dev/net/tun"
@@
-44,7
+46,7
@@
tap_find(const char *name)
return NULL;
}
return NULL;
}
-#ifndef RTE_EXEC_ENV_LINUX
APP
+#ifndef RTE_EXEC_ENV_LINUX
struct tap *
tap_create(const char *name __rte_unused)
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 */
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI; /* No packet information */
- s
nprintf(ifr.ifr_name, IFNAMSIZ, "%s", name
);
+ s
trlcpy(ifr.ifr_name, name, IFNAMSIZ
);
status = ioctl(fd, TUNSETIFF, (void *) &ifr);
status = ioctl(fd, TUNSETIFF, (void *) &ifr);
- if (status < 0)
+ if (status < 0) {
+ close(fd);
return NULL;
return NULL;
+ }
/* Node allocation */
tap = calloc(1, sizeof(struct tap));
/* Node allocation */
tap = calloc(1, sizeof(struct tap));
- if (tap == NULL)
+ if (tap == NULL) {
+ close(fd);
return NULL;
return NULL;
-
+ }
/* Node fill in */
/* Node fill in */
- str
n
cpy(tap->name, name, sizeof(tap->name));
+ str
l
cpy(tap->name, name, sizeof(tap->name));
tap->fd = fd;
/* Node add to list */
tap->fd = fd;
/* Node add to list */