Skip to contentSkip to conversation

libnfnetlink dependency elimination

PATCH In review Duncan Roe 2 participants 15 messages Nov 12, 2023 – Nov 24, 2023 netfilter

lore
Share & tools
lore

Duncan Roe

author
#0 lore raw

cover libnfnetlink dependency elimination

Hi Pablo,

We need this patch for mnl cut-over of nfnl API.
It's just an added function, should be fine to apply straight away(?)

Cheers ... Duncan.

Duncan Roe (1):
src: Add nfq_nlmsg_put2() - header flags include NLM_F_ACK

 .../libnetfilter_queue/libnetfilter_queue.h   |  1 +
 src/nlmsg.c                                   | 72 ++++++++++++++++---
 2 files changed, 65 insertions(+), 8 deletions(-)
Signature · 1 line
2.35.8
author
#1 lore raw

PATCH 1/1 src: Add nfq_nlmsg_put2() - header flags include NLM_F_ACK

Enable mnl programs to check whether a config request was accepted. (nfnl programs do this already).

---
 .../libnetfilter_queue/libnetfilter_queue.h   |  1 +
 src/nlmsg.c                                   | 72 ++++++++++++++++---
 2 files changed, 65 insertions(+), 8 deletions(-)
include/libnetfilter_queue/libnetfilter_queue.h +1 -0
index 3d8e444..084a2ea 100644
@@ -151,6 +151,7 @@ void nfq_nlmsg_verdict_put_pkt(struct nlmsghdr *nlh, const void *pkt, uint32_t p
 
 int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr);
 struct nlmsghdr *nfq_nlmsg_put(char *buf, int type, uint32_t queue_num);
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num);
 
 #ifdef __cplusplus
 } /* extern "C" */
src/nlmsg.c +64 -8

86 lines not on this page · raw message

Signature · 1 line
2.35.8
#2 lore raw

Re: [PATCH libnetfilter_queue 1/1] src: Add nfq_nlmsg_put2() - header flags include NLM_F_ACK

Quoted 14 lines · Duncan Roe

Enable mnl programs to check whether a config request was accepted. (nfnl programs do this already).

---
 .../libnetfilter_queue/libnetfilter_queue.h   |  1 +
 src/nlmsg.c                                   | 72 ++++++++++++++++---
 2 files changed, 65 insertions(+), 8 deletions(-)
include/libnetfilter_queue/libnetfilter_queue.h +0 -0
index 3d8e444..084a2ea 100644

include/libnetfilter_queue/libnetfilter_queue.h void nfq_nlmsg_verdict_put_pkt(struct nlmsghdr *nlh, const void *pkt, uint32_t p · line 154

Quoted 4 lines
include/libnetfilter_queue/libnetfilter_queue.h +1 -0
@@ -151,6 +151,7 @@ void nfq_nlmsg_verdict_put_pkt(struct nlmsghdr *nlh, const void *pkt, uint32_t p
 
 int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr);
 struct nlmsghdr *nfq_nlmsg_put(char *buf, int type, uint32_t queue_num);
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num);

I like this, but I'd suggest instead:

  struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num, uint16_flags);

I should have expose those netlink flags in first place.

There are more useful netlink flags, so just expose them all.

Please send a v2.

Thanks.

author
#3 lore raw

PATCH v2 1/1 src: Add nfq_nlmsg_put2() - user specifies header flags

Enable mnl programs to check whether a config request was accepted. (nfnl programs do this already).

v2: take flags as an arg (Pablo request)

---
 .../libnetfilter_queue/libnetfilter_queue.h   |  1 +
 src/nlmsg.c                                   | 57 ++++++++++++++++++-
 2 files changed, 57 insertions(+), 1 deletion(-)
include/libnetfilter_queue/libnetfilter_queue.h +1 -0
index 3d8e444..f254984 100644
@@ -151,6 +151,7 @@ void nfq_nlmsg_verdict_put_pkt(struct nlmsghdr *nlh, const void *pkt, uint32_t p
 
 int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr);
 struct nlmsghdr *nfq_nlmsg_put(char *buf, int type, uint32_t queue_num);
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num, uint16_t flags);
 
 #ifdef __cplusplus
 } /* extern "C" */
src/nlmsg.c +56 -1

66 lines not on this page · raw message

Signature · 1 line
2.35.8
#4 lore raw

