Skip to contentSkip to conversation

src: annotation: Correctly identify item for which header is needed

PATCH Superseded Duncan Roe 2 participants 12 messages Jul 4, 2021 – Jul 7, 2021 netfilter

lore
Share & tools
lore

Duncan Roe

author
#0 lore raw

PATCH 1/1 src: annotation: Correctly identify item for which header is needed

---
 examples/nf-queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/nf-queue.c +1 -1
index 3da2c24..7d34081 100644
@@ -15,7 +15,7 @@
 
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* only for CTA_MARK, not needed otherwise: */
 #include <linux/netfilter/nfnetlink_conntrack.h>
 
 static struct mnl_socket *nl;
Signature · 1 line
2.17.5
#1 lore raw
Quoted 10 lines · Duncan Roe
---
 examples/nf-queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/nf-queue.c +0 -0
index 3da2c24..7d34081 100644

examples/nf-queue.c line 18

Quoted 5 lines
examples/nf-queue.c +1 -1
@@ -15,7 +15,7 @@
 
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* only for CTA_MARK, not needed otherwise: */

The reference to NFQA_CT is correct.

enum nfqnl_attr_type {
NFQA_UNSPEC,
NFQA_PACKET_HDR,
NFQA_VERDICT_HDR, /* nfqnl_msg_verdict_hrd */
NFQA_MARK, /* __u32 nfmark */
NFQA_TIMESTAMP, /* nfqnl_msg_packet_timestamp */
NFQA_IFINDEX_INDEV, /* __u32 ifindex */
NFQA_IFINDEX_OUTDEV, /* __u32 ifindex */
NFQA_IFINDEX_PHYSINDEV, /* __u32 ifindex */
NFQA_IFINDEX_PHYSOUTDEV, /* __u32 ifindex */
NFQA_HWADDR, /* nfqnl_msg_packet_hw */
NFQA_PAYLOAD, /* opaque data payload */
NFQA_CT, /* nf_conntrack_netlink.h */

NFQA_CT the attribute nest that contains the CTA_* attributes that represent the conntrack object, ie.

        NFQA_CT
          CTA_...
          CTA_...
          CTA_...
author
#2 lore raw
Quoted 12 lines · Pablo Neira Ayuso
Quoted 11 lines · Duncan Roe
---
 examples/nf-queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/nf-queue.c +0 -0
index 3da2c24..7d34081 100644
@@ -15,7 +15,7 @@
 
Quoted 7 lines

examples/nf-queue.c line 18

Quoted 4 lines
examples/nf-queue.c +1 -1
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* only for CTA_MARK, not needed otherwise: */

#include <linux/netfilter/nfnetlink_conntrack.h>

The reference to NFQA_CT is correct.

If I comment out the #include, the compiler complains about CTA_MARK. It does not complain about NFQA_CT. Perhaps:

Review

Quoted 2 lines
(quoted diff) +1 -1
-/* only for NFQA_CT, not needed otherwise: */
+/* only for conntrack attribute CTA_MARK, not needed otherwise: */

In any case:

Quoted 2 lines

enum nfqnl_attr_type {

[...]

Quoted 2 lines

NFQA_CT, /* nf_conntrack_netlink.h */

The header is nfnetlink_conntrack.h, not nf_conntrack_netlink.h.

I can submit a v2 to also fix nf_conntrack_netlink in the cached headers.

Cheers ... Duncan.

#3 lore raw
Quoted 19 lines · Duncan Roe
Quoted 18 lines · Pablo Neira Ayuso
Quoted 10 lines · Duncan Roe
---
 examples/nf-queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/nf-queue.c +0 -0
index 3da2c24..7d34081 100644

examples/nf-queue.c line 18

Quoted 5 lines
examples/nf-queue.c +1 -1
@@ -15,7 +15,7 @@
 
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* only for CTA_MARK, not needed otherwise: */

#include <linux/netfilter/nfnetlink_conntrack.h>

Quoted 6 lines
Quoted 1 line

The reference to NFQA_CT is correct.

If I comment out the #include, the compiler complains about CTA_MARK. It does not complain about NFQA_CT. Perhaps:

Review

Quoted 2 lines
(quoted diff) +1 -1
-/* only for NFQA_CT, not needed otherwise: */
+/* only for conntrack attribute CTA_MARK, not needed otherwise: */

Maybe:

/* NFQA_CT requires CTA_* attributes defined in nfnetlink_conntrack.h */

Quoted 7 lines

In any case:

Quoted 2 lines

enum nfqnl_attr_type {

[...]

Quoted 2 lines

NFQA_CT, /* nf_conntrack_netlink.h */

The header is nfnetlink_conntrack.h, not nf_conntrack_netlink.h.

Good point.

Quoted 1 line

I can submit a v2 to also fix nf_conntrack_netlink in the cached headers.

Sure, go ahead.

author
#4 lore raw

PATCH v2 1/1 src: annotation: Correctly identify item for which header is needed

In reply to Duncan Roe

Also fix header annotation to refer to nfnetlink_conntrack.h, not nf_conntrack_netlink.h

---
 examples/nf-queue.c                                | 2 +-
 include/libnetfilter_queue/linux_nfnetlink_queue.h | 4 ++--
 include/linux/netfilter/nfnetlink_queue.h          | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
examples/nf-queue.c +1 -1
index 3da2c24..5b86e69 100644
@@ -15,7 +15,7 @@
 
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* NFQA_CT requires CTA_* attributes defined in nfnetlink_conntrack.h */
 #include <linux/netfilter/nfnetlink_conntrack.h>
 
