* [PATCH 1/2] tap: Use a common function to start a new connection
@ 2024-12-09 16:54 Laurent Vivier
2024-12-09 16:54 ` [PATCH 2/2] tap: Call vu_init() with --fd Laurent Vivier
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Laurent Vivier @ 2024-12-09 16:54 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
Merge code from tap_backend_init(), tap_sock_tun_init() and
tap_listen_handler() to set epoll_ref entry and to add it
to epollfd.
No functionality change
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
tap.c | 66 +++++++++++++++++++++++++++--------------------------------
1 file changed, 30 insertions(+), 36 deletions(-)
diff --git a/tap.c b/tap.c
index c4180643bd0a..b2d30456e8dc 100644
--- a/tap.c
+++ b/tap.c
@@ -1255,6 +1255,33 @@ static void tap_sock_unix_init(const struct ctx *c)
epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap_listen, &ev);
}
+/**
+ * tap_start_connection() - start a new connection
+ * @c: Execution context
+ */
+static void tap_start_connection(const struct ctx *c)
+{
+ struct epoll_event ev = { 0 };
+ union epoll_ref ref = { 0 };
+
+ ref.fd = c->fd_tap;
+ switch (c->mode) {
+ case MODE_PASST:
+ ref.type = EPOLL_TYPE_TAP_PASST;
+ break;
+ case MODE_PASTA:
+ ref.type = EPOLL_TYPE_TAP_PASTA;
+ break;
+ case MODE_VU:
+ ref.type = EPOLL_TYPE_VHOST_CMD;
+ break;
+ }
+
+ ev.events = EPOLLIN | EPOLLRDHUP;
+ ev.data.u64 = ref.u64;
+ epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
+}
+
/**
* tap_listen_handler() - Handle new connection on listening socket
* @c: Execution context
@@ -1262,8 +1289,6 @@ static void tap_sock_unix_init(const struct ctx *c)
*/
void tap_listen_handler(struct ctx *c, uint32_t events)
{
- struct epoll_event ev = { 0 };
- union epoll_ref ref = { 0 };
int v = INT_MAX / 2;
struct ucred ucred;
socklen_t len;
@@ -1302,14 +1327,7 @@ void tap_listen_handler(struct ctx *c, uint32_t events)
setsockopt(c->fd_tap, SOL_SOCKET, SO_SNDBUF, &v, sizeof(v)))
trace("tap: failed to set SO_SNDBUF to %i", v);
- ref.fd = c->fd_tap;
- if (c->mode == MODE_VU)
- ref.type = EPOLL_TYPE_VHOST_CMD;
- else
- ref.type = EPOLL_TYPE_TAP_PASST;
- ev.events = EPOLLIN | EPOLLRDHUP;
- ev.data.u64 = ref.u64;
- epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
+ tap_start_connection(c);
}
/**
@@ -1353,19 +1371,13 @@ static int tap_ns_tun(void *arg)
*/
static void tap_sock_tun_init(struct ctx *c)
{
- union epoll_ref ref = { .type = EPOLL_TYPE_TAP_PASTA };
- struct epoll_event ev = { 0 };
-
NS_CALL(tap_ns_tun, c);
if (c->fd_tap == -1)
die("Failed to set up tap device in namespace");
pasta_ns_conf(c);
- ref.fd = c->fd_tap;
- ev.events = EPOLLIN | EPOLLRDHUP;
- ev.data.u64 = ref.u64;
- epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
+ tap_start_connection(c);
}
/**
@@ -1399,26 +1411,8 @@ void tap_backend_init(struct ctx *c)
tap_sock_update_pool(pkt_buf, sizeof(pkt_buf));
if (c->fd_tap != -1) { /* Passed as --fd */
- struct epoll_event ev = { 0 };
- union epoll_ref ref;
-
ASSERT(c->one_off);
- ref.fd = c->fd_tap;
- switch (c->mode) {
- case MODE_PASST:
- ref.type = EPOLL_TYPE_TAP_PASST;
- break;
- case MODE_PASTA:
- ref.type = EPOLL_TYPE_TAP_PASTA;
- break;
- case MODE_VU:
- ref.type = EPOLL_TYPE_VHOST_CMD;
- break;
- }
-
- ev.events = EPOLLIN | EPOLLRDHUP;
- ev.data.u64 = ref.u64;
- epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
+ tap_start_connection(c);
return;
}
--
@@ -1255,6 +1255,33 @@ static void tap_sock_unix_init(const struct ctx *c)
epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap_listen, &ev);
}
+/**
+ * tap_start_connection() - start a new connection
+ * @c: Execution context
+ */
+static void tap_start_connection(const struct ctx *c)
+{
+ struct epoll_event ev = { 0 };
+ union epoll_ref ref = { 0 };
+
+ ref.fd = c->fd_tap;
+ switch (c->mode) {
+ case MODE_PASST:
+ ref.type = EPOLL_TYPE_TAP_PASST;
+ break;
+ case MODE_PASTA:
+ ref.type = EPOLL_TYPE_TAP_PASTA;
+ break;
+ case MODE_VU:
+ ref.type = EPOLL_TYPE_VHOST_CMD;
+ break;
+ }
+
+ ev.events = EPOLLIN | EPOLLRDHUP;
+ ev.data.u64 = ref.u64;
+ epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
+}
+
/**
* tap_listen_handler() - Handle new connection on listening socket
* @c: Execution context
@@ -1262,8 +1289,6 @@ static void tap_sock_unix_init(const struct ctx *c)
*/
void tap_listen_handler(struct ctx *c, uint32_t events)
{
- struct epoll_event ev = { 0 };
- union epoll_ref ref = { 0 };
int v = INT_MAX / 2;
struct ucred ucred;
socklen_t len;
@@ -1302,14 +1327,7 @@ void tap_listen_handler(struct ctx *c, uint32_t events)
setsockopt(c->fd_tap, SOL_SOCKET, SO_SNDBUF, &v, sizeof(v)))
trace("tap: failed to set SO_SNDBUF to %i", v);
- ref.fd = c->fd_tap;
- if (c->mode == MODE_VU)
- ref.type = EPOLL_TYPE_VHOST_CMD;
- else
- ref.type = EPOLL_TYPE_TAP_PASST;
- ev.events = EPOLLIN | EPOLLRDHUP;
- ev.data.u64 = ref.u64;
- epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
+ tap_start_connection(c);
}
/**
@@ -1353,19 +1371,13 @@ static int tap_ns_tun(void *arg)
*/
static void tap_sock_tun_init(struct ctx *c)
{
- union epoll_ref ref = { .type = EPOLL_TYPE_TAP_PASTA };
- struct epoll_event ev = { 0 };
-
NS_CALL(tap_ns_tun, c);
if (c->fd_tap == -1)
die("Failed to set up tap device in namespace");
pasta_ns_conf(c);
- ref.fd = c->fd_tap;
- ev.events = EPOLLIN | EPOLLRDHUP;
- ev.data.u64 = ref.u64;
- epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
+ tap_start_connection(c);
}
/**
@@ -1399,26 +1411,8 @@ void tap_backend_init(struct ctx *c)
tap_sock_update_pool(pkt_buf, sizeof(pkt_buf));
if (c->fd_tap != -1) { /* Passed as --fd */
- struct epoll_event ev = { 0 };
- union epoll_ref ref;
-
ASSERT(c->one_off);
- ref.fd = c->fd_tap;
- switch (c->mode) {
- case MODE_PASST:
- ref.type = EPOLL_TYPE_TAP_PASST;
- break;
- case MODE_PASTA:
- ref.type = EPOLL_TYPE_TAP_PASTA;
- break;
- case MODE_VU:
- ref.type = EPOLL_TYPE_VHOST_CMD;
- break;
- }
-
- ev.events = EPOLLIN | EPOLLRDHUP;
- ev.data.u64 = ref.u64;
- epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
+ tap_start_connection(c);
return;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] tap: Call vu_init() with --fd
2024-12-09 16:54 [PATCH 1/2] tap: Use a common function to start a new connection Laurent Vivier
@ 2024-12-09 16:54 ` Laurent Vivier
2024-12-10 1:17 ` David Gibson
2024-12-10 14:36 ` Stefano Brivio
2024-12-10 1:13 ` [PATCH 1/2] tap: Use a common function to start a new connection David Gibson
` (2 subsequent siblings)
3 siblings, 2 replies; 7+ messages in thread
From: Laurent Vivier @ 2024-12-09 16:54 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
We need to initialize vhost-user structures with --fd too.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
tap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tap.c b/tap.c
index b2d30456e8dc..cd32a901e534 100644
--- a/tap.c
+++ b/tap.c
@@ -1405,10 +1405,12 @@ void tap_sock_update_pool(void *base, size_t size)
*/
void tap_backend_init(struct ctx *c)
{
- if (c->mode == MODE_VU)
+ if (c->mode == MODE_VU) {
tap_sock_update_pool(NULL, 0);
- else
+ vu_init(c);
+ } else {
tap_sock_update_pool(pkt_buf, sizeof(pkt_buf));
+ }
if (c->fd_tap != -1) { /* Passed as --fd */
ASSERT(c->one_off);
@@ -1421,8 +1423,6 @@ void tap_backend_init(struct ctx *c)
tap_sock_tun_init(c);
break;
case MODE_VU:
- vu_init(c);
- /* fall through */
case MODE_PASST:
tap_sock_unix_init(c);
--
@@ -1405,10 +1405,12 @@ void tap_sock_update_pool(void *base, size_t size)
*/
void tap_backend_init(struct ctx *c)
{
- if (c->mode == MODE_VU)
+ if (c->mode == MODE_VU) {
tap_sock_update_pool(NULL, 0);
- else
+ vu_init(c);
+ } else {
tap_sock_update_pool(pkt_buf, sizeof(pkt_buf));
+ }
if (c->fd_tap != -1) { /* Passed as --fd */
ASSERT(c->one_off);
@@ -1421,8 +1423,6 @@ void tap_backend_init(struct ctx *c)
tap_sock_tun_init(c);
break;
case MODE_VU:
- vu_init(c);
- /* fall through */
case MODE_PASST:
tap_sock_unix_init(c);
--
2.47.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] tap: Call vu_init() with --fd
2024-12-09 16:54 ` [PATCH 2/2] tap: Call vu_init() with --fd Laurent Vivier
@ 2024-12-10 1:17 ` David Gibson
2024-12-10 14:36 ` Stefano Brivio
1 sibling, 0 replies; 7+ messages in thread
From: David Gibson @ 2024-12-10 1:17 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]
On Mon, Dec 09, 2024 at 05:54:50PM +0100, Laurent Vivier wrote:
> We need to initialize vhost-user structures with --fd too.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tap.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tap.c b/tap.c
> index b2d30456e8dc..cd32a901e534 100644
> --- a/tap.c
> +++ b/tap.c
> @@ -1405,10 +1405,12 @@ void tap_sock_update_pool(void *base, size_t size)
> */
> void tap_backend_init(struct ctx *c)
> {
> - if (c->mode == MODE_VU)
> + if (c->mode == MODE_VU) {
> tap_sock_update_pool(NULL, 0);
> - else
> + vu_init(c);
> + } else {
> tap_sock_update_pool(pkt_buf, sizeof(pkt_buf));
> + }
>
> if (c->fd_tap != -1) { /* Passed as --fd */
> ASSERT(c->one_off);
> @@ -1421,8 +1423,6 @@ void tap_backend_init(struct ctx *c)
> tap_sock_tun_init(c);
> break;
> case MODE_VU:
> - vu_init(c);
> - /* fall through */
> case MODE_PASST:
> tap_sock_unix_init(c);
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] tap: Call vu_init() with --fd
2024-12-09 16:54 ` [PATCH 2/2] tap: Call vu_init() with --fd Laurent Vivier
2024-12-10 1:17 ` David Gibson
@ 2024-12-10 14:36 ` Stefano Brivio
1 sibling, 0 replies; 7+ messages in thread
From: Stefano Brivio @ 2024-12-10 14:36 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev, David Gibson
On Mon, 9 Dec 2024 17:54:50 +0100
Laurent Vivier <lvivier@redhat.com> wrote:
> We need to initialize vhost-user structures with --fd too.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> tap.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Applied.
--
Stefano
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] tap: Use a common function to start a new connection
2024-12-09 16:54 [PATCH 1/2] tap: Use a common function to start a new connection Laurent Vivier
2024-12-09 16:54 ` [PATCH 2/2] tap: Call vu_init() with --fd Laurent Vivier
@ 2024-12-10 1:13 ` David Gibson
2024-12-10 14:36 ` Stefano Brivio
2024-12-10 14:36 ` Stefano Brivio
3 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2024-12-10 1:13 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 3849 bytes --]
On Mon, Dec 09, 2024 at 05:54:49PM +0100, Laurent Vivier wrote:
> Merge code from tap_backend_init(), tap_sock_tun_init() and
> tap_listen_handler() to set epoll_ref entry and to add it
> to epollfd.
>
> No functionality change
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tap.c | 66 +++++++++++++++++++++++++++--------------------------------
> 1 file changed, 30 insertions(+), 36 deletions(-)
>
> diff --git a/tap.c b/tap.c
> index c4180643bd0a..b2d30456e8dc 100644
> --- a/tap.c
> +++ b/tap.c
> @@ -1255,6 +1255,33 @@ static void tap_sock_unix_init(const struct ctx *c)
> epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap_listen, &ev);
> }
>
> +/**
> + * tap_start_connection() - start a new connection
> + * @c: Execution context
> + */
> +static void tap_start_connection(const struct ctx *c)
> +{
> + struct epoll_event ev = { 0 };
> + union epoll_ref ref = { 0 };
> +
> + ref.fd = c->fd_tap;
> + switch (c->mode) {
> + case MODE_PASST:
> + ref.type = EPOLL_TYPE_TAP_PASST;
> + break;
> + case MODE_PASTA:
> + ref.type = EPOLL_TYPE_TAP_PASTA;
> + break;
> + case MODE_VU:
> + ref.type = EPOLL_TYPE_VHOST_CMD;
> + break;
> + }
> +
> + ev.events = EPOLLIN | EPOLLRDHUP;
> + ev.data.u64 = ref.u64;
> + epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
> +}
> +
> /**
> * tap_listen_handler() - Handle new connection on listening socket
> * @c: Execution context
> @@ -1262,8 +1289,6 @@ static void tap_sock_unix_init(const struct ctx *c)
> */
> void tap_listen_handler(struct ctx *c, uint32_t events)
> {
> - struct epoll_event ev = { 0 };
> - union epoll_ref ref = { 0 };
> int v = INT_MAX / 2;
> struct ucred ucred;
> socklen_t len;
> @@ -1302,14 +1327,7 @@ void tap_listen_handler(struct ctx *c, uint32_t events)
> setsockopt(c->fd_tap, SOL_SOCKET, SO_SNDBUF, &v, sizeof(v)))
> trace("tap: failed to set SO_SNDBUF to %i", v);
>
> - ref.fd = c->fd_tap;
> - if (c->mode == MODE_VU)
> - ref.type = EPOLL_TYPE_VHOST_CMD;
> - else
> - ref.type = EPOLL_TYPE_TAP_PASST;
> - ev.events = EPOLLIN | EPOLLRDHUP;
> - ev.data.u64 = ref.u64;
> - epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
> + tap_start_connection(c);
> }
>
> /**
> @@ -1353,19 +1371,13 @@ static int tap_ns_tun(void *arg)
> */
> static void tap_sock_tun_init(struct ctx *c)
> {
> - union epoll_ref ref = { .type = EPOLL_TYPE_TAP_PASTA };
> - struct epoll_event ev = { 0 };
> -
> NS_CALL(tap_ns_tun, c);
> if (c->fd_tap == -1)
> die("Failed to set up tap device in namespace");
>
> pasta_ns_conf(c);
>
> - ref.fd = c->fd_tap;
> - ev.events = EPOLLIN | EPOLLRDHUP;
> - ev.data.u64 = ref.u64;
> - epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
> + tap_start_connection(c);
> }
>
> /**
> @@ -1399,26 +1411,8 @@ void tap_backend_init(struct ctx *c)
> tap_sock_update_pool(pkt_buf, sizeof(pkt_buf));
>
> if (c->fd_tap != -1) { /* Passed as --fd */
> - struct epoll_event ev = { 0 };
> - union epoll_ref ref;
> -
> ASSERT(c->one_off);
> - ref.fd = c->fd_tap;
> - switch (c->mode) {
> - case MODE_PASST:
> - ref.type = EPOLL_TYPE_TAP_PASST;
> - break;
> - case MODE_PASTA:
> - ref.type = EPOLL_TYPE_TAP_PASTA;
> - break;
> - case MODE_VU:
> - ref.type = EPOLL_TYPE_VHOST_CMD;
> - break;
> - }
> -
> - ev.events = EPOLLIN | EPOLLRDHUP;
> - ev.data.u64 = ref.u64;
> - epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
> + tap_start_connection(c);
> return;
> }
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] tap: Use a common function to start a new connection
2024-12-09 16:54 [PATCH 1/2] tap: Use a common function to start a new connection Laurent Vivier
2024-12-09 16:54 ` [PATCH 2/2] tap: Call vu_init() with --fd Laurent Vivier
2024-12-10 1:13 ` [PATCH 1/2] tap: Use a common function to start a new connection David Gibson
@ 2024-12-10 14:36 ` Stefano Brivio
2024-12-10 14:36 ` Stefano Brivio
3 siblings, 0 replies; 7+ messages in thread
From: Stefano Brivio @ 2024-12-10 14:36 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev, David Gibson
On Mon, 9 Dec 2024 17:54:49 +0100
Laurent Vivier <lvivier@redhat.com> wrote:
> Merge code from tap_backend_init(), tap_sock_tun_init() and
> tap_listen_handler() to set epoll_ref entry and to add it
> to epollfd.
>
> No functionality change
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> tap.c | 66 +++++++++++++++++++++++++++--------------------------------
> 1 file changed, 30 insertions(+), 36 deletions(-)
>
> diff --git a/tap.c b/tap.c
> index c4180643bd0a..b2d30456e8dc 100644
> --- a/tap.c
> +++ b/tap.c
> @@ -1255,6 +1255,33 @@ static void tap_sock_unix_init(const struct ctx *c)
> epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap_listen, &ev);
> }
>
> +/**
> + * tap_start_connection() - start a new connection
> + * @c: Execution context
> + */
> +static void tap_start_connection(const struct ctx *c)
> +{
> + struct epoll_event ev = { 0 };
> + union epoll_ref ref = { 0 };
> +
> + ref.fd = c->fd_tap;
> + switch (c->mode) {
> + case MODE_PASST:
> + ref.type = EPOLL_TYPE_TAP_PASST;
> + break;
> + case MODE_PASTA:
> + ref.type = EPOLL_TYPE_TAP_PASTA;
> + break;
> + case MODE_VU:
> + ref.type = EPOLL_TYPE_VHOST_CMD;
> + break;
> + }
> +
> + ev.events = EPOLLIN | EPOLLRDHUP;
> + ev.data.u64 = ref.u64;
> + epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
> +}
> +
> /**
> * tap_listen_handler() - Handle new connection on listening socket
> * @c: Execution context
> @@ -1262,8 +1289,6 @@ static void tap_sock_unix_init(const struct ctx *c)
> */
> void tap_listen_handler(struct ctx *c, uint32_t events)
> {
> - struct epoll_event ev = { 0 };
> - union epoll_ref ref = { 0 };
> int v = INT_MAX / 2;
> struct ucred ucred;
> socklen_t len;
> @@ -1302,14 +1327,7 @@ void tap_listen_handler(struct ctx *c, uint32_t events)
> setsockopt(c->fd_tap, SOL_SOCKET, SO_SNDBUF, &v, sizeof(v)))
> trace("tap: failed to set SO_SNDBUF to %i", v);
>
> - ref.fd = c->fd_tap;
> - if (c->mode == MODE_VU)
> - ref.type = EPOLL_TYPE_VHOST_CMD;
> - else
> - ref.type = EPOLL_TYPE_TAP_PASST;
> - ev.events = EPOLLIN | EPOLLRDHUP;
> - ev.data.u64 = ref.u64;
> - epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
> + tap_start_connection(c);
> }
>
> /**
> @@ -1353,19 +1371,13 @@ static int tap_ns_tun(void *arg)
> */
> static void tap_sock_tun_init(struct ctx *c)
> {
> - union epoll_ref ref = { .type = EPOLL_TYPE_TAP_PASTA };
> - struct epoll_event ev = { 0 };
> -
> NS_CALL(tap_ns_tun, c);
> if (c->fd_tap == -1)
> die("Failed to set up tap device in namespace");
>
> pasta_ns_conf(c);
>
> - ref.fd = c->fd_tap;
> - ev.events = EPOLLIN | EPOLLRDHUP;
> - ev.data.u64 = ref.u64;
> - epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
> + tap_start_connection(c);
> }
>
> /**
> @@ -1399,26 +1411,8 @@ void tap_backend_init(struct ctx *c)
> tap_sock_update_pool(pkt_buf, sizeof(pkt_buf));
>
> if (c->fd_tap != -1) { /* Passed as --fd */
> - struct epoll_event ev = { 0 };
> - union epoll_ref ref;
> -
> ASSERT(c->one_off);
> - ref.fd = c->fd_tap;
> - switch (c->mode) {
> - case MODE_PASST:
> - ref.type = EPOLL_TYPE_TAP_PASST;
> - break;
> - case MODE_PASTA:
> - ref.type = EPOLL_TYPE_TAP_PASTA;
> - break;
> - case MODE_VU:
> - ref.type = EPOLL_TYPE_VHOST_CMD;
> - break;
> - }
> -
> - ev.events = EPOLLIN | EPOLLRDHUP;
> - ev.data.u64 = ref.u64;
> - epoll_ctl(c->epollfd, EPOLL_CTL_ADD, c->fd_tap, &ev);
> + tap_start_connection(c);
> return;
> }
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] tap: Use a common function to start a new connection
2024-12-09 16:54 [PATCH 1/2] tap: Use a common function to start a new connection Laurent Vivier
` (2 preceding siblings ...)
2024-12-10 14:36 ` Stefano Brivio
@ 2024-12-10 14:36 ` Stefano Brivio
3 siblings, 0 replies; 7+ messages in thread
From: Stefano Brivio @ 2024-12-10 14:36 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev, David Gibson
[Sorry for the previous "dummy" reply]
On Mon, 9 Dec 2024 17:54:49 +0100
Laurent Vivier <lvivier@redhat.com> wrote:
> Merge code from tap_backend_init(), tap_sock_tun_init() and
> tap_listen_handler() to set epoll_ref entry and to add it
> to epollfd.
>
> No functionality change
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> tap.c | 66 +++++++++++++++++++++++++++--------------------------------
> 1 file changed, 30 insertions(+), 36 deletions(-)
Applied.
--
Stefano
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-12-10 14:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-09 16:54 [PATCH 1/2] tap: Use a common function to start a new connection Laurent Vivier
2024-12-09 16:54 ` [PATCH 2/2] tap: Call vu_init() with --fd Laurent Vivier
2024-12-10 1:17 ` David Gibson
2024-12-10 14:36 ` Stefano Brivio
2024-12-10 1:13 ` [PATCH 1/2] tap: Use a common function to start a new connection David Gibson
2024-12-10 14:36 ` Stefano Brivio
2024-12-10 14:36 ` Stefano Brivio
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).