Re: [PATCH libnetfilter_queue v2 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 370

Quoted 8 lines · Duncan Roe
src/nlmsg.c +4 -1
+EXPORT_SYMBOL
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num,
+				uint16_t flags)
 {
 	struct nlmsghdr *nlh = mnl_nlmsg_put_header(buf);
 	nlh->nlmsg_type = (NFNL_SUBSYS_QUEUE << 8) | type;
-	nlh->nlmsg_flags = NLM_F_REQUEST
+	nlh->nlmsg_flags = flags;

Leave this as is.

NLM_F_REQUEST means this message goes to the kernel, this flag is a must have.

author
#5 lore raw

Re: [PATCH libnetfilter_queue v2 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

Quoted 12 lines · Pablo Neira Ayuso

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 370

Quoted 8 lines · Duncan Roe
src/nlmsg.c +4 -1
+EXPORT_SYMBOL
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num,
+				uint16_t flags)
 {
 	struct nlmsghdr *nlh = mnl_nlmsg_put_header(buf);
 	nlh->nlmsg_type = (NFNL_SUBSYS_QUEUE << 8) | type;
-	nlh->nlmsg_flags = NLM_F_REQUEST
+	nlh->nlmsg_flags = flags;

Leave this as is.

Quoted 2 lines

NLM_F_REQUEST means this message goes to the kernel, this flag is a must have.

How about

	nlh->nlmsg_flags = NLM_F_REQUEST | flags;

Or, you could apply v1.
I couldn't see a use case for other flags (NLM_F_DUMP and so on) otherwise I would have made flags an arg in v1.

On Tue, Nov 14, 2023 at 04:26:26PM +0100, Pablo Neira Ayuso wrote:
[...]

Quoted 8 lines

I like this, but I'd suggest instead:

  struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num, uint16_flags);

I should have expose those netlink flags in first place.

There are more useful netlink flags, so just expose them all.

LMK,

Cheers ... Duncan.

#6 lore raw

Re: [PATCH libnetfilter_queue v2 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

Quoted 13 lines · Duncan Roe
Quoted 12 lines · Pablo Neira Ayuso

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 370

Quoted 8 lines · Duncan Roe
src/nlmsg.c +4 -1
+EXPORT_SYMBOL
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num,
+				uint16_t flags)
 {
 	struct nlmsghdr *nlh = mnl_nlmsg_put_header(buf);
 	nlh->nlmsg_type = (NFNL_SUBSYS_QUEUE << 8) | type;
-	nlh->nlmsg_flags = NLM_F_REQUEST
+	nlh->nlmsg_flags = flags;

Leave this as is.

Quoted 6 lines
Quoted 2 lines

NLM_F_REQUEST means this message goes to the kernel, this flag is a must have.

How about

	nlh->nlmsg_flags = NLM_F_REQUEST | flags;

Yes, that is fine.

author
#7 lore raw

PATCH v3 1/1 src: Add nfq_nlmsg_put2() - user specifies header flags

Enable mnl programs to check whether a config request was accepted. (nfnl programs do this already).

v3: force on NLM_F_REQUEST

v2: take flags as an arg (Pablo request)

---
 .../libnetfilter_queue/libnetfilter_queue.h   |  1 +
 src/nlmsg.c                                   | 55 ++++++++++++++++++-
 2 files changed, 55 insertions(+), 1 deletion(-)
include/libnetfilter_queue/libnetfilter_queue.h +1 -0
index 3d8e444..f254984 100644
@@ -151,6 +151,7 @@ void nfq_nlmsg_verdict_put_pkt(struct nlmsghdr *nlh, const void *pkt, uint32_t p
 
 int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr);
 struct nlmsghdr *nfq_nlmsg_put(char *buf, int type, uint32_t queue_num);
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num, uint16_t flags);
 
 #ifdef __cplusplus
 } /* extern "C" */
src/nlmsg.c +54 -1

64 lines not on this page · raw message

Signature · 1 line
2.35.8
#8 lore raw

Re: [PATCH libnetfilter_queue v3 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

Quoted 29 lines · Duncan Roe

Enable mnl programs to check whether a config request was accepted. (nfnl programs do this already).

v3: force on NLM_F_REQUEST

v2: take flags as an arg (Pablo request)

---
 .../libnetfilter_queue/libnetfilter_queue.h   |  1 +
 src/nlmsg.c                                   | 55 ++++++++++++++++++-
 2 files changed, 55 insertions(+), 1 deletion(-)
include/libnetfilter_queue/libnetfilter_queue.h +1 -0
index 3d8e444..f254984 100644
@@ -151,6 +151,7 @@ void nfq_nlmsg_verdict_put_pkt(struct nlmsghdr *nlh, const void *pkt, uint32_t p
 
 int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr);
 struct nlmsghdr *nfq_nlmsg_put(char *buf, int type, uint32_t queue_num);
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num, uint16_t flags);
 
 #ifdef __cplusplus
 } /* extern "C" */