 static struct mnl_socket *nl;
include/libnetfilter_queue/linux_nfnetlink_queue.h +2 -2
index 1975dfa..caa6788 100644
@@ -46,11 +46,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,			/* security context string */
include/linux/netfilter/nfnetlink_queue.h +2 -2
index 030672d..8e2e469 100644
@@ -42,11 +42,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,
Signature · 1 line
2.17.5
#5 lore raw
Quoted 2 lines · Duncan Roe

Also fix header annotation to refer to nfnetlink_conntrack.h, not nf_conntrack_netlink.h

Please, split this in two patches. See below. Thanks.

Quoted 12 lines
---
 examples/nf-queue.c                                | 2 +-
 include/libnetfilter_queue/linux_nfnetlink_queue.h | 4 ++--
 include/linux/netfilter/nfnetlink_queue.h          | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
examples/nf-queue.c +0 -0
index 3da2c24..5b86e69 100644

examples/nf-queue.c line 21

Quoted 8 lines
examples/nf-queue.c +1 -1
@@ -15,7 +15,7 @@
 
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* NFQA_CT requires CTA_* attributes defined in nfnetlink_conntrack.h */
 #include <linux/netfilter/nfnetlink_conntrack.h>
 
 static struct mnl_socket *nl;

This chunk belongs to libnetfilter_queue.

include/libnetfilter_queue/linux_nfnetlink_queue.h

Quoted 4 lines
include/libnetfilter_queue/linux_nfnetlink_queue.h +0 -0
index 1975dfa..caa6788 100644

This chunk below, belongs to the nf tree. You have to fix first the kernel UAPI, then you can refresh this copy that is stored in libnetfilter_queue.

Quoted 35 lines
include/libnetfilter_queue/linux_nfnetlink_queue.h +2 -2
@@ -46,11 +46,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,			/* security context string */
include/linux/netfilter/nfnetlink_queue.h +2 -2
index 030672d..8e2e469 100644
@@ -42,11 +42,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,
Signature · 1 line
2.17.5
author
#6 lore raw
Quoted 29 lines · Pablo Neira Ayuso
Quoted 2 lines · Duncan Roe

Also fix header annotation to refer to nfnetlink_conntrack.h, not nf_conntrack_netlink.h

Please, split this in two patches. See below. Thanks.

Quoted 12 lines
---
 examples/nf-queue.c                                | 2 +-
 include/libnetfilter_queue/linux_nfnetlink_queue.h | 4 ++--
 include/linux/netfilter/nfnetlink_queue.h          | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
examples/nf-queue.c +0 -0
index 3da2c24..5b86e69 100644

examples/nf-queue.c line 21

Quoted 8 lines
examples/nf-queue.c +1 -1
@@ -15,7 +15,7 @@
 
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* NFQA_CT requires CTA_* attributes defined in nfnetlink_conntrack.h */
 #include <linux/netfilter/nfnetlink_conntrack.h>
 
 static struct mnl_socket *nl;

This chunk belongs to libnetfilter_queue.

Quoted 8 lines

include/libnetfilter_queue/linux_nfnetlink_queue.h

Quoted 4 lines
include/libnetfilter_queue/linux_nfnetlink_queue.h +0 -0
index 1975dfa..caa6788 100644

This chunk below, belongs to the nf tree. You have to fix first the kernel UAPI, then you can refresh this copy that is stored in libnetfilter_queue.

I already sent you an nf-next patch which you said you would forward to nf.

I don't have the nf tree here but I guess the nf-next package will apply if I re-package.

Will send 3 patches as you request.

Cheers ... Duncan.

Quoted 36 lines
Quoted 36 lines
include/libnetfilter_queue/linux_nfnetlink_queue.h +2 -2
@@ -46,11 +46,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,			/* security context string */
include/linux/netfilter/nfnetlink_queue.h +2 -3
index 030672d..8e2e469 100644
@@ -42,11 +42,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,
--

2.17.5

#7 lore raw
Quoted 39 lines · Duncan Roe
Quoted 29 lines · Pablo Neira Ayuso
Quoted 2 lines · Duncan Roe

Also fix header annotation to refer to nfnetlink_conntrack.h, not nf_conntrack_netlink.h

Please, split this in two patches. See below. Thanks.

Quoted 12 lines
---
 examples/nf-queue.c                                | 2 +-
 include/libnetfilter_queue/linux_nfnetlink_queue.h | 4 ++--
 include/linux/netfilter/nfnetlink_queue.h          | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
examples/nf-queue.c +0 -0
index 3da2c24..5b86e69 100644

examples/nf-queue.c line 21

Quoted 8 lines
examples/nf-queue.c +1 -1
@@ -15,7 +15,7 @@
 
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* NFQA_CT requires CTA_* attributes defined in nfnetlink_conntrack.h */
 #include <linux/netfilter/nfnetlink_conntrack.h>
 
