[PATCH v3 2/4] tests: add check for NETLINK_NETFILTER parser
Chen Jingpiao
chenjingpiao at gmail.com
Wed Mar 7 14:32:23 UTC 2018
On 03/07 08:30, Eugene Syromyatnikov wrote:
> On Wed, Mar 7, 2018 at 4:34 AM, Chen Jingpiao <chenjingpiao at gmail.com>
wrote:
> > +# ifdef WORDS_BIGENDIAN
> > + printf("htons(NFNL_SUBSYS_NFTABLES)");
> > +# else
> > + printf("NFNL_SUBSYS_NFTABLES");
> > +# endif
>
> I thought that "network order" is big-endian (at least that is what
> byteorder(3) says), so htons() is no-op there.
>
> And I don't see a reason to print the value differently on
> little-endian and big-endian architectures.
because res_id in nftables using host byte order.
in Linux kernel source code: linux/net/netfilter/nfnetlink.c
(see linux commit v4.3-rc1~28^2~47^2~1)
static void nfnetlink_rcv_skb_batch(struct sk_buff *skb, struct nlmsghdr
*nlh)
{
...
/* Work around old nft using host byte order */
if (nfgenmsg->res_id == NFNL_SUBSYS_NFTABLES)
res_id = NFNL_SUBSYS_NFTABLES;
else
res_id = ntohs(nfgenmsg->res_id);
...
}
in nftables source code: nftables/src/mnl.c
static void nft_mnl_batch_put(char *buf, uint16_t type, uint32_t seqnum)
{
...
nfg->res_id = NFNL_SUBSYS_NFTABLES;
}
And in big-endian can not distinguish
nfg->res_id = NFNL_SUBSYS_NFTABLES;
and
nfg->res_id = htons(NFNL_SUBSYS_NFTABLES);
So nfg->res_id = NFNL_SUBSYS_NFTABLES print as
"res_id=NFNL_SUBSYS_NFTABLES" in little-endian architecture
"res_id=htons(NFNL_SUBSYS_NFTABLES)" in big-endian architecture
>
> +# ifdef NFNETLINK_V0
> + printf(", version=NFNETLINK_V0");
> +# else
> + printf(", version=%#x /* NFNETLINK_??? */",
msg.version);
> +# endif
>
> NFNETLINK_V0 is not architecture-specific, so you can safely provide a
> fallback definition in xlat *.in file (and always decode it, as a
> result).
Ok, thank you.
--
Chen Jingpiao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180307/882ba9a3/attachment.html>
More information about the Strace-devel
mailing list