From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202606 header.b=Dy+FqZrc; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id E9B4E5A026E for ; Fri, 03 Jul 2026 05:54:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1783050892; bh=1IOBT0vTuYQW0oRR4MlewJc/bSCYkUcV/We55yOVZ5w=; h=From:To:Cc:Subject:Date:From; b=Dy+FqZrcXCGYSamIOZOpRlWs4jgIyrJIp0XJ/nZE78uVTnEJqP7LZi5VG86vTVGiu rCs4ekqSVywUWCIkmqTntJ440dfaxl1EtEz1nTf43uiXA+QxgdPcYsoRp8Y4NdLxGh //7HwzCJ3O6rALepauoCsz8dYNlwvtI7JlEEAxu6tB8bGfMIvwbndFlEefE13IheZ4 01nxQtrmmYBvwaJbWSZjt3liBOvwi+bRREf4KxKgTsE7AwjcImaKG8cJL6DU2MCyBy NSsY4rTpt8ikRUqcs4amp+v+US9+0mNJ23eLHR3AY1eVF8LUoUFV678b13f78FY7BQ y5dEH41q8oF8w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gs0JD1J0Jz4xSx; Fri, 03 Jul 2026 13:54:52 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v5 00/13] Rework option parsing in preparation for destination remapping Date: Fri, 3 Jul 2026 13:54:32 +1000 Message-ID: <20260703035445.888394-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.55.0 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: AIFIIKUSNERHUA6H37MWGVHH5OZ7YVWD X-Message-ID-Hash: AIFIIKUSNERHUA6H37MWGVHH5OZ7YVWD X-MailFrom: dgibson@gandalf.ozlabs.org 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: 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: This was... a bit of a nightmare. It took way too long and went down a bunch of blind alleys. I'm not sure how much I like the final result: it's pleasingly terse in some cases, but in others it feels dangerously subtle, requiring a pretty careful understanding of the sequencing rules of C's &&, || and , operators. That said, while I was at many points ready to pack it in and hack my around the problems limiting the parsing for destination remapping, I couldn't really think of feasible way to do that either. So, here we are. v5: * Improvements to manpages and usage in 12/13 * No other changes v4: * Update manpages and --help to reflect changes in 12/13 * No other changes v3: * Fixed validation of ifnames in 13/13. * No other changes. v2: * Numerous minor tweaks based on Stefano's feedback. * The "minor issues" aren't actually minor - they're hard to solve in C, remain. David Gibson (13): Makefile: Add missing PESTO_HEADERS variable conf: Use parameter instead of global in conf_nat() parse: Start splitting out parsing helpers conf: Remove duplicate parsing of -F option conf: Clean up conf_ip4_prefix() parse: Add helper to parse unsigned integer values parse: Move parse_port_range() to new parsing framework parse: Add helpers for parsing IP addresses conf: Move address configuration into helper function conf: Remove unnecessary mode checks from conf_addr() conf: Use new parsing tools to handle -a option fwd_rule: Allow "all" port specs to be combined with other options fwd_rule: Rewrite forward rule parsing using parse.c helpers Makefile | 22 +-- common.h | 3 + conf.c | 218 ++++++++++++++++------------- conf.h | 1 + fwd_rule.c | 400 ++++++++++++++++++++++++----------------------------- fwd_rule.h | 2 - inany.c | 70 +--------- inany.h | 3 - parse.c | 244 ++++++++++++++++++++++++++++++++ parse.h | 37 +++++ passt.1 | 35 +++-- util.c | 12 +- 12 files changed, 621 insertions(+), 426 deletions(-) create mode 100644 parse.c create mode 100644 parse.h -- 2.55.0