[{"id":3673188,"web_url":"http://patchwork.ozlabs.org/comment/3673188/","msgid":"<20260403155314.GC5449@celephais.dreamlands>","list_archive_url":null,"date":"2026-04-03T15:53:14","subject":"Re: [nft PATCH 0/2] A bit of non-constant binop follow-up","submitter":{"id":76155,"url":"http://patchwork.ozlabs.org/api/people/76155/","name":"Jeremy Sowden","email":"jeremy@azazel.net"},"content":"On 2026-04-02, at 20:43:18 +0200, Phil Sutter wrote:\n> When asked about how to translate ebtables' --arp-gratuitous match, I\n> noticed that basically everything is there already but the parser\n> rejects it.\n> \n> While we can't do a simple 'arp saddr ip == arp daddr ip' because cmp\n> expression requires for one side of the equation to be constant, using\n> XOR on LHS we can work around this limitation:\n> \n> arp saddr ip ^ arp daddr ip == 0.0.0.0\n> \n> Thanks to Jeremy's work on bitwise expression (which one might want to\n> repeat for cmp),\n\nI'll take a look. :)\n\nJ.\n\n> the above is possible in VM code:\n> \n> [ payload load 4b @ network header + 14 => reg 1 ]\n> [ payload load 4b @ network header + 24 => reg 2 ]\n> [ bitwise reg 1 = ( reg 1 ^ reg 2 ) ]\n> [ cmp eq reg 1 0x00000000 ]\n> \n> Patch 2 of this series relaxes the parser so it accepts the input.\n> Basically it undoes an old workaround needed before we introduced start\n> conditions.\n> \n> Patch 1 removes a similar restriction in JSON parser. It is needed at\n> least to accept the JSON equivalent of above match (conversion to JSON\n> on output was already correct).\n> \n> Phil Sutter (2):\n>   parser_json: Accept non-RHS expressions in binop RHS\n>   parser_bison: Accept non-constant binop on LHS of relationals\n> \n>  doc/payload-expression.txt        |  6 ++++\n>  src/parser_bison.y                | 16 +++++-----\n>  src/parser_json.c                 |  2 +-\n>  src/scanner.l                     |  2 +-\n>  tests/py/arp/arp.t                |  4 +++\n>  tests/py/arp/arp.t.json           | 51 +++++++++++++++++++++++++++++++\n>  tests/py/arp/arp.t.payload        | 14 +++++++++\n>  tests/py/arp/arp.t.payload.netdev | 18 +++++++++++\n>  8 files changed, 104 insertions(+), 9 deletions(-)\n> \n> -- \n> 2.51.0\n> \n>","headers":{"Return-Path":"\n <netfilter-devel+bounces-11610-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","netfilter-devel@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n secure) header.d=azazel.net header.i=@azazel.net header.a=rsa-sha256\n header.s=20220717 header.b=VmsJNkOm;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11610-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key)\n header.d=azazel.net header.i=@azazel.net header.b=\"VmsJNkOm\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=35.176.194.208","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=azazel.net","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=azazel.net"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fnNYf0PTzz1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 04 Apr 2026 02:53:41 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 0906F301E30B\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  3 Apr 2026 15:53:28 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id ECAA13C65E7;\n\tFri,  3 Apr 2026 15:53:26 +0000 (UTC)","from azazel.net (taras.nevrast.org [35.176.194.208])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A31D92E1EE7\n\tfor <netfilter-devel@vger.kernel.org>; Fri,  3 Apr 2026 15:53:23 +0000 (UTC)","from [2a00:23c8:a49f:6601:3e21:9cff:fe2f:35f]\n (helo=celephais.dreamlands)\n\tby taras.nevrast.org with esmtpsa  (TLS1.3) tls\n TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384\n\t(Exim 4.98.2)\n\t(envelope-from <jeremy@azazel.net>)\n\tid 1w8gpg-0000000EQCl-0BOi;\n\tFri, 03 Apr 2026 16:53:16 +0100"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775231606; cv=none;\n b=YQC9XJ7C8BTfd7nHnLKDMruOY/CV9jgNtkJ4xB5vnvG+y1gwQnfZE6ODIN+JSLn/Q6SzRnbp5K8aZik2YRPnW9+lsICpQRMyeQAcyEcsWfQ+4GXdkSP9hTCEcAFuAsaHYqQxy2MSQC5GrDQwrjSYLY0Dl7clC8PupSfhyY9Wm2I=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775231606; c=relaxed/simple;\n\tbh=MjwxJvLLYZ1f7y8bbBxb5If0oh2osKSI/g5eC8H6dpA=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=OtvH+RoF61laXjroVvnYxlzrCb8oiATsItfkV22zyhiLN/MPdGAHd3EHeWiBFHyyPy2kr46xBBz+PyPN/wzmbagSnle7pzryFknTkw4c7NE58KEfJQ0EC8kKYDeAkn+lQMrynpCbbQYPccGEP6jYolhhTijbHFoS7BDVkKevyKY=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=azazel.net;\n spf=pass smtp.mailfrom=azazel.net;\n dkim=pass (2048-bit key) header.d=azazel.net header.i=@azazel.net\n header.b=VmsJNkOm; arc=none smtp.client-ip=35.176.194.208","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=azazel.net;\n\ts=20220717; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:\n\tSubject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=+M+gW0XOLNwATkZmrQ+4KSPsn2vv7qSO6D49Wf/sWUg=; b=VmsJNkOmINObrKyHqXxBrE3mcm\n\tYJuE/2bTaFRsph67/doa/zz7W8kW0Jd2kWFUsugftiroRV/9cayfF7i9NAd8LNlzFAxs3gNR8oznH\n\tUlXTs5LvfLWk34j33bte5dbujI8eVQ/KLngP3jM+qVyUDhimIvVkvcqU7oemL38oM5Z9i1YHK5BIb\n\tYxoAt5tWxk6thFJiKNixP7DUQcrpjIPEoH+NkCxaMOAzdgac32vm0WyDI6r66LoAWTSNKr2eXAzCf\n\thqkflyIsVjbakXPFi0lC1+g7V3MWUFmWUOMRE4ns3H9VWVzLjMj0otT6z5IPvPsgfK7wfSApQeuRb\n\tjiRqYA5g==;","Date":"Fri, 3 Apr 2026 16:53:14 +0100","From":"Jeremy Sowden <jeremy@azazel.net>","To":"Phil Sutter <phil@nwl.cc>","Cc":"netfilter-devel@vger.kernel.org","Subject":"Re: [nft PATCH 0/2] A bit of non-constant binop follow-up","Message-ID":"<20260403155314.GC5449@celephais.dreamlands>","References":"<20260402184320.14862-1-phil@nwl.cc>","Precedence":"bulk","X-Mailing-List":"netfilter-devel@vger.kernel.org","List-Id":"<netfilter-devel.vger.kernel.org>","List-Subscribe":"<mailto:netfilter-devel+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:netfilter-devel+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha512;\n\tprotocol=\"application/pgp-signature\"; boundary=\"mb0THA/CW7hWSlR+\"","Content-Disposition":"inline","In-Reply-To":"<20260402184320.14862-1-phil@nwl.cc>","X-SA-Exim-Connect-IP":"2a00:23c8:a49f:6601:3e21:9cff:fe2f:35f","X-SA-Exim-Mail-From":"jeremy@azazel.net","X-SA-Exim-Scanned":"No (on taras.nevrast.org); SAEximRunCond expanded to false"}},{"id":3673410,"web_url":"http://patchwork.ozlabs.org/comment/3673410/","msgid":"<adDaw2nCXsDPHHyE@orbyte.nwl.cc>","list_archive_url":null,"date":"2026-04-04T09:32:51","subject":"Re: [nft PATCH 0/2] A bit of non-constant binop follow-up","submitter":{"id":4285,"url":"http://patchwork.ozlabs.org/api/people/4285/","name":"Phil Sutter","email":"phil@nwl.cc"},"content":"On Fri, Apr 03, 2026 at 04:53:14PM +0100, Jeremy Sowden wrote:\n> On 2026-04-02, at 20:43:18 +0200, Phil Sutter wrote:\n> > When asked about how to translate ebtables' --arp-gratuitous match, I\n> > noticed that basically everything is there already but the parser\n> > rejects it.\n> > \n> > While we can't do a simple 'arp saddr ip == arp daddr ip' because cmp\n> > expression requires for one side of the equation to be constant, using\n> > XOR on LHS we can work around this limitation:\n> > \n> > arp saddr ip ^ arp daddr ip == 0.0.0.0\n> > \n> > Thanks to Jeremy's work on bitwise expression (which one might want to\n> > repeat for cmp),\n> \n> I'll take a look. :)\n\nCool, thanks! The ability for cmp to operate on two registers instead of\none register and payload (\"data reg\") would allow user space to\nimplement the above as 'arp saddr ip == arp daddr ip' (without the need\nfor an internal conversion into XOR). It is not a short-term solution\nthough due to the needed kernel support.\n\nCheers, Phil","headers":{"Return-Path":"\n <netfilter-devel+bounces-11624-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","netfilter-devel@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=nwl.cc header.i=@nwl.cc header.a=rsa-sha256\n header.s=mail2022 header.b=kVuax+VV;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11624-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key)\n header.d=nwl.cc header.i=@nwl.cc header.b=\"kVuax+VV\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=151.80.46.58","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=nwl.cc","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=nwl.cc"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fnr464g4Bz1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 04 Apr 2026 20:33:10 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 11A0A3019187\n\tfor <incoming@patchwork.ozlabs.org>; Sat,  4 Apr 2026 09:33:04 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id F15B7320A37;\n\tSat,  4 Apr 2026 09:33:02 +0000 (UTC)","from orbyte.nwl.cc (orbyte.nwl.cc [151.80.46.58])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 1145B40DFD5\n\tfor <netfilter-devel@vger.kernel.org>; Sat,  4 Apr 2026 09:32:59 +0000 (UTC)","from n0-1 by orbyte.nwl.cc with local (Exim 4.98.2)\n\t(envelope-from <phil@nwl.cc>)\n\tid 1w8xN5-000000000g1-2Dw6;\n\tSat, 04 Apr 2026 11:32:51 +0200"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775295182; cv=none;\n b=mGw6LLvxaLyHwrfyF0BCHKeQgo6+4YZ8ffG7nIxvUL6TOy1MOC+Z2NKzIBWCGmF9qqxe3oCUpIqjLvV5O9aFHR1nq7lvE3nOKU5rxj/KzoEvMs79vrthETZOTQAz3xWFMH6xJLLgj+3ODuQtQmmYuUlLHPmVc6oYAE/nl37MBSs=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775295182; c=relaxed/simple;\n\tbh=bHECIzgkNhNMz7HdHTgCNdPZmIDWnNNYtXYVNiv9+BM=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=Lkz4LhETd29Sw2OuYVLQinIEfF1/SzQbYrAH5ZylsGEDz9Hk9EMS0jn/0so/1uhBe9p/jQ+6vpLZBx37DzCtMSWsW8BK8W9+sr80LnWUNpXHcu+XSlLg/tdgEyy8Z3gkIhJCX54eIkaLopmWSHZCju6GS7GacslWCoUnRvjaKTI=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=nwl.cc;\n spf=pass smtp.mailfrom=nwl.cc;\n dkim=pass (2048-bit key) header.d=nwl.cc header.i=@nwl.cc header.b=kVuax+VV;\n arc=none smtp.client-ip=151.80.46.58","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nwl.cc;\n\ts=mail2022; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:\n\tSubject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=IeW8Wv9tLSB5ZsRVTcsOEdeeSV1L+3sEnyw/I94XyOA=; b=kVuax+VVlRCdSTBfJjoev16Va+\n\tbq99+iVQfoM9VckptUzO3odL4XJbrcL+UjIVDEinGRb8kJCa2DpWdHbRmN0KIn2NcaWDIdSyiLEFf\n\tmkEZ6+0aAkpKuidD4pKFsZctlCceJXMIpre1wm07TU3I3KwTIMP035hzaO+TWzfB46/YIkKeLBf3q\n\t6vEnCAbAhdkbqtIqAaP85lCeUySrUi81TArzpHq9L5GgDbkCOw6Ili33hTeYHZvWwF1nioPEk8MOd\n\tr/vYQH/wjhMOgJciObilv7O3R/bD5/KSujITv1wdXj6xUA878J7nyrH2OLzeiR1I47szONwy4gmeD\n\tFT+RqdKg==;","Date":"Sat, 4 Apr 2026 11:32:51 +0200","From":"Phil Sutter <phil@nwl.cc>","To":"Jeremy Sowden <jeremy@azazel.net>","Cc":"netfilter-devel@vger.kernel.org","Subject":"Re: [nft PATCH 0/2] A bit of non-constant binop follow-up","Message-ID":"<adDaw2nCXsDPHHyE@orbyte.nwl.cc>","References":"<20260402184320.14862-1-phil@nwl.cc>\n <20260403155314.GC5449@celephais.dreamlands>","Precedence":"bulk","X-Mailing-List":"netfilter-devel@vger.kernel.org","List-Id":"<netfilter-devel.vger.kernel.org>","List-Subscribe":"<mailto:netfilter-devel+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:netfilter-devel+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260403155314.GC5449@celephais.dreamlands>"}}]