Skip to contentSkip to conversation

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

PATCH In review [email protected] 1 participant 2 messages Nov 12, 2014 – Nov 19, 2014

lore
Share & tools
lore
#0 lore raw

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

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

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.

---
 meta-networking/recipes-filter/ebtables/ebtables_2.0.10-4.bb | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta-networking/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
2.1.0
#1 lore raw

Please drop it, it make x86 unable to work

-Roy

Quoted 67 lines · On 2014年11月12日 10:01, [email protected] wrote:

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

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.

---
  meta-networking/recipes-filter/ebtables/ebtables_2.0.10-4.bb | 11 +++++++++++
  1 file changed, 11 insertions(+)
meta-networking/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