From: Florian Westphal <fw@strlen.de>
To: "Serguei Bezverkhi (sbezverk)" <sbezverk@cisco.com>
Cc: Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
"netfilter-devel@vger.kernel.org"
<netfilter-devel@vger.kernel.org>
Subject: Re: Ipv6 address in concatenation
Date: Thu, 27 Feb 2020 22:45:38 +0100 [thread overview]
Message-ID: <20200227214538.GR19559@breakpoint.cc> (raw)
In-Reply-To: <C3A34108-BD5F-41CB-835B-277494505E85@cisco.com>
Serguei Bezverkhi (sbezverk) <sbezverk@cisco.com> wrote:
> Ok, I figured out the map issue, it was a length of the key in bits, damn copy/paste (
>
> Appreciate if somebody could comment about the following:
>
> sudo nft --debug=netlink insert rule ip6 kube-nfproxy-v6 k8s-nat-services ip6 nexthdr . ip6 daddr . th dport vmap @cluster-ip-set
> ip6 kube-nfproxy-v6 k8s-nat-services
> [ payload load 1b @ network header + 6 => reg 1 ]
> [ payload load 16b @ network header + 24 => reg 9 ]. < -- Is it loading reg 9 4-bytes, reg 10 4 bytes etc until reg 12? Or because the data 16 bytes long it has to skip 3 more register?
> [ payload load 2b @ transport header + 2 => reg 13 ]
The 'registers' are adjacent in memory, so loading 16 bytes to reg9
will also store data to 10, 11 and 12.
In case there are not enough next registers kernel will reject the
transaction.
> [ lookup reg 1 set cluster-ip-set dreg 0 ]
>
> I am just trying to figure out how to calculate next register to use. If there is algorithm for both ipv4 and ipv6 that would be awesome to know.
See netlink_gen_concat() in src/netlink_linearize.c in nftables.
Its basically enough to take the start register and then add the
length, rounded up to 4 (register is always 4 byte).
So for the above you need 1 + 1 * 4 + 1, i.e. 6 registers,
then pass the first/start register to the lookup expression.
The lookup expression takes the number of 'next registers' it
needs to look at from the set key length.
prev parent reply other threads:[~2020-02-27 21:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-27 16:21 Ipv6 address in concatenation Serguei Bezverkhi (sbezverk)
2020-02-27 17:17 ` Phil Sutter
2020-02-27 19:42 ` Florian Westphal
2020-02-27 19:43 ` Florian Westphal
2020-02-27 21:25 ` Serguei Bezverkhi (sbezverk)
2020-02-27 21:45 ` Florian Westphal [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=20200227214538.GR19559@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
--cc=sbezverk@cisco.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.