diff mbox

norm: fix build failure with old headers

Message ID 1459431938-28257-1-git-send-email-gustavo@zacarias.com.ar
State Accepted
Headers show

Commit Message

Gustavo Zacarias March 31, 2016, 1:45 p.m. UTC
The version check for the nfq_get_payload prototype is wrong since it's
done against linux headers when in fact it changed with the 1.0.0
release of libnetfilter_queue, leading to build failure in toolchains
that have old headers when libnetfilter_queue is present. Fixes:
http://autobuild.buildroot.net/results/c0e/c0e897a6db888d4a7e0302cdc1e0cbec7d1e88f3/

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
---
 .../0002-protolib-drop-linux-version-check.patch   | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 package/norm/0002-protolib-drop-linux-version-check.patch

Comments

Thomas Petazzoni March 31, 2016, 4:18 p.m. UTC | #1
Hello,

On Thu, 31 Mar 2016 10:45:38 -0300, Gustavo Zacarias wrote:
> The version check for the nfq_get_payload prototype is wrong since it's
> done against linux headers when in fact it changed with the 1.0.0
> release of libnetfilter_queue, leading to build failure in toolchains
> that have old headers when libnetfilter_queue is present. Fixes:
> http://autobuild.buildroot.net/results/c0e/c0e897a6db888d4a7e0302cdc1e0cbec7d1e88f3/
> 
> Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
> ---
>  .../0002-protolib-drop-linux-version-check.patch   | 38 ++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>  create mode 100644 package/norm/0002-protolib-drop-linux-version-check.patch

Applied to master, thanks. It would be good to submit the patch
upstream. Maybe the patch is not acceptable as-is because it will break
with older versions of libnetfilter_queue, but I guess an autoconf
check can be added for that.

Thanks,

Thomas
Gustavo Zacarias March 31, 2016, 4:23 p.m. UTC | #2
On 31/03/16 13:18, Thomas Petazzoni wrote:

> Applied to master, thanks. It would be good to submit the patch
> upstream. Maybe the patch is not acceptable as-is because it will break
> with older versions of libnetfilter_queue, but I guess an autoconf
> check can be added for that.

Hi.
Indeed it's probably not acceptable for old netfilter_queue 
compatibility, though i made it the quick way since it was polluting the 
autobuilders.
It's waf, my famous friend, i'll try to cook up a failproof test for it, 
unfortunately netfilter_queue doesn't version the API in a visible way, 
so maybe a pkg-config though i need to consult the author/maintainer 
since it would be a new dependency to build.
Regards.
Thomas Petazzoni March 31, 2016, 4:30 p.m. UTC | #3
Hello,

On Thu, 31 Mar 2016 13:23:01 -0300, Gustavo Zacarias wrote:

> Indeed it's probably not acceptable for old netfilter_queue 
> compatibility, though i made it the quick way since it was polluting the 
> autobuilders.

Sure. That's also why I applied.

> It's waf, my famous friend, i'll try to cook up a failproof test for it, 
> unfortunately netfilter_queue doesn't version the API in a visible way, 
> so maybe a pkg-config though i need to consult the author/maintainer 
> since it would be a new dependency to build.

I think version-based checks are broken. You should instead have a
check that actually tries to build a small piece of code that tests if
the API is old/new and see if the builds succeeds/fails.

But yeah, waf. Good luck.

Best regards,

Thomas
diff mbox

Patch

diff --git a/package/norm/0002-protolib-drop-linux-version-check.patch b/package/norm/0002-protolib-drop-linux-version-check.patch
new file mode 100644
index 0000000..7852a30
--- /dev/null
+++ b/package/norm/0002-protolib-drop-linux-version-check.patch
@@ -0,0 +1,38 @@ 
+The char * to unsigned char * change happened for the libnetfilter_queue
+1.0.0 release, not the linux headers.
+So drop the linux headers version check since it causes more harm than
+good by trying the old API when the toolchain uses old linux headers
+with a new-enough libnetfilter_queue.
+
+Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
+
+diff -Nura norm-1.5r6.orig/protolib/src/linux/linuxDetour.cpp norm-1.5r6/protolib/src/linux/linuxDetour.cpp
+--- norm-1.5r6.orig/protolib/src/linux/linuxDetour.cpp	2016-03-31 10:17:20.674745597 -0300
++++ norm-1.5r6/protolib/src/linux/linuxDetour.cpp	2016-03-31 10:36:58.923084395 -0300
+@@ -16,8 +16,6 @@
+ #include <linux/if_ether.h>  // for ETH_P_IP
+ #include <net/if_arp.h>   // for ARPHRD_ETHER
+ 
+-#include <linux/version.h>  // for LINUX_VERSION_CODE
+-
+ /** NOTES: 
+  *
+  * 1) This newer implementation of LinuxDetour uses netfilter_queue
+@@ -591,17 +589,7 @@
+     
+     // Finally record packet length and cache pointer to IP packet data
+     
+-    // A change to the nfq_get_payload() prototype seemed to kick in around Linux header files
+-    // version 3.6?  (This will probably need to be fine tuned for the right version threshold.)
+-
+-#define LINUX_VERSION_MAJOR (LINUX_VERSION_CODE/65536)
+-#define LINUX_VERSION_MINOR ((LINUX_VERSION_CODE - (LINUX_VERSION_MAJOR*65536)) / 256)
+-
+-#if ((LINUX_VERSION_MAJOR > 3) || ((LINUX_VERSION_MAJOR == 3) && (LINUX_VERSION_MINOR > 5)))
+     linuxDetour->nfq_pkt_len = nfq_get_payload(nfqData, (unsigned char**)(&linuxDetour->nfq_pkt_data));
+-#else
+-    linuxDetour->nfq_pkt_len = nfq_get_payload(nfqData, &linuxDetour->nfq_pkt_data);
+-#endif //
+     return 0;
+ }  // end LinuxDetour::NfqCallback()
+