From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=f6ki2+/s; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 7E0D35A0619 for ; Mon, 04 May 2026 16:34:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777905285; 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:autocrypt:autocrypt; bh=43oPRwerj9SwsOFjM7AlzEprdexY119Vo9IYMdI8iOo=; b=f6ki2+/svXQzT/kztauLlqmVD3fSe4oVpfRmLvKTOql6WJhd6kysF4Lz7MtMiVkb881xqI Kx3cGTKWh20sJoAYFUhsstdYYq/EIo/9VoK8Pfhw6vWIK0/rR4xOND5GyGNG9zugVgfX1P Xl3CXA0yIWkDIwofYKyhZnvPrIlOlM8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-310-spb2yJUsM_u6tY1WiP1uOg-1; Mon, 04 May 2026 10:34:44 -0400 X-MC-Unique: spb2yJUsM_u6tY1WiP1uOg-1 X-Mimecast-MFC-AGG-ID: spb2yJUsM_u6tY1WiP1uOg_1777905283 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-44f1b4d0fb0so430278f8f.1 for ; Mon, 04 May 2026 07:34:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777905283; x=1778510083; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=43oPRwerj9SwsOFjM7AlzEprdexY119Vo9IYMdI8iOo=; b=Xhpr/72CDdOl3HqpfgTgXF8Em54wVdE5JJGj0ScHuvdbbpTUcH1yzEw4AmAnPGcSY0 RG6BNeqeVgOCFz8kTipbFkvB0jRBk4FEA7OLtgGSnq3FPVpBN/X2cXsXgoiRIU4xG7em 5QliGeP6c2GGJ7ZAT0Y7RGPH7GOIMzuOpXXXnlSBW4llWt+VgBHbC8ZOGN3Tcem9lKcq rKD4RWUdSVMCfE572MJwCEDPUOd6K+SdQmq+CkSxbQ0RQEstojm5rMKM/PyfbCT33ImR swtMKLaE9ZnuvWt9tcqR0ToH3R/QbdvRchv56hODVb9aeraV7mtaulx6oJ36j8PHJJ2N aS2g== X-Forwarded-Encrypted: i=1; AFNElJ9nBMWp81Le0PLZ2BUHrWDUyJJrhIk9a6rfZCbPwMyQHMrauLURJepo4xFLyA88ICWLec5WKZpiCMk=@passt.top X-Gm-Message-State: AOJu0YzgUUpvzbYiI5WedJew7aobStP9pAWcVFsbUwA/wY84nGr5CvOW uuj7yTDbz58gW9mXBJ6ZvFgLmSnphuYwzNMHS5mHEv4LqehMeanXgvZ7laRo3r/fUL3gAuPa6PB 9YYGb1SjaIKw5TGEZ8SEBRwWY4tapCVGgs3FvGHMXcf8qzftEhQmi7Q== X-Gm-Gg: AeBDieslRbtoDMgOYevW1Pcm2kE/p78OD7NfQ78lmAdVxzggxeWtdE/CUz9msarZtxY SNlKe81ej67B4mH6Sk4pxd3t40eFB3i1yYNipg5ks607zSG++uYhjurnPgLKvbim3T3WdLEj9fw mbLuC304zzDUCVa0Co3WTLIyBnRchouV+rTZArz/R8Kq9ImpFh3mZWpCaUjJzAOqsYbLpkQRPX9 42shVBOD/967TtkqW5j2MpYZdhqq1qetbBexMRzlqncG+5dqgftXgrqLTj6j4PtHr4IK//V7Omv SBQsQ5x/WXWlyhoJltF75DSpPdB/6CqWXkGD27P20WvYbnopkhq2NNer07ouxmLFrYnEssUCbhK 1Ber1ju3HTu4pYi3XJ1o3hjsbOuBNV3hVZwXjoBh5mUuSXUr4B8IfKMnwoTh0HWaKYA== X-Received: by 2002:a05:600c:4e4d:b0:488:af7f:7707 with SMTP id 5b1f17b1804b1-48a98663189mr186135525e9.18.1777905282645; Mon, 04 May 2026 07:34:42 -0700 (PDT) X-Received: by 2002:a05:600c:4e4d:b0:488:af7f:7707 with SMTP id 5b1f17b1804b1-48a98663189mr186134625e9.18.1777905282167; Mon, 04 May 2026 07:34:42 -0700 (PDT) Received: from [192.168.100.100] (82-64-211-94.subs.proxad.net. [82.64.211.94]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a8eb75fe8sm283094935e9.8.2026.05.04.07.34.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 May 2026 07:34:41 -0700 (PDT) Message-ID: <536c86d4-b040-4661-9436-38694681c4c2@redhat.com> Date: Mon, 4 May 2026 16:34:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 11/18] pesto: Expose list of pifs to pesto and optionally display To: Stefano Brivio , passt-dev@passt.top References: <20260503215601.823029-1-sbrivio@redhat.com> <20260503215601.823029-12-sbrivio@redhat.com> From: Laurent Vivier Autocrypt: addr=lvivier@redhat.com; keydata= xsFNBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQ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keoGRGb8j4XjVpL8+2x OhXKrM1fzzb8JtAuSbuzZSQPDwQEI5CKKxp7zf76J21YeRrEW4WDznPyVcDTa+tz++q2S/Bp P4W98bXCBIuQgs2m+OflERv5c3Ojldp04/S4NEjXEYRWdiCxN7ca5iPml5gLtuvhJMSy36gl U6IW9kn30IWuSoBpTkgV7rLUEhh9Ms82VWW/h2TxL8enfx40PrfbDtWwqRID3WY8jLrjKfTd R3LW8BnUDNkG+c4FzvvGUs8AvuqxxyHbXAfDx9o/jXfPHVRmJVhSmd+hC3mcQ+4iX5bBPBPM oDqSoLt5w9GoQQ6gDVP2ZjTWqwSRMLzNr37rJjZ1pt0DCMMTbiYIUcrhX8eveCJtY7NGWNyx FCRkhxRuGcpwPmRVDwOl39MB3iTsRighiMnijkbLXiKoJ5CDVvX5yicNqYJPKh5MFXN1bvsB kmYiStMRbrD0HoY1kx5/VozBtc70OU0EB8Wrv9hZD+Ofp0T3KOr1RUHvCZoLURfFhSQ= In-Reply-To: <20260503215601.823029-12-sbrivio@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zmwQH8xw3siyE-YgCAaLNfIRhKkqk5ZarrbPYzzkbhA_1777905283 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: AXGU22N676NS252CYAWSTU7V6ODDCDJG X-Message-ID-Hash: AXGU22N676NS252CYAWSTU7V6ODDCDJG X-MailFrom: lvivier@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: Jon Maloy , 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 5/3/26 23:55, Stefano Brivio wrote: > From: David Gibson > > Extend the dynamic update protocol to expose the pif indices and names > from a running passt/pasta to the pesto tool. pesto records that data > and, if requested with a new --show flag, prints it out. There is no --show flag > > Signed-off-by: David Gibson > [sbrivio: In read_pif_conf(), force a redundant termination of the > interface name, the existing check isn't obvious enough for static > checkers] > [sbrivio: Drop @resv_ left-over in description of struct > pesto_pif_info, reported by Jon Maloy] > Signed-off-by: Stefano Brivio Reviewed-by: Laurent Vivier But I've noticed 3 minor cosmetic flaws below. > --- > Makefile | 1 + > common.h | 2 + > conf.c | 41 ++++++++++++++++ > pesto.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > pesto.h | 18 ++++++- > pif.h | 4 +- > serialise.c | 4 ++ > serialise.h | 1 + > util.h | 2 - > 9 files changed, 201 insertions(+), 6 deletions(-) > > diff --git a/Makefile b/Makefile > index 1718ddb..6da76b4 100644 > --- a/Makefile > +++ b/Makefile > @@ -223,6 +223,7 @@ cppcheck: passt.cppcheck passt-repair.cppcheck pesto.cppcheck qrap.cppcheck > $(CPPCHECK) $(CPPCHECK_FLAGS) $(BASE_CPPFLAGS) $^ > > passt.cppcheck: BASE_CPPFLAGS += -UPESTO > +passt.cppcheck: CPPCHECK_FLAGS += --suppress=unusedFunction:serialise.c > passt.cppcheck: $(PASST_SRCS) $(PASST_HEADERS) seccomp.h > > passt-repair.cppcheck: $(PASST_REPAIR_SRCS) $(PASST_REPAIR_HEADERS) seccomp_repair.h > diff --git a/common.h b/common.h > index 2f2e6f1..45f66ea 100644 > --- a/common.h > +++ b/common.h > @@ -53,4 +53,6 @@ static inline const char *strerror_(int errnum) > > #define strerror(x) @ "Don't call strerror() directly, use strerror_() instead" > > +#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0]))) > + > #endif /* _COMMON_H */ > diff --git a/conf.c b/conf.c > index 823e08d..3b2fe42 100644 > --- a/conf.c > +++ b/conf.c > @@ -1925,6 +1925,43 @@ void conf(struct ctx *c, int argc, char **argv) > > static void conf_accept(struct ctx *c); > > +/** > + * conf_send_rules() - Send current forwarding rules to config client (pesto) > + * @c: Execution context > + * @fd: Socket to the client > + * > + * Return: 0 on success, -1 on failure > + * > + * FIXME: So far only sends pif ids and names > + */ > +static int conf_send_rules(const struct ctx *c, int fd) > +{ > + unsigned pif; > + > + for (pif = 0; pif < PIF_NUM_TYPES; pif++) { > + struct pesto_pif_info info; > + int rc; > + > + if (!c->fwd[pif]) > + continue; > + > + assert(pif != PIF_NONE); > + > + rc = snprintf(info.name, sizeof(info.name), "%s", pif_name(pif)); > + assert(rc >= 0 && (size_t)rc < sizeof(info.name)); > + > + if (write_u8(fd, pif) < 0) > + return -1; > + if (write_all_buf(fd, &info, sizeof(info)) < 0) > + return -1; > + } > + > + if (write_u8(fd, PIF_NONE) < 0) > + return -1; > + > + return 0; > +} > + > /** > * conf_close() - Close configuration / control socket and clean up > * @c: Execution context > @@ -1968,6 +2005,7 @@ static void conf_accept(struct ctx *c) > struct pesto_hello hello = { > .magic = PESTO_SERVER_MAGIC, > .version = htonl(PESTO_PROTOCOL_VERSION), > + .pif_name_size = htonl(PIF_NAME_SIZE), > }; > union epoll_ref ref = { .type = EPOLL_TYPE_CONF }; > struct ucred uc = { 0 }; > @@ -2009,6 +2047,9 @@ retry: > "Warning: Using experimental unsupported configuration protocol"); > } > > + if (conf_send_rules(c, fd) < 0) > + goto fail; > + > return; > > fail: > diff --git a/pesto.c b/pesto.c > index 762cfe9..77244b3 100644 > --- a/pesto.c > +++ b/pesto.c > @@ -60,6 +60,127 @@ static void usage(const char *name, FILE *f, int status) > exit(status); > } > > +/* Maximum number of pifs with rule tables */ > +#define MAX_PIFS 3 > + > +struct pif_configuration { > + uint8_t pif; > + char name[PIF_NAME_SIZE]; > +}; > + > +struct configuration { > + uint32_t npifs; > + struct pif_configuration pif[MAX_PIFS]; > +}; > + > +/** > + * pif_conf_by_num() - Find a pif's configuration by pif id > + * @conf: Configuration description > + * @pif: pif id > + * > + * Return: pointer to the pif_configuration for @pif, or NULL if not found > + */ > +static struct pif_configuration *pif_conf_by_num(struct configuration *conf, > + uint8_t pif) > +{ > + unsigned i; > + > + for (i = 0; i < conf->npifs; i++) { > + if (conf->pif[i].pif == pif) > + return &conf->pif[i]; > + } > + > + return NULL; > +} > + > +/** > + * pif_conf_by_name() - Find a pif's configuration by name > + * @conf: Configuration description > + * @name: Interface name > + * > + * Return: pif_configuration for pif named @name, or NULL if not found > + */ > +static struct pif_configuration *pif_conf_by_name(struct configuration *conf, > + const char *name) > +{ > + unsigned i; > + > + for (i = 0; i < conf->npifs; i++) { > + if (strcmp(conf->pif[i].name, name) == 0) > + return &conf->pif[i]; > + } > + > + return NULL; > +} > + > +/** > + * pesto_read_rules() - Read rulestate from passt/pasta > + * @fd: Control socket > + * @conf: Configuration description to update > + */ > +static bool read_pif_conf(int fd, struct configuration *conf) > +{ > + struct pif_configuration *pc; > + struct pesto_pif_info info; > + uint8_t pif; > + > + if (read_u8(fd, &pif) < 0) > + die("Error reading from control socket"); > + > + if (pif == PIF_NONE) > + return false; > + > + debug("Receiving config for PIF %"PRIu8, pif); > + > + if (conf->npifs >= ARRAY_SIZE(conf->pif)) { > + die("passt has more pifs than pesto can manage (max %d)", > + ARRAY_SIZE(conf->pif)); > + } > + > + pc = &conf->pif[conf->npifs]; > + pc->pif = pif; > + > + if (read_all_buf(fd, &info, sizeof(info)) < 0) > + die("Error reading from control socket"); > + > + if (info.name[sizeof(info.name)-1]) > + die("Interface name was not NULL terminated"); > + /* Redundant, to make static checkers happy */ > + info.name[sizeof(info.name) - 1] = '\0'; > + > + static_assert(sizeof(info.name) == sizeof(pc->name), > + "Mismatching pif name lengths"); > + memcpy(pc->name, info.name, sizeof(pc->name)); > + > + debug("PIF %"PRIu8": %s", pc->pif, pc->name); > + > + /* O(n^2), but n is bounded by MAX_PIFS */ > + if (pif_conf_by_num(conf, pc->pif)) > + die("Received duplicate interface identifier"); > + > + /* O(n^2), but n is bounded by MAX_PIFS */ > + if (pif_conf_by_name(conf, pc->name)) > + die("Received duplicate interface name"); > + > + conf->npifs++; > + return true; > +} > + > +/** > + * show_conf() - Show current configuration obtained from passt/pasta > + * @conf: Configuration description > + */ > +static void show_conf(const struct configuration *conf) > +{ > + unsigned i; > + > + for (i = 0; i < conf->npifs; i++) { > + const struct pif_configuration *pc = &conf->pif[i]; > + printf(" %s\n", pc->name); > + printf(" TBD\n"); > + } > +} > + > /** > * main() - Dynamic reconfiguration client main program > * @argc: Argument count > @@ -80,6 +201,7 @@ int main(int argc, char **argv) > { 0 }, > }; > struct sockaddr_un a = { AF_UNIX, "" }; > + struct configuration conf = { 0 }; > const char *optstring = "dh"; > struct pesto_hello hello; > struct sock_fprog prog; > @@ -162,6 +284,18 @@ int main(int argc, char **argv) > "Warning: Using experimental protocol version, client and server must match\n"); > } > > + if (ntohl(hello.pif_name_size) != PIF_NAME_SIZE) { > + die("Server has unexpected pif name size (%" > + PRIu32" not %"PRIu32"\n", trailing '\n' > + ntohl(hello.pif_name_size), PIF_NAME_SIZE); > + } > + > + while (read_pif_conf(s, &conf)) > + ; > + > + printf("passt/pasta configuration (%s)\n", a.sun_path); > + show_conf(&conf); > + > if (shutdown(s, SHUT_RDWR) < 0 || close(s) < 0) > die_perror("Error shutting down control socket"); > > diff --git a/pesto.h b/pesto.h > index 92d4df3..1879759 100644 > --- a/pesto.h > +++ b/pesto.h > @@ -17,18 +17,32 @@ > /* Version 0 is reserved for unreleased / unsupported experimental versions */ > #define PESTO_PROTOCOL_VERSION 0 > > +/* Maxmimum size of a pif name, including \0 */ Typo copied from pif.h, should be "Maximum" > +#define PIF_NAME_SIZE (128) > +#define PIF_NONE 0 > + > /** > * struct pesto_hello - Server introduction message > - * @magic: PESTO_SERVER_MAGIC > - * @version: Version number > + * @magic: PESTO_SERVER_MAGIC > + * @version: Version number > + * @pif_name_size: Server's value for PIF_NAME_SIZE > */ > struct pesto_hello { > char magic[8]; > uint32_t version; > + uint32_t pif_name_size; > } __attribute__ ((__packed__)); > > static_assert(sizeof(PESTO_SERVER_MAGIC) > == sizeof(((struct pesto_hello *)0)->magic), > "PESTO_SERVER_MAGIC has wrong size"); > > +/** > + * struct pesto_pif_info - Message with basic metadata about a pif > + * @name: Name (\0 terminated) > + */ > +struct pesto_pif_info { > + char name[PIF_NAME_SIZE]; > +} __attribute__ ((__packed__)); > + > #endif /* PESTO_H */ > diff --git a/pif.h b/pif.h > index 90dd3a3..d770860 100644 > --- a/pif.h > +++ b/pif.h > @@ -11,6 +11,7 @@ > > #include > > +#include "pesto.h" > #include "epoll_type.h" > > union inany_addr; > @@ -24,7 +25,7 @@ union sockaddr_inany; > */ > enum pif_type { > /* Invalid or not present pif */ > - PIF_NONE = 0, > + PIF_NONE_ = PIF_NONE, > /* Host socket interface */ > PIF_HOST, > /* Qemu socket or namespace tuntap interface */ > @@ -36,7 +37,6 @@ enum pif_type { > }; > > /* Maxmimum size of a pif name, including \0 */ Perhaps you could remove the above comment too? > -#define PIF_NAME_SIZE (128) > extern const char pif_type_str[][PIF_NAME_SIZE]; > > static inline const char *pif_type(enum pif_type pt) > diff --git a/serialise.c b/serialise.c > index 346df99..e083112 100644 > --- a/serialise.c > +++ b/serialise.c > @@ -121,6 +121,10 @@ int write_all_buf(int fd, const void *buf, size_t len) > return write_all_buf(fd, &beval, sizeof(beval)); \ > } > > +#define be8toh(x) (x) > +#define htobe8(x) (x) > + > +SERIALISE_UINT(8) > SERIALISE_UINT(32) > > #undef SERIALISE_UINT > diff --git a/serialise.h b/serialise.h > index a88f3de..4714f4c 100644 > --- a/serialise.h > +++ b/serialise.h > @@ -16,6 +16,7 @@ int write_all_buf(int fd, const void *buf, size_t len); > int read_u##bits(int fd, uint##bits##_t *val); \ > int write_u##bits(int fd, uint##bits##_t val); > > +SERIALISE_UINT_DECL(8) > SERIALISE_UINT_DECL(32) > > #endif /* SERIALISE_H */ > diff --git a/util.h b/util.h > index e90be47..c788382 100644 > --- a/util.h > +++ b/util.h > @@ -87,8 +87,6 @@ void abort_with_msg(const char *fmt, ...) > #define V6 1 > #define IP_VERSIONS 2 > > -#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0]))) > - > #define foreach(item, array) \ > for ((item) = (array); (item) - (array) < ARRAY_SIZE(array); (item)++) >