]> git.hungrycats.org Git - linux/commitdiff
[EBTABLES]: Make it work on 32-on-64 platforms.
authorBart De Schuymer <bdschuym@pandora.be>
Fri, 25 Jul 2003 06:31:55 +0000 (23:31 -0700)
committerDavid S. Miller <davem@nuts.ninka.net>
Fri, 25 Jul 2003 06:31:55 +0000 (23:31 -0700)
12 files changed:
include/linux/netfilter_bridge/ebtables.h
net/bridge/netfilter/ebt_arp.c
net/bridge/netfilter/ebt_dnat.c
net/bridge/netfilter/ebt_ip.c
net/bridge/netfilter/ebt_log.c
net/bridge/netfilter/ebt_mark.c
net/bridge/netfilter/ebt_mark_m.c
net/bridge/netfilter/ebt_pkttype.c
net/bridge/netfilter/ebt_redirect.c
net/bridge/netfilter/ebt_snat.c
net/bridge/netfilter/ebt_stp.c
net/bridge/netfilter/ebt_vlan.c

index 1056e450ef1463bafb49a0736f8fb5d492f3954b..b9fcbf85f047f71e6de4c6b8081b89c1d34c2901 100644 (file)
@@ -33,6 +33,23 @@ struct ebt_counter
        uint64_t bcnt;
 };
 
+struct ebt_replace
+{
+       char name[EBT_TABLE_MAXNAMELEN];
+       unsigned int valid_hooks;
+       /* nr of rules in the table */
+       unsigned int nentries;
+       /* total size of the entries */
+       unsigned int entries_size;
+       /* start of the chains */
+       struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
+       /* nr of counters userspace expects back */
+       unsigned int num_counters;
+       /* where the kernel will put the old counters */
+       struct ebt_counter *counters;
+       char *entries;
+};
+
 struct ebt_entries {
        /* this field is always set to zero
         * See EBT_ENTRY_OR_ENTRIES.
@@ -47,7 +64,7 @@ struct ebt_entries {
        /* nr. of entries */
        unsigned int nentries;
        /* entry list */
-       char data[0];
+       char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 /* used for the bitmask of struct ebt_entry */
@@ -87,7 +104,7 @@ struct ebt_entry_match
        } u;
        /* size of data */
        unsigned int match_size;
-       unsigned char data[0];
+       unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 struct ebt_entry_watcher
@@ -98,7 +115,7 @@ struct ebt_entry_watcher
        } u;
        /* size of data */
        unsigned int watcher_size;
-       unsigned char data[0];
+       unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 struct ebt_entry_target
@@ -109,7 +126,7 @@ struct ebt_entry_target
        } u;
        /* size of data */
        unsigned int target_size;
-       unsigned char data[0];
+       unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 #define EBT_STANDARD_TARGET "standard"
@@ -143,24 +160,7 @@ struct ebt_entry {
        unsigned int target_offset;
        /* sizeof ebt_entry + matches + watchers + target */
        unsigned int next_offset;
-       unsigned char elems[0];
-};
-
-struct ebt_replace
-{
-       char name[EBT_TABLE_MAXNAMELEN];
-       unsigned int valid_hooks;
-       /* nr of rules in the table */
-       unsigned int nentries;
-       /* total size of the entries */
-       unsigned int entries_size;
-       /* start of the chains */
-       struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
-       /* nr of counters userspace expects back */
-       unsigned int num_counters;
-       /* where the kernel will put the old counters */
-       struct ebt_counter *counters;
-       char *entries;
+       unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 /* {g,s}etsockopt numbers */
@@ -263,6 +263,8 @@ struct ebt_table
        struct module *me;
 };
 
+#define EBT_ALIGN(s) (((s) + (__alignof__(struct ebt_replace)-1)) & \
+                    ~(__alignof__(struct ebt_replace)-1))
 extern int ebt_register_table(struct ebt_table *table);
 extern void ebt_unregister_table(struct ebt_table *table);
 extern int ebt_register_match(struct ebt_match *match);
index d63d7206bbcb3e6f6c8b79b44813723884860bef..eb675848fbc3e49c4706f113a5460c70a17c711e 100644 (file)
@@ -99,7 +99,7 @@ static int ebt_arp_check(const char *tablename, unsigned int hookmask,
 {
        struct ebt_arp_info *info = (struct ebt_arp_info *)data;
 
-       if (datalen != sizeof(struct ebt_arp_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_arp_info)))
                return -EINVAL;
        if ((e->ethproto != __constant_htons(ETH_P_ARP) &&
           e->ethproto != __constant_htons(ETH_P_RARP)) ||
index c8b3357cc090b2c3a5ebdbdc8243a3d531b21977..f9552dfb1655169cbca982c4f68b00de0b1edb87 100644 (file)
@@ -47,7 +47,7 @@ static int ebt_target_dnat_check(const char *tablename, unsigned int hookmask,
           (hookmask & ~((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT)))) &&
           (strcmp(tablename, "broute") || hookmask & ~(1 << NF_BR_BROUTING)) )
                return -EINVAL;
-       if (datalen != sizeof(struct ebt_nat_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_nat_info)))
                return -EINVAL;
        if (INVALID_TARGET)
                return -EINVAL;
