Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
[NETFILTER]: x_tables: switch xt_match->checkentry to bool
Browse files Browse the repository at this point in the history
Switch the return type of match functions to boolean

Signed-off-by: Jan Engelhardt <[email protected]>
Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jan Engelhardt authored and David S. Miller committed Jul 11, 2007
1 parent 1d93a9c commit ccb79bd
Show file tree
Hide file tree
Showing 33 changed files with 148 additions and 148 deletions.
10 changes: 5 additions & 5 deletions include/linux/netfilter/x_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ struct xt_match

/* Called when user tries to insert an entry of this type. */
/* Should return true or false. */
int (*checkentry)(const char *tablename,
const void *ip,
const struct xt_match *match,
void *matchinfo,
unsigned int hook_mask);
bool (*checkentry)(const char *tablename,
const void *ip,
const struct xt_match *match,
void *matchinfo,
unsigned int hook_mask);

/* Called when entry of this type deleted. */
void (*destroy)(const struct xt_match *match, void *matchinfo);
Expand Down
10 changes: 5 additions & 5 deletions net/ipv4/netfilter/ip_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,20 @@ ip_packet_match(const struct iphdr *ip,
return 1;
}

static inline int
static inline bool
ip_checkentry(const struct ipt_ip *ip)
{
if (ip->flags & ~IPT_F_MASK) {
duprintf("Unknown flag bits set: %08X\n",
ip->flags & ~IPT_F_MASK);
return 0;
return false;
}
if (ip->invflags & ~IPT_INV_MASK) {
duprintf("Unknown invflag bits set: %08X\n",
ip->invflags & ~IPT_INV_MASK);
return 0;
return false;
}
return 1;
return true;
}

static unsigned int
Expand Down Expand Up @@ -2149,7 +2149,7 @@ icmp_match(const struct sk_buff *skb,
}

