From: Laurent Vivier <lvivier@redhat.com>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: Jon Maloy <jmaloy@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v9 08/23] pesto: Introduce stub configuration tool
Date: Wed, 6 May 2026 12:44:38 +0200 [thread overview]
Message-ID: <ce89c4a1-1fc7-4eb9-bcbb-56103cd14d69@redhat.com> (raw)
In-Reply-To: <20260506092241.1607480-9-sbrivio@redhat.com>
On 5/6/26 11:22, Stefano Brivio wrote:
> From: David Gibson <david@gibson.dropbear.id.au>
>
> Build a new "pesto" binary, which will become the tool to update a running
> passt/pasta's configuration. For now, we just build a stub binary which
> sets up a basic environment, parses trivial command line options but does
> nothing else.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> [sbrivio: Dropped leading _ from comment to include guard endif,
> reported by Laurent]
> [sbrivio: Formatting changes in pesto.1: use 80 columns instead of
> wrapping at about 75. Add description for -d, -h, --version.]
> [sbrivio: Drop note from man page about pesto being experimental,
> we're shipping it so that people can actually use it]
> [sbrivio: Fix conflicts in the Makefile as I'm not applying the
> previous series reworking it]
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
> ---
> .gitignore | 2 +
> Makefile | 25 ++++++----
> common.h | 24 ++++++++++
> pesto.1 | 59 ++++++++++++++++++++++++
> pesto.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> pesto.h | 12 +++++
> util.h | 12 +----
> 7 files changed, 246 insertions(+), 20 deletions(-)
> create mode 100644 common.h
> create mode 100644 pesto.1
> create mode 100644 pesto.c
> create mode 100644 pesto.h
>
> diff --git a/.gitignore b/.gitignore
> index 3c16adc..3e40d9f 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -4,9 +4,11 @@
> /pasta
> /pasta.avx2
> /passt-repair
> +/pesto
> /qrap
> /pasta.1
> /seccomp.h
> +/seccomp_pesto.h
> /seccomp_repair.h
> /c*.json
> README.plain.md
> diff --git a/Makefile b/Makefile
> index f697c12..76b9b5c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -45,17 +45,18 @@ PASST_SRCS = arch.c arp.c bitmap.c checksum.c conf.c dhcp.c dhcpv6.c \
> vhost_user.c virtio.c vu_common.c
> QRAP_SRCS = qrap.c
> PASST_REPAIR_SRCS = passt-repair.c
> -SRCS = $(PASST_SRCS) $(QRAP_SRCS) $(PASST_REPAIR_SRCS)
> +PESTO_SRCS = pesto.c
> +SRCS = $(PASST_SRCS) $(QRAP_SRCS) $(PASST_REPAIR_SRCS) $(PESTO_SRCS)
>
> -MANPAGES = passt.1 pasta.1 qrap.1 passt-repair.1
> +MANPAGES = passt.1 pasta.1 pesto.1 qrap.1 passt-repair.1
>
> PASST_HEADERS = arch.h arp.h bitmap.h checksum.h conf.h dhcp.h dhcpv6.h \
> epoll_ctl.h flow.h fwd.h fwd_rule.h flow_table.h icmp.h icmp_flow.h \
> inany.h iov.h ip.h isolation.h lineread.h log.h migrate.h ndp.h \
> - netlink.h packet.h passt.h pasta.h pcap.h pif.h repair.h serialise.h \
> - siphash.h tap.h tcp.h tcp_buf.h tcp_conn.h tcp_internal.h tcp_splice.h \
> - tcp_vu.h udp.h udp_flow.h udp_internal.h udp_vu.h util.h vhost_user.h \
> - virtio.h vu_common.h
> + netlink.h packet.h passt.h pasta.h pesto.h pcap.h pif.h repair.h \
> + serialise.h siphash.h tap.h tcp.h tcp_buf.h tcp_conn.h tcp_internal.h \
> + tcp_splice.h tcp_vu.h udp.h udp_flow.h udp_internal.h udp_vu.h util.h \
> + vhost_user.h virtio.h vu_common.h
> HEADERS = $(PASST_HEADERS) seccomp.h
>
> C := \#include <sys/random.h>\nint main(){int a=getrandom(0, 0, 0);}
> @@ -76,9 +77,9 @@ mandir ?= $(datarootdir)/man
> man1dir ?= $(mandir)/man1
>
> ifeq ($(TARGET_ARCH),x86_64)
> -BIN := passt passt.avx2 pasta pasta.avx2 qrap passt-repair
> +BIN := passt passt.avx2 pasta pasta.avx2 qrap passt-repair pesto
> else
> -BIN := passt pasta qrap passt-repair
> +BIN := passt pasta qrap passt-repair pesto
> endif
>
> all: $(BIN) $(MANPAGES) docs
> @@ -92,6 +93,9 @@ seccomp.h: seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
> seccomp_repair.h: seccomp.sh $(PASST_REPAIR_SRCS)
> @ ARCH="$(TARGET_ARCH)" CC="$(CC)" ./seccomp.sh seccomp_repair.h $(PASST_REPAIR_SRCS)
>
> +seccomp_pesto.h: seccomp.sh $(PESTO_SRCS)
> + @ ARCH="$(TARGET_ARCH)" CC="$(CC)" ./seccomp.sh seccomp_pesto.h $(PESTO_SRCS)
> +
> passt: $(PASST_SRCS) $(HEADERS)
> $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(PASST_SRCS) -o passt $(LDFLAGS)
>
> @@ -111,6 +115,9 @@ qrap: $(QRAP_SRCS) passt.h
> passt-repair: $(PASST_REPAIR_SRCS) seccomp_repair.h
> $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(PASST_REPAIR_SRCS) -o passt-repair $(LDFLAGS)
>
> +pesto: $(PESTO_SRCS) $(PESTO_HEADERS) seccomp_pesto.h
> + $(CC) $(FLAGS) $(CFLAGS) $(CPPFLAGS) $(PESTO_SRCS) -o pesto $(LDFLAGS)
> +
> valgrind: EXTRA_SYSCALLS += rt_sigprocmask rt_sigtimedwait rt_sigaction \
> rt_sigreturn getpid gettid kill clock_gettime \
> mmap|mmap2 munmap open unlink gettimeofday futex \
> @@ -120,7 +127,7 @@ valgrind: all
>
> .PHONY: clean
> clean:
> - $(RM) $(BIN) *~ *.o seccomp.h seccomp_repair.h pasta.1 \
> + $(RM) $(BIN) *~ *.o seccomp.h seccomp_repair.h seccomp_pesto.h pasta.1 \
> passt.tar passt.tar.gz *.deb *.rpm \
> passt.pid README.plain.md
>
> diff --git a/common.h b/common.h
> new file mode 100644
> index 0000000..f3506b4
> --- /dev/null
> +++ b/common.h
> @@ -0,0 +1,24 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later
> + * Copyright Red Hat
> + * Author: David Gibson <david@gibson.dropbear.id.au>
> + *
> + * Definitions used by both passt/pasta and other tools
> + */
> +
> +#ifndef COMMON_H
> +#define COMMON_H
> +
> +#include <string.h>
> +
> +#define VERSION_BLOB \
> + VERSION "\n" \
> + "Copyright Red Hat\n" \
> + "GNU General Public License, version 2 or later\n" \
> + " <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n" \
> + "This is free software: you are free to change and redistribute it.\n" \
> + "There is NO WARRANTY, to the extent permitted by law.\n\n"
> +
> +/* FPRINTF() intentionally silences cert-err33-c clang-tidy warnings */
> +#define FPRINTF(f, ...) (void)fprintf(f, __VA_ARGS__)
> +
> +#endif /* COMMON_H */
> diff --git a/pesto.1 b/pesto.1
> new file mode 100644
> index 0000000..9f54362
> --- /dev/null
> +++ b/pesto.1
> @@ -0,0 +1,59 @@
> +.\" SPDX-License-Identifier: GPL-2.0-or-later
> +.\" Copyright Red Hat
> +.\" Author: David Gibson <david@gibson.dropbear.id.au>
> +.TH pesto 1
> +
> +.SH NAME
> +.B pesto
> +\- Configure a running \fBpasst\fR(1) or \fBpasta\fR(1) instance.
> +
> +.SH SYNOPSIS
> +.B pesto
> +[\fIOPTION\fR]... \fIPATH\fR
> +
> +.SH DESCRIPTION
> +
> +.B pesto
> +is a client to view and update the port forwarding configuration of a running
> +\fBpasst\fR(1) or \fBpasta\fR(1) instance.
> +
> +\fIPATH\fR gives the path to the UNIX domain socket created by \fBpasst\fR or
> +\fBpasta\fR. It should match the \fB-c\fR command line option given to that
> +instance.
> +
> +.SH OPTIONS
> +
> +.TP
> +.BR \-d ", " \-\-debug
> +Be verbose.
> +
> +.TP
> +.BR \-h ", " \-\-help
> +Display a help message and exit.
> +
> +.TP
> +.BR \-\-version
> +Show version and exit.
> +
> +.SH AUTHORS
> +
> +Stefano Brivio <sbrivio@redhat.com>,
> +David Gibson <david@gibson.dropbear.id.au>.
> +
> +.SH REPORTING BUGS
> +
> +Please report issues on the bug tracker at https://bugs.passt.top/, or send a
> +message to the passt-user@passt.top mailing list, see https://lists.passt.top/.
> +
> +.SH COPYRIGHT
> +
> +Copyright Red Hat
> +
> +\fBpesto\fR is free software: you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation, either version 2 of the License, or (at
> +your option) any later version.
> +
> +.SH SEE ALSO
> +
> +\fBpasst\fR(1), \fBpasta\fR(1), \fBunix\fR(7).
> diff --git a/pesto.c b/pesto.c
> new file mode 100644
> index 0000000..9f2fa5d
> --- /dev/null
> +++ b/pesto.c
> @@ -0,0 +1,132 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +/* PESTO - Programmable Extensible Socket Translation Orchestrator
> + * front-end for passt(1) and pasta(1) forwarding configuration
> + *
> + * pesto.c - Main program (it's not actually extensible)
> + *
> + * Copyright (c) 2026 Red Hat GmbH
> + * Author: Stefano Brivio <sbrivio@redhat.com>
> + */
> +
> +#include <arpa/inet.h>
> +#include <sys/prctl.h>
> +#include <sys/types.h>
> +#include <sys/socket.h>
> +#include <sys/un.h>
> +#include <errno.h>
> +#include <getopt.h>
> +#include <inttypes.h>
> +#include <stdbool.h>
> +#include <stddef.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <limits.h>
> +#include <unistd.h>
> +
> +#include <linux/audit.h>
> +#include <linux/capability.h>
> +#include <linux/filter.h>
> +#include <linux/seccomp.h>
> +
> +#include "common.h"
> +#include "seccomp_pesto.h"
> +#include "pesto.h"
> +
> +static bool debug_flag = false;
> +
> +static char stdout_buf[BUFSIZ];
> +
> +#define die(...) \
> + do { \
> + FPRINTF(stderr, __VA_ARGS__); \
> + FPRINTF(stderr, "\n"); \
> + exit(EXIT_FAILURE); \
> + } while (0)
> +
> +/**
> + * usage() - Print usage, exit with given status code
> + * @name: Executable name
> + * @f: Stream to print usage info to
> + * @status: Status code for exit(2)
> + *
> + * #syscalls:pesto exit_group fstat write
> + */
> +static void usage(const char *name, FILE *f, int status)
> +{
> + FPRINTF(f, "Usage: %s [OPTION]... PATH\n", name);
> + FPRINTF(f,
> + "\n"
> + " -d, --debug Print debugging messages\n"
> + " -h, --help Display this help message and exit\n"
> + " --version Show version and exit\n");
> + exit(status);
> +}
> +
> +/**
> + * main() - Dynamic reconfiguration client main program
> + * @argc: Argument count
> + * @argv: Arguments: socket path, operation, port specifiers
> + *
> + * Return: 0 on success, won't return on failure
> + *
> + * #syscalls:pesto exit_group fstat read write
> + */
> +int main(int argc, char **argv)
> +{
> + const struct option options[] = {
> + {"debug", no_argument, NULL, 'd' },
> + {"help", no_argument, NULL, 'h' },
> + {"version", no_argument, NULL, 1 },
> + { 0 },
> + };
> + const char *optstring = "dh";
> + struct sock_fprog prog;
> + int optname;
> +
> + prctl(PR_SET_DUMPABLE, 0);
> +
> + prog.len = (unsigned short)sizeof(filter_pesto) /
> + sizeof(filter_pesto[0]);
> + prog.filter = filter_pesto;
> + if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) ||
> + prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog))
> + die("Failed to apply seccomp filter");
> +
> + /* Explicitly set stdout buffer, otherwise printf() might allocate,
> + * breaking our seccomp profile.
> + */
> + if (setvbuf(stdout, stdout_buf, _IOFBF, sizeof(stdout_buf)))
> + die("Failed to set stdout buffer");
> +
> + do {
> + optname = getopt_long(argc, argv, optstring, options, NULL);
> +
> + switch (optname) {
> + case -1:
> + case 0:
> + break;
> + case 'h':
> + usage(argv[0], stdout, EXIT_SUCCESS);
> + break;
> + case 'd':
> + debug_flag = true;
> + break;
> + case 1:
> + FPRINTF(stdout, "pesto ");
> + FPRINTF(stdout, VERSION_BLOB);
> + exit(EXIT_SUCCESS);
> + default:
> + usage(argv[0], stderr, EXIT_FAILURE);
> + }
> + } while (optname != -1);
> +
> + if (argc - optind != 1)
> + usage(argv[0], stderr, EXIT_FAILURE);
> +
> + printf("debug_flag=%d, path=\"%s\"\n", debug_flag, argv[optind]);
> +
> + die("pesto is not implemented yet");
> +}
> diff --git a/pesto.h b/pesto.h
> new file mode 100644
> index 0000000..e9b329f
> --- /dev/null
> +++ b/pesto.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later
> + * Copyright Red Hat
> + * Author: David Gibson <david@gibson.dropbear.id.au>
> + *
> + * Definitions and functions used by both client and server of the configuration
> + * update protocol (pesto).
> + */
> +
> +#ifndef PESTO_H
> +#define PESTO_H
> +
> +#endif /* PESTO_H */
> diff --git a/util.h b/util.h
> index 92aeabc..770ff93 100644
> --- a/util.h
> +++ b/util.h
> @@ -19,16 +19,9 @@
> #include <sys/syscall.h>
> #include <net/ethernet.h>
>
> +#include "common.h"
> #include "log.h"
>
> -#define VERSION_BLOB \
> - VERSION "\n" \
> - "Copyright Red Hat\n" \
> - "GNU General Public License, version 2 or later\n" \
> - " <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n" \
> - "This is free software: you are free to change and redistribute it.\n" \
> - "There is NO WARRANTY, to the extent permitted by law.\n\n"
> -
> #ifndef SECCOMP_RET_KILL_PROCESS
> #define SECCOMP_RET_KILL_PROCESS SECCOMP_RET_KILL
> #endif
> @@ -307,9 +300,6 @@ static inline bool mod_between(unsigned x, unsigned i, unsigned j, unsigned m)
> return mod_sub(x, i, m) < mod_sub(j, i, m);
> }
>
> -/* FPRINTF() intentionally silences cert-err33-c clang-tidy warnings */
> -#define FPRINTF(f, ...) (void)fprintf(f, __VA_ARGS__)
> -
> void raw_random(void *buf, size_t buflen);
>
> /*
next prev parent reply other threads:[~2026-05-06 10:44 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 9:22 [PATCH v9 00/23] Dynamic configuration update implementation Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 01/23] conf, fwd: Stricter rule checking in fwd_rule_add() Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 02/23] fwd_rule: Move ephemeral port probing to fwd_rule.c Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 03/23] fwd, conf: Move rule parsing code to fwd_rule.[ch] Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 04/23] fwd_rule: Move conflict checking back within fwd_rule_add() Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 05/23] fwd: Generalise fwd_rules_info() Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 06/23] pif: Limit pif names to 128 bytes Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 07/23] fwd_rule: Fix some format specifiers Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 08/23] pesto: Introduce stub configuration tool Stefano Brivio
2026-05-06 10:44 ` Laurent Vivier [this message]
2026-05-06 9:22 ` [PATCH v9 09/23] pesto, log: Share log.h (but not log.c) with pesto tool Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 10/23] pesto, conf: Have pesto connect to passt and check versions Stefano Brivio
2026-05-06 10:57 ` Laurent Vivier
2026-05-06 11:58 ` Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 11/23] pesto: Expose list of pifs to pesto and display them Stefano Brivio
2026-05-06 23:25 ` David Gibson
2026-05-06 9:22 ` [PATCH v9 12/23] ip: Prepare ip.[ch] for sharing with pesto tool Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 13/23] inany: Prepare inany.[ch] " Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 14/23] pesto: Read current ruleset from passt/pasta and optionally display it Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 15/23] pesto: Parse and add new rules from command line Stefano Brivio
2026-05-06 11:00 ` Laurent Vivier
2026-05-06 9:22 ` [PATCH v9 16/23] pesto, conf: Send updated rules from pesto back to passt/pasta Stefano Brivio
2026-05-06 11:19 ` Laurent Vivier
2026-05-06 9:22 ` [PATCH v9 17/23] conf, fwd: Allow switching to new rules received from pesto Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 18/23] fwd_rule: Fix static checkers warnings in fwd_rule_add() Stefano Brivio
2026-05-06 11:21 ` Laurent Vivier
2026-05-06 23:28 ` David Gibson
2026-05-06 9:22 ` [PATCH v9 19/23] pesto, conf, fwd_rule: Add options and modes to add, delete, clear rules Stefano Brivio
2026-05-06 11:43 ` Laurent Vivier
2026-05-06 12:07 ` Stefano Brivio
2026-05-06 12:27 ` Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 20/23] apparmor: Add policy file for pesto Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 21/23] selinux: Add file context and type enforcement " Stefano Brivio
2026-05-06 9:22 ` [PATCH v9 22/23] fedora: Install pesto, its SELinux policy, and the man page from the spec file Stefano Brivio
2026-05-06 12:12 ` Laurent Vivier
2026-05-06 9:22 ` [PATCH v9 23/23] hooks: Copy static build of pesto and related man page to server Stefano Brivio
2026-05-06 12:16 ` Laurent Vivier
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=ce89c4a1-1fc7-4eb9-bcbb-56103cd14d69@redhat.com \
--to=lvivier@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=jmaloy@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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.
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).