From: Tiwei Bie <tiwei.bie@intel.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com
Subject: [dpdk-dev] [PATCH] examples/exception_path: add FreeBSD support
Date: Fri, 19 May 2017 08:13:48 +0800 [thread overview]
Message-ID: <20170519001348.34431-1-tiwei.bie@intel.com> (raw)
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
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 <getopt.h>
#include <netinet/in.h>
-#include <linux/if.h>
+#include <net/if.h>
+#ifdef RTE_EXEC_ENV_LINUXAPP
#include <linux/if_tun.h>
+#endif
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
@@ -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
next reply other threads:[~2017-05-19 0:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 0:13 Tiwei Bie [this message]
2017-05-19 10:57 ` Bruce Richardson
2017-06-05 15:56 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170519001348.34431-1-tiwei.bie@intel.com \
--to=tiwei.bie@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).