/* Called when user tries to insert an entry of this type. */
static int
static bool
icmp_checkentry(const char *tablename,
const void *info,
const struct xt_match *match,
Expand Down
6 changes: 3 additions & 3 deletions net/ipv4/netfilter/ipt_ah.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ match(const struct sk_buff *skb,
}

/* Called when user tries to insert an entry of this type. */
static int
static bool
checkentry(const char *tablename,
const void *ip_void,
const struct xt_match *match,
Expand All @@ -82,9 +82,9 @@ checkentry(const char *tablename,
/* Must specify no unknown invflags */
if (ahinfo->invflags & ~IPT_AH_INV_MASK) {
duprintf("ipt_ah: unknown flags %X\n", ahinfo->invflags);
return 0;
return false;
}
return 1;
return true;
}

static struct xt_match ah_match = {
Expand Down
14 changes: 7 additions & 7 deletions net/ipv4/netfilter/ipt_ecn.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,27 @@ static bool match(const struct sk_buff *skb,
return true;
}

static int checkentry(const char *tablename, const void *ip_void,
const struct xt_match *match,
void *matchinfo, unsigned int hook_mask)
static bool checkentry(const char *tablename, const void *ip_void,
const struct xt_match *match,
void *matchinfo, unsigned int hook_mask)
{
const struct ipt_ecn_info *info = matchinfo;
const struct ipt_ip *ip = ip_void;

if (info->operation & IPT_ECN_OP_MATCH_MASK)
return 0;
return false;

if (info->invert & IPT_ECN_OP_MATCH_MASK)
return 0;
return false;

if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR)
&& ip->proto != IPPROTO_TCP) {
printk(KERN_WARNING "ipt_ecn: can't match TCP bits in rule for"
" non-tcp packets\n");
return 0;
return false;
}

return 1;
return true;
}

static struct xt_match ecn_match = {
Expand Down
6 changes: 3 additions & 3 deletions net/ipv4/netfilter/ipt_owner.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ match(const struct sk_buff *skb,
return true;
}

static int
static bool
checkentry(const char *tablename,
const void *ip,
const struct xt_match *match,
Expand All @@ -63,9 +63,9 @@ checkentry(const char *tablename,
if (info->match & (IPT_OWNER_PID|IPT_OWNER_SID|IPT_OWNER_COMM)) {
printk("ipt_owner: pid, sid and command matching "
"not supported anymore\n");
return 0;
return false;
}
return 1;
return true;
}

static struct xt_match owner_match = {
Expand Down
14 changes: 7 additions & 7 deletions net/ipv4/netfilter/ipt_recent.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,32 +235,32 @@ ipt_recent_match(const struct sk_buff *skb,
return ret;
}

static int
static bool
ipt_recent_checkentry(const char *tablename, const void *ip,
const struct xt_match *match, void *matchinfo,
unsigned int hook_mask)
{
const struct ipt_recent_info *info = matchinfo;
struct recent_table *t;
unsigned i;
int ret = 0;
bool ret = false;

if (hweight8(info->check_set &
(IPT_RECENT_SET | IPT_RECENT_REMOVE |
IPT_RECENT_CHECK | IPT_RECENT_UPDATE)) != 1)
return 0;
return false;
if ((info->check_set & (IPT_RECENT_SET | IPT_RECENT_REMOVE)) &&
(info->seconds || info->hit_count))
return 0;
return false;
if (info->name[0] == '\0' ||
strnlen(info->name, IPT_RECENT_NAME_LEN) == IPT_RECENT_NAME_LEN)
return 0;
return false;

mutex_lock(&recent_mutex);
t = recent_table_lookup(info->name);
if (t != NULL) {
t->refcnt++;
ret = 1;
ret = true;
goto out;
}

Expand All @@ -287,7 +287,7 @@ ipt_recent_checkentry(const char *tablename, const void *ip,
spin_lock_bh(&recent_lock);
list_add_tail(&t->list, &tables);
spin_unlock_bh(&recent_lock);
ret = 1;
ret = true;
out:
mutex_unlock(&recent_mutex);
return ret;
Expand Down
14 changes: 7 additions & 7 deletions net/ipv6/netfilter/ip6_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,20 @@ ip6_packet_match(const struct sk_buff *skb,
}

/* should be ip6 safe */
static inline int
static inline bool
ip6_checkentry(const struct ip6t_ip6 *ipv6)
{
if (ipv6->flags & ~IP6T_F_MASK) {
duprintf("Unknown flag bits set: %08X\n",
ipv6->flags & ~IP6T_F_MASK);
return 0;
return false;
}
if (ipv6->invflags & ~IP6T_INV_MASK) {
duprintf("Unknown invflag bits set: %08X\n",
ipv6->invflags & ~IP6T_INV_MASK);
return 0;
return false;
}
return 1;
return true;
}

static unsigned int
Expand Down Expand Up @@ -1282,10 +1282,10 @@ void ip6t_unregister_table(struct xt_table *table)
}

/* Returns 1 if the type and code is matched by the range, 0 otherwise */
static inline int
static inline bool
icmp6_type_code_match(u_int8_t test_type, u_int8_t min_code, u_int8_t max_code,
u_int8_t type, u_int8_t code,
int invert)
bool invert)
{
return (type == test_type && code >= min_code && code <= max_code)
^ invert;
Expand Down Expand Up @@ -1325,7 +1325,7 @@ icmp6_match(const struct sk_buff *skb,
}

/* Called when user tries to insert an entry of this type. */
static int
static bool
icmp6_checkentry(const char *tablename,
const void *entry,
const struct xt_match *match,
Expand Down
6 changes: 3 additions & 3 deletions net/ipv6/netfilter/ip6t_ah.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ match(const struct sk_buff *skb,
}

/* Called when user tries to insert an entry of this type. */
static int
static bool
checkentry(const char *tablename,
const void *entry,
const struct xt_match *match,
Expand All @@ -114,9 +114,9 @@ checkentry(const char *tablename,

if (ahinfo->invflags & ~IP6T_AH_INV_MASK) {
DEBUGP("ip6t_ah: unknown flags %X\n", ahinfo->invflags);
return 0;
return false;
}
return 1;
return true;
}

static struct xt_match ah_match = {
Expand Down
6 changes: 3 additions & 3 deletions net/ipv6/netfilter/ip6t_frag.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ match(const struct sk_buff *skb,
}

/* Called when user tries to insert an entry of this type. */
static int
static bool
checkentry(const char *tablename,
const void *ip,
const struct xt_match *match,
Expand All @@ -131,9 +131,9 @@ checkentry(const char *tablename,

if (fraginfo->invflags & ~IP6T_FRAG_INV_MASK) {
DEBUGP("ip6t_frag: unknown flags %X\n", fraginfo->invflags);
return 0;
return false;
}
return 1;
return true;
}

static struct xt_match frag_match = {
Expand Down
6 changes: 3 additions & 3 deletions net/ipv6/netfilter/ip6t_hbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ match(const struct sk_buff *skb,
}

/* Called when user tries to insert an entry of this type. */
static int
static bool
checkentry(const char *tablename,
const void *entry,
const struct xt_match *match,
Expand All @@ -185,9 +185,9 @@ checkentry(const char *tablename,

if (optsinfo->invflags & ~IP6T_OPTS_INV_MASK) {
DEBUGP("ip6t_opts: unknown flags %X\n", optsinfo->invflags);
return 0;
return false;
}
return 1;
return true;
}

static struct xt_match opts_match[] = {
Expand Down
6 changes: 3 additions & 3 deletions net/ipv6/netfilter/ip6t_ipv6header.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ ipv6header_match(const struct sk_buff *skb,
}
}

static int
static bool
ipv6header_checkentry(const char *tablename,
const void *ip,
const struct xt_match *match,
Expand All @@ -136,9 +136,9 @@ ipv6header_checkentry(const char *tablename,
/* invflags is 0 or 0xff in hard mode */
if ((!info->modeflag) && info->invflags != 0x00 &&
info->invflags != 0xFF)
return 0;
return false;

return 1;
return true;
}

static struct xt_match ip6t_ipv6header_match = {
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6t_mh.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ match(const struct sk_buff *skb,
}

/* Called when user tries to insert an entry of this type. */
static int
static bool
mh_checkentry(const char *tablename,
const void *entry,
const struct xt_match *match,
Expand Down
6 changes: 3 additions & 3 deletions net/ipv6/netfilter/ip6t_owner.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ match(const struct sk_buff *skb,
return true;
}

static int
static bool
checkentry(const char *tablename,
const void *ip,
const struct xt_match *match,
Expand All @@ -65,9 +65,9 @@ checkentry(const char *tablename,
if (info->match & (IP6T_OWNER_PID | IP6T_OWNER_SID)) {
printk("ipt_owner: pid and sid matching "
"not supported anymore\n");
return 0;
return false;
}
return 1;
return true;
}

static struct xt_match owner_match = {
Expand Down
8 changes: 4 additions & 4 deletions net/ipv6/netfilter/ip6t_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ match(const struct sk_buff *skb,
}

/* Called when user tries to insert an entry of this type. */
static int
static bool
checkentry(const char *tablename,
const void *entry,
const struct xt_match *match,
Expand All @@ -209,17 +209,17 @@ checkentry(const char *tablename,

if (rtinfo->invflags & ~IP6T_RT_INV_MASK) {
DEBUGP("ip6t_rt: unknown flags %X\n", rtinfo->invflags);
return 0;
return false;
}
if ((rtinfo->flags & (IP6T_RT_RES | IP6T_RT_FST_MASK)) &&
(!(rtinfo->flags & IP6T_RT_TYP) ||
(rtinfo->rt_type != 0) ||
(rtinfo->invflags & IP6T_RT_INV_TYP))) {
DEBUGP("`--rt-type 0' required before `--rt-0-*'");
return 0;
return false;
}

return 1;
return true;
}

static struct xt_match rt_match = {
Expand Down
Loading

0 comments on commit ccb79bd

Please sign in to comment.