From: Tiwei Bie Date: Fri, 19 May 2017 00:13:48 +0000 (+0800) Subject: examples/exception_path: support FreeBSD X-Git-Tag: spdx-start~3190 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=67064d67959a75c5122aab63651f6aab3da4175c;p=dpdk.git examples/exception_path: support FreeBSD Signed-off-by: Tiwei Bie Acked-by: Bruce Richardson --- diff --git a/examples/exception_path/Makefile b/examples/exception_path/Makefile index 4b6e071751..76706c1245 100644 --- a/examples/exception_path/Makefile +++ b/examples/exception_path/Makefile @@ -38,13 +38,6 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc include $(RTE_SDK)/mk/rte.vars.mk -ifneq ($(CONFIG_RTE_EXEC_ENV),"linuxapp") -$(info This application can only operate in a linuxapp environment, \ -please change the definition of the RTE_TARGET environment variable) -all: -clean: -else - # binary name APP = exception_path @@ -55,5 +48,3 @@ CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) include $(RTE_SDK)/mk/rte.extapp.mk - -endif diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c index 89bf1cc060..fe30e07031 100644 --- a/examples/exception_path/main.c +++ b/examples/exception_path/main.c @@ -42,8 +42,10 @@ #include #include -#include +#include +#ifdef RTE_EXEC_ENV_LINUXAPP #include +#endif #include #include #include @@ -182,6 +184,7 @@ signal_handler(int signum) } } +#ifdef RTE_EXEC_ENV_LINUXAPP /* * Create a tap network interface, or use existing one with same name. * If name[0]='\0' then a name is automatically assigned and returned in name. @@ -214,6 +217,29 @@ static int tap_create(char *name) return fd; } +#else +/* + * Find a free tap network interface, or create a new one. + * The name is automatically assigned and returned in name. + */ +static int tap_create(char *name) +{ + int i, fd = -1; + char devname[PATH_MAX]; + + for (i = 0; i < 255; i++) { + snprintf(devname, sizeof(devname), "/dev/tap%d", i); + fd = open(devname, O_RDWR); + if (fd >= 0 || errno != EBUSY) + break; + } + + if (name) + snprintf(name, IFNAMSIZ, "tap%d", i); + + return fd; +} +#endif /* Main processing loop */ static int