[PATCH] make ebtables work on sparc64
Bart De Schuymer <[email protected]>
| Newsgroups | gmane.linux.network.bridge.ebtables.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Dave,
The patch below does the kernel part to get userspace32 and kernel64 to
communicate correctly on the Sparc64. This patch is compatible with
earlier versions of the ebtables userspace program, for the i386.
cheers,
Bart
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_redirect.c Fri Jul 25 21:47:33 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_redirect.c Fri Jul 25 20:51:19 2003
@@ -47,7 +47,7 @@ static int ebt_target_redirect_check(con
{
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;
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_arp.c Mon Jul 14 05:32:33 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_arp.c Fri Jul 25 20:48:11 2003
@@ -99,7 +99,7 @@ static int ebt_arp_check(const char *tab
{
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)) ||
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_ip.c Mon Jul 14 05:33:46 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_ip.c Fri Jul 25 20:50:08 2003
@@ -75,7 +75,7 @@ static int ebt_ip_check(const char *tabl
{
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)
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_stp.c Fri Jul 25 21:45:05 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_stp.c Fri Jul 25 20:51:52 2003
@@ -150,7 +150,7 @@ static int ebt_stp_check(const char *tab
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 };
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_pkttype.c Mon Jul 14 05:28:55 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_pkttype.c Fri Jul 25 20:51:04 2003
@@ -28,7 +28,7 @@ static int ebt_pkttype_check(const char
{
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;
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_vlan.c Mon Jul 14 05:34:33 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_vlan.c Fri Jul 25 20:52:52 2003
@@ -35,7 +35,7 @@ MODULE_DESCRIPTION("802.1Q match module
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));
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_log.c Mon Jul 14 05:35:56 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_log.c Wed Jul 23 22:36:12 2003
@@ -22,7 +22,7 @@ static int ebt_log_check(const char *tab
{
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;
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_mark.c Mon Jul 14 05:37:14 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_mark.c Fri Jul 25 20:50:29 2003
@@ -35,7 +35,7 @@ static int ebt_target_mark_check(const c
{
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;
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_mark_m.c Mon Jul 14 05:32:33 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_mark_m.c Fri Jul 25 20:50:43 2003
@@ -28,7 +28,7 @@ static int ebt_mark_check(const char *ta
{
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;
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_snat.c Fri Jul 25 21:47:33 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_snat.c Fri Jul 25 21:50:48 2003
@@ -40,7 +40,7 @@ static int ebt_target_snat_check(const c
{
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;
--- linux-2.6.0-test1/net/bridge/netfilter/ebt_dnat.c Fri Jul 25 21:47:33 2003
+++ linux-2.6.0-test1-keep/net/bridge/netfilter/ebt_dnat.c Fri Jul 25 21:50:53 2003
@@ -47,7 +47,7 @@ static int ebt_target_dnat_check(const c
(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;
--- linux-2.6.0-test1/include/linux/netfilter_bridge/ebtables.h Mon Jul 14 05:38:38 2003
+++ linux-2.6.0-test1-keep/include/linux/netfilter_bridge/ebtables.h Fri Jul 25 20:47:33 2003
@@ -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);
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01