* [PATCH] xtables: make XT_ALIGN() usable in exported headers
@ 2010-04-01 12:02 Alexey Dobriyan
2010-04-01 12:06 ` Patrick McHardy
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2010-04-01 12:02 UTC (permalink / raw)
To: Patrick McHardy
Cc: Stephen Hemminger, Ben Hutchings, Andreas Henriksson, jamal,
netdev
[-- Attachment #1: Type: text/plain, Size: 411 bytes --]
On Thu, Apr 1, 2010 at 1:50 PM, Patrick McHardy <kaber@trash•net> wrote:
> I can't think of anything but to restore the XT_ALIGN macro.
> We could add a XT_ALIGN definition to xtables.h, but that might
> still leave problems for other users.
>
> Alexey, do you have any better suggestions?
I like __KERNEL_ALIGN trick.
Sorry for attachment, my patch sending facility is broke.
Tested on iptables compilation.
[-- Attachment #2: xt-align.patch --]
[-- Type: text/x-diff, Size: 2528 bytes --]
[PATCH] xtables: make XT_ALIGN() usable in exported headers
XT_ALIGN() was rewritten through ALIGN() by commit 42107f5009da223daa800d6da6904d77297ae829
"netfilter: xtables: symmetric COMPAT_XT_ALIGN definition".
ALIGN() is not exported in userspace headers, which created compile problem for tc(8)
and will create problem for iptables(8).
We can't export generic looking name ALIGN() but we can export less generic
__ALIGN_KERNEL() (suggested by Ben Hutchings).
Google knows nothing about __ALIGN_KERNEL().
COMPAT_XT_ALIGN() changed for symmetry.
Reported-by: Andreas Henriksson <andreas@fatal•se>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail•com>
---
include/linux/kernel.h | 5 +++--
include/linux/netfilter/x_tables.h | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 7f07074..284ea99 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -4,6 +4,8 @@
/*
* 'kernel.h' contains some often-used function prototypes etc
*/
+#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
#ifdef __KERNEL__
@@ -37,8 +39,7 @@ extern const char linux_proc_banner[];
#define STACK_MAGIC 0xdeadbeef
-#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
-#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
+#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 84c7c92..f01ddbe 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -1,6 +1,6 @@
#ifndef _X_TABLES_H
#define _X_TABLES_H
-
+#include <linux/kernel.h>
#include <linux/types.h>
#define XT_FUNCTION_MAXNAMELEN 30
@@ -93,7 +93,7 @@ struct _xt_align {
__u64 u64;
};
-#define XT_ALIGN(s) ALIGN((s), __alignof__(struct _xt_align))
+#define XT_ALIGN(s) __ALIGN_KERNEL((s), __alignof__(struct _xt_align))
/* Standard return verdict, or do jump. */
#define XT_STANDARD_TARGET ""
@@ -598,7 +598,7 @@ struct _compat_xt_align {
compat_u64 u64;
};
-#define COMPAT_XT_ALIGN(s) ALIGN((s), __alignof__(struct _compat_xt_align))
+#define COMPAT_XT_ALIGN(s) __ALIGN_KERNEL((s), __alignof__(struct _compat_xt_align))
extern void xt_compat_lock(u_int8_t af);
extern void xt_compat_unlock(u_int8_t af);
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] xtables: make XT_ALIGN() usable in exported headers
2010-04-01 12:02 [PATCH] xtables: make XT_ALIGN() usable in exported headers Alexey Dobriyan
@ 2010-04-01 12:06 ` Patrick McHardy
2010-04-01 12:25 ` "YOSHIFUJI Hideaki (吉藤 英明)"
0 siblings, 1 reply; 3+ messages in thread
From: Patrick McHardy @ 2010-04-01 12:06 UTC (permalink / raw)
To: Alexey Dobriyan
Cc: Stephen Hemminger, Ben Hutchings, Andreas Henriksson, jamal,
netdev
Alexey Dobriyan wrote:
> On Thu, Apr 1, 2010 at 1:50 PM, Patrick McHardy <kaber@trash•net> wrote:
>> I can't think of anything but to restore the XT_ALIGN macro.
>> We could add a XT_ALIGN definition to xtables.h, but that might
>> still leave problems for other users.
>>
>> Alexey, do you have any better suggestions?
>
> I like __KERNEL_ALIGN trick.
>
> Sorry for attachment, my patch sending facility is broke.
> Tested on iptables compilation.
>
Seems fine to me, thanks. I'll wait a bit for others to comment.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xtables: make XT_ALIGN() usable in exported headers
2010-04-01 12:06 ` Patrick McHardy
@ 2010-04-01 12:25 ` "YOSHIFUJI Hideaki (吉藤 英明)"
0 siblings, 0 replies; 3+ messages in thread
From: "YOSHIFUJI Hideaki (吉藤 英明)" @ 2010-04-01 12:25 UTC (permalink / raw)
To: Patrick McHardy
Cc: Alexey Dobriyan, Stephen Hemminger, Ben Hutchings,
Andreas Henriksson, jamal, netdev
I think it is better to solicit comments on LKML.
This is not a new issue but rather a common one
(e.g. CMSG_ALIGN uses its own definition).
Regards,
--yoshfuji
(2010/04/01 21:06), Patrick McHardy wrote:
> Alexey Dobriyan wrote:
>> On Thu, Apr 1, 2010 at 1:50 PM, Patrick McHardy<kaber@trash•net> wrote:
>>> I can't think of anything but to restore the XT_ALIGN macro.
>>> We could add a XT_ALIGN definition to xtables.h, but that might
>>> still leave problems for other users.
>>>
>>> Alexey, do you have any better suggestions?
>>
>> I like __KERNEL_ALIGN trick.
>>
>> Sorry for attachment, my patch sending facility is broke.
>> Tested on iptables compilation.
>>
>
> Seems fine to me, thanks. I'll wait a bit for others to comment.
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger•kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-01 12:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-01 12:02 [PATCH] xtables: make XT_ALIGN() usable in exported headers Alexey Dobriyan
2010-04-01 12:06 ` Patrick McHardy
2010-04-01 12:25 ` "YOSHIFUJI Hideaki (吉藤 英明)"
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox