Skip to contentSkip to conversation

ebtables: make it be able to work on 64bit kernel with 32 bit userspace

PATCH In review Mark Hatle 3 participants 4 messages Nov 18, 2014 – Nov 19, 2014

lore
Share & tools
lore

Mark Hatle

author
#0 lore raw

PATCH 1/1 ebtables: make it be able to work on 64bit kernel with 32 bit userspace

From: "Roy.Li" <[email protected]>

[ This patch is being sent up for Yocto Project compliance. I'm not sure it's generally applicable. ]

Some structs, which is used to communicate between user space and kernel, have the alignment issue on 64bit kernel with 32 bit userspace. To fix this issue, ebtables redefines these struct, not use the kernel(sysroot) include/uapi/linux/netfilter_bridge/ebtables.h, like ebt_entry_target:

The kernel's:

struct ebt_entry_target {
        union {
                char name[EBT_FUNCTION_MAXNAMELEN];
                struct xt_target *target;
        } u;
        /* size of data */
        unsigned int target_size;
        unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};

The ebtables:
struct ebt_entry_target

{
        union {
                char name[EBT_FUNCTION_MAXNAMELEN];
                struct ebt_target *target;
        } u;
        /* size of data */
        unsigned int target_size;
|#ifdef KERNEL_64_USERSPACE_32
        unsigned int pad;
|#endif
        unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};

To make it work on 64bit kernel and 32bit userspace, KERNEL_64_USERSPACE_32 is needed to be enabled.

If the MLPREFIX of package matchs "lib.?32", the 32bit multilib package on 64bit kernel is being built.

---
 recipes-filter/ebtables/ebtables_2.0.10-4.bb | 11 +++++++++++
 1 file changed, 11 insertions(+)
recipes-filter/ebtables/ebtables_2.0.10-4.bb +11 -0
index 32cfc75..ca084e3 100644
@@ -27,6 +27,17 @@ S = "${WORKDIR}/ebtables-v${PV}"
 
 inherit update-rc.d systemd
 
+python __anonymous () {
+    import re
+
+    multilib = d.getVar('MLPREFIX', True)
+    if multilib:
+        searchstr = "lib.?32"
+        reg = re.compile(searchstr)
+        if reg.search(multilib):
+            d.appendVar('CFLAGS' ,' -DKERNEL_64_USERSPACE_32 -DEBT_MIN_ALIGN=8')
+}
+
 EXTRA_OEMAKE = " \
         BINDIR=${base_sbindir} \
         MANDIR=${mandir} \
Signature · 1 line
1.9.3
author
#1 lore raw

PATCH 1/1 polarssl: add dependency openssl

From: Kai Kang <[email protected]>

polarssl compiles with openssl to build unit test cases. If openssl doesn't exist, native libssl.so will be used. Then causes error:

| .../bitbake_build/tmp/sysroots/x86_64-linux/usr/lib/libssl.so: error adding symbols: File in wrong format

Add dependency openssl for polarssl to fix it.

---
 recipes-connectivity/polarssl/polarssl_1.3.8.bb | 1 +
 1 file changed, 1 insertion(+)
recipes-connectivity/polarssl/polarssl_1.3.8.bb +1 -0
index 8ca1b1c..7a496b7 100644
@@ -28,6 +28,7 @@ SRC_URI = "https://polarssl.org/download/polarssl-${PV}-gpl.tgz"
 SRC_URI[md5sum] = "d1a2b4f21727e888f143414d2e3144e6"
 SRC_URI[sha256sum] = "318171db41335cacbb5b0047c94f1faf91442ab70a223b5223436703c9406ff1"
 
+DEPENDS = "openssl"
 RDEPENDS_${PN} += "libcrypto"
 EXTRA_OECMAKE = "-DUSE_SHARED_POLARSSL_LIBRARY=on"
 
Signature · 1 line
1.9.3
#2 lore raw

