aboutsummaryrefslogtreecommitdiff
path: root/tools/tools/netmap/bridge.c
diff options
context:
space:
mode:
authorLuigi Rizzo <luigi@FreeBSD.org>2016-10-16 14:13:32 +0000
committerLuigi Rizzo <luigi@FreeBSD.org>2016-10-16 14:13:32 +0000
commit37e3a6d349581b4dd0aebf24be7b1b159a698dcf (patch)
tree0e61deea141c9733af511b0485cf1fd0f2dd17ed /tools/tools/netmap/bridge.c
parent63f6b1a75a8e6e33e4f9d65571c6a221444d3b05 (diff)
downloadsrc-37e3a6d349581b4dd0aebf24be7b1b159a698dcf.tar.gz
src-37e3a6d349581b4dd0aebf24be7b1b159a698dcf.zip
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including: + fixes on monitor ports + the 'ptnet' virtual device driver, and ptnetmap backend, for high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit) + improved emulated netmap mode + more robust error handling + removal of stale code + various fixes to code and documentation (some mixup between RX and TX parameters, and private and public variables) We also include an additional tool, nmreplay, which is functionally equivalent to tcpreplay but operating on netmap ports.
Notes
Notes: svn path=/head/; revision=307394
Diffstat (limited to 'tools/tools/netmap/bridge.c')
-rw-r--r--tools/tools/netmap/bridge.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/tools/tools/netmap/bridge.c b/tools/tools/netmap/bridge.c
index 0895d4ede676..e99a507a829a 100644
--- a/tools/tools/netmap/bridge.c
+++ b/tools/tools/netmap/bridge.c
@@ -143,7 +143,7 @@ static void
usage(void)
{
fprintf(stderr,
- "usage: bridge [-v] [-i ifa] [-i ifb] [-b burst] [-w wait_time] [iface]\n");
+ "usage: bridge [-v] [-i ifa] [-i ifb] [-b burst] [-w wait_time] [ifa [ifb [burst]]]\n");
exit(1);
}
@@ -201,12 +201,12 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
+ if (argc > 0)
+ ifa = argv[0];
if (argc > 1)
- ifa = argv[1];
+ ifb = argv[1];
if (argc > 2)
- ifb = argv[2];
- if (argc > 3)
- burst = atoi(argv[3]);
+ burst = atoi(argv[2]);
if (!ifb)
ifb = ifa;
if (!ifa) {
@@ -233,7 +233,7 @@ main(int argc, char **argv)
D("cannot open %s", ifa);
return (1);
}
- // XXX use a single mmap ?
+ /* try to reuse the mmap() of the first interface, if possible */
pb = nm_open(ifb, NULL, NM_OPEN_NO_MMAP, pa);
if (pb == NULL) {
D("cannot open %s", ifb);
@@ -262,6 +262,23 @@ main(int argc, char **argv)
pollfd[0].revents = pollfd[1].revents = 0;
n0 = pkt_queued(pa, 0);
n1 = pkt_queued(pb, 0);
+#if defined(_WIN32) || defined(BUSYWAIT)
+ if (n0){
+ ioctl(pollfd[1].fd, NIOCTXSYNC, NULL);
+ pollfd[1].revents = POLLOUT;
+ }
+ else {
+ ioctl(pollfd[0].fd, NIOCRXSYNC, NULL);
+ }
+ if (n1){
+ ioctl(pollfd[0].fd, NIOCTXSYNC, NULL);
+ pollfd[0].revents = POLLOUT;
+ }
+ else {
+ ioctl(pollfd[1].fd, NIOCRXSYNC, NULL);
+ }
+ ret = 1;
+#else
if (n0)
pollfd[1].events |= POLLOUT;
else
@@ -271,6 +288,7 @@ main(int argc, char **argv)
else
pollfd[1].events |= POLLIN;
ret = poll(pollfd, 2, 2500);
+#endif //defined(_WIN32) || defined(BUSYWAIT)
if (ret <= 0 || verbose)
D("poll %s [0] ev %x %x rx %d@%d tx %d,"
" [1] ev %x %x rx %d@%d tx %d",