From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 495035A004E for ; Wed, 12 Jun 2024 00:11:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718143885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H1lJKSUxfHxsGNQ/q/fdju4FCIYSfzNQ5PEfZsOIcN8=; b=gjUsCoZSAzmNq6CY3SpSGGhSFofwCKALhnj8Cz9O7lu5rYbPRBURXP/PYh1XOSPAQXLcmC yd7NahCq16V3TLzCiVqQ/dro2/X5hoN7H3JBV4e0f23140P15rqyQ+3akB32XNFRwEyAqa lVF9GRraa8i9wP6/hGzIUpWLHWVFxfo= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-Z6deN1Y2PqS1JZab8iSERw-1; Tue, 11 Jun 2024 18:11:23 -0400 X-MC-Unique: Z6deN1Y2PqS1JZab8iSERw-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6b077edfd2fso32583586d6.3 for ; Tue, 11 Jun 2024 15:11:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718143883; x=1718748683; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=H1lJKSUxfHxsGNQ/q/fdju4FCIYSfzNQ5PEfZsOIcN8=; b=S5JWqHjRiaJFt0F9fLFs59QYFmJs3BNqjpYgqBBFuQ/x4kO6XCL2Q2208lMm4D9OF6 ok4Tf+nG+g43/MnG0NZ/3UTOLt67R7BGZvY40DOSA/ZRmehjgu5ziUZaKEKWvK9180YP alaKJ+KkyHtlGXr72idnhz0eJIvVZj83pt7wiiqehXJKH+TbWGLTkMdBizMU4Z6gMuX1 yrbnMaStLvCtctixqJ/Lm/lbxfgLZQR44FCANWl2LBWwsiRiKnWcdEuMGpAG6Mf0GGeV 3IK1Vntv5A6e7mHn334JHGslmF+8U/Nl3UJAae8lZAW6ue01st2gYNVSXWSspyOXbpdK DN0A== X-Gm-Message-State: AOJu0Ywfj4fdtzXokIflzOPYCV+QkbzFfvyc+4c7eCS9s9pDBBXusjgn +L02oPb/LS0bP/fuMVUgjLMvPnqb2zMACwUtX9jneV2dxhdAbvo/vIUUlRa6DzTlgMtXgHzPIYv sxvCZ5UtUfMTnBWDHsCSEsdLi142s1imkLy4C5x1M92aEjF08YA== X-Received: by 2002:a05:6214:5912:b0:6b0:724a:6ed9 with SMTP id 6a1803df08f44-6b0724a70f9mr124912346d6.17.1718143882827; Tue, 11 Jun 2024 15:11:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsnf/xTueuFrhpN4H9rtEy6wFmMROaGD6fQWaWZAUw6lWMZOR7O/ZuYCGsHlBZt9+tiEbeOw== X-Received: by 2002:a05:6214:5912:b0:6b0:724a:6ed9 with SMTP id 6a1803df08f44-6b0724a70f9mr124911956d6.17.1718143882057; Tue, 11 Jun 2024 15:11:22 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b06519d521sm45331836d6.65.2024.06.11.15.11.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2024 15:11:21 -0700 (PDT) Date: Wed, 12 Jun 2024 00:10:46 +0200 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v5 6/8] vhost-user: compare mode MODE_PASTA and not MODE_PASST Message-ID: <20240612001046.45f06b01@elisabeth> In-Reply-To: <20240605152129.1641658-7-lvivier@redhat.com> References: <20240605152129.1641658-1-lvivier@redhat.com> <20240605152129.1641658-7-lvivier@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: NNTI5KCBVNLJN33RA7MQA2TTPZMDEZQH X-Message-ID-Hash: NNTI5KCBVNLJN33RA7MQA2TTPZMDEZQH X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 5 Jun 2024 17:21:27 +0200 Laurent Vivier wrote: > As we are going to introduce the MODE_VU that will act like > the mode MODE_PASST, compare to MODE_PASTA rather than to add > a comparison to MODE_VU when we check for MODE_PASST. > > Signed-off-by: Laurent Vivier > Reviewed-by: David Gibson > --- > conf.c | 14 +++++++------- > isolation.c | 10 +++++----- > passt.c | 2 +- > tap.c | 12 ++++++------ > tcp_buf.c | 2 +- > udp.c | 2 +- > 6 files changed, 21 insertions(+), 21 deletions(-) > > diff --git a/conf.c b/conf.c > index 50383a392f8d..b9d189ff4d26 100644 > --- a/conf.c > +++ b/conf.c > @@ -147,7 +147,7 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg, > if (fwd->mode) > goto mode_conflict; > > - if (c->mode != MODE_PASST) > + if (c->mode == MODE_PASTA) > die("'all' port forwarding is only allowed for passt"); > > fwd->mode = FWD_ALL; > @@ -1120,7 +1120,7 @@ static void conf_ugid(char *runas, uid_t *uid, gid_t *gid) > */ > static void conf_open_files(struct ctx *c) > { > - if (c->mode == MODE_PASST && c->fd_tap == -1) > + if (c->mode != MODE_PASTA && c->fd_tap == -1) > c->fd_tap_listen = tap_sock_unix_open(c->sock_path); > > c->pidfile_fd = pidfile_open(c->pidfile); > @@ -1261,7 +1261,7 @@ void conf(struct ctx *c, int argc, char **argv) > c->no_dhcp_dns = 0; > break; > case 6: > - if (c->mode != MODE_PASST) > + if (c->mode == MODE_PASTA) > die("--no-dhcp-dns is for passt mode only"); > > c->no_dhcp_dns = 1; > @@ -1273,7 +1273,7 @@ void conf(struct ctx *c, int argc, char **argv) > c->no_dhcp_dns_search = 0; > break; > case 8: > - if (c->mode != MODE_PASST) > + if (c->mode == MODE_PASTA) > die("--no-dhcp-search is for passt mode only"); > > c->no_dhcp_dns_search = 1; > @@ -1328,7 +1328,7 @@ void conf(struct ctx *c, int argc, char **argv) > break; > case 14: > fprintf(stdout, > - c->mode == MODE_PASST ? "passt " : "pasta "); > + c->mode == MODE_PASTA ? "pasta " : "passt "); > fprintf(stdout, VERSION_BLOB); > exit(EXIT_SUCCESS); > case 15: > @@ -1631,7 +1631,7 @@ void conf(struct ctx *c, int argc, char **argv) > v6_only = true; > break; > case '1': > - if (c->mode != MODE_PASST) > + if (c->mode == MODE_PASTA) > die("--one-off is for passt mode only"); > > if (c->one_off) > @@ -1678,7 +1678,7 @@ void conf(struct ctx *c, int argc, char **argv) > conf_ugid(runas, &uid, &gid); > > if (logfile) { > - logfile_init(c->mode == MODE_PASST ? "passt" : "pasta", > + logfile_init(c->mode == MODE_PASTA ? "pasta" : "passt", > logfile, logsize); > } > > diff --git a/isolation.c b/isolation.c > index f394e93b8526..ca2c68b52ec7 100644 > --- a/isolation.c > +++ b/isolation.c > @@ -312,7 +312,7 @@ int isolate_prefork(const struct ctx *c) > * PID namespace. For passt, use CLONE_NEWPID anyway, in case somebody > * ever gets around seccomp profiles -- there's no harm in passing it. > */ > - if (!c->foreground || c->mode == MODE_PASST) > + if (!c->foreground || c->mode != MODE_PASTA) > flags |= CLONE_NEWPID; > > if (unshare(flags)) { > @@ -379,12 +379,12 @@ void isolate_postfork(const struct ctx *c) > > prctl(PR_SET_DUMPABLE, 0); > > - if (c->mode == MODE_PASST) { > - prog.len = (unsigned short)ARRAY_SIZE(filter_passt); > - prog.filter = filter_passt; > - } else { > + if (c->mode == MODE_PASTA) { > prog.len = (unsigned short)ARRAY_SIZE(filter_pasta); > prog.filter = filter_pasta; > + } else { > + prog.len = (unsigned short)ARRAY_SIZE(filter_passt); > + prog.filter = filter_passt; > } > > if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) || > diff --git a/passt.c b/passt.c > index 69a59f1e9b6d..b02a0df17347 100644 > --- a/passt.c > +++ b/passt.c > @@ -333,7 +333,7 @@ loop: > uint32_t eventmask = events[i].events; > > trace("%s: epoll event on %s %i (events: 0x%08x)", > - c.mode == MODE_PASST ? "passt" : "pasta", > + c.mode == MODE_PASTA ? "pasta" : "passt", > EPOLL_TYPE_STR(ref.type), ref.fd, eventmask); > > switch (ref.type) { > diff --git a/tap.c b/tap.c > index 5fb3cb83f3d2..887cb7a279a9 100644 > --- a/tap.c > +++ b/tap.c > @@ -416,10 +416,10 @@ size_t tap_send_frames(const struct ctx *c, const struct iovec *iov, > if (!nframes) > return 0; > > - if (c->mode == MODE_PASST) > - m = tap_send_frames_passt(c, iov, bufs_per_frame, nframes); > - else > + if (c->mode == MODE_PASTA) > m = tap_send_frames_pasta(c, iov, bufs_per_frame, nframes); > + else > + m = tap_send_frames_passt(c, iov, bufs_per_frame, nframes); > > if (m < nframes) > debug("tap: failed to send %zu frames of %zu", > @@ -1332,7 +1332,9 @@ void tap_sock_init(struct ctx *c) > return; > } > > - if (c->mode == MODE_PASST) { > + if (c->mode == MODE_PASTA) > + tap_sock_tun_init(c); > + else { For consistency: if the else clause has curly brackets, then the main clause should have them as well. > tap_sock_unix_init(c); > > /* In passt mode, we don't know the guest's MAC address until it > @@ -1340,7 +1342,5 @@ void tap_sock_init(struct ctx *c) > * first packets will reach it. > */ > memset(&c->mac_guest, 0xff, sizeof(c->mac_guest)); > - } else { > - tap_sock_tun_init(c); > } > } > diff --git a/tcp_buf.c b/tcp_buf.c > index 89e19f598cc0..4175c4219215 100644 > --- a/tcp_buf.c > +++ b/tcp_buf.c > @@ -35,7 +35,7 @@ > > #define TCP_FRAMES_MEM 128 > #define TCP_FRAMES \ > - (c->mode == MODE_PASST ? TCP_FRAMES_MEM : 1) > + (c->mode == MODE_PASTA ? 1 : TCP_FRAMES_MEM) > > /** > * tcp_buf_seq_update - Sequences to update with length of frames once sent > diff --git a/udp.c b/udp.c > index a13013901e26..def3d57a6183 100644 > --- a/udp.c > +++ b/udp.c > @@ -748,7 +748,7 @@ void udp_buf_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t eve > * whether we'll use tap or splice, always go one at a time > * for pasta mode. > */ > - ssize_t n = (c->mode == MODE_PASST ? UDP_MAX_FRAMES : 1); > + ssize_t n = (c->mode == MODE_PASTA ? 1 : UDP_MAX_FRAMES); > in_port_t dstport = ref.udp.port; > bool v6 = ref.udp.v6; > struct mmsghdr *mmh_recv; The rest of the series looks good to me. -- Stefano