Re: [meta-networking][PATCH] polarssl: add dependency openssl

Quoted 7 lines · Mark Hatle

From: Kai Kang <[email protected]>

polarssl compiles with openssl to build unit test cases. If openssl doesn't exist, native libssl.so will be used. Then causes error:

| .../bitbake_build/tmp/sysroots/x86_64-linux/usr/lib/libssl.so: error adding symbols: File in wrong format

Quoted 7 lines

Add dependency openssl for polarssl to fix it.

---
 recipes-connectivity/polarssl/polarssl_1.3.8.bb | 1 +
 1 file changed, 1 insertion(+)

Doesn't apply because it doesn't have meta-networking/ directory prefix

Quoted 21 lines
recipes-connectivity/polarssl/polarssl_1.3.8.bb +1 -0
index 8ca1b1c..7a496b7 100644
@@ -28,6 +28,7 @@ SRC_URI = "https://polarssl.org/download/polarssl-${PV}-gpl.tgz"
 SRC_URI[md5sum] = "d1a2b4f21727e888f143414d2e3144e6"
 SRC_URI[sha256sum] = "318171db41335cacbb5b0047c94f1faf91442ab70a223b5223436703c9406ff1"
 
+DEPENDS = "openssl"
 RDEPENDS_${PN} += "libcrypto"
 EXTRA_OECMAKE = "-DUSE_SHARED_POLARSSL_LIBRARY=on"
 
Signature · 7 lines
1.9.3

-- 
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#3 lore raw
In reply to Mark Hatle
Quoted 5 lines · Mark Hatle

From: "Roy.Li" <[email protected]>

[ This patch is being sent up for Yocto Project compliance. I'm not sure it's generally applicable. ]

This patch has been merged into meta-oe, but it lead to x86-64 with 32bit user space unable to work, I am see the root cause.

-Roy

Quoted 67 lines

Some structs, which is used to communicate between user space and kernel, have the alignment issue on 64bit kernel with 32 bit userspace. To fix this issue, ebtables redefines these struct, not use the kernel(sysroot) include/uapi/linux/netfilter_bridge/ebtables.h, like ebt_entry_target:

The kernel's:

struct ebt_entry_target {
         union {
                 char name[EBT_FUNCTION_MAXNAMELEN];
                 struct xt_target *target;
         } u;
         /* size of data */
         unsigned int target_size;
         unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};

The ebtables:
struct ebt_entry_target

{
         union {
                 char name[EBT_FUNCTION_MAXNAMELEN];
                 struct ebt_target *target;
         } u;
         /* size of data */
         unsigned int target_size;
|#ifdef KERNEL_64_USERSPACE_32
         unsigned int pad;
|#endif
         unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};

To make it work on 64bit kernel and 32bit userspace, KERNEL_64_USERSPACE_32 is needed to be enabled.

If the MLPREFIX of package matchs "lib.?32", the 32bit multilib package on 64bit kernel is being built.

---
  recipes-filter/ebtables/ebtables_2.0.10-4.bb | 11 +++++++++++
  1 file changed, 11 insertions(+)
recipes-filter/ebtables/ebtables_2.0.10-4.bb +11 -0
index 32cfc75..ca084e3 100644
@@ -27,6 +27,17 @@ S = "${WORKDIR}/ebtables-v${PV}"
 
  inherit update-rc.d systemd
 
+python __anonymous () {
+    import re
+
+    multilib = d.getVar('MLPREFIX', True)
+    if multilib:
+        searchstr = "lib.?32"
+        reg = re.compile(searchstr)
+        if reg.search(multilib):
+            d.appendVar('CFLAGS' ,' -DKERNEL_64_USERSPACE_32 -DEBT_MIN_ALIGN=8')
+}
+
  EXTRA_OEMAKE = " \
          BINDIR=${base_sbindir} \
          MANDIR=${mandir} \
Signature · 2 lines
Best Reagrds,
Roy | RongQing Li