Skip to content

Commit

Permalink
netfilter: xtables: resolve indirect macros 2/3
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
  • Loading branch information
Jan Engelhardt committed Oct 13, 2010
1 parent 12b00c2 commit 87a2e70
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 108 deletions.
15 changes: 7 additions & 8 deletions include/linux/netfilter_arp/arp_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#ifndef __KERNEL__
#define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
#define arpt_entry_target xt_entry_target
#define arpt_standard_target xt_standard_target
#endif

#define ARPT_DEV_ADDR_LEN_MAX 16
Expand Down Expand Up @@ -65,9 +67,6 @@ struct arpt_arp {
u_int16_t invflags;
};

#define arpt_entry_target xt_entry_target
#define arpt_standard_target xt_standard_target

/* Values for "flag" field in struct arpt_ip (general arp structure).
* No flags defined yet.
*/
Expand Down Expand Up @@ -208,7 +207,7 @@ struct arpt_get_entries {
#define ARPT_ERROR_TARGET XT_ERROR_TARGET

/* Helper functions */
static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e)
static __inline__ struct xt_entry_target *arpt_get_target(struct arpt_entry *e)
{
return (void *)e + e->target_offset;
}
Expand All @@ -227,11 +226,11 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e
/* Standard entry. */
struct arpt_standard {
struct arpt_entry entry;
struct arpt_standard_target target;
struct xt_standard_target target;
};

struct arpt_error_target {
struct arpt_entry_target target;
struct xt_entry_target target;
char errorname[XT_FUNCTION_MAXNAMELEN];
};

Expand All @@ -250,7 +249,7 @@ struct arpt_error {
{ \
.entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \
.target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \
sizeof(struct arpt_standard_target)), \
sizeof(struct xt_standard_target)), \
.target.verdict = -(__verdict) - 1, \
}

Expand Down Expand Up @@ -287,7 +286,7 @@ struct compat_arpt_entry {
unsigned char elems[0];
};