src/nlmsg.c +0 -0
index 5400dd7..999ccfe 100644

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 318

Quoted 10 lines
src/nlmsg.c +7 -0
@@ -309,10 +309,63 @@ int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr)
  */
 EXPORT_SYMBOL
 struct nlmsghdr *nfq_nlmsg_put(char *buf, int type, uint32_t queue_num)
+{
+	return nfq_nlmsg_put2(buf, type, queue_num, 0);
+}
+
+/**
+ * nfq_nlmsg_put2 - Convert memory buffer into a Netlink buffer with
+ * user-specified flags

This is setting up a netlink header in the memory buffer.

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 323

Quoted 5 lines
src/nlmsg.c +5 -0
+ * \param *buf Pointer to memory buffer
+ * \param type Either NFQNL_MSG_CONFIG or NFQNL_MSG_VERDICT
+ * \param queue_num Queue number
+ * \param flags additional (to NLM_F_REQUEST) flags to put in message header,
+ *              commonly NLM_F_ACK

remove NLM_F_REQUEST here.

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 324

Quoted 1 line
src/nlmsg.c +1 -0
+ * \returns Pointer to netlink message

Pointer to netlink header

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 326

Quoted 2 lines
src/nlmsg.c +2 -0
+ *
+ * Use NLM_F_ACK before performing an action that might fail, e.g.

Failures are always reported.

if you set NLM_F_ACK, then you always get an acknowledgment from the kernel, either 0 to report success or negative to report failure.

if you do not set NLM_F_ACK, then only failures are reported by the kernel.

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 330

Quoted 4 lines
src/nlmsg.c +4 -0
+ * attempt to configure NFQA_CFG_F_SECCTX on a system not runnine SELinux.
+ * \n
+ * NLM_F_ACK instructs the kernel to send a message in response
+ * to a successful command.

As I said above, this is not accurate.

Quoted 45 lines
src/nlmsg.c +35 -1
+ * The kernel always sends a message in response to a failed command.
+ * \n
+ * This code snippet demonstrates reading these responses:
+ * \verbatim
+	nlh = nfq_nlmsg_put2(nltxbuf, NFQNL_MSG_CONFIG, queue_num, NLM_F_ACK);
+	mnl_attr_put_u32(nlh, NFQA_CFG_FLAGS, NFQA_CFG_F_SECCTX);
+	mnl_attr_put_u32(nlh, NFQA_CFG_MASK, NFQA_CFG_F_SECCTX);
+
+	if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
+		perror("mnl_socket_send");
+		exit(EXIT_FAILURE);
+	}
+
+	ret = mnl_socket_recvfrom(nl, nlrxbuf, sizeof nlrxbuf);
+	if (ret == -1) {
+		perror("mnl_socket_recvfrom");
+		exit(EXIT_FAILURE);
+	}
+
+	ret = mnl_cb_run(nlrxbuf, ret, 0, portid, NULL, NULL);
+	if (ret == -1)
+		perror("configure NFQA_CFG_F_SECCTX");
+\endverbatim
+ *
+ * \note
+ * The program above can continue after the error because NFQA_CFG_F_SECCTX
+ * was the only item in the preceding **mnl_socket_sendto**.
+ * If there had been other items, they would not have been actioned and it would
+ * not now be safe to proceed.
+ */
+
+EXPORT_SYMBOL
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num,
+				uint16_t flags)
 {
 	struct nlmsghdr *nlh = mnl_nlmsg_put_header(buf);
 	nlh->nlmsg_type = (NFNL_SUBSYS_QUEUE << 8) | type;
-	nlh->nlmsg_flags = NLM_F_REQUEST;
+	nlh->nlmsg_flags = NLM_F_REQUEST | flags;
 
 	struct nfgenmsg *nfg = mnl_nlmsg_put_extra_header(nlh, sizeof(*nfg));
 	nfg->nfgen_family = AF_UNSPEC;
Signature · 1 line
2.35.8
author
#9 lore raw

Re: [PATCH libnetfilter_queue v3 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

Quoted 34 lines · Pablo Neira Ayuso
Quoted 33 lines · Duncan Roe

Enable mnl programs to check whether a config request was accepted. (nfnl programs do this already).

v3: force on NLM_F_REQUEST

v2: take flags as an arg (Pablo request)

---
 .../libnetfilter_queue/libnetfilter_queue.h   |  1 +
 src/nlmsg.c                                   | 55 ++++++++++++++++++-
 2 files changed, 55 insertions(+), 1 deletion(-)
include/libnetfilter_queue/libnetfilter_queue.h +1 -0
index 3d8e444..f254984 100644
@@ -151,6 +151,7 @@ void nfq_nlmsg_verdict_put_pkt(struct nlmsghdr *nlh, const void *pkt, uint32_t p
 
 int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr);
 struct nlmsghdr *nfq_nlmsg_put(char *buf, int type, uint32_t queue_num);
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num, uint16_t flags);
 
 #ifdef __cplusplus
 } /* extern "C" */
