From: Ian Pilcher <arequipeno@gmail.com>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [RFC PATCH 1/1] libnftnl: Fix res_id byte order
Date: Tue, 18 Oct 2022 11:45:28 -0500 [thread overview]
Message-ID: <20221018164528.250049-2-arequipeno@gmail.com> (raw)
In-Reply-To: <20221018164528.250049-1-arequipeno@gmail.com>
The res_id member of struct nfgenmsg is supposed to be in network
byte order (big endian). Call htons() in __nftnl_nlmsg_build_hdr()
to ensure that this is true on little endian systems.
Signed-off-by: Ian Pilcher <arequipeno@gmail.com>
---
src/common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/common.c b/src/common.c
index 2d83c12..08572c3 100644
--- a/src/common.c
+++ b/src/common.c
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <sys/socket.h>
#include <time.h>
+#include <arpa/inet.h>
#include <linux/netlink.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nf_tables.h>
@@ -37,7 +38,7 @@ static struct nlmsghdr *__nftnl_nlmsg_build_hdr(char *buf, uint16_t type,
nfh = mnl_nlmsg_put_extra_header(nlh, sizeof(struct nfgenmsg));
nfh->nfgen_family = family;
nfh->version = NFNETLINK_V0;
- nfh->res_id = res_id;
+ nfh->res_id = htons(res_id);
return nlh;
}
--
2.37.3
next prev parent reply other threads:[~2022-10-18 16:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 16:45 [RFC PATCH 0/1] libnftnl: Incorrect res_id byte order? Ian Pilcher
2022-10-18 16:45 ` Ian Pilcher [this message]
2022-10-19 6:44 ` [RFC PATCH 1/1] libnftnl: Fix res_id byte order Pablo Neira Ayuso
2022-10-20 15:05 ` Ian Pilcher
2022-10-21 9:28 ` Pablo Neira Ayuso
2022-10-25 10:37 ` Pablo Neira Ayuso
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=20221018164528.250049-2-arequipeno@gmail.com \
--to=arequipeno@gmail.com \
--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