netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Serguei Bezverkhi (sbezverk)" <sbezverk@cisco.com>
To: "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Michael Stapelberg <michael@stapelberg.ch>
Subject: Rearranging expressions in the rule
Date: Wed, 30 Oct 2019 14:26:34 +0000	[thread overview]
Message-ID: <FCE200C6-A84D-4689-B1E4-3174C52999F6@contoso.com> (raw)

Hello,

I came across an anomaly (at least I think it is anomaly), but wanted to confirm my observation.  

The following sequence of expressions:
[
{"DestRegister":1,"Base":"expr.PayloadBaseNetworkHeader","Len":1,"Offset":9}, 
{"Op":"expr.CmpOpEq","Register":1,"Data":["0x1"]},
{"DestRegister":1,"Base":"expr.PayloadBaseNetworkHeader","Len":4,"Offset":16},
{"SourceRegister":1,"DestRegister":1,"Len":4,"Mask":["0xff","0xff","0x0","0x0"],"Xor":["0x0","0x0","0x0","0x0"]},
{"Op":"expr.CmpOpEq","Register":1,"Data":["0x1","0x1","0x0","0x0"]},
{"Kind":"0x0"}
]

correctly generates nft like rule:

ip protocol icmp ip daddr 1.1.0.0/16 drop

Then I request netlink to get me the same rule back (I am testing functionality to read and absorb already existing nft rules), I get different set of expressions for the same rule. Here is what I get:
[
{"DestRegister":1,"Base":"expr.PayloadBaseNetworkHeader","Len":1,"Offset":9},
{"Op":"expr.CmpOpEq","Register":1,"Data":["0x1"]},
{"DestRegister":1,"Base":"expr.PayloadBaseNetworkHeader","Len":4,"Offset":16},
{"Op":"expr.CmpOpEq","Register":1,"Data":["0x1","0x1","0x0","0x0"]},
{"Kind":"0x0"}
]

It does not look correct because it loses subnet length information.  I would appreciate if somebody could confirm if it is not expected behavior and if anybody observed something similar.

Thank you
Serguei


                 reply	other threads:[~2019-10-30 14:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=FCE200C6-A84D-4689-B1E4-3174C52999F6@contoso.com \
    --to=sbezverk@cisco.com \
    --cc=michael@stapelberg.ch \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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).