static inline struct arpt_entry_target *
static inline struct xt_entry_target *
compat_arpt_get_target(struct compat_arpt_entry *e)
{
return (void *)e + e->target_offset;
Expand Down
18 changes: 8 additions & 10 deletions include/linux/netfilter_ipv4/ip_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#define ipt_target xt_target
#define ipt_table xt_table
#define ipt_get_revision xt_get_revision
#define ipt_entry_match xt_entry_match
#define ipt_entry_target xt_entry_target
#define ipt_standard_target xt_standard_target
#define ipt_counters xt_counters
#endif

/* Yes, Virginia, you have to zero the padding. */
Expand All @@ -54,12 +58,6 @@ struct ipt_ip {
u_int8_t invflags;
};

#define ipt_entry_match xt_entry_match
#define ipt_entry_target xt_entry_target
#define ipt_standard_target xt_standard_target

#define ipt_counters xt_counters

/* Values for "flag" field in struct ipt_ip (general ip structure). */
#define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */
#define IPT_F_GOTO 0x02 /* Set if jump is a goto */
Expand Down Expand Up @@ -219,7 +217,7 @@ struct ipt_get_entries {
#define IPT_ERROR_TARGET XT_ERROR_TARGET

/* Helper functions */
static __inline__ struct ipt_entry_target *
static __inline__ struct xt_entry_target *
ipt_get_target(struct ipt_entry *e)
{
return (void *)e + e->target_offset;
Expand Down Expand Up @@ -251,11 +249,11 @@ extern void ipt_unregister_table(struct net *net, struct xt_table *table);
/* Standard entry. */
struct ipt_standard {
struct ipt_entry entry;
struct ipt_standard_target target;
struct xt_standard_target target;
};

struct ipt_error_target {
struct ipt_entry_target target;
struct xt_entry_target target;
char errorname[XT_FUNCTION_MAXNAMELEN];
};

Expand Down Expand Up @@ -309,7 +307,7 @@ struct compat_ipt_entry {
};

/* Helper functions */
static inline struct ipt_entry_target *
static inline struct xt_entry_target *
compat_ipt_get_target(struct compat_ipt_entry *e)
{
return (void *)e + e->target_offset;
Expand Down
20 changes: 9 additions & 11 deletions include/linux/netfilter_ipv6/ip6_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#define ip6t_target xt_target
#define ip6t_table xt_table
#define ip6t_get_revision xt_get_revision
#define ip6t_entry_match xt_entry_match
#define ip6t_entry_target xt_entry_target
#define ip6t_standard_target xt_standard_target
#define ip6t_counters xt_counters
#endif

/* Yes, Virginia, you have to zero the padding. */
Expand Down Expand Up @@ -63,12 +67,6 @@ struct ip6t_ip6 {
u_int8_t invflags;
};

#define ip6t_entry_match xt_entry_match
#define ip6t_entry_target xt_entry_target
#define ip6t_standard_target xt_standard_target

#define ip6t_counters xt_counters

/* Values for "flag" field in struct ip6t_ip6 (general ip6 structure). */
#define IP6T_F_PROTO 0x01 /* Set if rule cares about upper
protocols */
Expand Down Expand Up @@ -113,11 +111,11 @@ struct ip6t_entry {
/* Standard entry */
struct ip6t_standard {
struct ip6t_entry entry;
struct ip6t_standard_target target;
struct xt_standard_target target;
};

struct ip6t_error_target {
struct ip6t_entry_target target;
struct xt_entry_target target;
char errorname[XT_FUNCTION_MAXNAMELEN];
};

Expand All @@ -136,7 +134,7 @@ struct ip6t_error {
{ \
.entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \
.target = XT_TARGET_INIT(IP6T_STANDARD_TARGET, \
sizeof(struct ip6t_standard_target)), \
sizeof(struct xt_standard_target)), \
.target.verdict = -(__verdict) - 1, \
}

Expand Down Expand Up @@ -275,7 +273,7 @@ struct ip6t_get_entries {
#define IP6T_ERROR_TARGET XT_ERROR_TARGET

/* Helper functions */
static __inline__ struct ip6t_entry_target *
static __inline__ struct xt_entry_target *
ip6t_get_target(struct ip6t_entry *e)
{
return (void *)e + e->target_offset;
Expand Down Expand Up @@ -332,7 +330,7 @@ struct compat_ip6t_entry {
unsigned char elems[0];
};

static inline struct ip6t_entry_target *
static inline struct xt_entry_target *
compat_ip6t_get_target(struct compat_ip6t_entry *e)
{
return (void *)e + e->target_offset;
Expand Down
38 changes: 19 additions & 19 deletions net/ipv4/netfilter/arp_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ arpt_error(struct sk_buff *skb, const struct xt_action_param *par)
return NF_DROP;
}

static inline const struct arpt_entry_target *
static inline const struct xt_entry_target *
arpt_get_target_c(const struct arpt_entry *e)
{
return arpt_get_target((struct arpt_entry *)e);
Expand Down Expand Up @@ -282,7 +282,7 @@ unsigned int arpt_do_table(struct sk_buff *skb,

arp = arp_hdr(skb);
do {
const struct arpt_entry_target *t;
const struct xt_entry_target *t;

if (!arp_packet_match(arp, skb->dev, indev, outdev, &e->arp)) {
e = arpt_next_entry(e);
Expand All @@ -297,7 +297,7 @@ unsigned int arpt_do_table(struct sk_buff *skb,
if (!t->u.kernel.target->target) {
int v;

v = ((struct arpt_standard_target *)t)->verdict;
v = ((struct xt_standard_target *)t)->verdict;
if (v < 0) {
/* Pop from stack? */
if (v != ARPT_RETURN) {
Expand Down Expand Up @@ -377,7 +377,7 @@ static int mark_source_chains(const struct xt_table_info *newinfo,
e->counters.pcnt = pos;

for (;;) {
const struct arpt_standard_target *t
const struct xt_standard_target *t
= (void *)arpt_get_target_c(e);
int visited = e->comefrom & (1 << hook);

Expand Down Expand Up @@ -464,14 +464,14 @@ static int mark_source_chains(const struct xt_table_info *newinfo,

static inline int check_entry(const struct arpt_entry *e, const char *name)
{
const struct arpt_entry_target *t;
const struct xt_entry_target *t;

if (!arp_checkentry(&e->arp)) {
duprintf("arp_tables: arp check failed %p %s.\n", e, name);
return -EINVAL;
}

if (e->target_offset + sizeof(struct arpt_entry_target) > e->next_offset)
if (e->target_offset + sizeof(struct xt_entry_target) > e->next_offset)
return -EINVAL;

t = arpt_get_target_c(e);
Expand All @@ -483,7 +483,7 @@ static inline int check_entry(const struct arpt_entry *e, const char *name)

static inline int check_target(struct arpt_entry *e, const char *name)
{
struct arpt_entry_target *t = arpt_get_target(e);
struct xt_entry_target *t = arpt_get_target(e);
int ret;
struct xt_tgchk_param par = {
.table = name,
Expand All @@ -506,7 +506,7 @@ static inline int check_target(struct arpt_entry *e, const char *name)
static inline int
find_check_entry(struct arpt_entry *e, const char *name, unsigned int size)
{
struct arpt_entry_target *t;
struct xt_entry_target *t;
struct xt_target *target;
int ret;

Expand Down Expand Up @@ -536,15 +536,15 @@ find_check_entry(struct arpt_entry *e, const char *name, unsigned int size)

static bool check_underflow(const struct arpt_entry *e)
{
const struct arpt_entry_target *t;
const struct xt_entry_target *t;
unsigned int verdict;

if (!unconditional(&e->arp))
return false;
t = arpt_get_target_c(e);
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0)
return false;
verdict = ((struct arpt_standard_target *)t)->verdict;
verdict = ((struct xt_standard_target *)t)->verdict;
verdict = -verdict - 1;
return verdict == NF_DROP || verdict == NF_ACCEPT;
}
Expand All @@ -566,7 +566,7 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,
}

if (e->next_offset
< sizeof(struct arpt_entry) + sizeof(struct arpt_entry_target)) {
< sizeof(struct arpt_entry) + sizeof(struct xt_entry_target)) {
duprintf("checking: element %p size %u\n",
e, e->next_offset);
return -EINVAL;
Expand Down Expand Up @@ -598,7 +598,7 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,
static inline void cleanup_entry(struct arpt_entry *e)
{
struct xt_tgdtor_param par;
struct arpt_entry_target *t;
struct xt_entry_target *t;

t = arpt_get_target(e);
par.target = t->u.kernel.target;
Expand Down Expand Up @@ -794,7 +794,7 @@ static int copy_entries_to_user(unsigned int total_size,
/* FIXME: use iterator macros --RR */
/* ... then go back and fix counters and names */
for (off = 0, num = 0; off < total_size; off += e->next_offset, num++){
const struct arpt_entry_target *t;
const struct xt_entry_target *t;

e = (struct arpt_entry *)(loc_cpu_entry + off);
if (copy_to_user(userptr + off
Expand All @@ -807,7 +807,7 @@ static int copy_entries_to_user(unsigned int total_size,

t = arpt_get_target_c(e);
if (copy_to_user(userptr + off + e->target_offset
+ offsetof(struct arpt_entry_target,
+ offsetof(struct xt_entry_target,
u.user.name),
t->u.kernel.target->name,
strlen(t->u.kernel.target->name)+1) != 0) {
Expand Down Expand Up @@ -844,7 +844,7 @@ static int compat_calc_entry(const struct arpt_entry *e,
const struct xt_table_info *info,
const void *base, struct xt_table_info *newinfo)
{
const struct arpt_entry_target *t;
const struct xt_entry_target *t;
unsigned int entry_offset;
int off, i, ret;

Expand Down Expand Up @@ -1204,7 +1204,7 @@ static int do_add_counters(struct net *net, const void __user *user,
#ifdef CONFIG_COMPAT
static inline void compat_release_entry(struct compat_arpt_entry *e)
{
struct arpt_entry_target *t;
struct xt_entry_target *t;

t = compat_arpt_get_target(e);
module_put(t->u.kernel.target->me);
Expand All @@ -1220,7 +1220,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
const unsigned int *underflows,
const char *name)
{
struct arpt_entry_target *t;
struct xt_entry_target *t;
struct xt_target *target;
unsigned int entry_offset;
int ret, off, h;
Expand Down Expand Up @@ -1288,7 +1288,7 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
unsigned int *size, const char *name,
struct xt_table_info *newinfo, unsigned char *base)
{
struct arpt_entry_target *t;
struct xt_entry_target *t;
struct xt_target *target;
struct arpt_entry *de;
unsigned int origsize;
Expand Down Expand Up @@ -1567,7 +1567,7 @@ static int compat_copy_entry_to_user(struct arpt_entry *e, void __user **dstptr,
struct xt_counters *counters,
unsigned int i)
{
struct arpt_entry_target *t;
struct xt_entry_target *t;
struct compat_arpt_entry __user *ce;
u_int16_t target_offset, next_offset;
compat_uint_t origsize;
Expand Down
Loading

0 comments on commit 87a2e70

Please sign in to comment.