netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Garver <eric@garver.life>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, sbrivio@redhat.com
Subject: Re: [PATCH nft] src: support for selectors with different byteorder with interval concatenations
Date: Wed, 7 Dec 2022 15:06:01 -0500	[thread overview]
Message-ID: <Y5DyKcPZ+vzphv11@wsfd-netdev-vmhost.ntdv.lab.eng.bos.redhat.com> (raw)
In-Reply-To: <20221124114602.277741-1-pablo@netfilter.org>

On Thu, Nov 24, 2022 at 12:46:02PM +0100, Pablo Neira Ayuso wrote:
> Assuming the following interval set with concatenations:
> 
>  set test {
> 	typeof ip saddr . meta mark
> 	flags interval
>  }
> 
> then, the following rule:
> 
>  ip saddr . meta mark @test
> 
> requires bytecode that swaps the byteorder for the meta mark selector in
> case the set contains intervals and concatenations.
> 
>  inet x y
>    [ meta load nfproto => reg 1 ]
>    [ cmp eq reg 1 0x00000002 ]
>    [ payload load 4b @ network header + 12 => reg 1 ]
>    [ meta load mark => reg 9 ]
>    [ byteorder reg 9 = hton(reg 9, 4, 4) ] 	<----- this is required !
>    [ lookup reg 1 set test dreg 0 ]
> 
> This patch updates byteorder_conversion() to add the unary expression
> that introduces the byteorder expression.
> 
> Moreover, store the meta mark range component of the element tuple in
> the set in big endian as it is required for the range comparisons. Undo
> the byteorder swap in the netlink delinearize path to listing the meta
> mark values accordingly.
> 
> Update tests/py to validate that byteorder expression is emitted in the
> bytecode. Update tests/shell to validate insertion and listing of a
> named map declaration.
> 
> A similar commit 806ab081dc9a ("netlink: swap byteorder for
> host-endian concat data") already exists in the tree to handle this for
> strings with prefix (e.g. eth*).
> 
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---

Hi Pablo,

This patch reversed the byte order on output.

Thanks.
Eric.


--->8---


# cat /tmp/foo
table inet foobar {
        set foobar {
                type ipv4_addr . mark
                flags interval
                elements = { 10.10.10.10 . 0x00000100,
                             20.20.20.20 . 0x00000200 }
        }
}

# ./src/nft -f /tmp/foo

# ./src/nft list table inet foobar
table inet foobar {
        set foobar {
                type ipv4_addr . mark
                flags interval
                elements = { 10.10.10.10 . 0x00010000,
                             20.20.20.20 . 0x00020000 }
        }
}

# nft list table inet foobar
table inet foobar {
        set foobar {
                type ipv4_addr . mark
                flags interval
                elements = { 10.10.10.10 . 0x00000100,
                             20.20.20.20 . 0x00000200 }
        }
}


      reply	other threads:[~2022-12-07 20:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 11:46 [PATCH nft] src: support for selectors with different byteorder with interval concatenations Pablo Neira Ayuso
2022-12-07 20:06 ` Eric Garver [this message]

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=Y5DyKcPZ+vzphv11@wsfd-netdev-vmhost.ntdv.lab.eng.bos.redhat.com \
    --to=eric@garver.life \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --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.
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 NNTP newsgroup(s).