 static struct mnl_socket *nl;

This chunk belongs to libnetfilter_queue.

Quoted 8 lines

include/libnetfilter_queue/linux_nfnetlink_queue.h

Quoted 4 lines
include/libnetfilter_queue/linux_nfnetlink_queue.h +0 -0
index 1975dfa..caa6788 100644

This chunk below, belongs to the nf tree. You have to fix first the kernel UAPI, then you can refresh this copy that is stored in libnetfilter_queue.

Quoted 1 line

I already sent you an nf-next patch which you said you would forward to nf.

Yes, it can be applied to nf as I said since it is a fix, it needs changes, I'm refering to this patch:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

Quoted 2 lines

I don't have the nf tree here but I guess the nf-next package will apply if I re-package.

The nf and nf-next trees look the same for nfnetlink_queue.h, you can base your patch on either tree, just use [PATCH nf] to target this to the nf git.

Quoted 1 line

Will send 3 patches as you request.

Thanks. I'll review them.

author
#8 lore raw

PATCH 1/1 netfilter: uapi: refer to nfnetlink_conntrack.h, not nf_conntrack_netlink.h

In reply to Pablo Neira Ayuso

nf_conntrack_netlink.h does not exist, refer to nfnetlink_conntrack.h instead.

---
 include/uapi/linux/netfilter/nfnetlink_log.h   | 2 +-
 include/uapi/linux/netfilter/nfnetlink_queue.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/uapi/linux/netfilter/nfnetlink_log.h +1 -1
index 45c8d3b027e0..0af9c113d665 100644
@@ -61,7 +61,7 @@ enum nfulnl_attr_type {
 	NFULA_HWTYPE,			/* hardware type */
 	NFULA_HWHEADER,			/* hardware header */
 	NFULA_HWLEN,			/* hardware header length */
-	NFULA_CT,                       /* nf_conntrack_netlink.h */
+	NFULA_CT,                       /* nfnetlink_conntrack.h */
 	NFULA_CT_INFO,                  /* enum ip_conntrack_info */
 	NFULA_VLAN,			/* nested attribute: packet vlan info */
 	NFULA_L2HDR,			/* full L2 header */
include/uapi/linux/netfilter/nfnetlink_queue.h +2 -2
index bcb2cb5d40b9..aed90c4df0c8 100644
@@ -51,11 +51,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,			/* security context string */
Signature · 1 line
2.17.5
maintainer Applied
#9 lore raw

Re: [PATCH nf] netfilter: uapi: refer to nfnetlink_conntrack.h, not nf_conntrack_netlink.h

Quoted 1 line · Duncan Roe

nf_conntrack_netlink.h does not exist, refer to nfnetlink_conntrack.h instead.

Applied to nf, thanks.

author
#10 lore raw

PATCH 1/1 src: annotation: Correctly identify item for which header is needed

In reply to Pablo Neira Ayuso
---
 examples/nf-queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
examples/nf-queue.c +1 -1
index 3da2c24..5b86e69 100644
@@ -15,7 +15,7 @@
 
 #include <libnetfilter_queue/libnetfilter_queue.h>
 
-/* only for NFQA_CT, not needed otherwise: */
+/* NFQA_CT requires CTA_* attributes defined in nfnetlink_conntrack.h */
 #include <linux/netfilter/nfnetlink_conntrack.h>
 
 static struct mnl_socket *nl;
Signature · 1 line
2.17.5
author
#11 lore raw

PATCH 1/1 include: refer to nfnetlink_conntrack.h, not nf_conntrack_netlink.h

In reply to Pablo Neira Ayuso

nf_conntrack_netlink.h does not exist, refer to nfnetlink_conntrack.h instead.

---
 include/libnetfilter_queue/linux_nfnetlink_queue.h | 4 ++--
 include/linux/netfilter/nfnetlink_queue.h          | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/libnetfilter_queue/linux_nfnetlink_queue.h +2 -2
index 1975dfa..caa6788 100644
@@ -46,11 +46,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,			/* security context string */
include/linux/netfilter/nfnetlink_queue.h +2 -2
index 030672d..8e2e469 100644
@@ -42,11 +42,11 @@ enum nfqnl_attr_type {
 	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */
 	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */
 	NFQA_PAYLOAD,			/* opaque data payload */
-	NFQA_CT,			/* nf_conntrack_netlink.h */
+	NFQA_CT,			/* nfnetlink_conntrack.h */
 	NFQA_CT_INFO,			/* enum ip_conntrack_info */
 	NFQA_CAP_LEN,			/* __u32 length of captured packet */
 	NFQA_SKB_INFO,			/* __u32 skb meta information */
-	NFQA_EXP,			/* nf_conntrack_netlink.h */
+	NFQA_EXP,			/* nfnetlink_conntrack.h */
 	NFQA_UID,			/* __u32 sk uid */
 	NFQA_GID,			/* __u32 sk gid */
 	NFQA_SECCTX,
Signature · 1 line
2.17.5