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=K7l3sDK/; 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 D33135A0265 for ; Thu, 02 Jul 2026 01:12:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782947525; 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=ZloDQlkyKho1LwoWzxgsJAt/f7NBlV3VOmF+xoSKU78=; b=K7l3sDK/u7KGcxcA8iqTrwvSkynpUhqSv/gqoFE9e9Co7SF3wdh6aaNiSH/sqwmz+pLB9C 3blAgSyfstkv0GttRhBEFe2PBDbmOc1kJ+MG+CCAlsDPU/OCMNCEpIr2jER4RV+tR58bIv sSfONCeMHfmmfJ56TDt/NzvzC4V17MA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-feejoV63Nam7YszY9cMgsQ-1; Wed, 01 Jul 2026 19:12:04 -0400 X-MC-Unique: feejoV63Nam7YszY9cMgsQ-1 X-Mimecast-MFC-AGG-ID: feejoV63Nam7YszY9cMgsQ_1782947523 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4924725bec9so9528645e9.1 for ; Wed, 01 Jul 2026 16:12:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782947523; x=1783552323; h=date:content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZloDQlkyKho1LwoWzxgsJAt/f7NBlV3VOmF+xoSKU78=; b=JYM2WpWLrQXTEoqeHO9Q3ht4ecsmxCdzclC2mSB+uvKm3oHK0neBamSqv4JY7AsQv1 ge1LvFTZd2b/YiE6sQ8kqyVlmQZN2pSSc1z5DaGh1yaFwGVaHS/CZe18RGRqhMCG1MV0 1wgXHYMMj8q26qrKzjEGA1Cj5x+7Ur+CRBEjLgPoE55xU42nW8ztE03QpKtr0rzfPwtq yB7y/gkET9pG+TbA5EBKivkqfAC1Ew5aWuiSDAhiq9Poq3OFEUMsUDtOFsd/kYYAFy7F yH7F+LBUAyend7Cv1pThr5xjlYtTffpMYiaJWpOhT5t7JXTWECv3h/xY9v6W1OYoIaGp K4zg== X-Gm-Message-State: AOJu0YwaXjHMYr9NNPmvpwbFPafSW2mHN1+W5uahHXSJ/o2jdfAW6XW8 1nNbNllUHQBYSk5l75RdsX2VuAXM+51VtDh0CGvShFazsCW0gSvTtev2LuPBRFDppis3h6vlWYi SO0VoRc+D0pFDcE+cVRrPklMeBBw4k8AC9e3yKR/vEUunp5y4T+Nrfx0OUKg3mw== X-Gm-Gg: AfdE7cnnNNGGeAtLg2E5DpIDXFuPpYdFuVcobJMpLqHErV3S5J44OxQTp0jMV7p4cGR WjXWEzc4147K1e1sYAIJKJ6y99K4MIf0H/DLJIEcBOdf57hVy1BYNLg8YIpS0GCwJebyhe3SI+K 0/GvTzygMV9akyv7LUJCDmVYUlXrcQZ3d/YBUZri+nVwOrZrNIkdIMBpDaYHeCibPqOfygm2ouS DSoBrlowooM0xZl+jFEQYobFrBSftSbFm6mAqOb1y/kfH/OyQdxBh3z8RYoeTy8ITyqBKejI37l vhn19AhP7sQQg+0tRk3W/K552/Adb3Eb2gKNhES+nfR+ul1ZWnsHbEfeVQwY2DDtP7+/HYQCfeb F4t7DmTHo1g7doxc9cd6U71ziYLWtCk3PUu9uCgE= X-Received: by 2002:a05:600c:1912:b0:492:4c2e:9613 with SMTP id 5b1f17b1804b1-493c2b9050dmr48292205e9.18.1782947523183; Wed, 01 Jul 2026 16:12:03 -0700 (PDT) X-Received: by 2002:a05:600c:1912:b0:492:4c2e:9613 with SMTP id 5b1f17b1804b1-493c2b9050dmr48291815e9.18.1782947522597; Wed, 01 Jul 2026 16:12:02 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493c58ec9d9sm8184635e9.1.2026.07.01.16.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 16:12:01 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 13/13] fwd_rule: Rewrite forward rule parsing using parse.c helpers Message-ID: <20260702011159.0aed0531@elisabeth> In-Reply-To: <20260701053155.1219264-14-david@gibson.dropbear.id.au> References: <20260701053155.1219264-1-david@gibson.dropbear.id.au> <20260701053155.1219264-14-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Thu, 02 Jul 2026 01:12:00 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YRUXhD_GGBCztpXN51ZHJAQV0Sd2Ea4zHzxAHKF2s6U_1782947523 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 7FWD5L64VDH2OQJ377V3V4HSQEZBWQNE X-Message-ID-Hash: 7FWD5L64VDH2OQJ377V3V4HSQEZBWQNE 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 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, 1 Jul 2026 15:31:55 +1000 David Gibson wrote: > +++ b/parse.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > > #include "common.h" > #include "parse.h" > @@ -213,3 +214,31 @@ bool parse_inany_(const char **cursor, union inany_addr *addr, > > return false; > } > + > +/** > + * parse_ifspec() - Parse a interface name specifier (starting with %) > + * @ifname: On success updated with parsed name (must have IFNAMSIZ space) > + * > + * This will accept a missing specifier (empty string), setting ifname to "" > + */ > +bool parse_ifspec(const char **cursor, char *ifname) > +{ > + const char *p = *cursor; > + size_t len; > + > + if (!parse_literal(&p, "%")) { > + /* No interface specifier */ > + ifname[0] = '\0'; > + return true; > + } > + > + /* ifnames can have anything that's not '/', '.' or whitespace */ > + len = strcspn(p, "/. \f\n\r\t\v"); I was about to apply the series when I spotted this: '.' is definitely valid in interface names, and even commonly used (think of VLANs), it's just "." and ".." _as an interface name_ that are not supported. If we forbid any interface name with '.' we might very well break somebody's use case. I can fix this up with: /* ifnames can't contain /, :, or whitespace */ len = strcspn(p, "/: \f\n\r\t\v"); if (!len || len >= IFNAMSIZ) return false; /* ...and they can't be '..' or '.' either */ if (!strcmp(p, ".") || !strcmp(p, "..")) return false; if you're fine with it. > + if (!len || len >= IFNAMSIZ) > + return false; > + > + memcpy(ifname, p, len); > + ifname[len] = '\0'; > + *cursor = p + len; > + return true; > +} > diff --git a/parse.h b/parse.h > index ab1d5adb..257b9c58 100644 > --- a/parse.h > +++ b/parse.h > @@ -32,4 +32,6 @@ bool parse_inany_(const char **cursor, union inany_addr *addr, > > #define parse_inany(cursor, addr) parse_inany_((cursor), (addr), NULL) > > +bool parse_ifspec(const char **cursor, char *ifname); > + > #endif /* _PARSE_H */ -- Stefano