From patchwork Thu Apr 1 12:02:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 49209 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id ECA62B7D06 for ; Thu, 1 Apr 2010 23:02:33 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755826Ab0DAMCT (ORCPT ); Thu, 1 Apr 2010 08:02:19 -0400 Received: from mail-pz0-f179.google.com ([209.85.222.179]:49487 "EHLO mail-pz0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755769Ab0DAMCQ (ORCPT ); Thu, 1 Apr 2010 08:02:16 -0400 Received: by pzk9 with SMTP id 9so1015774pzk.21 for ; Thu, 01 Apr 2010 05:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:cc:content-type; bh=qLnxxIIudiW0qIqahmJLrpdE/PrYQY8Vcyo1OLvNygw=; b=JLENzNya1W83ps8Qck2u7Qc/IJZ/BS7ibYHQNBfbxZPzyjN/iFTZ2gId8dRAJMeJ4a 98vbijglYDD4j+qEH8N61yCyOUmp1jD0R7LDisV9MhwztHYIcK3+Km4TT7nDUUO/jpPW DC4C7jFNScV7g/G/YaEGfpT86jnAXhdaSRxpY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=lyd3kbF8N18QDjh3GtWevCBQSJW6ZIC2A28BwCt/AN0HDTK+I/9VNUFJt5eWdoGzAR cZ9C9wjq48YHCZKGCUl1qhE7KFrFsLlQGzB6GoZPIogAXhy8qiSkjyqCSV9nXnfVexs2 ouM3N8LuFc4pL7s6nhza/VqN97Sl7fLegGU9U= MIME-Version: 1.0 Received: by 10.140.141.2 with HTTP; Thu, 1 Apr 2010 05:02:14 -0700 (PDT) Date: Thu, 1 Apr 2010 15:02:14 +0300 Received: by 10.140.87.23 with SMTP id k23mr260517rvb.108.1270123334834; Thu, 01 Apr 2010 05:02:14 -0700 (PDT) Message-ID: Subject: [PATCH] xtables: make XT_ALIGN() usable in exported headers From: Alexey Dobriyan To: Patrick McHardy Cc: Stephen Hemminger , Ben Hutchings , Andreas Henriksson , jamal , netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Apr 1, 2010 at 1:50 PM, Patrick McHardy 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. [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 Signed-off-by: Alexey Dobriyan --- 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 #include #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);