1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
5 #include <netinet/in.h>
6 #ifdef RTE_EXEC_ENV_LINUXAPP
8 #include <linux/if_tun.h>
10 #include <sys/ioctl.h>
20 #define TAP_DEV "/dev/net/tun"
22 static struct tap_list tap_list;
27 TAILQ_INIT(&tap_list);
33 tap_find(const char *name)
40 TAILQ_FOREACH(tap, &tap_list, node)
41 if (strcmp(tap->name, name) == 0)
47 #ifndef RTE_EXEC_ENV_LINUXAPP
50 tap_create(const char *name __rte_unused)
58 tap_create(const char *name)
64 /* Check input params */
70 fd = open(TAP_DEV, O_RDWR | O_NONBLOCK);
74 memset(&ifr, 0, sizeof(ifr));
75 ifr.ifr_flags = IFF_TAP | IFF_NO_PI; /* No packet information */
76 snprintf(ifr.ifr_name, IFNAMSIZ, "%s", name);
78 status = ioctl(fd, TUNSETIFF, (void *) &ifr);
83 tap = calloc(1, sizeof(struct tap));
88 strncpy(tap->name, name, sizeof(tap->name));
91 /* Node add to list */
92 TAILQ_INSERT_TAIL(&tap_list, tap, node);