From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 4D9E32C5 for ; Fri, 19 May 2017 02:25:48 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 May 2017 17:25:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,361,1491289200"; d="scan'208";a="103962881" Received: from dpdk19.sh.intel.com (HELO localhost.localdomain) ([10.239.129.163]) by fmsmga005.fm.intel.com with ESMTP; 18 May 2017 17:25:46 -0700 From: Tiwei Bie To: dev@dpdk.org Cc: bruce.richardson@intel.com Date: Fri, 19 May 2017 08:13:48 +0800 Message-Id: <20170519001348.34431-1-tiwei.bie@intel.com> X-Mailer: git-send-email 2.12.1 Subject: [dpdk-dev] [PATCH] examples/exception_path: add FreeBSD support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 May 2017 00:25:49 -0000 Signed-off-by: Tiwei Bie --- examples/exception_path/Makefile | 9 --------- examples/exception_path/main.c | 28 +++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/examples/exception_path/Makefile b/examples/exception_path/Makefile index 4b6e07175..76706c124 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 89bf1cc06..fe30e0703 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 -- 2.12.1