Skip to contentSkip to conversation

examples: nft-rule-add: Fix compile on musl libc

PATCH In review Anna Wilcox 2 participants 3 messages Mar 20 – Mar 22 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples: nft-rule-add: Fix compile on musl libc

Without _GNU_SOURCE, the dest field on tcphdr is not present:

nft-rule-add.c: In function 'setup_rule':
nft-rule-add.c:108:21: error: 'struct tcphdr' has no member named 'dest'

---
 examples/nft-rule-add.c | 1 +
 1 file changed, 1 insertion(+)
examples/nft-rule-add.c +1 -0
index 937b436..486544a 100644
@@ -5,6 +5,7 @@
  * This software has been sponsored by Sophos Astaro <http://www.sophos.com>
  */
 
+#define _GNU_SOURCE	/* for tcphdr.dest */
 #include <stdlib.h>
 #include <time.h>
 #include <string.h>
Signature · 1 line
2.52.0
#1 lore raw
Quoted 4 lines · Anna Wilcox

Without _GNU_SOURCE, the dest field on tcphdr is not present:

nft-rule-add.c: In function 'setup_rule':
nft-rule-add.c:108:21: error: 'struct tcphdr' has no member named 'dest'

Do more examples need this?

Quoted 21 lines
---
 examples/nft-rule-add.c | 1 +
 1 file changed, 1 insertion(+)
examples/nft-rule-add.c +1 -0
index 937b436..486544a 100644
@@ -5,6 +5,7 @@
  * This software has been sponsored by Sophos Astaro <http://www.sophos.com>
  */
 
+#define _GNU_SOURCE	/* for tcphdr.dest */
 #include <stdlib.h>
 #include <time.h>
 #include <string.h>
Signature · 1 line
2.52.0
author
#2 lore raw
Quoted 8 lines · Pablo Neira Ayuso
Quoted 4 lines · Anna Wilcox

Without _GNU_SOURCE, the dest field on tcphdr is not present:

nft-rule-add.c: In function 'setup_rule':
nft-rule-add.c:108:21: error: 'struct tcphdr' has no member named 'dest'

Do more examples need this?

No. The libnftnl test suite passes fully once this patch is applied.

Best,
-Anna