index 7ef0662f81c62f72c176fdfb74aa4bdefc1f7d66..7bab7d065bd3038cd1bc96c081a9f90f77d6078d 100644 (file)
@@ -75,7 +75,7 @@ static int ebt_ip_check(const char *tablename, unsigned int hookmask,
 {
        struct ebt_ip_info *info = (struct ebt_ip_info *)data;
 
-       if (datalen != sizeof(struct ebt_ip_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_ip_info)))
                return -EINVAL;
        if (e->ethproto != __constant_htons(ETH_P_IP) ||
           e->invflags & EBT_IPROTO)
index e7a3ef4afe5a47d1ddc8f51373abb6f7e178e5f8..2da7c682744d386954ca13dde1476607ada18343 100644 (file)
@@ -22,7 +22,7 @@ static int ebt_log_check(const char *tablename, unsigned int hookmask,
 {
        struct ebt_log_info *info = (struct ebt_log_info *)data;
 
-       if (datalen != sizeof(struct ebt_log_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_log_info)))
                return -EINVAL;
        if (info->bitmask & ~EBT_LOG_MASK)
                return -EINVAL;
index b7a87f612983f3a63fbabb2dbdd4c670a43526ba..02c632b4d3259a97b91a972d97e882dc46959e09 100644 (file)
@@ -35,7 +35,7 @@ static int ebt_target_mark_check(const char *tablename, unsigned int hookmask,
 {
        struct ebt_mark_t_info *info = (struct ebt_mark_t_info *)data;
 
-       if (datalen != sizeof(struct ebt_mark_t_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info)))
                return -EINVAL;
        if (BASE_CHAIN && info->target == EBT_RETURN)
                return -EINVAL;
index c710b4e0be14f0ee957fccfc19be26455a1b93bb..625102de1495ef423ba1c7c7f42791785d7629fd 100644 (file)
@@ -28,7 +28,7 @@ static int ebt_mark_check(const char *tablename, unsigned int hookmask,
 {
         struct ebt_mark_m_info *info = (struct ebt_mark_m_info *) data;
 
-       if (datalen != sizeof(struct ebt_mark_m_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_m_info)))
                return -EINVAL;
        if (info->bitmask & ~EBT_MARK_MASK)
                return -EINVAL;
index f6458adea80a463ba9020e01cd78c32202cb0ba3..ecd3b42b19b0d399d526bc9d26e52e1fb5eeb2dc 100644 (file)
@@ -28,7 +28,7 @@ static int ebt_pkttype_check(const char *tablename, unsigned int hookmask,
 {
        struct ebt_pkttype_info *info = (struct ebt_pkttype_info *)data;
 
-       if (datalen != sizeof(struct ebt_pkttype_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_pkttype_info)))
                return -EINVAL;
        if (info->invert != 0 && info->invert != 1)
                return -EINVAL;
index d97d05fdd14f4b053148619473c89e8f5016521c..998bab1c5ef9202f781c71cd042aa3673b3bffc0 100644 (file)
@@ -47,7 +47,7 @@ static int ebt_target_redirect_check(const char *tablename, unsigned int hookmas
 {
        struct ebt_redirect_info *info = (struct ebt_redirect_info *)data;
 
-       if (datalen != sizeof(struct ebt_redirect_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_redirect_info)))
                return -EINVAL;
        if (BASE_CHAIN && info->target == EBT_RETURN)
                return -EINVAL;
index c457ac90c5c62c524e51dde6e2252bd9adf3785f..ae0f0539c5f09676bf710dcea89cfdb241dfcc2f 100644 (file)
@@ -40,7 +40,7 @@ static int ebt_target_snat_check(const char *tablename, unsigned int hookmask,
 {
        struct ebt_nat_info *info = (struct ebt_nat_info *) data;
 
-       if (datalen != sizeof(struct ebt_nat_info))
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_nat_info)))
                return -EINVAL;
        if (BASE_CHAIN && info->target == EBT_RETURN)
                return -EINVAL;
index 8be478935ba8ef19bb2095f9b3514286a25389a4..d0299efa10017e0d05f0625abf971ac10c1358b4 100644 (file)
@@ -150,7 +150,7 @@ static int ebt_stp_check(const char *tablename, unsigned int hookmask,
    const struct ebt_entry *e, void *data, unsigned int datalen)
 {
        struct ebt_stp_info *info = (struct ebt_stp_info *)data;
-       int len = sizeof(struct ebt_stp_info);
+       int len = EBT_ALIGN(sizeof(struct ebt_stp_info));
        uint8_t bridge_ula[6] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
        uint8_t msk[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
index 54120a771d3ea8e5b8fdfe5c43890d497f90d6cc..341af7d5708b301086aa55d2886f62772118687b 100644 (file)
@@ -35,7 +35,7 @@ MODULE_DESCRIPTION("802.1Q match module (ebtables extension), v"
 MODULE_LICENSE("GPL");
 
 
-#define DEBUG_MSG(...) if (debug) printk (KERN_DEBUG "ebt_vlan: " __VA_ARGS__)
+#define DEBUG_MSG(args...) if (debug) printk (KERN_DEBUG "ebt_vlan: " args)
 #define INV_FLAG(_inv_flag_) (info->invflags & _inv_flag_) ? "!" : ""
 #define GET_BITMASK(_BIT_MASK_) info->bitmask & _BIT_MASK_
 #define SET_BITMASK(_BIT_MASK_) info->bitmask |= _BIT_MASK_
@@ -94,7 +94,7 @@ ebt_check_vlan(const char *tablename,
        struct ebt_vlan_info *info = (struct ebt_vlan_info *) data;
 
        /* Parameters buffer overflow check */
-       if (datalen != sizeof(struct ebt_vlan_info)) {
+       if (datalen != EBT_ALIGN(sizeof(struct ebt_vlan_info))) {
                DEBUG_MSG
                    ("passed size %d is not eq to ebt_vlan_info (%Zd)\n",
                     datalen, sizeof(struct ebt_vlan_info));