From 6b4e68383c66bd8a3863d9a708bae583d18dc056 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 17 Nov 2022 18:49:34 +0000 Subject: passt, tap: Add --fd option This passes a fully connected stream socket to passt. Signed-off-by: Richard W.M. Jones [sbrivio: reuse fd_tap instead of adding a new descriptor, imply --one-off on --fd, add to optstring and usage()] Signed-off-by: Stefano Brivio --- tap.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tap.c') diff --git a/tap.c b/tap.c index 5a20b75..2cfd82b 100644 --- a/tap.c +++ b/tap.c @@ -1069,6 +1069,15 @@ void tap_sock_init(struct ctx *c) } if (c->fd_tap != -1) { + if (c->one_off) { /* Passed as --fd */ + struct epoll_event ev = { 0 }; + + ev.data.fd = c->fd_tap; + ev.events = EPOLLIN | EPOLLET | EPOLLRDHUP; + epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev); + return; + } + epoll_ctl(c->epollfd, EPOLL_CTL_DEL, c->fd_tap, NULL); close(c->fd_tap); c->fd_tap = -1; -- cgit v1.2.3