src/nlmsg.c +1 -0
index 5400dd7..999ccfe 100644
@@ -309,10 +309,63 @@ int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr)
  */
 EXPORT_SYMBOL
 struct nlmsghdr *nfq_nlmsg_put(char *buf, int type, uint32_t queue_num)
+{
Quoted 8 lines

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 318

Quoted 6 lines
src/nlmsg.c +6 -0
+	return nfq_nlmsg_put2(buf, type, queue_num, 0);
+}
+
+/**
+ * nfq_nlmsg_put2 - Convert memory buffer into a Netlink buffer with
+ * user-specified flags

This is setting up a netlink header in the memory buffer.

Yes. I just copied the description from nfq_nlmsg_put and tacked on "with user-specified flags". Do you want to see

Quoted 1 line

Set up a netlink header in a memory buffer with user-specified flags

perhaps better

Quoted 1 line

Set up a netlink header with user-specified flags in a memory buffer

instead? And would you like me to change the nfq_nlmsg_put description to match?

Quoted 8 lines

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 323

Quoted 6 lines
src/nlmsg.c +5 -0
+ * \param *buf Pointer to memory buffer
+ * \param type Either NFQNL_MSG_CONFIG or NFQNL_MSG_VERDICT
+ * \param queue_num Queue number
+ * \param flags additional (to NLM_F_REQUEST) flags to put in message header,
+ *              commonly NLM_F_ACK

remove NLM_F_REQUEST here.

Ok

Quoted 4 lines

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 324

Quoted 2 lines
src/nlmsg.c +1 -0
+ * \returns Pointer to netlink message

Pointer to netlink header

Again, copied from nfq_nlmsg_put. Fix that as well?

Quoted 11 lines

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 326

Quoted 3 lines
src/nlmsg.c +2 -0
+ *
+ * Use NLM_F_ACK before performing an action that might fail, e.g.

Failures are always reported.

if you set NLM_F_ACK, then you always get an acknowledgment from the kernel, either 0 to report success or negative to report failure.

if you do not set NLM_F_ACK, then only failures are reported by the kernel.

Yes, I was trying to explain that. The point being, if you don't specify NLM_F_ACK and the command succeeds then mnl_socket_recvfrom() will hang.

Quoted 7 lines

src/nlmsg.c int nfq_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr **attr) · line 330

Quoted 5 lines
src/nlmsg.c +4 -0
+ * attempt to configure NFQA_CFG_F_SECCTX on a system not runnine SELinux.
+ * \n
+ * NLM_F_ACK instructs the kernel to send a message in response
+ * to a successful command.

As I said above, this is not accurate.

Sorry, it looks to me to be the same as what you said. Which bit is not accurate, what should it say instead?

Quoted 46 lines
Quoted 46 lines
src/nlmsg.c +35 -2
+ * The kernel always sends a message in response to a failed command.
+ * \n
+ * This code snippet demonstrates reading these responses:
+ * \verbatim
+	nlh = nfq_nlmsg_put2(nltxbuf, NFQNL_MSG_CONFIG, queue_num, NLM_F_ACK);
+	mnl_attr_put_u32(nlh, NFQA_CFG_FLAGS, NFQA_CFG_F_SECCTX);
+	mnl_attr_put_u32(nlh, NFQA_CFG_MASK, NFQA_CFG_F_SECCTX);
+
+	if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
+		perror("mnl_socket_send");
+		exit(EXIT_FAILURE);
+	}
+
+	ret = mnl_socket_recvfrom(nl, nlrxbuf, sizeof nlrxbuf);
+	if (ret == -1) {
+		perror("mnl_socket_recvfrom");
+		exit(EXIT_FAILURE);
+	}
+
+	ret = mnl_cb_run(nlrxbuf, ret, 0, portid, NULL, NULL);
+	if (ret == -1)
+		perror("configure NFQA_CFG_F_SECCTX");
+\endverbatim
+ *
+ * \note
+ * The program above can continue after the error because NFQA_CFG_F_SECCTX
+ * was the only item in the preceding **mnl_socket_sendto**.
+ * If there had been other items, they would not have been actioned and it would
+ * not now be safe to proceed.
+ */
+
+EXPORT_SYMBOL
+struct nlmsghdr *nfq_nlmsg_put2(char *buf, int type, uint32_t queue_num,
+				uint16_t flags)
 {
 	struct nlmsghdr *nlh = mnl_nlmsg_put_header(buf);
 	nlh->nlmsg_type = (NFNL_SUBSYS_QUEUE << 8) | type;
-	nlh->nlmsg_flags = NLM_F_REQUEST;
+	nlh->nlmsg_flags = NLM_F_REQUEST | flags;
 
 	struct nfgenmsg *nfg = mnl_nlmsg_put_extra_header(nlh, sizeof(*nfg));
 	nfg->nfgen_family = AF_UNSPEC;
--

2.35.8

author
#10 lore raw

Re: [PATCH libnetfilter_queue v3 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

In reply to Pablo Neira Ayuso

Hi Pablo,

Can we please sort out just what you want before I send nfq_nlmsg_put2 v4?

And, where applicable, would you like the same changes made to nfq_nlmsg_put?

Quoted 5 lines · Pablo Neira Ayuso

[...]

Quoted 2 lines

+ * nfq_nlmsg_put2 - Convert memory buffer into a Netlink buffer with
+ * user-specified flags

This is setting up a netlink header in the memory buffer.

propose

Quoted 7 lines
Quoted 2 lines

+ * nfq_nlmsg_put2 - Set up a netlink header with user-specified flags
+ * in a memory buffer

[...]

Quoted 2 lines

+ * \param flags additional (to NLM_F_REQUEST) flags to put in message header,
+ * commonly NLM_F_ACK

remove NLM_F_REQUEST here.

propose

Quoted 5 lines
Quoted 1 line

+ * \param flags flags to put in message header, commonly NLM_F_ACK

[...]

Quoted 1 line

+ * \returns Pointer to netlink message

Pointer to netlink header

propose

Quoted 12 lines
Quoted 1 line

+ * \returns Pointer to netlink header

[...]

Quoted 1 line

+ * Use NLM_F_ACK before performing an action that might fail, e.g.

Failures are always reported.

if you set NLM_F_ACK, then you always get an acknowledgment from the kernel, either 0 to report success or negative to report failure.

if you do not set NLM_F_ACK, then only failures are reported by the kernel.

Quoted 7 lines
Quoted 4 lines

+ * attempt to configure NFQA_CFG_F_SECCTX on a system not runnine SELinux.
+ * \n
+ * NLM_F_ACK instructs the kernel to send a message in response
+ * to a successful command.

As I said above, this is not accurate.

Quoted 1 line

+ * The kernel always sends a message in response to a failed command.

I dispute that my description was inaccurate, but admit it could be clearer, maybe if I change the order and elaborate a bit.
propose

Quoted 4 lines
Quoted 3 lines

+ * The kernel always sends a message in response to a failed command.
+ * NLM_F_ACK instructs the kernel to also send a message in response
+ * to a successful command. This ensures a following read() will not block.

[...]

Cheers ... Duncan.

#11 lore raw

Re: [PATCH libnetfilter_queue v3 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

Quoted 5 lines · Duncan Roe

Hi Pablo,

Can we please sort out just what you want before I send nfq_nlmsg_put2 v4?

And, where applicable, would you like the same changes made to nfq_nlmsg_put?

Just send a v4 with the changes I request for this patch, then once applied, you can follow up to update nfq_nlmsg_put() in a separated patch to amend that description too.

So, please, only one patch series at a time.

Quoted 1 line · Pablo Neira Ayuso

[...]

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

+ * attempt to configure NFQA_CFG_F_SECCTX on a system not runnine SELinux.
+ * \n
+ * NLM_F_ACK instructs the kernel to send a message in response
+ * to a successful command.

Quoted 10 lines
Quoted 2 lines

As I said above, this is not accurate.

Quoted 1 line

+ * The kernel always sends a message in response to a failed command.

I dispute that my description was inaccurate, but admit it could be clearer, maybe if I change the order and elaborate a bit.
propose

Quoted 3 lines
Quoted 3 lines

+ * The kernel always sends a message in response to a failed command.
+ * NLM_F_ACK instructs the kernel to also send a message in response
+ * to a successful command.

LGTM, however:

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This ensures a following read() will not block.

Remove this sentence, because the blocking behaviour you observe is because !NLM_F_ACK and no failure means no message is sent, and if your application is there to recv(), it will wait forever because kernel will send nothing.

author
#12 lore raw

Re: [PATCH libnetfilter_queue v3 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

Hi Pablo,

Quoted 31 lines · Pablo Neira Ayuso
Quoted 5 lines · Duncan Roe

Hi Pablo,

Can we please sort out just what you want before I send nfq_nlmsg_put2 v4?

And, where applicable, would you like the same changes made to nfq_nlmsg_put?

Just send a v4 with the changes I request for this patch, then once applied, you can follow up to update nfq_nlmsg_put() in a separated patch to amend that description too.

So, please, only one patch series at a time.

Quoted 1 line · Pablo Neira Ayuso

[...]

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

+ * attempt to configure NFQA_CFG_F_SECCTX on a system not runnine SELinux.
+ * \n
+ * NLM_F_ACK instructs the kernel to send a message in response
+ * to a successful command.

Quoted 10 lines
Quoted 2 lines

As I said above, this is not accurate.

Quoted 1 line

+ * The kernel always sends a message in response to a failed command.

I dispute that my description was inaccurate, but admit it could be clearer, maybe if I change the order and elaborate a bit.
propose

Quoted 3 lines
Quoted 3 lines

+ * The kernel always sends a message in response to a failed command.
+ * NLM_F_ACK instructs the kernel to also send a message in response
+ * to a successful command.

Quoted 8 lines

LGTM, however:

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This ensures a following read() will not block.

Remove this sentence, because the blocking behaviour you observe is because !NLM_F_ACK and no failure means no message is sent, and if your application is there to recv(), it will wait forever because kernel will send nothing.

I did post v4 but forgot --in-reply-to in git format-patch. You'll find the updated patch furtheron in your mbox.

Cheers ... Duncan.

author
#13 lore raw

Re: [PATCH libnetfilter_queue v4 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

Hey Pablo,

Are you too busy to reply to my emails? There will be a lot more. Have you thought of passing management of this libmnl-conversion project to another core team member?

Quoted 42 lines · Duncan Roe

Hi Pablo,

Quoted 39 lines · Pablo Neira Ayuso
Quoted 5 lines · Duncan Roe

Hi Pablo,

Can we please sort out just what you want before I send nfq_nlmsg_put2 v4?

And, where applicable, would you like the same changes made to nfq_nlmsg_put?

Just send a v4 with the changes I request for this patch, then once applied, you can follow up to update nfq_nlmsg_put() in a separated patch to amend that description too.

So, please, only one patch series at a time.

Quoted 1 line · Pablo Neira Ayuso

[...]

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

+ * attempt to configure NFQA_CFG_F_SECCTX on a system not runnine SELinux.
+ * \n
+ * NLM_F_ACK instructs the kernel to send a message in response
+ * to a successful command.

Quoted 10 lines
Quoted 2 lines

As I said above, this is not accurate.

Quoted 1 line

+ * The kernel always sends a message in response to a failed command.

I dispute that my description was inaccurate, but admit it could be clearer, maybe if I change the order and elaborate a bit.
propose

Quoted 3 lines
Quoted 3 lines

+ * The kernel always sends a message in response to a failed command.
+ * NLM_F_ACK instructs the kernel to also send a message in response
+ * to a successful command.

LGTM, however:

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This ensures a following read() will not block.

Remove this sentence, because the blocking behaviour you observe is because !NLM_F_ACK and no failure means no message is sent, and if your application is there to recv(), it will wait forever because kernel will send nothing.

"it will wait forever" i.e. it will block.

I could send a v5 with this:

Quoted 1 line

+ * Use NLM_F_ACK to ensure a kernel response for your application to read.

[...]

Cheers ... Duncan.

#14 lore raw

Re: [PATCH libnetfilter_queue v4 1/1] src: Add nfq_nlmsg_put2() - user specifies header flags

Quoted 3 lines · Duncan Roe

Hey Pablo,

Are you too busy to reply to my emails?

Yes, I am very busy.

Quoted 2 lines

There will be a lot more. Have you thought of passing management of this libmnl-conversion project to another core team member?

Absolutely not.

Please, be patient.